Fix AMD threshold register definitions and activate vmce_amd_* functions
cover Fix AMD threshold register definitions and activate vmce_amd_* functions
Patch 1: Deals with correcting AMD threshold register definitions. Patch 2: Fixes mask in vmce.c to allow vmce_amd_* functions to handle access to
AMD thresholding registers.
Aravind Gopalakrishnan (2):
hvm,svm: Update AMD Thresholding MSR definitions mcheck,vmce: Allow vmce_amd_* functions to handle AMD thresolding
MSRs
xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- xen/arch/x86/hvm/svm/svm.c | 10 ++++++---- xen/include/asm-x86/msr-index.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 hvm, svm: Update AMD Thresholding MSR definitions
MSR 0xC000040A is marked as reserved from Fam15 onwards and MSR 0x413 is marked alias of MSR0xC000040A on Fam10 BKDG. So remove the unnecessary definition of the reserved MSR and use MSR_IA32_MCx_MISC() to define MSR 0x413.
Also, according to BKDG, MSR 0x413 is the first of the thresholding registers; MSR 0xC0000408 and MSR 0xC0000409 are second and third respectively. So rework the #define's accordingly.
Fam15 Model 00h-0fh BKDG reference:
http://support.amd.com/TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdf
--- xen/arch/x86/hvm/svm/svm.c | 10 ++++++---- xen/include/asm-x86/msr-index.h | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-)
xen/arch/x86/hvm/svm/svm.c +6 -4
@@ -1461,8 +1461,9 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) *msr_content = v->arch.hvm_svm.guest_sysenter_eip;break ; -case MSR_IA32_MCx_MISC (4 ):/* Threshold register */ - case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: +case MSR_F10_MC4_MISC1 :/* Threshold registers */ +case MSR_F10_MC4_MISC2 : +case MSR_F10_MC4_MISC3 :/* * MCA/MCE: We report that the threshold register is unavailable * for OS use (locked by the BIOS).
@@ -1660,8 +1661,9 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content)vpmu_do_wrmsr (msr, msr_content);break ; -case MSR_IA32_MCx_MISC (4 ):/* Threshold register */ - case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: +case MSR_F10_MC4_MISC1 :/* Threshold registers */ +case MSR_F10_MC4_MISC2 : +case MSR_F10_MC4_MISC3 :/* * MCA/MCE: Threshold register is reported to be locked, so we ignore * all write accesses. This behaviour matches real HW, so guests should
xen/include/asm-x86/msr-index.h +3 -3
@@ -219,9 +219,9 @@#define AMD64_NB_CFG_CF8_EXT_ENABLE_BIT 46/* AMD Family10h machine check MSRs */ -#define MSR_F10_MC4_MISC1 0xc0000408 -#define MSR_F10_MC4_MISC2 0xc0000409 -#define MSR_F10_MC4_MISC3 0xc000040A +#define MSR_F10_MC4_MISC1 MSR_IA32_MCx_MISC(4) +#define MSR_F10_MC4_MISC2 0xc0000408 +#define MSR_F10_MC4_MISC3 0xc0000409/* AMD Family10h Bus Unit MSRs */ #define MSR_F10_BU_CFG 0xc0011023
Signature · 1 line
1.7.9.5
Re: [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions
Quoted 9 lines · Aravind Gopalakrishnan
MSR
0xC000040Ais marked as reserved from Fam15 onwards and MSR0x413is marked alias of MSR0xC000040A on Fam10 BKDG. So remove the unnecessary definition of the reserved MSR and useMSR_IA32_MCx_MISC()to define MSR0x413.Also, according to BKDG, MSR
0x413is the first of the thresholding registers; MSR0xC0000408and MSR0xC0000409are second and third respectively. So rework the #define's accordingly.
Quoted 5 lines
Fam15 Model 00h-0fh BKDG reference:
http://support.amd.com/TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdfSigned-off-by Aravind Gopalakrishnan <[email protected]>Reviewed-by Suravee Suthikulpanit <[email protected]>
Quoted 51 lines
--- xen/arch/x86/hvm/svm/svm.c | 10 ++++++---- xen/include/asm-x86/msr-index.h | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-)xen/arch/x86/hvm/svm/svm.c +6
-4@@ -1461,8 +1461,9 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) *msr_content = v->arch.hvm_svm.guest_sysenter_eip;break ; -case MSR_IA32_MCx_MISC (4 ):/* Threshold register */ - case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: +case MSR_F10_MC4_MISC1 :/* Threshold registers */ +case MSR_F10_MC4_MISC2 : +case MSR_F10_MC4_MISC3 :/* * MCA/MCE: We report that the threshold register is unavailable * for OS use (locked by the BIOS). @@ -1660,8 +1661,9 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content)vpmu_do_wrmsr (msr, msr_content);break ; -case MSR_IA32_MCx_MISC (4 ):/* Threshold register */ - case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: +case MSR_F10_MC4_MISC1 :/* Threshold registers */ +case MSR_F10_MC4_MISC2 : +case MSR_F10_MC4_MISC3 :/* * MCA/MCE: Threshold register is reported to be locked, so we ignore * all write accesses. This behaviour matches real HW, so guests should xen/include/asm-x86/msr-index.h +3
-3@@ -219,9 +219,9 @@#define AMD64_NB_CFG_CF8_EXT_ENABLE_BIT 46/* AMD Family10h machine check MSRs */ -#define MSR_F10_MC4_MISC1 0xc0000408 -#define MSR_F10_MC4_MISC2 0xc0000409 -#define MSR_F10_MC4_MISC3 0xc000040A +#define MSR_F10_MC4_MISC1 MSR_IA32_MCx_MISC(4) +#define MSR_F10_MC4_MISC2 0xc0000408 +#define MSR_F10_MC4_MISC3 0xc0000409/* AMD Family10h Bus Unit MSRs */ #define MSR_F10_BU_CFG 0xc0011023
Re: [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions
In reply to Aravind GopalakrishnanQuoted 9 lines · Aravind Gopalakrishnan
MSR
0xC000040Ais marked as reserved from Fam15 onwards and MSR0x413is marked alias of MSR0xC000040A on Fam10 BKDG. So remove the unnecessary definition of the reserved MSR and useMSR_IA32_MCx_MISC()to define MSR0x413.Also, according to BKDG, MSR
0x413is the first of the thresholding registers; MSR0xC0000408and MSR0xC0000409are second and third respectively. So rework the #define's accordingly.
Quoted 5 lines
Fam15 Model 00h-0fh BKDG reference:
http://support.amd.com/TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdfSigned-off-by Aravind Gopalakrishnan <[email protected]>Reviewed-by Suravee Suthikulpanit <[email protected]>
Since you haven't provided a bug description or a justification for a freeze exception, I take it this is targeted at 4.5?
-George
Quoted 59 lines
--- xen/arch/x86/hvm/svm/svm.c | 10 ++++++---- xen/include/asm-x86/msr-index.h | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-)xen/arch/x86/hvm/svm/svm.c +6
-4@@ -1461,8 +1461,9 @@ static int svm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) *msr_content = v->arch.hvm_svm.guest_sysenter_eip;break ; -case MSR_IA32_MCx_MISC (4 ):/* Threshold register */ - case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: +case MSR_F10_MC4_MISC1 :/* Threshold registers */ +case MSR_F10_MC4_MISC2 : +case MSR_F10_MC4_MISC3 :/* * MCA/MCE: We report that the threshold register is unavailable * for OS use (locked by the BIOS). @@ -1660,8 +1661,9 @@ static int svm_msr_write_intercept(unsigned int msr, uint64_t msr_content)vpmu_do_wrmsr (msr, msr_content);break ; -case MSR_IA32_MCx_MISC (4 ):/* Threshold register */ - case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: +case MSR_F10_MC4_MISC1 :/* Threshold registers */ +case MSR_F10_MC4_MISC2 : +case MSR_F10_MC4_MISC3 :/* * MCA/MCE: Threshold register is reported to be locked, so we ignore * all write accesses. This behaviour matches real HW, so guests should xen/include/asm-x86/msr-index.h +3
-4@@ -219,9 +219,9 @@#define AMD64_NB_CFG_CF8_EXT_ENABLE_BIT 46/* AMD Family10h machine check MSRs */ -#define MSR_F10_MC4_MISC1 0xc0000408 -#define MSR_F10_MC4_MISC2 0xc0000409 -#define MSR_F10_MC4_MISC3 0xc000040A +#define MSR_F10_MC4_MISC1 MSR_IA32_MCx_MISC(4) +#define MSR_F10_MC4_MISC2 0xc0000408 +#define MSR_F10_MC4_MISC3 0xc0000409/* AMD Family10h Bus Unit MSRs */ #define MSR_F10_BU_CFG 0xc0011023 --1.7.9.5
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 2/2 mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
In reply to Aravind Gopalakrishnanvmce_amd_[rd|wr]msr functions can handle accesses to AMD thresholding registers. But due to this statement here:
switch ( msr & (MSR_IA32_MC0_CTL | 3) )
we are wrongly masking off top two bits and bit 4 which meant the register accesses never made it to vmce_amd_* functions.
We correct this problem by modifying the mask in this patch to allow AMD thresholding registers to fall to 'default' case which in turn allows vmce_amd_* functions to handle access to the registers.
--- xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/cpu/mcheck/vmce.c +2 -2
@@ -107,7 +107,7 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) *val =0 ; -switch ( msr & (MSR_IA32_MC0_CTL |3 ) ) +switch ( msr & (MSR_IA32_MC0_CTL | (0x3 <<30 ) |0x13 )) {case MSR_IA32_MC0_CTL :/* stick all 1's to MCi_CTL */
@@ -210,7 +210,7 @@ static int bank_mce_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)int ret =1 ;unsigned int bank = (msr -MSR_IA32_MC0_CTL ) /4 ; -switch ( msr & (MSR_IA32_MC0_CTL |3 ) ) +switch ( msr & (MSR_IA32_MC0_CTL | (0x3 <<30 ) |0x13 )) {case MSR_IA32_MC0_CTL :/*
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
Quoted 21 lines · Aravind Gopalakrishnan
vmce_amd_[rd|wr]msr functions can handle accesses to AMD thresholding registers. But due to this statement here:
switch ( msr & (MSR_IA32_MC0_CTL| 3) )
we are wrongly masking off top two bits and bit 4 which meant the register accesses never made it to vmce_amd_* functions.We correct this problem by modifying the mask in this patch to allow AMD thresholding registers to fall to 'default' case which in turn allows vmce_amd_* functions to handle access to the registers.
Signed-off-by Aravind Gopalakrishnan <[email protected]>Reviewed-by Suravee Suthikulpanit <[email protected]>--- xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)xen/arch/x86/cpu/mcheck/vmce.c +0
-0
xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) · line 110
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1@@ -107,7 +107,7 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) *val =0 ; - switch ( msr & (MSR_IA32_MC0_CTL | 3) ) + switch ( msr & (MSR_IA32_MC0_CTL | (0x3 << 30) | 0x13))
Which MSRs are going to be handled in the non-default cases? MSR0000_040[0:3] and MSRC000_040[0:3]? The first four already have explicit cases and I think it would be more readable if you explicitly created case statements for the latter four and had a simple 'switch(msr)'.
In fact, do MSRC000_040[0:3] even exist?
(You may also want to adjust your clock --- your emails are being sent from distant past ;-) )
-boris
Quoted 12 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1{case MSR_IA32_MC0_CTL :/* stick all 1's to MCi_CTL */ @@ -210,7 +210,7 @@ static int bank_mce_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)int ret =1 ;unsigned int bank = (msr -MSR_IA32_MC0_CTL ) /4 ; -switch ( msr & (MSR_IA32_MC0_CTL |3 ) ) +switch ( msr & (MSR_IA32_MC0_CTL | (0x3 <<30 ) |0x13 )) {case MSR_IA32_MC0_CTL :/*
Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
Quoted 14 lines · Boris Ostrovsky
xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu *v, · line 110
Quoted 10 lines · Aravind Gopalakrishnan
xen/arch/x86/cpu/mcheck/vmce.c +1
-0@@ -107,7 +107,7 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) *val =0 ; - switch ( msr & (MSR_IA32_MC0_CTL | 3) ) + switch ( msr & (MSR_IA32_MC0_CTL | (0x3 << 30) | 0x13))Which MSRs are going to be handled in the non-default cases? MSR0000_040[0:3] and MSRC000_040[0:3]? The first four already have explicit cases and I think it would be more readable if you explicitly created case statements for the latter four and had a simple 'switch(msr)'.
In non-default cases, we need to handle MSR0x40[0:7]. MSR0x40[0:3] is bank 0 and remaining ones are bank 1. We can't do a simple switch(msr) since if we do that, MSR0x40[4:7] will fall to 'default' (which is incorrect)
Quoted 2 lines
In fact, do MSRC000_040[0:3] even exist?
Nope. They don't..
we only allow MCE MSR's here anyway:
ret = mce_bank_msr(cur, msr) ? bank_mce_rdmsr(cur, msr, val) : 0;
'mce_bank_msr' returns 1 only if we see MSR0x40[0:7] or some 'special MSR's' which in AMD's case are the three thresholding regs MSR_F10_MC4_MISC1 to MSR_F10_MC4_MISC3
Quoted 3 lines
(You may also want to adjust your clock --- your emails are being sent from distant past ;-) )
Yes, thanks for pointing that out :)
I'll correct that and send V2
-Aravind.
Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
Quoted 14 lines · Aravind Gopalakrishnan
Quoted 13 lines · Boris Ostrovsky
xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu *v, · line 110
Quoted 10 lines · Aravind Gopalakrishnan
xen/arch/x86/cpu/mcheck/vmce.c +1
-0@@ -107,7 +107,7 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) *val =0 ; - switch ( msr & (MSR_IA32_MC0_CTL | 3) ) + switch ( msr & (MSR_IA32_MC0_CTL | (0x3 << 30) | 0x13))Which MSRs are going to be handled in the non-default cases? MSR0000_040[0:3] and MSRC000_040[0:3]? The first four already have explicit cases and I think it would be more readable if you explicitly created case statements for the latter four and had a simple 'switch(msr)'.
I didn't realize this was common code so ignore this.
One thing I suggest you change is instead of (0x3<<30) use 0xc0000000 because the latter is immediately familiar to anyone used to AMD MSR spaces. And as for 0x13, I'd add a comment explaining why you have it.
Also, Intel processors have 0x413+ registers as well and Intel folks should probably confirm that your change won't break code there.
-boris
Quoted 21 lines
Quoted 1 line
In non-default cases, we need to handle MSR0x40[0:7]. MSR0x40[0:3] is bank 0 and remaining ones are bank 1. We can't do a simple switch(msr) since if we do that, MSR0x40[4:7] will fall to 'default' (which is incorrect)
Quoted 2 lines
In fact, do MSRC000_040[0:3] even exist?
Nope. They don't..
we only allow MCE MSR's here anyway:
ret =mce_bank_msr(cur, msr)?bank_mce_rdmsr(cur, msr, val): 0;'
mce_bank_msr' returns 1 only if we see MSR0x40[0:7] or some 'special MSR's' which in AMD's case are the three thresholding regsMSR_F10_MC4_MISC1toMSR_F10_MC4_MISC3Quoted 3 lines
(You may also want to adjust your clock --- your emails are being sent from distant past ;-) )
Yes, thanks for pointing that out :)
I'll correct that and send V2-Aravind.
Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
In reply to Aravind GopalakrishnanQuoted 21 lines · Aravind Gopalakrishnan
vmce_amd_[rd|wr]msr functions can handle accesses to AMD thresholding registers. But due to this statement here:
switch ( msr & (MSR_IA32_MC0_CTL| 3) )
we are wrongly masking off top two bits and bit 4 which meant the register accesses never made it to vmce_amd_* functions.We correct this problem by modifying the mask in this patch to allow AMD thresholding registers to fall to 'default' case which in turn allows vmce_amd_* functions to handle access to the registers.
Signed-off-by Aravind Gopalakrishnan <[email protected]>Reviewed-by Suravee Suthikulpanit <[email protected]>--- xen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)xen/arch/x86/cpu/mcheck/vmce.c +0
-0
xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) · line 110
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1@@ -107,7 +107,7 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) *val =0 ; - switch ( msr & (MSR_IA32_MC0_CTL | 3) ) + switch ( msr & (MSR_IA32_MC0_CTL | (0x3 << 30) | 0x13))
I prefer #defines for the two bits to make the code more meaningfull to the reader.
xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) · line 213
Quoted 9 lines
xen/arch/x86/cpu/mcheck/vmce.c +1
-1{case MSR_IA32_MC0_CTL :/* stick all 1's to MCi_CTL */ @@ -210,7 +210,7 @@ static int bank_mce_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)int ret =1 ;unsigned int bank = (msr -MSR_IA32_MC0_CTL ) /4 ; - switch ( msr & (MSR_IA32_MC0_CTL | 3) ) + switch ( msr & (MSR_IA32_MC0_CTL | (0x3 << 30) | 0x13))
Ditto.
Christoph
Quoted 4 lines
xen/arch/x86/cpu/mcheck/vmce.c +0
-0{case MSR_IA32_MC0_CTL :/*
On Sat, Mar 15, 2008 at 04:50:23PM -0500, Aravind Gopalakrishnan wrote:
^^^^
Please check your system clock.
--msw
Quoted 14 lines
Patch 1: Deals with correcting AMD threshold register definitions. Patch 2: Fixes mask in
vmce.cto allow vmce_amd_* functions to handle access to
AMD thresholding registers.Aravind Gopalakrishnan (2):
hvm,svm: Update AMD Thresholding MSR definitions mcheck,vmce: Allow vmce_amd_* functions to handle AMD thresolding
MSRsxen/arch/x86/cpu/mcheck/vmce.c | 4 ++-- xen/arch/x86/hvm/svm/svm.c | 10 ++++++---- xen/include/asm-x86/msr-index.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-)