Skip to contentSkip to conversation

KVM: nested VMX: disable perf cpuid reporting

PATCH Marcelo Tosatti 2 participants 4 messages Sep 18, 2014 – Sep 22, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Initilization of L2 guest with -cpu host, on L1 guest with -cpu host triggers:

(qemu) KVM: entry failed, hardware error 0x7
...
nested_vmx_run: VMCS MSR_{LOAD,STORE} unsupported

Nested VMX MSR load/store support is not sufficient to allow perf for L2 guest.

Until properly fixed, trap CPUID and disable function 0xA.

arch/x86/kvm/cpuid.c +6 -0
index e28d798..976e3a5 100644
@@ -774,6 +774,12 @@ void kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
 	if (!best)
 		best = check_cpuid_limit(vcpu, function, index);
 
+	/*
+	 * Perfmon not yet supported for L2 guest.
+	 */
+	if (is_guest_mode(vcpu) && function == 0xa)
+		best = NULL;
+
 	if (best) {
 		*eax = best->eax;
 		*ebx = best->ebx;
arch/x86/kvm/vmx.c +2 -0
index e8f08e9..2ab5047 100644
@@ -6986,6 +6986,8 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
 	case EXIT_REASON_TASK_SWITCH:
 		return 1;
 	case EXIT_REASON_CPUID:
+		if (kvm_register_read(vcpu, VCPU_REGS_RAX) == 0xa)
+			return 0;
 		return 1;
 	case EXIT_REASON_HLT:
 		return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING);
maintainer
#1 lore raw

Il 18/09/2014 23:24, Marcelo Tosatti ha scritto:

Quoted 38 lines

Initilization of L2 guest with -cpu host, on L1 guest with -cpu host triggers:

(qemu) KVM: entry failed, hardware error 0x7
...
nested_vmx_run: VMCS MSR_{LOAD,STORE} unsupported

Nested VMX MSR load/store support is not sufficient to allow perf for L2 guest.

Until properly fixed, trap CPUID and disable function 0xA.

arch/x86/kvm/cpuid.c +6 -0
index e28d798..976e3a5 100644
@@ -774,6 +774,12 @@ void kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
 	if (!best)
 		best = check_cpuid_limit(vcpu, function, index);
 
+	/*
+	 * Perfmon not yet supported for L2 guest.
+	 */
+	if (is_guest_mode(vcpu) && function == 0xa)
+		best = NULL;
+
 	if (best) {
 		*eax = best->eax;
 		*ebx = best->ebx;
arch/x86/kvm/vmx.c +0 -0
index e8f08e9..2ab5047 100644

arch/x86/kvm/vmx.c static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) · line 6993

Quoted 8 lines
arch/x86/kvm/vmx.c +2 -0
@@ -6986,6 +6986,8 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
 	case EXIT_REASON_TASK_SWITCH:
 		return 1;
 	case EXIT_REASON_CPUID:
+		if (kvm_register_read(vcpu, VCPU_REGS_RAX) == 0xa)
+			return 0;
 		return 1;
 	case EXIT_REASON_HLT:
 		return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING);

Nice solution. :)

Paolo

#2 lore raw
In reply to Marcelo Tosatti
Quoted 8 lines · Marcelo Tosatti

Initilization of L2 guest with -cpu host, on L1 guest with -cpu host triggers:

(qemu) KVM: entry failed, hardware error 0x7
...
nested_vmx_run: VMCS MSR_{LOAD,STORE} unsupported

Quoted 6 lines

Nested VMX MSR load/store support is not sufficient to allow perf for L2 guest.

Until properly fixed, trap CPUID and disable function 0xA.

Ping, Paolo?

maintainer
#3 lore raw

Il 22/09/2014 21:01, Marcelo Tosatti ha scritto:

Quoted 9 lines · Marcelo Tosatti
Quoted 8 lines

Initilization of L2 guest with -cpu host, on L1 guest with -cpu host triggers:

(qemu) KVM: entry failed, hardware error 0x7
...
nested_vmx_run: VMCS MSR_{LOAD,STORE} unsupported

Quoted 9 lines
Quoted 6 lines

Nested VMX MSR load/store support is not sufficient to allow perf for L2 guest.

Until properly fixed, trap CPUID and disable function 0xA.

Ping, Paolo?

Sorry, didn't push to kvm/queue but I've already applied the patch locally. I will do it first thing tomorrow (my workstation is off right now so I cannot send you a SHA).

Paolo