[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/12] x86/mm: pull a sanity check earlier in xenmem_add_to_physmap_one()
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Fri, 25 Jun 2021 15:22:55 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TOsEQIQ7DC4In8gkn+d6JI6dXDcB4jJx1x6CvkOlsRs=; b=eqGAmsarqy5g4BLw8UmE2yP/9ADmi6ZcoQKEjyn3SjIHA7s23IAkQQTZvX2Ptr5r5vUifTbqxmQbT5jl8R8Q8vcF1Nj0NHXgOUXz3IRBIj6VHT9Ari5xGPE1fOPQCMAy5WFHowPpy0cd9qoQBNUMJvIe14rjtJnaXAiGbjD1XKtoc1I7rdm6VYTiBBA+hAdT4W5Mp1xXgZs7+C6+UgI/MLMqDSpO+ozM9y4ccJiPrB024dimBcEUYOQ3r3nDrARKo8IpdyhhDbsKUihsVipPiV7kdTUFqW4iIEzmWm7ne4lFokBlDzxZo//gG8s/sjrpOeZ1h7c3//bG1I4EH/wXcw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dcTx8zSM+36hmkBn9SkOeA1y9eGzh77AwAiCevfWZFWyqsKahC6oa3Su8EMpfslsbP4aHVclDh2NG+WxE467GiCMry6fEQsrDs1dEVeFq1ZqJdPyoyTkFg7q31K7lD3Jd2BU620dkjrazEOgv8LjwwKa45vD/s7AjY6c7DGPgzzZzade8NFpK8Mh6Sav/Wdr1WMIF4i1tqZk/lof3G9qwZnfaeMmixGal+gjFsXssFg4VCRGq0n7nzxYke5cskDI9LZC4p3/hKl8BVfyvc2ubzyJZifS/FnNQgPQv/wHANfLm9HWBKEeEjZkItMtWsx9aMFk26cjErh/gbCFUvZZZg==
- Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
- Delivery-date: Fri, 25 Jun 2021 13:23:04 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
We should try to limit the failure reasons after we've started making
changes.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2763,6 +2763,15 @@ int xenmem_add_to_physmap_one(
goto put_both;
}
+ /* XENMAPSPACE_gmfn: Check if the MFN is associated with another GFN. */
+ old_gpfn = get_gpfn_from_mfn(mfn_x(mfn));
+ ASSERT(!SHARED_M2P(old_gpfn));
+ if ( space == XENMAPSPACE_gmfn && old_gpfn != gfn )
+ {
+ rc = -EXDEV;
+ goto put_both;
+ }
+
/* Remove previously mapped page if it was present. */
prev_mfn = get_gfn(d, gfn_x(gpfn), &p2mt);
if ( mfn_valid(prev_mfn) )
@@ -2781,13 +2790,6 @@ int xenmem_add_to_physmap_one(
goto put_both;
/* Unmap from old location, if any. */
- old_gpfn = get_gpfn_from_mfn(mfn_x(mfn));
- ASSERT(!SHARED_M2P(old_gpfn));
- if ( space == XENMAPSPACE_gmfn && old_gpfn != gfn )
- {
- rc = -EXDEV;
- goto put_both;
- }
if ( old_gpfn != INVALID_M2P_ENTRY )
rc = guest_physmap_remove_page(d, _gfn(old_gpfn), mfn, PAGE_ORDER_4K);
|