From: Joerg Roedel <joerg.roedel@amd.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 11/11] KVM: SVM: Don't call instruction emulator for invd and wbinvd
Date: Fri, 19 Feb 2010 16:23:10 +0100 [thread overview]
Message-ID: <1266592990-8911-12-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1266592990-8911-1-git-send-email-joerg.roedel@amd.com>
There is an intercept for WBINVD and INVD in SVM so we don't
need the instruction emulator. The primary reason is that
the current instruction emulator fails to emulate these
instructions and the rip is not advanced.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kvm/emulate.c | 4 ++++
arch/x86/kvm/svm.c | 14 ++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 9beda8e..0180cb1 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1029,6 +1029,10 @@ done_prefixes:
/* Unrecognised? */
if (c->d == 0) {
+ /* Don't fail for invd and wbinvd*/
+ if (c->twobyte && (c->b == 0x08 || c->b == 0x09))
+ return 0;
+
DPRINTF("Cannot emulate %02x\n", c->b);
return -1;
}
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 8119355..5fd00e8 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2117,6 +2117,16 @@ static int cpuid_interception(struct vcpu_svm *svm)
return 1;
}
+static int invd_interception(struct vcpu_svm *svm)
+{
+ svm->next_rip = kvm_rip_read(&svm->vcpu) + 2;
+ skip_emulated_instruction(&svm->vcpu);
+
+ /* Nop */
+
+ return 1;
+}
+
static int iret_interception(struct vcpu_svm *svm)
{
++svm->vcpu.stat.nmi_window_exits;
@@ -2418,7 +2428,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = {
/* [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, */
[SVM_EXIT_CPUID] = cpuid_interception,
[SVM_EXIT_IRET] = iret_interception,
- [SVM_EXIT_INVD] = emulate_on_interception,
+ [SVM_EXIT_INVD] = invd_interception,
[SVM_EXIT_PAUSE] = pause_interception,
[SVM_EXIT_HLT] = halt_interception,
[SVM_EXIT_INVLPG] = invlpg_interception,
@@ -2434,7 +2444,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = {
[SVM_EXIT_STGI] = stgi_interception,
[SVM_EXIT_CLGI] = clgi_interception,
[SVM_EXIT_SKINIT] = skinit_interception,
- [SVM_EXIT_WBINVD] = emulate_on_interception,
+ [SVM_EXIT_WBINVD] = invd_interception,
[SVM_EXIT_MONITOR] = invalid_op_interception,
[SVM_EXIT_MWAIT] = invalid_op_interception,
[SVM_EXIT_NPF] = pf_interception,
--
1.6.6
next prev parent reply other threads:[~2010-02-19 15:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 15:22 [PATCH 0/11] Nested SVM fixes v2 Joerg Roedel
2010-02-19 15:23 ` [PATCH 01/11] KVM: SVM: Don't use kmap_atomic in nested_svm_map Joerg Roedel
2010-02-19 15:23 ` [PATCH 02/11] KVM: SVM: Fix wrong interrupt injection in enable_irq_windows Joerg Roedel
2010-02-22 10:29 ` Joerg Roedel
2010-02-22 11:05 ` Avi Kivity
2010-02-19 15:23 ` [PATCH 03/11] KVM: SVM: Fix schedule-while-atomic on nested exception handling Joerg Roedel
2010-02-19 15:23 ` [PATCH 04/11] KVM: SVM: Sync all control registers on nested vmexit Joerg Roedel
2010-02-19 15:23 ` [PATCH 05/11] KVM: SVM: Annotate nested_svm_map with might_sleep() Joerg Roedel
2010-02-19 15:23 ` [PATCH 06/11] KVM: SVM: Fix nested msr intercept handling Joerg Roedel
2010-02-19 15:23 ` [PATCH 07/11] KVM: SVM: Don't sync nested cr8 to lapic and back Joerg Roedel
2010-02-19 15:23 ` [PATCH 08/11] KVM: SVM: Activate nested state only when guest state is complete Joerg Roedel
2010-02-19 15:23 ` [PATCH 09/11] KVM: SVM: Make lazy FPU switching work with nested svm Joerg Roedel
2010-02-19 15:23 ` [PATCH 10/11] KVM: SVM: Remove newlines from nested trace points Joerg Roedel
2010-02-19 15:23 ` Joerg Roedel [this message]
2010-02-21 9:53 ` [PATCH 11/11] KVM: SVM: Don't call instruction emulator for invd and wbinvd Avi Kivity
2010-02-21 11:37 ` Joerg Roedel
2010-02-21 12:00 ` Avi Kivity
2010-02-21 12:12 ` Joerg Roedel
2010-02-21 9:56 ` [PATCH 0/11] Nested SVM fixes v2 Avi Kivity
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=1266592990-8911-12-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®