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

[PATCH v5 2/6] x86: rearrange how mod_l*_entry() functions call UPDATE_ENTRY


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Date: Thu, 12 Nov 2026 10:00:01 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=N1AQA4t6vMrBwdpJvNjYpirZUbgYm4+HlO7lBcKfTbQ=; b=fCAXWch8asCnnYZVLVzQpbnXKAiCI+24AyKWczjm2b7WhSQUySBxdZwMMzayKbyq5jp3K3i+Icu4JI50gEtQA5sdYkPyGXPCG9rWzEF2zGZqy4nPqxSQPdjAXiwuzHvVsGMtc2pJRvdvUFV1IBwBRWav6UF0bkitB0EPEB83UQcEGFKKFaaJpR5SyhomVxY78gtg0Y83FYLAuMYFOO9CNcwALWUkJ4KYg0LbRDrqaYi+cIyvTy15Td2bRicH5RvVOkeWD3z65N+wM17jtqRdaZMkUQuwqnyu3qlT95DOmF6EHJLY4VbLOAHomudPTw7ZwreQadeUaK2e21UHrZROJQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bRH45O3+Tm86vj/AutVdwTuJFqY1rCWWROmpNTneaVukgB4cuEaMP4T4nBDzNw10VQyq+G+T5oMBL9qe4KkbsvioCdMCk2DZ0zxi6ZoX6+tJRoqiZwxTARoatz1xQAAXxXPWoBjcsreW2jNpiRLKKzZIl6L1tPHGBJl3ZGAFzIkiZoDEqX29O736xxW0GMqoaceEUJWKtMrPKK5Y1hBTgyWuVra9ZG7Sha0CNGJz7o42EFZDlL0I3Lo9fusX9lD7vVVw/SCeZ8O3zFJ+h1GC28ARGMxl2mARAIW3tmxydvSUtoHOMFGkNqddfe/mAus4mjPYe2Bid2QiY7wFq16fjQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: jbeulich@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, roger@xxxxxxxxxxxxxx, teddy.astie@xxxxxxxxxx, Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Delivery-date: Thu, 12 Nov 2026 10:00:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

bloat-o-meter:
Function                                     old     new   delta
mod_l1_entry                                1186    1113     -73
do_mmu_update                               5546    5392    -154

Signed-off-by: Kevin Lampis <kevin.lampis@xxxxxxxxxx>

---
Changes in v5:
- New patch
---
 xen/arch/x86/mm.c | 45 +++++++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index e42cd33c0d09..dc0e0d451c02 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2197,12 +2197,12 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, 
l1_pgentry_t nl1e,
 {
     l1_pgentry_t ol1e = l1e_read(pl1e);
     struct domain *pt_dom = pt_vcpu->domain;
-    int rc = 0;
 
     ASSERT(!paging_mode_refcounts(pt_dom));
 
     if ( l1e_get_flags(nl1e) & _PAGE_PRESENT )
     {
+        int rc;
         struct page_info *page = NULL;
         uint32_t disallow = l1_disallow_mask(pt_dom);
 
@@ -2276,16 +2276,14 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, 
l1_pgentry_t nl1e,
         }
         if ( page )
             put_page(page);
-
-        UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, update_flags);
     }
     else if ( pv_l1tf_check_l1e(pt_dom, nl1e) )
         return -ERESTART;
-    else
-        UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, update_flags);
+
+    UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, update_flags);
 
     put_page_from_l1e(ol1e, pt_dom);
-    return rc;
+    return 0;
 }
 
 
