[PATCH 41/41] KVM: SVM: enable LBRV virtualization if available
- From: Avi Kivity <avi@xxxxxxxxxxxx>
- Date: Sun, 1 Apr 2007 17:35:38 +0300
From: Joerg Roedel <joerg.roedel@xxxxxxx>
This patch enables the virtualization of the last branch record MSRs on
SVM if this feature is available in hardware. It also introduces a small
and simple check feature for specific SVM extensions.
Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx>
Signed-off-by: Avi Kivity <avi@xxxxxxxxxxxx>
---
drivers/kvm/svm.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 303e959..b7e1410 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -44,6 +44,10 @@ MODULE_LICENSE("GPL");
#define KVM_EFER_LMA (1 << 10)
#define KVM_EFER_LME (1 << 8)
+#define SVM_FEATURE_NPT (1 << 0)
+#define SVM_FEATURE_LBRV (1 << 1)
+#define SVM_DEATURE_SVML (1 << 2)
+
unsigned long iopm_base;
unsigned long msrpm_base;
@@ -68,6 +72,7 @@ struct svm_cpu_data {
};
static DEFINE_PER_CPU(struct svm_cpu_data *, svm_data);
+static uint32_t svm_features;
struct svm_init_data {
int cpu;
@@ -82,6 +87,11 @@ static u32 msrpm_ranges[] = {0, 0xc0000000, 0xc0010000};
#define MAX_INST_SIZE 15
+static inline u32 svm_has(u32 feat)
+{
+ return svm_features & feat;
+}
+
static unsigned get_addr_size(struct kvm_vcpu *vcpu)
{
struct vmcb_save_area *sa = &vcpu->svm->vmcb->save;
@@ -302,6 +312,7 @@ static void svm_hardware_enable(void *garbage)
svm_data->asid_generation = 1;
svm_data->max_asid = cpuid_ebx(SVM_CPUID_FUNC) - 1;
svm_data->next_asid = svm_data->max_asid + 1;
+ svm_features = cpuid_edx(SVM_CPUID_FUNC);
asm volatile ( "sgdt %0" : "=m"(gdt_descr) );
gdt = (struct desc_struct *)gdt_descr.address;
@@ -511,6 +522,8 @@ static void init_vmcb(struct vmcb *vmcb)
control->msrpm_base_pa = msrpm_base;
control->tsc_offset = 0;
control->int_ctl = V_INTR_MASKING_MASK;
+ if (svm_has(SVM_FEATURE_LBRV))
+ control->lbr_ctl = 1ULL;
init_seg(&save->es);
init_seg(&save->ss);
--
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/
- 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 30/41] KVM: SVM: forbid guest to execute monitor/mwait
- From: Avi Kivity
- [PATCH 31/41] KVM: MMU: Fix hugepage pdes mapping same physical address with different access
- From: Avi Kivity
- [PATCH 32/41] KVM: SVM: Ensure timestamp counter monotonicity
- From: Avi Kivity
- [PATCH 33/41] KVM: Remove unused function
- From: Avi Kivity
- [PATCH 34/41] KVM: Use list_move()
- From: Avi Kivity
- [PATCH 35/41] KVM: Remove debug message
- From: Avi Kivity
- [PATCH 36/41] KVM: x86 emulator: fix bit string operations operand size
- From: Avi Kivity
- [PATCH 37/41] KVM: Add mmu cache clear function
- From: Avi Kivity
- [PATCH 38/41] KVM: Simply gfn_to_page()
- From: Avi Kivity
- [PATCH 39/41] KVM: Add physical memory aliasing feature
- From: Avi Kivity
- [PATCH 40/41] KVM: Add fpu get/set operations
- From: Avi Kivity
- [PATCH 00/41] kvm updates for 2.6.22
- Prev by Date: [PATCH 06/41] KVM: Use a shared page for kernel/user communication when runing a vcpu
- Next by Date: [PATCH 32/41] KVM: SVM: Ensure timestamp counter monotonicity
- Previous by thread: [PATCH 40/41] KVM: Add fpu get/set operations
- Index(es):
Relevant Pages
|
|