KVM: nVMX: WARN on failure to set IA32_PERF_GLOBAL_CTRL
PATCH 1/1 KVM: nVMX: WARN on failure to set IA32_PERF_GLOBAL_CTRL
Writes to MSR_CORE_PERF_GLOBAL_CONTROL should never fail if the VM-exit and VM-entry controls are exposed to L1. Promote the checks to perform a full WARN if kvm_set_msr() fails and remove the now unused macro SET_MSR_OR_WARN().
--- arch/x86/kvm/vmx/nested.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
arch/x86/kvm/vmx/nested.c +4 -14
@@ -28,16 +28,6 @@ module_param(nested_early_check, bool, S_IRUGO); failed; \ }) -#define SET_MSR_OR_WARN (vcpu, idx, data) \ -({ \ - bool failed = kvm_set_msr(vcpu, idx, data); \ - if (failed) \ - pr_warn_ratelimited( \ - "%s cannot write MSR (0x%x, 0x%llx)\n", \ - __func__, idx, data); \ - failed; \ -}) -/* * Hyper-V requires all of these, so mark them as supported even though * they are just treated the same as all-context.
@@ -2550,8 +2540,8 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, vcpu->arch.walk_mmu->inject_page_fault = vmx_inject_page_fault_nested;if ((vmcs12->vm_entry_controls &VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL ) && -SET_MSR_OR_WARN (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , - vmcs12->guest_ia32_perf_global_ctrl)) +WARN_ON_ONCE (kvm_set_msr (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , + vmcs12->guest_ia32_perf_global_ctrl)))return -EINVAL ;kvm_rsp_write (vcpu, vmcs12->guest_rsp);
@@ -3999,8 +3989,8 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, vcpu->arch.pat = vmcs12->host_ia32_pat; }if (vmcs12->vm_exit_controls &VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL ) -SET_MSR_OR_WARN (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , - vmcs12->host_ia32_perf_global_ctrl); +WARN_ON_ONCE (kvm_set_msr (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , + vmcs12->host_ia32_perf_global_ctrl));/* Set L1 segment info according to Intel SDM 27.5.2 Loading Host Segment and Descriptor-Table Registers */
Signature · 1 line
2.24.1.735.g03f4e72817-goog
Quoted 9 lines · Oliver Upton
Writes to
MSR_CORE_PERF_GLOBAL_CONTROLshould never fail if the VM-exit and VM-entry controls are exposed to L1. Promote the checks to perform a full WARN ifkvm_set_msr()fails and remove the now unused macroSET_MSR_OR_WARN().Suggested-by Sean Christopherson <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Oliver Upton <[email protected]>---
Quoted 6 lines · Sean Christopherson
Quoted 5 lines · Oliver Upton
Writes to
MSR_CORE_PERF_GLOBAL_CONTROLshould never fail if the VM-exit and VM-entry controls are exposed to L1. Promote the checks to perform a full WARN ifkvm_set_msr()fails and remove the now unused macroSET_MSR_OR_WARN().
Quoted 6 lines
Quoted 4 lines
Suggested-by Sean Christopherson <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Oliver Upton <[email protected]>---
Reviewed-by Sean Christopherson <[email protected]>
Ping :)
Quoted 46 lines · Oliver Upton
Writes to
MSR_CORE_PERF_GLOBAL_CONTROLshould never fail if the VM-exit and VM-entry controls are exposed to L1. Promote the checks to perform a full WARN ifkvm_set_msr()fails and remove the now unused macroSET_MSR_OR_WARN().Suggested-by Sean Christopherson <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Oliver Upton <[email protected]>--- arch/x86/kvm/vmx/nested.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)arch/x86/kvm/vmx/nested.c +2
-12@@ -28,16 +28,6 @@ module_param(nested_early_check, bool, S_IRUGO); failed; \ }) -#define SET_MSR_OR_WARN (vcpu, idx, data) \ -({ \ - bool failed = kvm_set_msr(vcpu, idx, data); \ - if (failed) \ - pr_warn_ratelimited( \ - "%s cannot write MSR (0x%x, 0x%llx)\n", \ - __func__, idx, data); \ - failed; \ -}) -/* * Hyper-V requires all of these, so mark them as supported even though * they are just treated the same as all-context. @@ -2550,8 +2540,8 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, vcpu->arch.walk_mmu->inject_page_fault = vmx_inject_page_fault_nested;if ((vmcs12->vm_entry_controls &VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL ) && -SET_MSR_OR_WARN (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , - vmcs12->guest_ia32_perf_global_ctrl)) +WARN_ON_ONCE (kvm_set_msr (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , + vmcs12->guest_ia32_perf_global_ctrl)))return -EINVAL ;kvm_rsp_write (vcpu, vmcs12->guest_rsp);
arch/x86/kvm/vmx/nested.c static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, · line 3996
Quoted 10 lines
arch/x86/kvm/vmx/nested.c +2
-2@@ -3999,8 +3989,8 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, vcpu->arch.pat = vmcs12->host_ia32_pat; }if (vmcs12->vm_exit_controls &VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL ) -SET_MSR_OR_WARN (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , - vmcs12->host_ia32_perf_global_ctrl); +WARN_ON_ONCE (kvm_set_msr (vcpu,MSR_CORE_PERF_GLOBAL_CTRL , + vmcs12->host_ia32_perf_global_ctrl));/* Set L1 segment info according to Intel SDM 27.5.2 Loading Host Segment and Descriptor-Table Registers */
Queued, thanks.
Paolo