Skip to contentSkip to conversation

mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs

PATCH In review Aravind Gopalakrishnan 3 participants 14 messages Feb 12, 2014 – Feb 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mcheck, vmce: Allow vmce_amd_* functions to handle AMD thresolding MSRs

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 which meant the register accesses never made it to vmce_amd_* functions.

Corrected 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.

While at it, remove some clutter in the vmce_amd* functions. Retained current policy of returning zero for reads and ignoring writes.

---
 xen/arch/x86/cpu/mcheck/amd_f10.c |   41 ++++++-------------------------------
 xen/arch/x86/cpu/mcheck/vmce.c    |   14 +++++++++++--
 2 files changed, 18 insertions(+), 37 deletions(-)
xen/arch/x86/cpu/mcheck/amd_f10.c +6 -35
index 61319dc..03797ab 100644
@@ -105,43 +105,14 @@ enum mcheck_type amd_f10_mcheck_init(struct cpuinfo_x86 *c)
 /* amd specific MCA MSR */
 int vmce_amd_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
 {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		v->arch.vmce.bank[1].mci_misc = val; 
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* ignore write: we do not emulate link and l3 cache errors
-		 * to the guest.
-		 */
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Do nothing as we don't emulate this MC bank currently */
+    mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
+    return 1;
 }
 
 int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		*val = v->arch.vmce.bank[1].mci_misc;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* we do not emulate link and l3 cache
-		 * errors to the guest.
-		 */
-		*val = 0;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Assign '0' as we don't emulate this MC bank currently */
+    *val = 0;
+    return 1;
 }
xen/arch/x86/cpu/mcheck/vmce.c +12 -2
index f6c35db..84843fc 100644
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /* stick all 1's to MCi_CTL */
@@ -148,6 +149,10 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
             ret = vmce_intel_rdmsr(v, msr, val);
             break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall into default. 
+             * Handle reads here.
+             */
             ret = vmce_amd_rdmsr(v, msr, val);
             break;
         default:
@@ -210,7 +215,8 @@ 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) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /*
@@ -246,6 +252,10 @@ static int bank_mce_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
             ret = vmce_intel_wrmsr(v, msr, val);
             break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall into default. 
+             * Handle writes here.
+             */
             ret = vmce_amd_wrmsr(v, msr, val);
             break;
         default:
Signature · 1 line
1.7.9.5
#1 lore raw

xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) · line 114

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Aravind Gopalakrishnan
xen/arch/x86/cpu/mcheck/vmce.c +2 -1
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /* stick all 1's to MCi_CTL */

I'm confused: You now add a comment as if the mask was including bit 4, which it doesn't. What am I missing?

Also, please get used to mention (commonly at the bottom of the commit message, after a --- separator) what changed compared to the previous iteration.

Jan

#2 lore raw
Quoted 10 lines · Jan Beulich

xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) · line 114

Quoted 8 lines
    *val = 0;
xen/arch/x86/cpu/mcheck/vmce.c +2 -1
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
      {
      case MSR_IA32_MC0_CTL:
          /* stick all 1's to MCi_CTL */

I'm confused: You now add a comment as if the mask was including bit 4, which it doesn't. What am I missing?

Darn. Sorry about that. Will fix..

Quoted 5 lines

Also, please get used to mention (commonly at the bottom of the commit message, after a --- separator) what changed compared to the previous iteration.

Okay, will do.

-Aravind.

#3 lore raw
Quoted 8 lines · Aravind Gopalakrishnan
Quoted 7 lines · Jan Beulich
Quoted 7 lines
    *val = 0;

- switch ( msr & (MSR_IA32_MC0_CTL | 3) )

xen/arch/x86/cpu/mcheck/vmce.c +2 -0
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
      {
      case MSR_IA32_MC0_CTL:
          /* stick all 1's to MCi_CTL */
Quoted 4 lines
Quoted 2 lines

I'm confused: You now add a comment as if the mask was including bit 4, which it doesn't. What am I missing?

Darn. Sorry about that. Will fix..

Jan,

Do let me know if the following wording is fine:

/*
* Apply mask to allow bits[0:1] (necessary to uniquely identify MC0)
* MC1 is handled by virtue of 'bank' value.
*/

If not, I'm open to suggestions:)

Thanks,
-Aravind.

#4 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 13.02.14 at 19:24, Aravind Gopalakrishnan <[email protected]>

Quoted 16 lines · wrote:
Quoted 8 lines · Aravind Gopalakrishnan
Quoted 7 lines · Jan Beulich
Quoted 7 lines
    *val = 0;

- switch ( msr & (MSR_IA32_MC0_CTL | 3) )

xen/arch/x86/cpu/mcheck/vmce.c +2 -0
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
      {
      case MSR_IA32_MC0_CTL:
          /* stick all 1's to MCi_CTL */
Quoted 4 lines
Quoted 2 lines

I'm confused: You now add a comment as if the mask was including bit 4, which it doesn't. What am I missing?

Darn. Sorry about that. Will fix..

Jan,

Quoted 8 lines

Do let me know if the following wording is fine:

/*
* Apply mask to allow bits[0:1] (necessary to uniquely identify MC0)
* MC1 is handled by virtue of 'bank' value.
*/

If not, I'm open to suggestions:)

I don't particularly like this, but I also don't have a good alternative suggestion. It was Christoph who asked for a comment in the first place. Since I don't see a particular need for a comment here, you two should work out what best suits both of you.

Jan

#5 lore raw

Sorry, Jan and Aravind, I just return from long Chinese Spring Festival vacation. I will review the thread ASAP.

Thanks,
Jinsong

Quoted 36 lines · Jan Beulich
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On 13.02.14 at 19:24, Aravind Gopalakrishnan
<[email protected]>

Quoted 18 lines · wrote:
Quoted 8 lines · Aravind Gopalakrishnan
Quoted 7 lines · Jan Beulich
Quoted 7 lines
    *val = 0;

- switch ( msr & (MSR_IA32_MC0_CTL | 3) )

xen/arch/x86/cpu/mcheck/vmce.c +2 -0
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
      {
      case MSR_IA32_MC0_CTL:
          /* stick all 1's to MCi_CTL */
Quoted 4 lines
Quoted 2 lines

I'm confused: You now add a comment as if the mask was including bit 4, which it doesn't. What am I missing?

Darn. Sorry about that. Will fix..

Jan,

Do let me know if the following wording is fine:

Quoted 7 lines

/*
* Apply mask to allow bits[0:1] (necessary to uniquely identify
MC0)
* MC1 is handled by virtue of 'bank' value.
*/

If not, I'm open to suggestions:)

I don't particularly like this, but I also don't have a good alternative suggestion. It was Christoph who asked for a comment in the first place. Since I don't see a particular need for a comment here, you
two should work out what best suits both of you.

Jan

#6 lore raw
In reply to Aravind Gopalakrishnan

For Intel it didn't disturb Intel's vmce logic so it's OK for me.

For AMD, c000_040x is bank4 (MC4_MISCj), while vmce current only support bank0/1. Even considering in the future AMD may add MC0/1_MISCj, it doesn't need emulation (say, read return 0 and write ignore). So how about simply filter out AMD MCx_MISCj at mce_vendor_bank_msr()?

Thanks,
Jinsong

Quoted 123 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 which meant the register accesses never made it to vmce_amd_* functions.

Corrected 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.

While at it, remove some clutter in the vmce_amd* functions. Retained current policy of returning zero for reads and ignoring writes.

---
 xen/arch/x86/cpu/mcheck/amd_f10.c |   41

++++++------------------------------- xen/arch/x86/cpu/mcheck/vmce.c
| 14 +++++++++++-- 2 files changed, 18 insertions(+), 37
deletions(-)

xen/arch/x86/cpu/mcheck/amd_f10.c +6 -35
index 61319dc..03797ab 100644
@@ -105,43 +105,14 @@ enum mcheck_type amd_f10_mcheck_init(struct
 cpuinfo_x86 *c) /* amd specific MCA MSR */
 int vmce_amd_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
 {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		v->arch.vmce.bank[1].mci_misc = val;
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* ignore write: we do not emulate link and l3 cache errors
-		 * to the guest.
-		 */
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Do nothing as we don't emulate this MC bank currently */
+    mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
+    return 1;
 }
 
 int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		*val = v->arch.vmce.bank[1].mci_misc;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* we do not emulate link and l3 cache
-		 * errors to the guest.
-		 */
-		*val = 0;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Assign '0' as we don't emulate this MC bank currently */
+    *val = 0;
+    return 1;
 }
xen/arch/x86/cpu/mcheck/vmce.c +2 -1
index f6c35db..84843fc 100644
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu *v,
 uint32_t msr, uint64_t *val) 
 
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /* stick all 1's to MCi_CTL */
xen/arch/x86/cpu/mcheck/vmce.c +2 -0
@@ -148,6 +149,10 @@ static int bank_mce_rdmsr(const struct vcpu *v,
             uint32_t msr, uint64_t *val) ret = vmce_intel_rdmsr(v,
             msr, val); break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall

into default. + * Handle reads here.

xen/arch/x86/cpu/mcheck/vmce.c +5 -1
+             */
             ret = vmce_amd_rdmsr(v, msr, val);
             break;
         default:
@@ -210,7 +215,8 @@ 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) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /*
@@ -246,6 +252,10 @@ static int bank_mce_wrmsr(struct vcpu *v,
             uint32_t msr, uint64_t val) ret = vmce_intel_wrmsr(v,
             msr, val); break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall

into default. + * Handle writes here.
+ */

             ret = vmce_amd_wrmsr(v, msr, val);
             break;
         default:
#7 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Jinsong

For Intel it didn't disturb Intel's vmce logic so it's OK for me.

For AMD, c000_040x is bank4 (MC4_MISCj), while vmce current only support bank0/1. Even considering in the future AMD may add MC0/1_MISCj, it doesn't need emulation (say, read return 0 and write ignore). So how about simply filter out AMD MCx_MISCj at mce_vendor_bank_msr()?

mce_vendor_bank_msr() already has

    case X86_VENDOR_AMD:
        switch (msr) {
        case MSR_F10_MC4_MISC1:
        case MSR_F10_MC4_MISC2:
        case MSR_F10_MC4_MISC3:
            return 1;
        }

Jan

Quoted 124 lines
Quoted 123 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 which meant the register accesses never made it to vmce_amd_* functions.

Corrected 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.

While at it, remove some clutter in the vmce_amd* functions. Retained current policy of returning zero for reads and ignoring writes.

---
 xen/arch/x86/cpu/mcheck/amd_f10.c |   41

++++++------------------------------- xen/arch/x86/cpu/mcheck/vmce.c
| 14 +++++++++++-- 2 files changed, 18 insertions(+), 37
deletions(-)

xen/arch/x86/cpu/mcheck/amd_f10.c +6 -35
index 61319dc..03797ab 100644
@@ -105,43 +105,14 @@ enum mcheck_type amd_f10_mcheck_init(struct
 cpuinfo_x86 *c) /* amd specific MCA MSR */
 int vmce_amd_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
 {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		v->arch.vmce.bank[1].mci_misc = val;
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* ignore write: we do not emulate link and l3 cache errors
-		 * to the guest.
-		 */
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Do nothing as we don't emulate this MC bank currently */
+    mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
+    return 1;
 }
 
 int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		*val = v->arch.vmce.bank[1].mci_misc;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* we do not emulate link and l3 cache
-		 * errors to the guest.
-		 */
-		*val = 0;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Assign '0' as we don't emulate this MC bank currently */
+    *val = 0;
+    return 1;
 }
