From: Yang Zhang <yang.zhang.wz@gmail.com>
To: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
"rkrcmar@redhat.com" <rkrcmar@redhat.com>
Subject: [PATCH] KVM: x86: no need to check CPL for XSETBV on VMX
Date: Fri, 15 Apr 2016 09:55:47 +0800 [thread overview]
Message-ID: <57104A23.4070405@gmail.com> (raw)
The CPL check for XSETBV instruction is done by hardware on VMX.
It only needs by SVM.
Signed-off-by: Yang Zhang <yang.zhang.wz@gmail.com>
---
arch/x86/kvm/svm.c | 4 +++-
arch/x86/kvm/x86.c | 3 +--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 31346a3..14680f5 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2715,7 +2715,9 @@ static int xsetbv_interception(struct vcpu_svm *svm)
u64 new_bv = kvm_read_edx_eax(&svm->vcpu);
u32 index = kvm_register_read(&svm->vcpu, VCPU_REGS_RCX);
- if (kvm_set_xcr(&svm->vcpu, index, new_bv) == 0) {
+ if (svm_get_cpl(&svm->vcpu) != 0)
+ kvm_inject_gp(&svm->vcpu, 0);
+ else if (kvm_set_xcr(&svm->vcpu, index, new_bv) == 0) {
svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
skip_emulated_instruction(&svm->vcpu);
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8f57335..3cfc59f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -709,8 +709,7 @@ static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32
index, u64 xcr)
int kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
{
- if (kvm_x86_ops->get_cpl(vcpu) != 0 ||
- __kvm_set_xcr(vcpu, index, xcr)) {
+ if (__kvm_set_xcr(vcpu, index, xcr)) {
kvm_inject_gp(vcpu, 0);
return 1;
}
--
1.8.3.1
next reply other threads:[~2016-04-15 1:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 1:55 Yang Zhang [this message]
2016-04-15 10:11 ` [PATCH] KVM: x86: no need to check CPL for XSETBV on VMX Paolo Bonzini
2016-04-15 10:37 ` Yang Zhang
2016-04-15 10:43 ` Paolo Bonzini
2016-04-15 10:55 ` Yang Zhang
2016-04-15 11:03 ` Paolo Bonzini
2016-04-15 11:23 ` Yang Zhang
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=57104A23.4070405@gmail.com \
--to=yang.zhang.wz@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/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.