* [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions
2008-03-15 21:50 [PATCH 0/2] Fix AMD threshold register definitions and activate vmce_amd_* functions Aravind Gopalakrishnan
@ 2008-03-15 21:50 ` Aravind Gopalakrishnan
2014-01-28 9:13 ` Egger, Christoph
2014-01-28 10:27 ` George Dunlap
2008-03-15 21:50 ` [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs Aravind Gopalakrishnan
2014-02-03 22:48 ` [PATCH 0/2] Fix AMD threshold register definitions and activate vmce_amd_* functions Matt Wilson
2 siblings, 2 replies; 10+ messages in thread
From: Aravind Gopalakrishnan @ 2008-03-15 21:50 UTC (permalink / raw)
To: chegger, jinsong.liu, boris.ostrovsky, suravee.suthikulpanit,
xen-devel
Cc: Aravind Gopalakrishnan
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
Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
xen/arch/x86/hvm/svm/svm.c | 10 ++++++----
xen/include/asm-x86/msr-index.h | 6 +++---
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 406d394..07c2684 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -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
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index fc9fbc6..e5ffbf2 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -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
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions
2008-03-15 21:50 ` [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions Aravind Gopalakrishnan
@ 2014-01-28 9:13 ` Egger, Christoph
2014-01-28 10:27 ` George Dunlap
1 sibling, 0 replies; 10+ messages in thread
From: Egger, Christoph @ 2014-01-28 9:13 UTC (permalink / raw)
To: Aravind Gopalakrishnan, jinsong.liu, boris.ostrovsky,
suravee.suthikulpanit, xen-devel
On 15.03.08 22:50, Aravind Gopalakrishnan wrote:
> 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
>
> Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
> Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reviewed-by: Christoph Egger <chegger@amazon.de>
> ---
> xen/arch/x86/hvm/svm/svm.c | 10 ++++++----
> xen/include/asm-x86/msr-index.h | 6 +++---
> 2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index 406d394..07c2684 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -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
> diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
> index fc9fbc6..e5ffbf2 100644
> --- a/xen/include/asm-x86/msr-index.h
> +++ b/xen/include/asm-x86/msr-index.h
> @@ -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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions
2008-03-15 21:50 ` [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions Aravind Gopalakrishnan
2014-01-28 9:13 ` Egger, Christoph
@ 2014-01-28 10:27 ` George Dunlap
1 sibling, 0 replies; 10+ messages in thread
From: George Dunlap @ 2014-01-28 10:27 UTC (permalink / raw)
To: Aravind Gopalakrishnan
Cc: Liu, Jinsong, Boris Ostrovsky, chegger, Suravee Suthikulpanit,
xen-devel@lists.xen.org
On Sat, Mar 15, 2008 at 9:50 PM, Aravind Gopalakrishnan
<aravind.gopalakrishnan@amd.com> wrote:
> 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
>
> Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
> Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
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
> ---
> xen/arch/x86/hvm/svm/svm.c | 10 ++++++----
> xen/include/asm-x86/msr-index.h | 6 +++---
> 2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index 406d394..07c2684 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -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
> diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
> index fc9fbc6..e5ffbf2 100644
> --- a/xen/include/asm-x86/msr-index.h
> +++ b/xen/include/asm-x86/msr-index.h
> @@ -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
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
2008-03-15 21:50 [PATCH 0/2] Fix AMD threshold register definitions and activate vmce_amd_* functions Aravind Gopalakrishnan
2008-03-15 21:50 ` [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions Aravind Gopalakrishnan
@ 2008-03-15 21:50 ` Aravind Gopalakrishnan
2014-01-27 19:17 ` Boris Ostrovsky
2014-01-28 9:09 ` Egger, Christoph
2014-02-03 22:48 ` [PATCH 0/2] Fix AMD threshold register definitions and activate vmce_amd_* functions Matt Wilson
2 siblings, 2 replies; 10+ messages in thread
From: Aravind Gopalakrishnan @ 2008-03-15 21:50 UTC (permalink / raw)
To: chegger, jinsong.liu, boris.ostrovsky, suravee.suthikulpanit,
xen-devel
Cc: 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 <aravind.gopalakrishnan@amd.com>
Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
xen/arch/x86/cpu/mcheck/vmce.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index f6c35db..cb4fd12 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -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:
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
2008-03-15 21:50 ` [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs Aravind Gopalakrishnan
@ 2014-01-27 19:17 ` Boris Ostrovsky
2014-01-27 22:46 ` Aravind Gopalakrishnan
2014-01-28 9:09 ` Egger, Christoph
1 sibling, 1 reply; 10+ messages in thread
From: Boris Ostrovsky @ 2014-01-27 19:17 UTC (permalink / raw)
To: Aravind Gopalakrishnan
Cc: jinsong.liu, chegger, suravee.suthikulpanit, xen-devel
On 03/15/2008 05:50 PM, Aravind Gopalakrishnan wrote:
> 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 <aravind.gopalakrishnan@amd.com>
> Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
> xen/arch/x86/cpu/mcheck/vmce.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
> index f6c35db..cb4fd12 100644
> --- a/xen/arch/x86/cpu/mcheck/vmce.c
> +++ b/xen/arch/x86/cpu/mcheck/vmce.c
> @@ -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
> {
> 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:
> /*
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
2014-01-27 19:17 ` Boris Ostrovsky
@ 2014-01-27 22:46 ` Aravind Gopalakrishnan
2014-01-27 23:29 ` Boris Ostrovsky
0 siblings, 1 reply; 10+ messages in thread
From: Aravind Gopalakrishnan @ 2014-01-27 22:46 UTC (permalink / raw)
To: Boris Ostrovsky; +Cc: jinsong.liu, chegger, suravee.suthikulpanit, xen-devel
On 1/27/2014 1:17 PM, Boris Ostrovsky wrote:
> On 03/15/2008 05:50 PM, Aravind Gopalakrishnan wrote:
>>
>> diff --git a/xen/arch/x86/cpu/mcheck/vmce.c
>> b/xen/arch/x86/cpu/mcheck/vmce.c
>> index f6c35db..cb4fd12 100644
>> --- a/xen/arch/x86/cpu/mcheck/vmce.c
>> +++ b/xen/arch/x86/cpu/mcheck/vmce.c
>> @@ -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)
> 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
> (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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
2014-01-27 22:46 ` Aravind Gopalakrishnan
@ 2014-01-27 23:29 ` Boris Ostrovsky
0 siblings, 0 replies; 10+ messages in thread
From: Boris Ostrovsky @ 2014-01-27 23:29 UTC (permalink / raw)
To: Aravind Gopalakrishnan
Cc: jinsong.liu, chegger, suravee.suthikulpanit, xen-devel
On 01/27/2014 05:46 PM, Aravind Gopalakrishnan wrote:
> On 1/27/2014 1:17 PM, Boris Ostrovsky wrote:
>> On 03/15/2008 05:50 PM, Aravind Gopalakrishnan wrote:
>>>
>>> diff --git a/xen/arch/x86/cpu/mcheck/vmce.c
>>> b/xen/arch/x86/cpu/mcheck/vmce.c
>>> index f6c35db..cb4fd12 100644
>>> --- a/xen/arch/x86/cpu/mcheck/vmce.c
>>> +++ b/xen/arch/x86/cpu/mcheck/vmce.c
>>> @@ -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
>>
> 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)
>
>> 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
>
>> (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.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs
2008-03-15 21:50 ` [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs Aravind Gopalakrishnan
2014-01-27 19:17 ` Boris Ostrovsky
@ 2014-01-28 9:09 ` Egger, Christoph
1 sibling, 0 replies; 10+ messages in thread
From: Egger, Christoph @ 2014-01-28 9:09 UTC (permalink / raw)
To: Aravind Gopalakrishnan, jinsong.liu, boris.ostrovsky,
suravee.suthikulpanit, xen-devel
On 15.03.08 22:50, Aravind Gopalakrishnan wrote:
> 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 <aravind.gopalakrishnan@amd.com>
> Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
> xen/arch/x86/cpu/mcheck/vmce.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
> index f6c35db..cb4fd12 100644
> --- a/xen/arch/x86/cpu/mcheck/vmce.c
> +++ b/xen/arch/x86/cpu/mcheck/vmce.c
> @@ -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.
> {
> 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
> {
> case MSR_IA32_MC0_CTL:
> /*
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Fix AMD threshold register definitions and activate vmce_amd_* functions
2008-03-15 21:50 [PATCH 0/2] Fix AMD threshold register definitions and activate vmce_amd_* functions Aravind Gopalakrishnan
2008-03-15 21:50 ` [PATCH 1/2] hvm, svm: Update AMD Thresholding MSR definitions Aravind Gopalakrishnan
2008-03-15 21:50 ` [PATCH 2/2] mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs Aravind Gopalakrishnan
@ 2014-02-03 22:48 ` Matt Wilson
2 siblings, 0 replies; 10+ messages in thread
From: Matt Wilson @ 2014-02-03 22:48 UTC (permalink / raw)
To: Aravind Gopalakrishnan
Cc: jinsong.liu, boris.ostrovsky, chegger, suravee.suthikulpanit,
xen-devel
On Sat, Mar 15, 2008 at 04:50:23PM -0500, Aravind Gopalakrishnan wrote:
^^^^
Please check your system clock.
--msw
> 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(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread