Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH] kvm: vmx: Raise #UD on unsupported RDSEED
@ 2017-08-18 18:43 Jim Mattson
  2017-08-18 18:45 ` [PATCH v2] " Jim Mattson
  2017-08-21 13:00 ` [PATCH] " David Hildenbrand
  0 siblings, 2 replies; 19+ messages in thread
From: Jim Mattson @ 2017-08-18 18:43 UTC (permalink / raw)
  To: kvm; +Cc: Jim Mattson

A guest may not be configured to support RDSEED, even when the host
does. If the guest does not support RDSEED, intercept the instruction
and synthesize #UD.
---
 arch/x86/kvm/vmx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ed1074e98b8e..8b9015f081b7 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3662,6 +3662,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
 			SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
 			SECONDARY_EXEC_SHADOW_VMCS |
 			SECONDARY_EXEC_XSAVES |
+			SECONDARY_EXEC_RDSEED_EXITING |
 			SECONDARY_EXEC_ENABLE_PML |
 			SECONDARY_EXEC_TSC_SCALING |
 			SECONDARY_EXEC_ENABLE_VMFUNC;
@@ -5298,6 +5299,9 @@ static u32 vmx_secondary_exec_control(struct vcpu_vmx *vmx)
 	if (!enable_pml)
 		exec_control &= ~SECONDARY_EXEC_ENABLE_PML;
 
+	if (guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDSEED))
+		exec_control &= ~SECONDARY_EXEC_RDSEED_EXITING;
+
 	return exec_control;
 }
 
@@ -6806,6 +6810,12 @@ static int handle_mwait(struct kvm_vcpu *vcpu)
 	return handle_nop(vcpu);
 }
 
+static int handle_invalid_op(struct kvm_vcpu *vcpu)
+{
+	kvm_queue_exception(vcpu, UD_VECTOR);
+	return 1;
+}
+
 static int handle_monitor_trap(struct kvm_vcpu *vcpu)
 {
 	return 1;
@@ -8050,6 +8060,7 @@ static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
 	[EXIT_REASON_MONITOR_INSTRUCTION]     = handle_monitor,
 	[EXIT_REASON_INVEPT]                  = handle_invept,
 	[EXIT_REASON_INVVPID]                 = handle_invvpid,
+	[EXIT_REASON_RDSEED]                  = handle_invalid_op,
 	[EXIT_REASON_XSAVES]                  = handle_xsaves,
 	[EXIT_REASON_XRSTORS]                 = handle_xrstors,
 	[EXIT_REASON_PML_FULL]		      = handle_pml_full,
-- 
2.14.1.480.gb18f417b89-goog

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-08-23 23:33 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18 18:43 [PATCH] kvm: vmx: Raise #UD on unsupported RDSEED Jim Mattson
2017-08-18 18:45 ` [PATCH v2] " Jim Mattson
2017-08-21  1:49   ` Wanpeng Li
2017-08-21 13:00 ` [PATCH] " David Hildenbrand
2017-08-21 16:37   ` Jim Mattson
2017-08-21 16:50     ` David Hildenbrand
2017-08-21 17:01       ` Jim Mattson
2017-08-21 18:37         ` Jim Mattson
2017-08-21 19:16           ` [PATCH v4] " Jim Mattson
2017-08-21 16:38   ` [PATCH v3] " Jim Mattson
2017-08-21 19:26     ` [PATCH v5] " Jim Mattson
2017-08-21 20:32       ` Radim Krčmář
2017-08-21 22:03         ` Jim Mattson
2017-08-22 11:21           ` David Hildenbrand
2017-08-22 11:11       ` David Hildenbrand
2017-08-23 21:34       ` Paolo Bonzini
2017-08-23 22:37         ` Jim Mattson
2017-08-23 23:32           ` [PATCH v6 1/2] " Jim Mattson
2017-08-23 23:32             ` [PATCH v6 2/2] kvm: vmx: Raise #UD on unsupported RDRAND Jim Mattson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox