On Wed, Apr 24, 2019 at 4:43 PM Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> wrote: > > According to section "CHECKING AND LOADING GUEST STATE" in Intel SDM vol 3C, > the following checks are performed on vmentry of nested guests: > > "If the "load IA32_PERF_GLOBAL_CTRL" VM-entry control is 1, bits reserved > in the IA32_PERF_GLOBAL_CTRL MSR must be 0 in the field for that > register." > > Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> > Reviewed-by: Karl Heubaum <karl.heubaum@xxxxxxxxxx> > --- > arch/x86/kvm/vmx/nested.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index d2067370e288..a7bf19eaa70b 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -2691,6 +2691,10 @@ static int nested_vmx_check_vmentry_postreqs(struct kvm_vcpu *vcpu, > return 1; > } > > + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL && > + !kvm_valid_perf_global_ctrl(vmcs12->guest_ia32_perf_global_ctrl)) > + return 1; > + I'd rather see this built on an interface like: bool kvm_valid_msr_value(u32 msr_index, u64 value); But as long as we don't end up with a plethora of kvm_valid_MSR_NAME(u64 value) functions, this looks fine. Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>