xen/arch/x86/cpu/mcheck/vmce.c +2 -1
index f6c35db..84843fc 100644
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu *v,
 uint32_t msr, uint64_t *val) 
 
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /* stick all 1's to MCi_CTL */
xen/arch/x86/cpu/mcheck/vmce.c +2 -0
@@ -148,6 +149,10 @@ static int bank_mce_rdmsr(const struct vcpu *v,
             uint32_t msr, uint64_t *val) ret = vmce_intel_rdmsr(v,
             msr, val); break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall

into default. + * Handle reads here.

xen/arch/x86/cpu/mcheck/vmce.c +5 -1
+             */
             ret = vmce_amd_rdmsr(v, msr, val);
             break;
         default:
@@ -210,7 +215,8 @@ 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) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /*
@@ -246,6 +252,10 @@ static int bank_mce_wrmsr(struct vcpu *v,
             uint32_t msr, uint64_t val) ret = vmce_intel_wrmsr(v,
             msr, val); break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall

into default. + * Handle writes here.
+ */

             ret = vmce_amd_wrmsr(v, msr, val);
             break;
         default:
#8 lore raw
Quoted 19 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Jinsong

For Intel it didn't disturb Intel's vmce logic so it's OK for me.

For AMD, c000_040x is bank4 (MC4_MISCj), while vmce current only support bank0/1. Even considering in the future AMD may add MC0/1_MISCj, it doesn't need emulation (say, read return 0 and write ignore). So how about simply filter out AMD MCx_MISCj at mce_vendor_bank_msr()?

