[PATCH] KVM: x86: Assign separate names for Intel and AMD to LBR MSRs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some of the MSRs related to LBR (Last Branch Record) have different names
and layouts among Intel and AMD, but the kernel does not distinguish them.
Currently it does not invoke any bugs, but it is better to assign them separate
macros in order to avoid confusion.

Signed-off-by: Soramichi Akiyama <akiyama@xxxxxxxxxxxxxx>
---
 arch/x86/include/asm/msr-index.h | 19 +++++++++++++++----
 arch/x86/kvm/x86.c               |  8 ++++----
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 34c4922bbc3f..a1c69de453d1 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -123,10 +123,21 @@
 #define MSR_IA32_CR_PAT			0x00000277
 
 #define MSR_IA32_DEBUGCTLMSR		0x000001d9
-#define MSR_IA32_LASTBRANCHFROMIP	0x000001db
-#define MSR_IA32_LASTBRANCHTOIP		0x000001dc
-#define MSR_IA32_LASTINTFROMIP		0x000001dd
-#define MSR_IA32_LASTINTTOIP		0x000001de
+/*
+ * 0x1db - 0x1de have different names and layouts between Intel and AMD
+ * so it is better to define dedicated macros for each of them.
+ * An Intel one (e.g. MSR_IA32_LASTBRANCH0) contains both "from" and "to"
+ * addresses (because they are used only in old 32 bit CPUs), while an AMD
+ * one (e.g. MSR_IA32_LASTBRANCHFROMIP) contains only one 64 bits address.
+ */
+#define MSR_IA32_LASTBRANCH0		0x000001db /* Intel */
+#define MSR_IA32_LASTBRANCH1		0x000001dc /* Intel */
+#define MSR_IA32_LASTBRANCH2		0x000001dd /* Intel */
+#define MSR_IA32_LASTBRANCH3		0x000001de /* Intel */
+#define MSR_IA32_LASTBRANCHFROMIP	0x000001db /* AMD */
+#define MSR_IA32_LASTBRANCHTOIP		0x000001dc /* AMD */
+#define MSR_IA32_LASTINTFROMIP		0x000001dd /* AMD */
+#define MSR_IA32_LASTINTTOIP		0x000001de /* AMD */
 
 /* DEBUGCTLMSR bits (others vary by model): */
 #define DEBUGCTLMSR_LBR			(1UL <<  0) /* last branch recording */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 56d036b9ad75..cef109f112f5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2434,10 +2434,10 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	case MSR_IA32_PLATFORM_ID:
 	case MSR_IA32_EBL_CR_POWERON:
 	case MSR_IA32_DEBUGCTLMSR:
-	case MSR_IA32_LASTBRANCHFROMIP:
-	case MSR_IA32_LASTBRANCHTOIP:
-	case MSR_IA32_LASTINTFROMIP:
-	case MSR_IA32_LASTINTTOIP:
+	case MSR_IA32_LASTBRANCH0:
+	case MSR_IA32_LASTBRANCH1:
+	case MSR_IA32_LASTBRANCH2:
+	case MSR_IA32_LASTBRANCH3:
 	case MSR_K8_SYSCFG:
 	case MSR_K8_TSEG_ADDR:
 	case MSR_K8_TSEG_MASK:
-- 
2.11.0



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux