KVM: VMX: Add a macro to track which DEBUGCTL bits are host-owned
Add VMX_HOST_OWNED_DEBUGCTL_BITS to track which bits are host-owned, i.e. need to be preserved when running the guest, to dedup the logic without having to incur a memory load to get at kvm_x86_ops.HOST_OWNED_DEBUGCTL. No functional change intended. Suggested-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Link: https://lore.kernel.org/all/aF1yni8U6XNkyfRf@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
@@ -915,7 +915,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
|
||||
.vcpu_load = vt_op(vcpu_load),
|
||||
.vcpu_put = vt_op(vcpu_put),
|
||||
|
||||
.HOST_OWNED_DEBUGCTL = DEBUGCTLMSR_FREEZE_IN_SMM,
|
||||
.HOST_OWNED_DEBUGCTL = VMX_HOST_OWNED_DEBUGCTL_BITS,
|
||||
|
||||
.update_exception_bitmap = vt_op(update_exception_bitmap),
|
||||
.get_feature_msr = vmx_get_feature_msr,
|
||||
|
||||
@@ -410,27 +410,29 @@ void vmx_update_cpu_dirty_logging(struct kvm_vcpu *vcpu);
|
||||
u64 vmx_get_supported_debugctl(struct kvm_vcpu *vcpu, bool host_initiated);
|
||||
bool vmx_is_valid_debugctl(struct kvm_vcpu *vcpu, u64 data, bool host_initiated);
|
||||
|
||||
#define VMX_HOST_OWNED_DEBUGCTL_BITS (DEBUGCTLMSR_FREEZE_IN_SMM)
|
||||
|
||||
static inline void vmx_guest_debugctl_write(struct kvm_vcpu *vcpu, u64 val)
|
||||
{
|
||||
WARN_ON_ONCE(val & DEBUGCTLMSR_FREEZE_IN_SMM);
|
||||
WARN_ON_ONCE(val & VMX_HOST_OWNED_DEBUGCTL_BITS);
|
||||
|
||||
val |= vcpu->arch.host_debugctl & DEBUGCTLMSR_FREEZE_IN_SMM;
|
||||
val |= vcpu->arch.host_debugctl & VMX_HOST_OWNED_DEBUGCTL_BITS;
|
||||
vmcs_write64(GUEST_IA32_DEBUGCTL, val);
|
||||
}
|
||||
|
||||
static inline u64 vmx_guest_debugctl_read(void)
|
||||
{
|
||||
return vmcs_read64(GUEST_IA32_DEBUGCTL) & ~DEBUGCTLMSR_FREEZE_IN_SMM;
|
||||
return vmcs_read64(GUEST_IA32_DEBUGCTL) & ~VMX_HOST_OWNED_DEBUGCTL_BITS;
|
||||
}
|
||||
|
||||
static inline void vmx_reload_guest_debugctl(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u64 val = vmcs_read64(GUEST_IA32_DEBUGCTL);
|
||||
|
||||
if (!((val ^ vcpu->arch.host_debugctl) & DEBUGCTLMSR_FREEZE_IN_SMM))
|
||||
if (!((val ^ vcpu->arch.host_debugctl) & VMX_HOST_OWNED_DEBUGCTL_BITS))
|
||||
return;
|
||||
|
||||
vmx_guest_debugctl_write(vcpu, val & ~DEBUGCTLMSR_FREEZE_IN_SMM);
|
||||
vmx_guest_debugctl_write(vcpu, val & ~VMX_HOST_OWNED_DEBUGCTL_BITS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user