[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 3/4] x86/shadow: slightly consolidate sh_unshadow_for_p2m_change() (part III)


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 19 Jul 2022 08:52:06 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MrLpz4xOfSP6s3F5vbYICU8lK4kwS1kPHKk6aMNfEXs=; b=l9pRrY8ivRG0VOWy2y5d8v7+nUGo/VYvm+GiCkAPrvf18vkD0LyR8d/Vr5MvXLjh0cz5oPlQIIaMDNKgYqWWZtUG/cPoqvtqlEQSv3JzCL6mw1PzKArlvaIf3olCMLrMvFiBTBldtbBWXQuInP10AuFFCy+om7OkNsZBGWab9wUOm0/ziOq1N2sXvs5cB5qe0hCRyQkot5ErJWt7UcPYmz7rZeAShw+WfaSfgHybNLcKO/PMSZB7OQTo7Rh2ibIOhQRmqESvVpZVPrCZ/qE5hy9BCN+5LeK3uVdoJls0hIQFSYXh9AXfBupm287UePAVgvMP9+6P1tO599LEDN/PGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LDe5K/R3ZfIqyr2oCPK9TWvBA+EP3cLt23cytxrAUlvSm5g5T6tZ72QzluKiBiKm1Xm/1A9CYjVN651Jq/QC1Sa5i6jnuVIzApEb5c0Y4APwVsGPFInLnxcNJ/KoCtyP+9JyYFeR71+LuF1Y6as/Wzdqwxf+4UpP/Oj+rT51OYvOJWsqJ6FmQ0Lqa7ql4KB9ww6Nu32UOImgL8QgINJGVFABxeJ6+j8LYyVtVSMQgcOT7M+H0BWWBms6yINB02q6eQddjZUEZwHGvcwjmX0W2uar2gbwW+lb68/myzNxUE9xlBPgX51miSTGQv9+pKCK4A3JubXNzRIJI5yXQdghnQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>
  • Delivery-date: Tue, 19 Jul 2022 06:52:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

In preparation for reactivating the presently dead 2M page path of the
function, also deal with the case of replacing an L1 page table all in
one go.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Split from previous bigger patch.

--- a/xen/arch/x86/mm/shadow/hvm.c
+++ b/xen/arch/x86/mm/shadow/hvm.c
@@ -847,14 +847,9 @@ static void cf_check sh_unshadow_for_p2m
      * scheme, that's OK, but otherwise they must be unshadowed.
      */
     case 2:
-        if ( !(oflags & _PAGE_PSE) )
-            break;
-
-        ASSERT(!p2m_is_grant(p2mt));
-
         {
             unsigned int i;
-            l1_pgentry_t *npte = NULL;
+            l1_pgentry_t *npte = NULL, *opte = NULL;
 
             /* If we're replacing a superpage with a normal L1 page, map it */
             if ( (l1e_get_flags(new) & _PAGE_PRESENT) &&
@@ -862,24 +857,39 @@ static void cf_check sh_unshadow_for_p2m
                  mfn_valid(nmfn) )
                 npte = map_domain_page(nmfn);
 
+            /* If we're replacing a normal L1 page, map it as well. */
+            if ( !(oflags & _PAGE_PSE) )
+                opte = map_domain_page(omfn);
+
             gfn &= ~(L1_PAGETABLE_ENTRIES - 1);
 
             for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
             {
-                if ( !npte ||
-                     !(l1e_get_flags(npte[i]) & _PAGE_PRESENT) ||
-                     !mfn_eq(l1e_get_mfn(npte[i]), omfn) )
+                if ( opte )
+                {
+                    if ( !(l1e_get_flags(opte[i]) & _PAGE_PRESENT) )
+                        continue;
+                    omfn = l1e_get_mfn(opte[i]);
+                }
+
+                if ( npte )
+                    nmfn = l1e_get_flags(npte[i]) & _PAGE_PRESENT
+                           ? l1e_get_mfn(npte[i]) : INVALID_MFN;
+
+                if ( !mfn_eq(nmfn, omfn) )
                 {
                     /* This GFN->MFN mapping has gone away */
                     sh_remove_all_shadows_and_parents(d, omfn);
                     if ( sh_remove_all_mappings(d, omfn, _gfn(gfn + i)) )
                         flush = true;
                 }
+
                 omfn = mfn_add(omfn, 1);
+                nmfn = mfn_add(nmfn, 1);
             }
 
-            if ( npte )
-                unmap_domain_page(npte);
+            unmap_domain_page(opte);
+            unmap_domain_page(npte);
         }
 
         break;




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.