@@ -2300,7 +2298,6 @@ static int mod_l2_entry(l2_pgentry_t *pl2e,
     struct domain *d = vcpu->domain;
     struct page_info *l2pg = mfn_to_page(mfn);
     unsigned long type = l2pg->u.inuse.type_info;
-    int rc = 0;
 
     if ( unlikely(!is_guest_l2_slot(d, type, pgentry_ptr_to_slot(pl2e))) )
     {
@@ -2313,6 +2310,8 @@ static int mod_l2_entry(l2_pgentry_t *pl2e,
 
     if ( l2e_get_flags(nl2e) & _PAGE_PRESENT )
     {
+        int rc;
+
         if ( unlikely(l2e_get_flags(nl2e) & L2_DISALLOW_MASK) )
         {
             gdprintk(XENLOG_WARNING, "Bad L2 flags %x\n",
@@ -2331,17 +2330,15 @@ static int mod_l2_entry(l2_pgentry_t *pl2e,
 
         if ( unlikely((rc = get_page_from_l2e(nl2e, mfn, d, 0)) < 0) )
             return rc;
-
-        UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, mfn, vcpu, update_flags);
     }
     else if ( pv_l1tf_check_l2e(d, nl2e) )
         return -ERESTART;
-    else
-        UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, mfn, vcpu, update_flags);
+
+    UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, mfn, vcpu, update_flags);
 
     put_page_from_l2e(ol2e, mfn, PTF_defer);
 
-    return rc;
+    return 0;
 }
 
 /* Update the L3 entry at pl3e to new value nl3e. pl3e is within frame mfn. */
@@ -2353,7 +2350,6 @@ static int mod_l3_entry(l3_pgentry_t *pl3e,
 {
     l3_pgentry_t ol3e;
     struct domain *d = vcpu->domain;
-    int rc = 0;
 
     /*
      * Disallow updates to final L3 slot. It contains Xen mappings, and it
@@ -2366,6 +2362,8 @@ static int mod_l3_entry(l3_pgentry_t *pl3e,
 
     if ( l3e_get_flags(nl3e) & _PAGE_PRESENT )
     {
+        int rc;
+
         if ( unlikely(l3e_get_flags(nl3e) & l3_disallow_mask(d)) )
         {
             gdprintk(XENLOG_WARNING, "Bad L3 flags %x\n",
@@ -2385,17 +2383,14 @@ static int mod_l3_entry(l3_pgentry_t *pl3e,
         rc = get_page_from_l3e(nl3e, mfn, d, 0);
         if ( unlikely(rc < 0) )
             return rc;
-        rc = 0;
-
-        UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, mfn, vcpu, update_flags);
     }
     else if ( pv_l1tf_check_l3e(d, nl3e) )
         return -ERESTART;
-    else
-        UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, mfn, vcpu, update_flags);
+
+    UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, mfn, vcpu, update_flags);
 
     put_page_from_l3e(ol3e, mfn, PTF_defer);
-    return rc;
+    return 0;
 }
 
 /* Update the L4 entry at pl4e to new value nl4e. pl4e is within frame mfn. */
@@ -2407,7 +2402,6 @@ static int mod_l4_entry(l4_pgentry_t *pl4e,
 {
     struct domain *d = vcpu->domain;
     l4_pgentry_t ol4e;
-    int rc = 0;
 
     if ( unlikely(!is_guest_l4_slot(d, pgentry_ptr_to_slot(pl4e))) )
     {
@@ -2420,6 +2414,8 @@ static int mod_l4_entry(l4_pgentry_t *pl4e,
 
     if ( l4e_get_flags(nl4e) & _PAGE_PRESENT )
     {
+        int rc;
+
         if ( unlikely(l4e_get_flags(nl4e) & L4_DISALLOW_MASK) )
         {
             gdprintk(XENLOG_WARNING, "Bad L4 flags %x\n",
@@ -2439,17 +2435,14 @@ static int mod_l4_entry(l4_pgentry_t *pl4e,
         rc = get_page_from_l4e(nl4e, mfn, d, 0);
         if ( unlikely(rc < 0) )
             return rc;
-        rc = 0;
-
-        UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, mfn, vcpu, update_flags);
     }
     else if ( pv_l1tf_check_l4e(d, nl4e) )
         return -ERESTART;
-    else
-        UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, mfn, vcpu, update_flags);
+
+    UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, mfn, vcpu, update_flags);
 
     put_page_from_l4e(ol4e, mfn, PTF_defer);
-    return rc;
+    return 0;
 }
 #endif /* CONFIG_PV */
 
-- 
2.52.0




 


Rackspace

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