KVM: x86: don't expose MSR_IA32_UMWAIT_CONTROL unconditionally
PATCH 1/1 KVM: x86: don't expose MSR_IA32_UMWAIT_CONTROL unconditionally
From: Maxim Levitsky <[email protected]>
This msr is only available when the host supports WAITPKG feature.
This breaks a nested guest, if the L1 hypervisor is set to ignore unknown msrs, because the only other safety check that the kernel does is that it attempts to read the msr and rejects it if it gets an exception.
Message-Id: <[email protected]>
use boot_cpu_has for checking the feature)
--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/x86.c +4 -0
@@ -5226,6 +5226,10 @@ static void kvm_init_msr_list(void)if (!kvm_x86_ops->rdtscp_supported ())continue ;break ; +case MSR_IA32_UMWAIT_CONTROL : +if (!boot_cpu_has (X86_FEATURE_WAITPKG )) +continue ; +break ;case MSR_IA32_RTIT_CTL :case MSR_IA32_RTIT_STATUS :if (!kvm_x86_ops->pt_supported ())
Signature · 1 line
2.25.1
Quoted 28 lines · Jack Wang
From: Maxim Levitsky <[email protected]>
This msr is only available when the host supports WAITPKG feature.
This breaks a nested guest, if the L1 hypervisor is set to ignore unknown msrs, because the only other safety check that the kernel does is that it attempts to read the msr and rejects it if it gets an exception.
Fixes 6e3ba4abce ("KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL")Signed-off-by Maxim Levitsky <[email protected]>Message-Id: <[email protected]>
Reviewed-by Sean Christopherson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>(cherry picked from commit f4cfcd2d5aea4e96c5d483c476f3057b6b7baf6ause
boot_cpu_hasfor checking the feature)Signed-off-by Jack Wang <[email protected]>--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c static void kvm_init_msr_list(void) · line 5235
Quoted 10 lines
arch/x86/kvm/x86.c +4
-0@@ -5226,6 +5226,10 @@ static void kvm_init_msr_list(void)if (!kvm_x86_ops->rdtscp_supported ())continue ;break ; +case MSR_IA32_UMWAIT_CONTROL : +if (!boot_cpu_has (X86_FEATURE_WAITPKG )) +continue ; +break ;case MSR_IA32_RTIT_CTL :case MSR_IA32_RTIT_STATUS :if (!kvm_x86_ops->pt_supported ())
Thanks,
Paolo
Quoted 33 lines · Paolo Bonzini
Quoted 32 lines · Jack Wang
From: Maxim Levitsky <[email protected]>
This msr is only available when the host supports WAITPKG feature.
This breaks a nested guest, if the L1 hypervisor is set to ignore unknown msrs, because the only other safety check that the kernel does is that it attempts to read the msr and rejects it if it gets an exception.
Fixes 6e3ba4abce ("KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL")Signed-off-by Maxim Levitsky <[email protected]>Message-Id: <[email protected]>
Reviewed-by Sean Christopherson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>(cherry picked from commit f4cfcd2d5aea4e96c5d483c476f3057b6b7baf6ause
boot_cpu_hasfor checking the feature)Signed-off-by Jack Wang <[email protected]>--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kvm/x86.c +2
-0@@ -5226,6 +5226,10 @@ static void kvm_init_msr_list(void)if (!kvm_x86_ops->rdtscp_supported ())continue ;break ; +case MSR_IA32_UMWAIT_CONTROL : +if (!boot_cpu_has (X86_FEATURE_WAITPKG ))
Quoted 8 lines
arch/x86/kvm/x86.c static void kvm_init_msr_list(void) · line 5235
Quoted 6 lines
arch/x86/kvm/x86.c +2
-0+continue ; +break ;case MSR_IA32_RTIT_CTL :case MSR_IA32_RTIT_STATUS :if (!kvm_x86_ops->pt_supported ())Acked-by Paolo Bonzini <[email protected]>
Queued up, thanks!
Signature · 2 lines
Thanks, Sasha