mce_vendor_bank_msr() already has

    case X86_VENDOR_AMD:
        switch (msr) {
        case MSR_F10_MC4_MISC1:
        case MSR_F10_MC4_MISC2:
        case MSR_F10_MC4_MISC3:
            return 1;
        }
Quoted 1 line

Jan

OK.

Quoted 83 lines
Quoted 83 lines
Quoted 81 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 which meant the register accesses never made it to vmce_amd_* functions.

Corrected 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.

While at it, remove some clutter in the vmce_amd* functions. Retained current policy of returning zero for reads and ignoring writes.

Signed-off-by: Aravind Gopalakrishnan
<[email protected]> ---

 xen/arch/x86/cpu/mcheck/amd_f10.c |   41

++++++-------------------------------
xen/arch/x86/cpu/mcheck/vmce.c | 14 +++++++++++-- 2 files
changed, 18 insertions(+), 37 deletions(-)

xen/arch/x86/cpu/mcheck/amd_f10.c +3 -35
index 61319dc..03797ab 100644
@@ -105,43 +105,14 @@ enum mcheck_type amd_f10_mcheck_init(struct
 cpuinfo_x86 *c) /* amd specific MCA MSR */
 int vmce_amd_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)  {
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		v->arch.vmce.bank[1].mci_misc = val;
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* ignore write: we do not emulate link and l3 cache errors
-		 * to the guest.
-		 */
-		mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Do nothing as we don't emulate this MC bank currently */
+    mce_printk(MCE_VERBOSE, "MCE: wr msr %#"PRIx64"\n", val); +   
 return 1; }
 
 int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t
 *val)  { 
-	switch (msr) {
-	case MSR_F10_MC4_MISC1: /* DRAM error type */
-		*val = v->arch.vmce.bank[1].mci_misc;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	case MSR_F10_MC4_MISC2: /* Link error type */
-	case MSR_F10_MC4_MISC3: /* L3 cache error type */
-		/* we do not emulate link and l3 cache
-		 * errors to the guest.
-		 */
-		*val = 0;
-		mce_printk(MCE_VERBOSE, "MCE: rd msr %#"PRIx64"\n", *val);
-		break;
-	default:
-		return 0;
-	}
-
-	return 1;
+    /* Assign '0' as we don't emulate this MC bank currently */ + 
 *val = 0; +    return 1;
 }
xen/arch/x86/cpu/mcheck/vmce.c +0 -0
index f6c35db..84843fc 100644
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu *v,
 uint32_t msr, uint64_t *val) 
 
Quoted 4 lines
Quoted 4 lines

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 4 lines
xen/arch/x86/cpu/mcheck/vmce.c +1 -1
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */

I don't think this comments is good here. Remove it is better.

Thanks,
Jinsong

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
xen/arch/x86/cpu/mcheck/vmce.c +1 -0
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /* stick all 1's to MCi_CTL */
xen/arch/x86/cpu/mcheck/vmce.c +2 -0
@@ -148,6 +149,10 @@ static int bank_mce_rdmsr(const struct vcpu *v,
             uint32_t msr, uint64_t *val) ret = vmce_intel_rdmsr(v,
             msr, val); break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall

into default. + * Handle reads here.

xen/arch/x86/cpu/mcheck/vmce.c +5 -1
+             */
             ret = vmce_amd_rdmsr(v, msr, val);
             break;
         default:
@@ -210,7 +215,8 @@ 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) )
+    /* Allow only first 3 MC banks into switch() */
+    switch ( msr & (-MSR_IA32_MC0_CTL | 3) )
     {
     case MSR_IA32_MC0_CTL:
         /*
@@ -246,6 +252,10 @@ static int bank_mce_wrmsr(struct vcpu *v,
             uint32_t msr, uint64_t val) ret = vmce_intel_wrmsr(v,
             msr, val); break;
         case X86_VENDOR_AMD:
+            /*
+             * Extended block of AMD thresholding registers fall

into default. + * Handle writes here.
+ */

             ret = vmce_amd_wrmsr(v, msr, val);
             break;
         default:
#9 lore raw
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Jinsong
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c +0 -0
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu *v,
 uint32_t msr, uint64_t *val) 
 
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

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 4 lines
xen/arch/x86/cpu/mcheck/vmce.c +1 -1
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */

I don't think this comments is good here. Remove it is better.

I had asked for this to be removed again too. I'm really thinking that V3 is what we should go with.

Jan

#10 lore raw
Quoted 13 lines · Jan Beulich
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Jinsong
Quoted 5 lines
xen/arch/x86/cpu/mcheck/vmce.c +0 -0
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu
 *v, uint32_t msr, uint64_t *val) 
 
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

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 4 lines
xen/arch/x86/cpu/mcheck/vmce.c +1 -1
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */

I don't think this comments is good here. Remove it is better.

Quoted 4 lines

I had asked for this to be removed again too. I'm really thinking that V3 is what we should go with.

Jan

V3 is fine, except adding comments for '-MSR_IA32_MC0_CTL' is slightly better.

Thanks,
Jinsong

#11 lore raw
Quoted 15 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 10 lines
Quoted 10 lines · Jinsong

xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu · line 111

Quoted 9 lines
xen/arch/x86/cpu/mcheck/vmce.c +1 -1
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu
 *v, uint32_t msr, uint64_t *val) 
 
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */

I don't think this comments is good here. Remove it is better.

Quoted 5 lines
Quoted 2 lines

I had asked for this to be removed again too. I'm really thinking that V3 is what we should go with.

V3 is fine, except adding comments for '-MSR_IA32_MC0_CTL' is slightly better.

Can I read this as an ack then (I already explained elsewhere why I think a comment there is rather pointless)?

Jan

Reviewed-by
#12 lore raw
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 16 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · Jinsong
xen/arch/x86/cpu/mcheck/vmce.c +0 -0
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu
 *v, uint32_t msr, uint64_t *val)
 
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu · line 111

Quoted 4 lines
xen/arch/x86/cpu/mcheck/vmce.c +1 -1
     *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */

I don't think this comments is good here. Remove it is better.

I had asked for this to be removed again too. I'm really thinking that V3 is what we should go with.

Quoted 7 lines
Quoted 2 lines

V3 is fine, except adding comments for '-MSR_IA32_MC0_CTL' is slightly better.

Can I read this as an ack then (I already explained elsewhere why I think a comment there is rather pointless)?

Jan

Yes, please.

#13 lore raw
Quoted 15 lines · Jinsong
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

xen/arch/x86/cpu/mcheck/vmce.c static int bank_mce_rdmsr(const struct vcpu · line 111

Quoted 9 lines · Jinsong
xen/arch/x86/cpu/mcheck/vmce.c +1 -1
@@ -107,7 +107,8 @@ static int bank_mce_rdmsr(const struct vcpu
 *v, uint32_t msr, uint64_t *val)
 
      *val = 0;
 
-    switch ( msr & (MSR_IA32_MC0_CTL | 3) )
+    /* Allow only first 3 MC banks into switch() */

I don't think this comments is good here. Remove it is better.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I had asked for this to be removed again too. I'm really thinking that V3 is what we should go with.

V3 is fine, except adding comments for '-MSR_IA32_MC0_CTL' is slightly better.

Can I read this as an ack then (I already explained elsewhere why I think a comment there is rather pointless)?

Jan

Ok, guess V3 is good enough..

Quoted 3 lines

Yes, please.

Thanks,
-Aravind.