Skip to contentSkip to conversation

SVM: enable LBRV virtualization if available

PATCH In review Joerg Roedel 2 participants 6 messages Mar 30, 2007 – Apr 2, 2007 5 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SVM: enable LBRV virtualization if available

From: Joerg Roedel <[email protected]>

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.

Signature · 3 lines
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG
drivers/kvm/svm.c +10 -0
index ddc0505..421eeb8 100644
@@ -44,6 +44,12 @@ 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)
+
+#define svm_has(feat) (svm_features & (feat))
+
 unsigned long iopm_base;
 unsigned long msrpm_base;
 
@@ -68,6 +74,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;
@@ -309,6 +316,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;
@@ -518,6 +526,8 @@ static void init_vmcb(struct vmcb *vmcb)
 	rdtscll(tsc);
 	control->tsc_offset = -tsc;
 	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);

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 9 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

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.

+#define SVM_DEATURE_SVML (1 << 2)

FEATURE? DENTURE?

drivers/kvm/svm.c MODULE_LICENSE("GPL"); · line 52

Quoted 4 lines
drivers/kvm/svm.c +3 -0
+
+#define svm_has(feat) (svm_features & (feat))
+

I prefer a static inline instead of a function-like macro.

drivers/kvm/svm.c struct svm_cpu_data { · line 78

Quoted 9 lines

unsigned long iopm_base;
unsigned long msrpm_base;

drivers/kvm/svm.c +1 -0
@@ -68,6 +74,7 @@ struct svm_cpu_data {
 };
 
 static DEFINE_PER_CPU(struct svm_cpu_data *, svm_data);
+static uint32_t svm_features;
 

u32 outside userspace headers.

Anyway I fixed these up and applied.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 460D18ED.909-atKUWr5tajBWk0Htik3J/[email protected]

#4 lore raw
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

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.

Quoted 4 lines
Quoted 2 lines

+#define SVM_DEATURE_SVML (1 << 2)

FEATURE? DENTURE?

Uh, a typo went in the patch. This must be SVM_FEATURE_SVML.

Quoted 6 lines

drivers/kvm/svm.c MODULE_LICENSE("GPL"); · line 52

Quoted 4 lines
drivers/kvm/svm.c +3 -0
+
+#define svm_has(feat) (svm_features & (feat))
+

I prefer a static inline instead of a function-like macro.

Ok, will remember that in the next patches.

Quoted 9 lines

drivers/kvm/svm.c struct svm_cpu_data { · line 77

Quoted 7 lines

unsigned long iopm_base;
unsigned long msrpm_base;

drivers/kvm/svm.c +1 -0
@@ -68,6 +74,7 @@ struct svm_cpu_data {
 };
 static DEFINE_PER_CPU(struct svm_cpu_data *, svm_data);
+static uint32_t svm_features;
 

u32 outside userspace headers.

Is struct svm_cpu_data a userspace data structure. I ask because in a previous version of the patch the svm_features variable was part of that struct. Thats why I used this type.

Quoted 1 line

Anyway I fixed these up and applied.

Thanks,
Joerg

Signature · 11 lines
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 4 lines · Joerg Roedel

Is struct svm_cpu_data a userspace data structure. I ask because in a previous version of the patch the svm_features variable was part of that struct. Thats why I used this type.

No, all userspace stuff is in include/linux/kvm*.h (which uses __u32; uint32_t is for libkvm and qemu).

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 4610CF62.6040204-atKUWr5tajBWk0Htik3J/[email protected]

#8 lore raw
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Joerg Roedel

Is struct svm_cpu_data a userspace data structure. I ask because in a previous version of the patch the svm_features variable was part of that struct. Thats why I used this type.

No, all userspace stuff is in include/linux/kvm*.h (which uses __u32; uint32_t is for libkvm and qemu).

Ok, then the types in that structure should also be fixed :)

Joerg

Signature · 11 lines
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 11 lines · Joerg Roedel
Quoted 8 lines
Quoted 5 lines

Is struct svm_cpu_data a userspace data structure. I ask because in a previous version of the patch the svm_features variable was part of that struct. Thats why I used this type.

No, all userspace stuff is in include/linux/kvm*.h (which uses __u32; uint32_t is for libkvm and qemu).

Ok, then the types in that structure should also be fixed :)

Right, done :)

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV