From: Ross Lagerwall <ross.lagerwall@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: "Ross Lagerwall" <ross.lagerwall@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger@xenproject.org>,
"Jason Andryuk" <jason.andryuk@amd.com>,
"Teddy Astie" <teddy.astie@vates.tech>
Subject: [PATCH 1/5] x86/svm: Cleanup vintr_t type
Date: Mon, 28 Sep 2026 15:02:44 +0100 [thread overview]
Message-ID: <20260928140248.1543013-2-ross.lagerwall@citrix.com> (raw)
In-Reply-To: <20260928140248.1543013-1-ross.lagerwall@citrix.com>
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@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
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
next prev parent reply other threads:[~2026-09-28 14:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 14:02 [PATCH 0/5] x86/svm: Cleanup types Ross Lagerwall
2026-09-28 14:02 ` Ross Lagerwall [this message]
2026-09-28 23:58 ` [PATCH 1/5] x86/svm: Cleanup vintr_t type Jason Andryuk
2026-09-29 16:05 ` Jan Beulich
2026-09-30 8:57 ` Ross Lagerwall
2026-09-28 14:02 ` [PATCH 2/5] x86/svm: Remove ioio_info_t type Ross Lagerwall
2026-09-28 23:58 ` Jason Andryuk
2026-09-29 17:15 ` Andrew Cooper
2026-09-28 14:02 ` [PATCH 3/5] x86/svm: Cleanup virt_ext_t type Ross Lagerwall
2026-09-28 23:59 ` Jason Andryuk
2026-09-30 6:34 ` Jan Beulich
2026-09-28 14:02 ` [PATCH 4/5] x86/svm: Use C99 types in VMCB struct Ross Lagerwall
2026-09-29 0:00 ` Jason Andryuk
2026-09-30 6:35 ` Jan Beulich
2026-09-28 14:02 ` [PATCH 5/5] x86/svm: Cleanup ns_hostflags type Ross Lagerwall
2026-09-29 0:02 ` Jason Andryuk
2026-09-30 6:37 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260928140248.1543013-2-ross.lagerwall@citrix.com \
--to=ross.lagerwall@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jason.andryuk@amd.com \
--cc=jbeulich@suse.com \
--cc=roger@xenproject.org \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.