[PATCH 30/41] KVM: SVM: forbid guest to execute monitor/mwait
- From: Avi Kivity <avi@xxxxxxxxxxxx>
- Date: Sun, 1 Apr 2007 17:35:27 +0300
From: Joerg Roedel <joerg.roedel@xxxxxxx>
This patch forbids the guest to execute monitor/mwait instructions on
SVM. This is necessary because the guest can execute these instructions
if they are available even if the kvm cpuid doesn't report its
existence.
Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx>
Signed-off-by: Avi Kivity <avi@xxxxxxxxxxxx>
---
drivers/kvm/svm.c | 6 +++++-
drivers/kvm/svm.h | 6 ++++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index ddc0505..0542d33 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -511,7 +511,9 @@ static void init_vmcb(struct vmcb *vmcb)
(1ULL << INTERCEPT_VMSAVE) |
(1ULL << INTERCEPT_STGI) |
(1ULL << INTERCEPT_CLGI) |
- (1ULL << INTERCEPT_SKINIT);
+ (1ULL << INTERCEPT_SKINIT) |
+ (1ULL << INTERCEPT_MONITOR) |
+ (1ULL << INTERCEPT_MWAIT);
control->iopm_base_pa = iopm_base;
control->msrpm_base_pa = msrpm_base;
@@ -1292,6 +1294,8 @@ static int (*svm_exit_handlers[])(struct kvm_vcpu *vcpu,
[SVM_EXIT_STGI] = invalid_op_interception,
[SVM_EXIT_CLGI] = invalid_op_interception,
[SVM_EXIT_SKINIT] = invalid_op_interception,
+ [SVM_EXIT_MONITOR] = invalid_op_interception,
+ [SVM_EXIT_MWAIT] = invalid_op_interception,
};
diff --git a/drivers/kvm/svm.h b/drivers/kvm/svm.h
index df731c3..5e93814 100644
--- a/drivers/kvm/svm.h
+++ b/drivers/kvm/svm.h
@@ -44,6 +44,9 @@ enum {
INTERCEPT_RDTSCP,
INTERCEPT_ICEBP,
INTERCEPT_WBINVD,
+ INTERCEPT_MONITOR,
+ INTERCEPT_MWAIT,
+ INTERCEPT_MWAIT_COND,
};
@@ -298,6 +301,9 @@ struct __attribute__ ((__packed__)) vmcb {
#define SVM_EXIT_RDTSCP 0x087
#define SVM_EXIT_ICEBP 0x088
#define SVM_EXIT_WBINVD 0x089
+#define SVM_EXIT_MONITOR 0x08a
+#define SVM_EXIT_MWAIT 0x08b
+#define SVM_EXIT_MWAIT_COND 0x08c
#define SVM_EXIT_NPF 0x400
#define SVM_EXIT_ERR -1
--
1.5.0.5
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- References:
- [PATCH 00/41] kvm updates for 2.6.22
- From: Avi Kivity
- [PATCH 01/41] KVM: Fix guest register corruption on paravirt hypercall
- From: Avi Kivity
- [PATCH 02/41] KVM: Use the generic skip_emulated_instruction() in hypercall code
- From: Avi Kivity
- [PATCH 03/41] KVM: Use own minor number
- From: Avi Kivity
- [PATCH 04/41] KVM: Export <linux/kvm.h>
- From: Avi Kivity
- [PATCH 05/41] KVM: Fix bogus sign extension in mmu mapping audit
- From: Avi Kivity
- [PATCH 06/41] KVM: Use a shared page for kernel/user communication when runing a vcpu
- From: Avi Kivity
- [PATCH 07/41] KVM: Do not communicate to userspace through cpu registers during PIO
- From: Avi Kivity
- [PATCH 08/41] KVM: Handle cpuid in the kernel instead of punting to userspace
- From: Avi Kivity
- [PATCH 09/41] KVM: Remove the 'emulated' field from the userspace interface
- From: Avi Kivity
- [PATCH 10/41] KVM: Remove minor wart from KVM_CREATE_VCPU ioctl
- From: Avi Kivity
- [PATCH 11/41] KVM: Renumber ioctls
- From: Avi Kivity
- [PATCH 12/41] KVM: Add method to check for backwards-compatible API extensions
- From: Avi Kivity
- [PATCH 13/41] KVM: Allow userspace to process hypercalls which have no kernel handler
- From: Avi Kivity
- [PATCH 14/41] KVM: Fold kvm_run::exit_type into kvm_run::exit_reason
- From: Avi Kivity
- [PATCH 15/41] KVM: Add a special exit reason when exiting due to an interrupt
- From: Avi Kivity
- [PATCH 16/41] KVM: Initialize the apic_base msr on svm too
- From: Avi Kivity
- [PATCH 17/41] KVM: Add guest mode signal mask
- From: Avi Kivity
- [PATCH 18/41] KVM: Allow kernel to select size of mmap() buffer
- From: Avi Kivity
- [PATCH 19/41] KVM: Future-proof argument-less ioctls
- From: Avi Kivity
- [PATCH 21/41] KVM: MMU: Remove unnecessary check for pdptr access
- From: Avi Kivity
- [PATCH 22/41] KVM: MMU: Remove global pte tracking
- From: Avi Kivity
- [PATCH 23/41] KVM: Workaround vmx inability to virtualize the reset state
- From: Avi Kivity
- [PATCH 24/41] KVM: Remove set_cr0_no_modeswitch() arch op
- From: Avi Kivity
- [PATCH 25/41] KVM: Modify guest segments after potentially switching modes
- From: Avi Kivity
- [PATCH 26/41] KVM: Hack real-mode segments on vmx from KVM_SET_SREGS
- From: Avi Kivity
- [PATCH 27/41] KVM: Don't allow the guest to turn off the cpu cache
- From: Avi Kivity
- [PATCH 28/41] KVM: Remove unused and write-only variables
- From: Avi Kivity
- [PATCH 29/41] KVM: Handle writes to MCG_STATUS msr
- From: Avi Kivity
- [PATCH 00/41] kvm updates for 2.6.22
- Prev by Date: [PATCH 40/41] KVM: Add fpu get/set operations
- Next by Date: [PATCH 28/41] KVM: Remove unused and write-only variables
- Previous by thread: [PATCH 29/41] KVM: Handle writes to MCG_STATUS msr
- Next by thread: [PATCH 31/41] KVM: MMU: Fix hugepage pdes mapping same physical address with different access
- Index(es):