|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2] x86/svm: Cleanup vintr_t type
From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
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>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
CC: Teddy Astie <teddy.astie@xxxxxxxxxx>
CC: Jason Andryuk <jason.andryuk@xxxxxxx>
CC: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
CC: Denis Mukhin <dmukhin@xxxxxxxx>
v2:
* Further adjustments to names, swap to true/false for bools.
---
xen/arch/x86/hvm/svm/intr.c | 19 +++++++--------
xen/arch/x86/hvm/svm/nestedsvm.c | 33 +++++++++++++------------
xen/arch/x86/hvm/svm/svm.c | 18 +++++++-------
xen/arch/x86/hvm/svm/vmcb.c | 6 ++---
xen/arch/x86/hvm/svm/vmcb.h | 41 +++++++++++++++-----------------
5 files changed, 55 insertions(+), 62 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/intr.c b/xen/arch/x86/hvm/svm/intr.c
index 2224f1834741..dfe6d8347605 100644
--- a/xen/arch/x86/hvm/svm/intr.c
+++ b/xen/arch/x86/hvm/svm/intr.c
@@ -34,9 +34,9 @@ static void svm_inject_nmi(struct vcpu *v)
uint32_t general1_intercepts;
intinfo_t event;
- if ( vintr.fields.vnmi_enable )
+ if ( vintr.vnmi_en )
{
- vintr.fields.vnmi_pending = true;
+ vintr.nmi_pending = true;
vmcb_set_vintr(vmcb, vintr);
return;
}
@@ -93,7 +93,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.intr_pending )
return;
}
}
@@ -122,10 +122,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.intr_pending = true;
+ intr.intr_prio = intack.vector >> 4;
+ intr.ign_tpr = (intack.source != hvm_intsrc_lapic);
+ intr.vector = 0;
vmcb_set_vintr(vmcb, intr);
vmcb_set_general1_intercepts(
vmcb, general1_intercepts | GENERAL1_INTERCEPT_VINTR);
@@ -153,15 +153,14 @@ void asmlinkage svm_intr_assist(void)
intblk = hvm_interrupt_blocked(v, intack);
/*
- * When vNMI is active, NMIs can be injected by setting vnmi_pending
+ * When vNMI is active, NMIs can be injected by setting nmi_pending
* and hardware will deliver them at the next appropriate opportunity.
* Consider them not blocked, to avoid trying to open an NMI Window.
*
* Correctness here relies on the fact that all vNMI capable hardware
* has vGIF, and vGIF is always activated when appropriate.
*/
- if ( intblk == hvm_intblk_nmi_iret &&
- vmcb->_vintr.fields.vnmi_enable )
+ if ( intblk == hvm_intblk_nmi_iret && 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 d970869cfd96..610c8c213cf2 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -427,7 +427,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.vintr_masking = true;
}
/* Interrupt state */
@@ -637,7 +637,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.vintrmask = ns_vmcb->_vintr.fields.intr_masking;
+ svm->ns_hostflags.vintrmask = ns_vmcb->_vintr.vintr_masking;
/* Save l1 guest state (= host state) */
ret = nsvm_vcpu_hostsave(v, inst_len);
@@ -723,8 +723,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.gif = false;
else
svm->ns_gif = 0;
@@ -979,7 +979,7 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct
cpu_user_regs *regs)
/* Virtual Interrupts */
ns_vmcb->_vintr = n2vmcb->_vintr;
if ( !svm->ns_hostflags.vintrmask )
- ns_vmcb->_vintr.fields.intr_masking = 0;
+ ns_vmcb->_vintr.vintr_masking = false;
/* Interrupt state */
ns_vmcb->int_stat = n2vmcb->int_stat;
@@ -1198,8 +1198,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.gif = false;
else
svm->ns_gif = 0;
@@ -1461,8 +1461,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.gif;
else
return svm->ns_gif;
}
@@ -1509,7 +1509,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.intr_pending = false;
general1_intercepts &= ~GENERAL1_INTERCEPT_VINTR;
vmcb_set_vintr(vmcb, intr);
vmcb_set_general1_intercepts(vmcb, general1_intercepts);
@@ -1543,12 +1543,11 @@ void svm_nested_features_on_efer_update(struct vcpu *v)
vmcb_set_general2_intercepts(vmcb, general2_intercepts);
}
- if ( !vmcb->_vintr.fields.vgif_enable &&
- cpu_has_svm_vgif )
+ 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.gif = svm->ns_gif;
+ vintr.vgif_en = true;
vmcb_set_vintr(vmcb, vintr);
general2_intercepts = vmcb_get_general2_intercepts(vmcb);
general2_intercepts &= ~(GENERAL2_INTERCEPT_STGI |
@@ -1567,11 +1566,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.gif;
+ vintr.vgif_en = false;
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 666bcd3eb483..3e08610d151f 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.nmi_blocked
: (vmcb_get_general1_intercepts(vmcb) & GENERAL1_INTERCEPT_IRET) )
intr_shadow |= HVM_INTR_SHADOW_NMI;
@@ -516,9 +516,9 @@ 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 ( vintr.fields.vnmi_enable )
+ if ( vintr.vnmi_en )
{
- vintr.fields.vnmi_blocking = block_nmi;
+ vintr.nmi_blocked = block_nmi;
vmcb_set_vintr(vmcb, vintr);
}
else
@@ -964,8 +964,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);
}
@@ -2542,7 +2541,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));
}
@@ -2776,7 +2775,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.intr_pending = false;
general1_intercepts &= ~GENERAL1_INTERCEPT_VINTR;
vmcb_set_vintr(vmcb, intr);
@@ -3067,8 +3066,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 33c85ea3bfc5..91b9581a2e34 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.vintr_masking = true;
/* 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 8b351679fac5..bfe4a4521dcb 100644
--- a/xen/arch/x86/hvm/svm/vmcb.h
+++ b/xen/arch/x86/hvm/svm/vmcb.h
@@ -328,28 +328,25 @@ typedef union {
uint64_t raw;
} intstat_t;
-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;
+typedef union {
+ struct { /* Cleanbit 3 (TPR), APM Name */
+ uint8_t tpr; /* c V_TPR */
+ bool intr_pending:1; /* c V_IRQ */
+ bool gif:1; /* VGIF */
+ bool :1;
+ bool nmi_pending:1; /* c V_NMI */
+ bool nmi_blocked:1; /* c V_NMI_MASK */
+ uint8_t :3;
+ uint8_t intr_prio:4; /* c V_INTR_PRIO */
+ bool ign_tpr:1; /* c V_IGN_TPR */
+ uint8_t :3;
+ bool vintr_masking:1; /* c V_INTR_MASKING */
+ bool vgif_en:1; /* VGIF_EN */
+ bool vnmi_en:1; /* V_NMI_ENABLE */
+ uint8_t :5;
+ uint8_t vector; /* c V_INTR_VECTOR */
+ };
+ uint64_t raw;
} vintr_t;
typedef union
--
2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |