From: "Jan Beulich" Subject: [PATCH] x86: remove redundant MCE related MSR definitions Date: Mon, 12 Dec 2011 15:35:20 +0000 Message-ID: <4EE62D480200007800066FE7@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF7D85228.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartF7D85228.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Two definitions (the first register and a macro to calculate the register for a given bank) are sufficient per kind of register. Signed-off-by: Jan Beulich --- 2011-11-23.orig/xen/arch/x86/cpu/mcheck/amd_nonfatal.c 2011-12-05 = 11:38:33.000000000 +0100 +++ 2011-11-23/xen/arch/x86/cpu/mcheck/amd_nonfatal.c 2011-12-05 = 11:24:15.000000000 +0100 @@ -144,7 +144,7 @@ static void mce_amd_work_fn(void *data) uint64_t value; uint32_t counter; =20 - value =3D mca_rdmsr(MSR_IA32_MC4_MISC); + value =3D mca_rdmsr(MSR_IA32_MCx_MISC(4)); /* Only the error counter field is of interest * Bit field is described in AMD K8 BKDG chapter 6.4.5.5 */ @@ -174,7 +174,7 @@ static void mce_amd_work_fn(void *data) value &=3D ~(0x60FFF00000000ULL); /* Counter enable */ value |=3D (1ULL << 51); - mca_wrmsr(MSR_IA32_MC4_MISC, value); + mca_wrmsr(MSR_IA32_MCx_MISC(4), value); wmb(); } } @@ -217,7 +217,7 @@ void amd_nonfatal_mcheck_init(struct cpu =20 /* hw threshold registers present */ hw_threshold =3D 1; - rdmsrl(MSR_IA32_MC4_MISC, value); + rdmsrl(MSR_IA32_MCx_MISC(4), value); =20 if (value & (1ULL << 61)) { /* Locked bit */ /* Locked by BIOS. Not available for use */ @@ -238,7 +238,7 @@ void amd_nonfatal_mcheck_init(struct cpu value &=3D ~(0x60FFF00000000ULL); /* Counter enable */ value |=3D (1ULL << 51); - wrmsrl(MSR_IA32_MC4_MISC, value); + wrmsrl(MSR_IA32_MCx_MISC(4), value); /* serialize */ wmb(); printk(XENLOG_INFO "MCA: Use hw thresholding to = adjust polling frequency\n"); --- 2011-11-23.orig/xen/arch/x86/cpu/mcheck/mce_amd_quirks.c 2011-12-05 = 11:41:00.000000000 +0100 +++ 2011-11-23/xen/arch/x86/cpu/mcheck/mce_amd_quirks.c 2011-12-05 = 11:42:03.000000000 +0100 @@ -68,8 +68,8 @@ int mcequirk_amd_apply(enum mcequirk_amd * TBL walk error reporting, which trips off incorrectly * with AGP GART & 3ware & Cerberus. */ - wrmsrl(MSR_IA32_MC4_CTL, ~(1ULL << 10)); - wrmsrl(MSR_IA32_MC4_STATUS, 0ULL); + wrmsrl(MSR_IA32_MCx_CTL(4), ~(1ULL << 10)); + wrmsrl(MSR_IA32_MCx_STATUS(4), 0ULL); break; case MCEQUIRK_F10_GART: if (rdmsr_safe(MSR_AMD64_MCx_MASK(4), val) =3D=3D 0) --- 2011-11-23.orig/xen/arch/x86/cpu/mcheck/mce_intel.c 2011-12-05 = 11:38:33.000000000 +0100 +++ 2011-11-23/xen/arch/x86/cpu/mcheck/mce_intel.c 2011-12-05 = 11:27:53.000000000 +0100 @@ -986,7 +986,7 @@ static DEFINE_SPINLOCK(cmci_discover_loc */ static int do_cmci_discover(int i) { - unsigned msr =3D MSR_IA32_MC0_CTL2 + i; + unsigned msr =3D MSR_IA32_MCx_CTL2(i); u64 val; =20 rdmsrl(msr, val); @@ -1095,7 +1095,7 @@ static void clear_cmci(void) smp_processor_id()); =20 for (i =3D 0; i < nr_mce_banks; i++) { - unsigned msr =3D MSR_IA32_MC0_CTL2 + i; + unsigned msr =3D MSR_IA32_MCx_CTL2(i); u64 val; if (!mcabanks_test(i, __get_cpu_var(mce_banks_owned))) continue; --- 2011-11-23.orig/xen/arch/x86/hvm/svm/svm.c 2011-12-05 11:38:33.0000000= 00 +0100 +++ 2011-11-23/xen/arch/x86/hvm/svm/svm.c 2011-12-05 11:25:55.0000000= 00 +0100 @@ -1318,7 +1318,7 @@ static int svm_msr_read_intercept(unsign *msr_content =3D v->arch.hvm_svm.guest_sysenter_eip; break; =20 - case MSR_IA32_MC4_MISC: /* Threshold register */ + case MSR_IA32_MCx_MISC(4): /* Threshold register */ case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: /* * MCA/MCE: We report that the threshold register is unavailable @@ -1498,7 +1498,7 @@ static int svm_msr_write_intercept(unsig vpmu_do_wrmsr(msr, msr_content); break; =20 - case MSR_IA32_MC4_MISC: /* Threshold register */ + case MSR_IA32_MCx_MISC(4): /* Threshold register */ case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3: /* * MCA/MCE: Threshold register is reported to be locked, so we = ignore --- 2011-11-23.orig/xen/include/asm-x86/msr-index.h 2011-12-05 = 11:06:39.000000000 +0100 +++ 2011-11-23/xen/include/asm-x86/msr-index.h 2011-12-05 11:21:46.0000000= 00 +0100 @@ -100,58 +100,11 @@ =20 #define MSR_AMD64_MC0_MASK 0xc0010044 =20 -#define MSR_IA32_MC1_CTL 0x00000404 -#define MSR_IA32_MC1_CTL2 0x00000281 -#define MSR_IA32_MC1_STATUS 0x00000405 -#define MSR_IA32_MC1_ADDR 0x00000406 -#define MSR_IA32_MC1_MISC 0x00000407 - -#define MSR_IA32_MC2_CTL 0x00000408 -#define MSR_IA32_MC2_CTL2 0x00000282 -#define MSR_IA32_MC2_STATUS 0x00000409 -#define MSR_IA32_MC2_ADDR 0x0000040A -#define MSR_IA32_MC2_MISC 0x0000040B - -#define MSR_IA32_MC3_CTL2 0x00000283 -#define MSR_IA32_MC3_CTL 0x0000040C -#define MSR_IA32_MC3_STATUS 0x0000040D -#define MSR_IA32_MC3_ADDR 0x0000040E -#define MSR_IA32_MC3_MISC 0x0000040F - -#define MSR_IA32_MC4_CTL2 0x00000284 -#define MSR_IA32_MC4_CTL 0x00000410 -#define MSR_IA32_MC4_STATUS 0x00000411 -#define MSR_IA32_MC4_ADDR 0x00000412 -#define MSR_IA32_MC4_MISC 0x00000413 - -#define MSR_IA32_MC5_CTL2 0x00000285 -#define MSR_IA32_MC5_CTL 0x00000414 -#define MSR_IA32_MC5_STATUS 0x00000415 -#define MSR_IA32_MC5_ADDR 0x00000416 -#define MSR_IA32_MC5_MISC 0x00000417 - -#define MSR_IA32_MC6_CTL2 0x00000286 -#define MSR_IA32_MC6_CTL 0x00000418 -#define MSR_IA32_MC6_STATUS 0x00000419 -#define MSR_IA32_MC6_ADDR 0x0000041A -#define MSR_IA32_MC6_MISC 0x0000041B - -#define MSR_IA32_MC7_CTL2 0x00000287 -#define MSR_IA32_MC7_CTL 0x0000041C -#define MSR_IA32_MC7_STATUS 0x0000041D -#define MSR_IA32_MC7_ADDR 0x0000041E -#define MSR_IA32_MC7_MISC 0x0000041F - -#define MSR_IA32_MC8_CTL2 0x00000288 -#define MSR_IA32_MC8_CTL 0x00000420 -#define MSR_IA32_MC8_STATUS 0x00000421 -#define MSR_IA32_MC8_ADDR 0x00000422 -#define MSR_IA32_MC8_MISC 0x00000423 - #define MSR_IA32_MCx_CTL(x) (MSR_IA32_MC0_CTL + 4*(x)) #define MSR_IA32_MCx_STATUS(x) (MSR_IA32_MC0_STATUS + 4*(x)) #define MSR_IA32_MCx_ADDR(x) (MSR_IA32_MC0_ADDR + 4*(x)) #define MSR_IA32_MCx_MISC(x) (MSR_IA32_MC0_MISC + 4*(x))=20 +#define MSR_IA32_MCx_CTL2(x) (MSR_IA32_MC0_CTL2 + (x)) =20 #define MSR_AMD64_MCx_MASK(x) (MSR_AMD64_MC0_MASK + (x)) =20 --=__PartF7D85228.0__= Content-Type: text/plain; name="x86-mce-msr-names.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mce-msr-names.patch" x86: remove redundant MCE related MSR definitions=0A=0ATwo definitions = (the first register and a macro to calculate the=0Aregister for a given = bank) are sufficient per kind of register.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- 2011-11-23.orig/xen/arch/x86/cpu/mcheck/amd_no= nfatal.c 2011-12-05 11:38:33.000000000 +0100=0A+++ 2011-11-23/xen/ar= ch/x86/cpu/mcheck/amd_nonfatal.c 2011-12-05 11:24:15.000000000 = +0100=0A@@ -144,7 +144,7 @@ static void mce_amd_work_fn(void *data)=0A = uint64_t value;=0A uint32_t counter;=0A =0A- = value =3D mca_rdmsr(MSR_IA32_MC4_MISC);=0A+ value =3D = mca_rdmsr(MSR_IA32_MCx_MISC(4));=0A /* Only the error counter = field is of interest=0A * Bit field is described in AMD = K8 BKDG chapter 6.4.5.5=0A */=0A@@ -174,7 +174,7 @@ static = void mce_amd_work_fn(void *data)=0A value &=3D = ~(0x60FFF00000000ULL);=0A /* Counter enable */=0A = value |=3D (1ULL << 51);=0A- mca_wrmsr(M= SR_IA32_MC4_MISC, value);=0A+ mca_wrmsr(MSR_IA32_MCx_MISC= (4), value);=0A wmb();=0A }=0A = }=0A@@ -217,7 +217,7 @@ void amd_nonfatal_mcheck_init(struct cpu=0A =0A = /* hw threshold registers present */=0A hw_threshol= d =3D 1;=0A- rdmsrl(MSR_IA32_MC4_MISC, value);=0A+ = rdmsrl(MSR_IA32_MCx_MISC(4), value);=0A =0A if (value & (1ULL = << 61)) { /* Locked bit */=0A /* Locked by BIOS. Not = available for use */=0A@@ -238,7 +238,7 @@ void amd_nonfatal_mcheck_init(st= ruct cpu=0A value &=3D ~(0x60FFF00000000ULL);=0A = /* Counter enable */=0A value |=3D (1ULL = << 51);=0A- wrmsrl(MSR_IA32_MC4_MISC, value);=0A+ = wrmsrl(MSR_IA32_MCx_MISC(4), value);=0A /* = serialize */=0A wmb();=0A = printk(XENLOG_INFO "MCA: Use hw thresholding to adjust polling frequency\n"= );=0A--- 2011-11-23.orig/xen/arch/x86/cpu/mcheck/mce_amd_quirks.c = 2011-12-05 11:41:00.000000000 +0100=0A+++ 2011-11-23/xen/arch/x86/cpu/mchec= k/mce_amd_quirks.c 2011-12-05 11:42:03.000000000 +0100=0A@@ -68,8 = +68,8 @@ int mcequirk_amd_apply(enum mcequirk_amd=0A * TBL = walk error reporting, which trips off incorrectly=0A * with = AGP GART & 3ware & Cerberus.=0A */=0A- wrmsrl(MSR_= IA32_MC4_CTL, ~(1ULL << 10));=0A- wrmsrl(MSR_IA32_MC4_STATUS,= 0ULL);=0A+ wrmsrl(MSR_IA32_MCx_CTL(4), ~(1ULL << 10));=0A+ = wrmsrl(MSR_IA32_MCx_STATUS(4), 0ULL);=0A break;=0A = case MCEQUIRK_F10_GART:=0A if (rdmsr_safe(MSR_AMD64_MCx_MASK(4= ), val) =3D=3D 0)=0A--- 2011-11-23.orig/xen/arch/x86/cpu/mcheck/mce_intel.c= 2011-12-05 11:38:33.000000000 +0100=0A+++ 2011-11-23/xen/arch/x86/c= pu/mcheck/mce_intel.c 2011-12-05 11:27:53.000000000 +0100=0A@@ -986,7 = +986,7 @@ static DEFINE_SPINLOCK(cmci_discover_loc=0A */=0A static int = do_cmci_discover(int i)=0A {=0A- unsigned msr =3D MSR_IA32_MC0_CTL2 + = i;=0A+ unsigned msr =3D MSR_IA32_MCx_CTL2(i);=0A u64 val;=0A =0A = rdmsrl(msr, val);=0A@@ -1095,7 +1095,7 @@ static void clear_cmci(void)=0A = smp_processor_id());=0A =0A for (i =3D 0; i < nr_mce_banks;= i++) {=0A- unsigned msr =3D MSR_IA32_MC0_CTL2 + i;=0A+ = unsigned msr =3D MSR_IA32_MCx_CTL2(i);=0A u64 val;=0A if = (!mcabanks_test(i, __get_cpu_var(mce_banks_owned)))=0A = continue;=0A--- 2011-11-23.orig/xen/arch/x86/hvm/svm/svm.c 2011-12-05 = 11:38:33.000000000 +0100=0A+++ 2011-11-23/xen/arch/x86/hvm/svm/svm.c = 2011-12-05 11:25:55.000000000 +0100=0A@@ -1318,7 +1318,7 @@ static int = svm_msr_read_intercept(unsign=0A *msr_content =3D v->arch.hvm_svm.g= uest_sysenter_eip;=0A break;=0A =0A- case MSR_IA32_MC4_MISC: /* = Threshold register */=0A+ case MSR_IA32_MCx_MISC(4): /* Threshold = register */=0A case MSR_F10_MC4_MISC1 ... MSR_F10_MC4_MISC3:=0A = /*=0A * MCA/MCE: We report that the threshold register is = unavailable=0A@@ -1498,7 +1498,7 @@ static int svm_msr_write_intercept(unsi= g=0A vpmu_do_wrmsr(msr, msr_content);=0A break;=0A =0A- = case MSR_IA32_MC4_MISC: /* Threshold register */=0A+ case MSR_IA32_MCx_M= ISC(4): /* Threshold register */=0A case MSR_F10_MC4_MISC1 ... = MSR_F10_MC4_MISC3:=0A /*=0A * MCA/MCE: Threshold register = is reported to be locked, so we ignore=0A--- 2011-11-23.orig/xen/include/as= m-x86/msr-index.h 2011-12-05 11:06:39.000000000 +0100=0A+++ = 2011-11-23/xen/include/asm-x86/msr-index.h 2011-12-05 11:21:46.0000000= 00 +0100=0A@@ -100,58 +100,11 @@=0A =0A #define MSR_AMD64_MC0_MASK = 0xc0010044=0A =0A-#define MSR_IA32_MC1_CTL 0x00000404=0A-#defi= ne MSR_IA32_MC1_CTL2 0x00000281=0A-#define MSR_IA32_MC1_STATUS = 0x00000405=0A-#define MSR_IA32_MC1_ADDR 0x00000406=0A-#defi= ne MSR_IA32_MC1_MISC 0x00000407=0A-=0A-#define MSR_IA32_MC2_CTL = 0x00000408=0A-#define MSR_IA32_MC2_CTL2 0x00000282=0A-#defi= ne MSR_IA32_MC2_STATUS 0x00000409=0A-#define MSR_IA32_MC2_ADDR = 0x0000040A=0A-#define MSR_IA32_MC2_MISC 0x0000040B=0A-=0A-#define = MSR_IA32_MC3_CTL2 0x00000283=0A-#define MSR_IA32_MC3_CTL = 0x0000040C=0A-#define MSR_IA32_MC3_STATUS 0x0000040D=0A-#defi= ne MSR_IA32_MC3_ADDR 0x0000040E=0A-#define MSR_IA32_MC3_MISC = 0x0000040F=0A-=0A-#define MSR_IA32_MC4_CTL2 0x00000284=0A-#defi= ne MSR_IA32_MC4_CTL 0x00000410=0A-#define MSR_IA32_MC4_STATUS = 0x00000411=0A-#define MSR_IA32_MC4_ADDR 0x00000412=0A-#defi= ne MSR_IA32_MC4_MISC 0x00000413=0A-=0A-#define MSR_IA32_MC5_CTL2= 0x00000285=0A-#define MSR_IA32_MC5_CTL 0x00000414= =0A-#define MSR_IA32_MC5_STATUS 0x00000415=0A-#define MSR_IA32_MC5_= ADDR 0x00000416=0A-#define MSR_IA32_MC5_MISC 0x00000417= =0A-=0A-#define MSR_IA32_MC6_CTL2 0x00000286=0A-#define = MSR_IA32_MC6_CTL 0x00000418=0A-#define MSR_IA32_MC6_STATUS = 0x00000419=0A-#define MSR_IA32_MC6_ADDR 0x0000041A=0A-#defi= ne MSR_IA32_MC6_MISC 0x0000041B=0A-=0A-#define MSR_IA32_MC7_CTL2= 0x00000287=0A-#define MSR_IA32_MC7_CTL 0x0000041C= =0A-#define MSR_IA32_MC7_STATUS 0x0000041D=0A-#define MSR_IA32_MC7_= ADDR 0x0000041E=0A-#define MSR_IA32_MC7_MISC 0x0000041F= =0A-=0A-#define MSR_IA32_MC8_CTL2 0x00000288=0A-#define = MSR_IA32_MC8_CTL 0x00000420=0A-#define MSR_IA32_MC8_STATUS = 0x00000421=0A-#define MSR_IA32_MC8_ADDR 0x00000422=0A-#defi= ne MSR_IA32_MC8_MISC 0x00000423=0A-=0A #define MSR_IA32_MCx_CTL(= x) (MSR_IA32_MC0_CTL + 4*(x))=0A #define MSR_IA32_MCx_STATUS(x= ) (MSR_IA32_MC0_STATUS + 4*(x))=0A #define MSR_IA32_MCx_ADDR(= x) (MSR_IA32_MC0_ADDR + 4*(x))=0A #define MSR_IA32_MCx_MISC(x)= (MSR_IA32_MC0_MISC + 4*(x)) =0A+#define MSR_IA32_MCx_CTL2(x= ) (MSR_IA32_MC0_CTL2 + (x))=0A =0A #define MSR_AMD64_MCx_MASK= (x) (MSR_AMD64_MC0_MASK + (x))=0A =0A --=__PartF7D85228.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartF7D85228.0__=--