[PATCH 41/41] KVM: SVM: enable LBRV virtualization if available



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/



Relevant Pages

  • Re: Massive Console History update
    ... game based on the dungeons and dragons universe. ... My second suggestion concerns your Snes history page. ... Genesis (which had no hardware support for it). ... Neo Geo lacked this feature in hardware. ...
    (rec.games.video.sega)
  • Re: Anyone used Portmon on a USB-RS232?
    ... I was a hardware guy, then moved to embedded firmware, now pretty much ... software consulting. ... I still get the odd maintenance or feature ... at least he still deals with some hardware because he own a large ...
    (comp.arch.embedded)
  • Re: Cisco Software Advisor - used for baselining software versions?
    ... The Cisco Software Advisor is the most worthless tool Cisco has ever come ... it should tell you what version of code and what feature ... set you need when you feed your hardware and specific features you need. ... Advisor", it's pretty cool but I have some questions about it that I ...
    (comp.dcom.sys.cisco)
  • Re: Infinite Loops and Explicit Exits
    ... INSTRUCTION PLACED A RETURN ADDRESS AT THE ADDRESS ... >as THE HARDWARE CHANGED, THE COBOL FEATURE OF PERFORM HAD TO CONTINUE ... The only hardware change was the addition of stack. ...
    (comp.lang.cobol)
  • Re: [PATCH] x86 NUMA panic compile error
    ... testbox found at least one other NUMA bug already). ... Since you wrote that patch the ability to try ... alignment thing) could very well affect non-obsolete hardware too. ... Fact is, the more hardware a given feature can be tried on, the better ...
    (Linux-Kernel)