[5/8,nVMX] : Check "load IA32_PERF_GLOBAL_CTRL" VM-entry control on vmentry of nested guests
diff mbox series

Message ID 20190424231724.2014-6-krish.sadhukhan@oracle.com
State New
Headers show
Series
  • [1/8,KVMnVMX] : Enable "load IA32_PERF_GLOBAL_CTRL" VM-exit control for nested guests
Related show

Commit Message

Krish Sadhukhan April 24, 2019, 11:17 p.m. UTC
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@oracle.com>
Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
---
 arch/x86/kvm/vmx/nested.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jim Mattson Aug. 15, 2019, 10:36 p.m. UTC | #1
On Wed, Apr 24, 2019 at 4:43 PM Krish Sadhukhan
<krish.sadhukhan@oracle.com> 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@oracle.com>
> Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
> ---
>  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@google.com>

Patch
diff mbox series

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;
+
 	/*
 	 * If the load IA32_EFER VM-entry control is 1, the following checks
 	 * are performed on the field for the IA32_EFER MSR: