Skip to contentSkip to conversation

x86/AMD: Apply workaround for AMD F16h Erratum792

PATCH In review Aravind Gopalakrishnan 2 participants 3 messages Feb 6, 2014 – Feb 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 x86/AMD: Apply workaround for AMD F16h Erratum792

Workaround for the Erratum will be in BIOSes spun only after Jan 2014 onwards. But initial production parts shipped in 2013 itself. Since there is a coverage hole, we should carry this fix in software in case BIOS does not do the right thing or someone is using old BIOS.

Refer to Revision Guide for AMD F16h models 00h-0fh, document 51810 Rev. 3.04, November2013 for details on the Erratum.

Tested the patch on Fam16h server platform and it works fine.

Changes in V2: (per Andrew.C comments)
- Move pci_val into same scope
- rework indentation to match linux style
Changes in V3: (per Jan comments)
- remove pci_val, use 'l' and 'h' instead
- print warning message to hypervisor log

---
 xen/arch/x86/cpu/amd.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
xen/arch/x86/cpu/amd.c +36 -0
index 3307141..d83906a 100644
@@ -477,6 +477,42 @@ static void __devinit init_amd(struct cpuinfo_x86 *c)
 		       " all your (PV) guest kernels. ***\n");
 
 	if (c->x86 == 0x16 && c->x86_model <= 0xf) {
+		/*
+		 * Apply workaround for erratum 792
+		 * Description:
+		 * Processor does not ensure DRAM scrub read/write sequence
+		 * is atomic wrt accesses to CC6 save state area. Therefore
+		 * if a concurrent scrub read/write access is to same address
+		 * the entry may appear as if it is not written. This quirk
+		 * applies to Fam16h models 00h-0Fh
+		 *
+		 * See "Revision Guide" for AMD F16h models 00h-0fh,
+		 * document 51810 rev. 3.04, Nov 2013
+		 *
+		 * Equivalent Linux patch link:
+		 * http://marc.info/?l=linux-kernel&m=139066012217149&w=2
+		 */
+		if (smp_processor_id() == 0) {
+			l = pci_conf_read32(0, 0, 0x18, 0x3, 0x58);
+			h = pci_conf_read32(0, 0, 0x18, 0x3, 0x5c);
+			printk(KERN_WARNING
+			       "CPU%u: Applying workaround for erratum 792:%s %s %s\n",
+			       smp_processor_id(),
+			       (l & 0x1f)? "clearing bits 0-4 of D18F3x58" : "" ,
+			       ((l & 0x1f) && (h & 0x1)) ? "and" : "" , 
+			       (h & 0x1) ? "clearing bit 0 of D18F3x5C" : "");
+
+			if (l & 0x1f) {
+				l &= ~0x1f;
+				pci_conf_write32(0, 0, 0x18, 0x3, 0x58, l);
+			}
+
+			if (h & 0x1) {
+				h &= ~0x1;
+				pci_conf_write32(0, 0, 0x18, 0x3, 0x5c, h);
+			}
+		}
+
 		rdmsrl(MSR_AMD64_LS_CFG, value);
 		if (!(value & (1 << 15))) {
 			static bool_t warned;
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Aravind Gopalakrishnan

Workaround for the Erratum will be in BIOSes spun only after Jan 2014 onwards. But initial production parts shipped in 2013 itself. Since there is a coverage hole, we should carry this fix in software in case BIOS does not do the right thing or someone is using old BIOS.

Refer to Revision Guide for AMD F16h models 00h-0fh, document 51810 Rev. 3.04, November2013 for details on the Erratum.

Tested the patch on Fam16h server platform and it works fine.

Changes in V2: (per Andrew.C comments)
- Move pci_val into same scope
- rework indentation to match linux style
Changes in V3: (per Jan comments)
- remove pci_val, use 'l' and 'h' instead
- print warning message to hypervisor log

Quoted 3 lines

Applied after some more editing. Please double check.

Jan

#2 lore raw
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Aravind Gopalakrishnan

Workaround for the Erratum will be in BIOSes spun only after Jan 2014 onwards. But initial production parts shipped in 2013 itself. Since there is a coverage hole, we should carry this fix in software in case BIOS does not do the right thing or someone is using old BIOS.

Refer to Revision Guide for AMD F16h models 00h-0fh, document 51810 Rev. 3.04, November2013 for details on the Erratum.

Tested the patch on Fam16h server platform and it works fine.

Changes in V2: (per Andrew.C comments)
- Move pci_val into same scope
- rework indentation to match linux style
Changes in V3: (per Jan comments)
- remove pci_val, use 'l' and 'h' instead
- print warning message to hypervisor log

Quoted 6 lines
Quoted 3 lines

Applied after some more editing. Please double check.

Tested staging branch on F16h to make sure; and works fine..

Thanks,
-Aravind.