[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 5/9] x86/vmx: Fix handing of MSR_DEBUGCTL on VMExit
Currently, whenever the guest writes a nonzero value to MSR_DEBUGCTL, Xen updates a host MSR load list entry with the current hardware value of MSR_DEBUGCTL. This is wrong. On VMExit, hardware automatically resets MSR_DEBUGCTL to 0. The only case where different behaviour is needed is if Xen is debugging itself, and this needs setting up unconditionally for the lifetime of the VM. The `ler` command line boolean is the only way to configure any use of MSR_DEBUGCTL for Xen, so tie the host load list entry to this setting in construct_vmcs(). Any runtime update of Xen's MSR_DEBUGCTL setting requires more complicated synchronisation across all the running VMs. In the exceedingly common case, this avoids the unnecessary overhead of having a host load entry performing the same zeroing operation that hardware has already performed as part of the VMExit. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Jun Nakajima <jun.nakajima@xxxxxxxxx> CC: Kevin Tian <kevin.tian@xxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> Notes for backporting: This change probably does want backporting, but depends on the previous patch "Support remote access to the MSR lists", and adds an extra rdmsr to the vcpu construction path (resolved in a later patch). --- xen/arch/x86/hvm/vmx/vmcs.c | 6 ++++++ xen/arch/x86/hvm/vmx/vmx.c | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 8bf54c4..2035a6d 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -996,6 +996,7 @@ static int construct_vmcs(struct vcpu *v) struct domain *d = v->domain; u32 vmexit_ctl = vmx_vmexit_control; u32 vmentry_ctl = vmx_vmentry_control; + int rc; vmx_vmcs_enter(v); @@ -1266,6 +1267,11 @@ static int construct_vmcs(struct vcpu *v) if ( cpu_has_vmx_tsc_scaling ) __vmwrite(TSC_MULTIPLIER, d->arch.hvm_domain.tsc_scaling_ratio); + /* If using host debugging, restore Xen's setting on vmexit. */ + if ( this_cpu(ler_msr) && + (rc = vmx_add_host_load_msr(v, MSR_IA32_DEBUGCTLMSR)) ) + return rc; + vmx_vmcs_exit(v); /* will update HOST & GUEST_CR3 as reqd */ diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 3950b12..f9cfb6d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3120,8 +3120,7 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) } } - if ( (rc < 0) || - (msr_content && (vmx_add_host_load_msr(v, msr) < 0)) ) + if ( rc < 0 ) hvm_inject_hw_exception(TRAP_machine_check, X86_EVENT_NO_EC); else __vmwrite(GUEST_IA32_DEBUGCTL, msr_content); -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |