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

[PATCH 1/5] x86/svm: Cleanup vintr_t type


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Mon, 28 Sep 2026 15:02:44 +0100
  • 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=0qTizuk1gzC5fdnXGMO16arr/pQ2aZmERraj6XVXQjw=; b=IDPz7TdfZPaT9fM3rllLxfKFVwjbqq/FmR7L0u1NMv76hWjFKVFgLUwS6jHy50cbxMV7xcPGhi7CJ93Fj0ZPuJQdbt6lTP13jEKxKCBO23g4J3iAzl4PDPs2Ms/plxTyyJymq01uiX3p/WzFBUc5Pjxnxod/DCmNQgPXalkIrJ19HMRCiicRPE8Ge8KFJxzmtIrUjJMyA10sS9uVmtohdaKVinhJrQef7f/qYJ/q+jPhEJLLF79lqdpUwmQjGom0oDzhQ5RC1CWVDEryaGuIQwMDy4wvajoGp0YRwQDtkD5MDcnA6k3ew+7gaQAWwx6mn+wM+Y/l1KYk4QmwhqlaXA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J6Zv8thdujbPZxt52d2u/rIyjXxXEUE9T1GibPar+sMR/AqshtFweuKShVWjRNp+T5D9WDg8jVN697hdrj4i6w6yoipZsdArYCZg9PLGDjAF2Y70kGXK3v8xfyarI2DZi6GZNCmrokG1Rc5ci3139UKbW+a6KdQdmnkYi5dY1KWZykUOhCbtSZp6mLYKWZYZD4LQUA4fe1Kpl0qErm3ocdz/YYYQkPzZ0j5QV4cGqawDbOIXf1zvNzp2X3ghQ3zL9YhjRK80nHMfQyruP+AMVts8oMHJ93K05IIP/Q8yqGJXXtNw1FDJEULqc7mnPmeeuD25bxI9rJsp3HXufG2AGA==
  • 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: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Mon, 28 Sep 2026 14:03:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Rearrange the union to drop the .fields infix, rename bytes to the more
common raw, adjust types where appropriate, and simplify some names.
Adjust the users accordingly.

No functional change intended.

Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/intr.c      | 16 +++++++--------
 xen/arch/x86/hvm/svm/nestedsvm.c | 32 ++++++++++++++---------------
 xen/arch/x86/hvm/svm/svm.c       | 18 ++++++++--------
 xen/arch/x86/hvm/svm/vmcb.c      |  6 +++---
 xen/arch/x86/hvm/svm/vmcb.h      | 35 ++++++++++++++++----------------
 5 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/intr.c b/xen/arch/x86/hvm/svm/intr.c
index 4b0debfa9a2e..883fde873e73 100644
--- a/xen/arch/x86/hvm/svm/intr.c
+++ b/xen/arch/x86/hvm/svm/intr.c
@@ -33,9 +33,9 @@ static void svm_inject_nmi(struct vcpu *v)
     u32 general1_intercepts = vmcb_get_general1_intercepts(vmcb);
     intinfo_t event;
 
-    if ( vmcb->_vintr.fields.vnmi_enable )
+    if ( vmcb->_vintr.vnmi_en )
     {
-        vmcb->_vintr.fields.vnmi_pending = true;
+        vmcb->_vintr.vnmi_pending = true;
         return;
     }
 
@@ -90,7 +90,7 @@ static void svm_enable_intr_window(struct vcpu *v, struct 
hvm_intack intack)
              */
             ASSERT(gvmcb != NULL);
             intr = vmcb_get_vintr(gvmcb);
-            if ( intr.fields.irq )
+            if ( intr.irq )
                 return;
         }
     }
@@ -119,10 +119,10 @@ static void svm_enable_intr_window(struct vcpu *v, struct 
hvm_intack intack)
         return;
 
     intr = vmcb_get_vintr(vmcb);
-    intr.fields.irq     = 1;
-    intr.fields.vector  = 0;
-    intr.fields.prio    = intack.vector >> 4;
-    intr.fields.ign_tpr = (intack.source != hvm_intsrc_lapic);
+    intr.irq     = 1;
+    intr.vector  = 0;
+    intr.prio    = intack.vector >> 4;
+    intr.ign_tpr = (intack.source != hvm_intsrc_lapic);
     vmcb_set_vintr(vmcb, intr);
     vmcb_set_general1_intercepts(
         vmcb, general1_intercepts | GENERAL1_INTERCEPT_VINTR);
@@ -158,7 +158,7 @@ void asmlinkage svm_intr_assist(void)
          * has vGIF, and vGIF is always activated when appropriate.
          */
         if ( intblk == hvm_intblk_nmi_iret &&
-             vmcb->_vintr.fields.vnmi_enable )
+             vmcb->_vintr.vnmi_en )
             intblk = hvm_intblk_none;
 
         if ( intblk == hvm_intblk_svm_gif )
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 81579370b8bf..65556136852b 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -442,7 +442,7 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct 
cpu_user_regs *regs)
     if ( !clean.tpr )
     {
         n2vmcb->_vintr = ns_vmcb->_vintr;
-        n2vmcb->_vintr.fields.intr_masking = 1;
+        n2vmcb->_vintr.intr_masking = 1;
     }
 
     /* Interrupt state */
@@ -652,7 +652,7 @@ nsvm_vcpu_vmentry(struct vcpu *v, struct cpu_user_regs 
*regs,
     svm->ns_hap_enabled = vmcb_get_np(ns_vmcb);
 
     /* Remember the V_INTR_MASK in hostflags */
-    svm->ns_hostflags.fields.vintrmask = !!ns_vmcb->_vintr.fields.intr_masking;
+    svm->ns_hostflags.fields.vintrmask = !!ns_vmcb->_vintr.intr_masking;
 
     /* Save l1 guest state (= host state) */
     ret = nsvm_vcpu_hostsave(v, inst_len);
@@ -738,8 +738,8 @@ nsvm_vcpu_vmexit_inject(struct vcpu *v, struct 
cpu_user_regs *regs,
     struct vmcb_struct *ns_vmcb;
     struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;
 
-    if ( vmcb->_vintr.fields.vgif_enable )
-        vmcb->_vintr.fields.vgif = 0;
+    if ( vmcb->_vintr.vgif_en )
+        vmcb->_vintr.vgif = 0;
     else
         svm->ns_gif = 0;
 
@@ -997,7 +997,7 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct 
cpu_user_regs *regs)
     /* Virtual Interrupts */
     ns_vmcb->_vintr = n2vmcb->_vintr;
     if ( !svm->ns_hostflags.fields.vintrmask )
-        ns_vmcb->_vintr.fields.intr_masking = 0;
+        ns_vmcb->_vintr.intr_masking = 0;
 
     /* Interrupt state */
     ns_vmcb->int_stat = n2vmcb->int_stat;
@@ -1217,8 +1217,8 @@ nestedsvm_vmexit_defer(struct vcpu *v,
     struct nestedsvm *svm = &vcpu_nestedsvm(v);
     struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;
 
-    if ( vmcb->_vintr.fields.vgif_enable )
-        vmcb->_vintr.fields.vgif = 0;
+    if ( vmcb->_vintr.vgif_en )
+        vmcb->_vintr.vgif = 0;
     else
         svm->ns_gif = 0;
 
@@ -1485,8 +1485,8 @@ nestedsvm_gif_isset(struct vcpu *v)
     struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;
 
     /* get the vmcb gif value if using vgif */
-    if ( vmcb->_vintr.fields.vgif_enable )
-        return vmcb->_vintr.fields.vgif;
+    if ( vmcb->_vintr.vgif_en )
+        return vmcb->_vintr.vgif;
     else
         return svm->ns_gif;
 }
@@ -1533,7 +1533,7 @@ void svm_vmexit_do_clgi(struct cpu_user_regs *regs, 
struct vcpu *v)
 
     /* After a CLGI no interrupts should come */
     intr = vmcb_get_vintr(vmcb);
-    intr.fields.irq = 0;
+    intr.irq = 0;
     general1_intercepts &= ~GENERAL1_INTERCEPT_VINTR;
     vmcb_set_vintr(vmcb, intr);
     vmcb_set_general1_intercepts(vmcb, general1_intercepts);
@@ -1569,12 +1569,12 @@ void svm_nested_features_on_efer_update(struct vcpu *v)
             vmcb_set_general2_intercepts(vmcb, general2_intercepts);
         }
 
-        if ( !vmcb->_vintr.fields.vgif_enable &&
+        if ( !vmcb->_vintr.vgif_en &&
              cpu_has_svm_vgif )
         {
             vintr = vmcb_get_vintr(vmcb);
-            vintr.fields.vgif = svm->ns_gif;
-            vintr.fields.vgif_enable = 1;
+            vintr.vgif = svm->ns_gif;
+            vintr.vgif_en = 1;
             vmcb_set_vintr(vmcb, vintr);
             general2_intercepts  = vmcb_get_general2_intercepts(vmcb);
             general2_intercepts &= ~(GENERAL2_INTERCEPT_STGI |
@@ -1593,11 +1593,11 @@ void svm_nested_features_on_efer_update(struct vcpu *v)
             vmcb_set_general2_intercepts(vmcb, general2_intercepts);
         }
 
-        if ( vmcb->_vintr.fields.vgif_enable )
+        if ( vmcb->_vintr.vgif_en )
         {
             vintr = vmcb_get_vintr(vmcb);
-            svm->ns_gif = vintr.fields.vgif;
-            vintr.fields.vgif_enable = 0;
+            svm->ns_gif = vintr.vgif;
+            vintr.vgif_en = 0;
             vmcb_set_vintr(vmcb, vintr);
             general2_intercepts  = vmcb_get_general2_intercepts(vmcb);
             general2_intercepts |= (GENERAL2_INTERCEPT_STGI |
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 71e48351f22c..05e25764f4b3 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -498,8 +498,8 @@ static unsigned cf_check int 
svm_get_interrupt_shadow(struct vcpu *v)
     if ( vmcb->int_stat.intr_shadow )
         intr_shadow |= HVM_INTR_SHADOW_MOV_SS | HVM_INTR_SHADOW_STI;
 
-    if ( vmcb->_vintr.fields.vnmi_enable
-         ? vmcb->_vintr.fields.vnmi_blocking
+    if ( vmcb->_vintr.vnmi_en
+         ? vmcb->_vintr.vnmi_blocking
          : (vmcb_get_general1_intercepts(vmcb) & GENERAL1_INTERCEPT_IRET) )
         intr_shadow |= HVM_INTR_SHADOW_NMI;
 
@@ -515,8 +515,8 @@ static void cf_check svm_set_interrupt_shadow(
     vmcb->int_stat.intr_shadow =
         !!(intr_shadow & (HVM_INTR_SHADOW_MOV_SS|HVM_INTR_SHADOW_STI));
 
-    if ( vmcb->_vintr.fields.vnmi_enable )
-        vmcb->_vintr.fields.vnmi_blocking = block_nmi;
+    if ( vmcb->_vintr.vnmi_en )
+        vmcb->_vintr.vnmi_blocking = block_nmi;
     else
     {
         uint32_t gen1 = vmcb_get_general1_intercepts(vmcb);
@@ -961,8 +961,7 @@ static void noreturn cf_check svm_do_resume(void)
 
         /* Reflect the vlapic's TPR in the hardware vtpr */
         intr = vmcb_get_vintr(vmcb);
-        intr.fields.tpr =
-            (vlapic_get_reg(vlapic, APIC_TASKPRI) & 0xFF) >> 4;
+        intr.tpr = (vlapic_get_reg(vlapic, APIC_TASKPRI) & 0xFF) >> 4;
         vmcb_set_vintr(vmcb, intr);
     }
 
@@ -2538,7 +2537,7 @@ void asmlinkage svm_vmexit_handler(void)
     {
         intr = vmcb_get_vintr(vmcb);
         vlapic_set_reg(vlapic, APIC_TASKPRI,
-                   ((intr.fields.tpr & 0x0F) << 4) |
+                   ((intr.tpr & 0x0F) << 4) |
                    (vlapic_get_reg(vlapic, APIC_TASKPRI) & 0x0F));
     }
 
@@ -2772,7 +2771,7 @@ void asmlinkage svm_vmexit_handler(void)
         u32 general1_intercepts = vmcb_get_general1_intercepts(vmcb);
         intr = vmcb_get_vintr(vmcb);
 
-        intr.fields.irq = 0;
+        intr.irq = 0;
         general1_intercepts &= ~GENERAL1_INTERCEPT_VINTR;
 
         vmcb_set_vintr(vmcb, intr);
@@ -3063,8 +3062,7 @@ void asmlinkage svm_vmexit_handler(void)
 
     /* The exit may have updated the TPR: reflect this in the hardware vtpr */
     intr = vmcb_get_vintr(vmcb);
-    intr.fields.tpr =
-        (vlapic_get_reg(vlapic, APIC_TASKPRI) & 0xFF) >> 4;
+    intr.tpr = (vlapic_get_reg(vlapic, APIC_TASKPRI) & 0xFF) >> 4;
     vmcb_set_vintr(vmcb, intr);
 }
 
diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c
index a6f09672a7c5..753f5d295064 100644
--- a/xen/arch/x86/hvm/svm/vmcb.c
+++ b/xen/arch/x86/hvm/svm/vmcb.c
@@ -105,7 +105,7 @@ static int construct_vmcb(struct vcpu *v)
     vmcb->_iopm_base_pa = __pa(v->domain->arch.hvm.io_bitmap);
 
     /* Virtualise EFLAGS.IF and LAPIC TPR (CR8). */
-    vmcb->_vintr.fields.intr_masking = 1;
+    vmcb->_vintr.intr_masking = 1;
 
     /* Don't need to intercept RDTSC if CPU supports TSC rate scaling */
     if ( v->domain->arch.vtsc && !cpu_has_tsc_ratio )
@@ -192,7 +192,7 @@ static int construct_vmcb(struct vcpu *v)
     if ( default_xen_spec_ctrl == SPEC_CTRL_STIBP )
         v->arch.msrs->spec_ctrl.raw = SPEC_CTRL_STIBP;
 
-    vmcb->_vintr.fields.vnmi_enable = cpu_has_svm_vnmi;
+    vmcb->_vintr.vnmi_en = cpu_has_svm_vnmi;
 
     return 0;
 }
@@ -275,7 +275,7 @@ void svm_vmcb_dump(const char *from, const struct 
vmcb_struct *vmcb)
            vmcb_get_iopm_base_pa(vmcb), vmcb_get_msrpm_base_pa(vmcb),
            vmcb_get_tsc_offset(vmcb));
     printk("tlb_control = %#x vintr = %#"PRIx64" int_stat = %#"PRIx64"\n",
-           vmcb->tlb_control, vmcb_get_vintr(vmcb).bytes,
+           vmcb->tlb_control, vmcb_get_vintr(vmcb).raw,
            vmcb->int_stat.raw);
     printk("event_inj %016"PRIx64", valid? %d, ec? %d, type %u, vector %#x\n",
            vmcb->event_inj.raw, vmcb->event_inj.v,
diff --git a/xen/arch/x86/hvm/svm/vmcb.h b/xen/arch/x86/hvm/svm/vmcb.h
index 3760f71a8625..869d965ba398 100644
--- a/xen/arch/x86/hvm/svm/vmcb.h
+++ b/xen/arch/x86/hvm/svm/vmcb.h
@@ -330,26 +330,25 @@ typedef union {
 
 typedef union
 {
-    u64 bytes;
     struct
     {
-        u64 tpr:          8;
-        u64 irq:          1;
-        u64 vgif:         1;
-        u64 :             1;
-        u64 vnmi_pending: 1;
-        u64 vnmi_blocking:1;
-        u64 :             3;
-        u64 prio:         4;
-        u64 ign_tpr:      1;
-        u64 rsvd1:        3;
-        u64 intr_masking: 1;
-        u64 vgif_enable:  1;
-        u64 vnmi_enable:  1;
-        u64 :             5;
-        u64 vector:       8;
-        u64 rsvd3:       24;
-    } fields;
+        uint8_t tpr;
+        bool irq:1;
+        bool vgif:1;
+        bool :1;
+        bool vnmi_pending:1;
+        bool vnmi_blocking:1;
+        uint8_t :3;
+        uint8_t prio:4;
+        bool ign_tpr:1;
+        uint8_t rsvd1:3;
+        bool intr_masking:1;
+        bool vgif_en:1;
+        bool vnmi_en:1;
+        uint8_t :5;
+        uint8_t vector;
+    };
+    uint64_t raw;
 } vintr_t;
 
 typedef union
-- 
2.55.0




 


Rackspace

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