From: Jim Mattson <jmattson@google.com>
To: kvm@vger.kernel.org
Cc: Jim Mattson <jmattson@google.com>
Subject: [PATCH] kvm: vmx: Raise #UD on unsupported RDSEED
Date: Fri, 18 Aug 2017 11:43:10 -0700 [thread overview]
Message-ID: <20170818184310.117806-1-jmattson@google.com> (raw)
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
next reply other threads:[~2017-08-18 18:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 18:43 Jim Mattson [this message]
2017-08-18 18:45 ` [PATCH v2] kvm: vmx: Raise #UD on unsupported RDSEED 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170818184310.117806-1-jmattson@google.com \
--to=jmattson@google.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.