|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 11/28] x86/hvm: introduce vcpu_is_vlapic_tpr_emulated()
From: Denis Mukhin <dmukhin@xxxxxxxx>
Introduce vcpu_is_vlapic_tpr_emulated() in genetic SVM code to account
for the case when platform provides accelerated access to vLAPIC's TPR.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
xen/arch/x86/hvm/svm/svm.c | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 673c818a0039..14a86ca4ff8f 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -925,6 +925,19 @@ static void cf_check svm_ctxt_switch_to(struct vcpu *v)
}
}
+static bool vcpu_is_vlapic_tpr_emulated(const struct vcpu *v, bool
force_noaccel)
+{
+ const struct vlapic *vlapic = vcpu_vlapic(v);
+
+ if ( force_noaccel )
+ return false;
+
+ if ( vlapic_hw_disabled(vlapic) )
+ return false;
+
+ return true;
+}
+
static void noreturn cf_check svm_do_resume(void)
{
struct vcpu *v = current;
@@ -933,7 +946,6 @@ static void noreturn cf_check svm_do_resume(void)
v->domain->arch.monitor.software_breakpoint_enabled ||
v->domain->arch.monitor.debug_exception_enabled);
bool vcpu_guestmode = false;
- struct vlapic *vlapic = vcpu_vlapic(v);
if ( nestedhvm_enabled(v->domain) && nestedhvm_vcpu_in_guestmode(v) )
vcpu_guestmode = 1;
@@ -959,8 +971,9 @@ static void noreturn cf_check svm_do_resume(void)
vmcb->cleanbits.raw = 0;
}
- if ( !vcpu_guestmode && !vlapic_hw_disabled(vlapic) )
+ if ( vcpu_is_vlapic_tpr_emulated(v, vcpu_guestmode) )
{
+ struct vlapic *vlapic = vcpu_vlapic(v);
vintr_t intr;
/* Reflect the vlapic's TPR in the hardware vtpr */
@@ -2538,7 +2551,6 @@ void asmlinkage svm_vmexit_handler(void)
int insn_len;
vintr_t intr;
bool vcpu_guestmode = false;
- struct vlapic *vlapic = vcpu_vlapic(v);
regs->rax = vmcb->rax;
regs->rip = vmcb->rip;
@@ -2565,8 +2577,10 @@ void asmlinkage svm_vmexit_handler(void)
* NB. We need to preserve the low bits of the TPR to make checked builds
* of Windows work, even though they don't actually do anything.
*/
- if ( !vcpu_guestmode && !vlapic_hw_disabled(vlapic) )
+ if ( vcpu_is_vlapic_tpr_emulated(v, vcpu_guestmode) )
{
+ struct vlapic *vlapic = vcpu_vlapic(v);
+
intr = vmcb_get_vintr(vmcb);
vlapic_set_reg(vlapic, APIC_TASKPRI,
((intr.fields.tpr & 0x0F) << 4) |
@@ -3097,14 +3111,16 @@ void asmlinkage svm_vmexit_handler(void)
}
out:
- if ( vcpu_guestmode || vlapic_hw_disabled(vlapic) )
- return;
+ if ( vcpu_is_vlapic_tpr_emulated(v, vcpu_guestmode ) )
+ {
+ struct vlapic *vlapic = vcpu_vlapic(v);
- /* 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;
- vmcb_set_vintr(vmcb, intr);
+ /* 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;
+ vmcb_set_vintr(vmcb, intr);
+ }
}
/*
--
2.55.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |