linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/AMD: Apply erratum 688 on machines without a BIOS fix
@ 2016-10-19 13:58 sonofagun
  2016-10-19 15:00 ` Borislav Petkov
  0 siblings, 1 reply; 24+ messages in thread
From: sonofagun @ 2016-10-19 13:58 UTC (permalink / raw)
  To: linux-kernel


AMD F14h machines have an erratum which can cause unpredictable program 
behaviour under specific branch conditions. The workaround is to set 
MSRC001_1021[14] and MSRC001_1021[3]. Both bits are reserved for this 
MSR, so we trust AMD suggestions. Since there is no BIOS update 
containing that workaround for some machines, we do it ourselves 
unconditionally on this family too. Our Compaq CQ57 laptop which has 
broken firmware in various areas does not contain both 
workarounds(MSRc0011021: 0000000010208000)...

HP does not release a proper BIOS even though we have contacted them and 
requested an updated BIOS that will fix all errors we spotted. As it is 
not currently covered by any warranty, they do not support it. HP does 
not care, but Linux kernel cares to patch out-of-warranty hardware with 
crappy firmware!

Thanks to the author of commit d1992996753132e2dafe955cccb2fb0714d3cfc4 
(x86/AMD: Apply erratum 665 on machines without a BIOS fix) as he paved 
the way to this fix. That patch was not applicable on our machine but it 
brought back to surface a long standing bug of our E-300 laptop. Poor 
performance under Debian was observed and things got worse after 
switching to Ubuntu as crashes became more frequent! As a result the 
laptop got replaced with a desktop.

After some time, we decided to dig deeper and see what is wrong with our 
laptop. Actually perf proved that something was terrible wrong as 
branch-misses reached 40% within a minute after booting the E-300 
ontario C0 APU! Disabling the second CPU did not help either. CPU 
Revision Guide erratum 688 seemed promising as it described our issues 
and we prepared a fix. Now the laptop works and has both 
workarounds(MSRc0011021: 000000001020c008)! Since this erratum affects 
many laptops and some tablets, we request to backport it to stable 
kernels.

Tested on Compaq CQ57-499 laptop.


Signed-off-by: Ioannis Barkas <sonofagun@openmailbox.org>
Signed-off-by: Nikos Barkas <levelwol@gmail.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>

---

Hello we are Ioannis Barkas (sonofagun@openmailbox.org) and Nikos Barkas 
(levelwol@gmail.com).

This patch was sent from my yahoo e-mail in the morning and got 
rejected! Why?
Resending...

We have had poor performance on our AMD laptop with Debian for some 
years. Initial value of MSRc0011021 is 0000000010208000h and D18F4x164 
is 00000003h. Our laptop was not usable even with Ubuntu 16.04 using the 
radeon driver. What is worse, opening firefox with 
https://planefinder.net/ after booting Ubuntu, resulted in firefox 
crashes again and again. After this patch we have not met any problem 
with that webpage and firefox. Unfortunately linux-tools were not 
present for our custom kernel and perf could not be launched:( When the 
patch arrives on Ubuntu 16.10 kernel, we shall recheck it. If 
branch-misses remain above 10%, we will open a bug for it.

--- a/arch/x86/kernel/cpu/amd.c	2016-10-07 16:03:33.000000000 +0300
+++ b/arch/x86/kernel/cpu/amd.c	2016-10-12 13:25:34.791720549 +0300
@@ -680,6 +680,18 @@ static void init_amd_ln(struct cpuinfo_x
  	msr_set_bit(MSR_AMD64_DE_CFG, 31);
  }

+#define MSR_AMD64_IC_CFG	0xC0011021
+
+static void init_amd_on(struct cpuinfo_x86 *c)
+{
+	/*
+	 * Apply erratum 688 fix unconditionally so machines without a BIOS
+	 * fix work.
+	 */
+	msr_set_bit(MSR_AMD64_IC_CFG, 3);
+	msr_set_bit(MSR_AMD64_IC_CFG, 14);
+}
+
  static void init_amd_bd(struct cpuinfo_x86 *c)
  {
  	u64 value;
@@ -738,6 +750,7 @@ static void init_amd(struct cpuinfo_x86
  	case 0xf:  init_amd_k8(c); break;
  	case 0x10: init_amd_gh(c); break;
  	case 0x12: init_amd_ln(c); break;
+	case 0x14: init_amd_on(c); break;
  	case 0x15: init_amd_bd(c); break;
  	}

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: [PATCH] x86/AMD: Apply erratum 688 on machines without a BIOS fix
@ 2016-10-21 16:19 sonofagun
  2016-10-21 16:47 ` Borislav Petkov
  0 siblings, 1 reply; 24+ messages in thread
From: sonofagun @ 2016-10-21 16:19 UTC (permalink / raw)
  To: linux-kernel


Sorry for the late reply! This machine has caused nothing but trouble. 
HP will not fix it and we will not choose their laptops anymore...

My brother told me that we apply a quirk to the last Ontario APUs that 
do not need it but I did not think it would be an issue since they have 
fixed the error.
It seems better this way so that only affected APUs are patched. Be 
patient, we are compiling the new patch right now but compiling is run 
on a different high end AMD machine of my brother. Tomorrow I will have 
access to the laptop and I will update the kernel and send you the V2 
patch. Compiling to that laptop would possibly need a whole day even 
with AC power!


Do you want /proc/cpuinfo on the V2 patch e-mail? Both CPUs needed?
Here is a dump from an older installation some months ago I kept on my 
disk(tomorrow I will dump it again if you want):
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 20
model		: 2
model name	: AMD E-300 APU with Radeon(tm) HD Graphics
stepping	: 0
microcode	: 0x5000119
cpu MHz		: 1300.000
cache size	: 512 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 6
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt 
pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid 
aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic 
cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt hw_pstate 
vmmcall arat npt lbrv svm_lock nrip_save pausefilter
bugs		: fxsave_leak sysret_ss_attrs
bogomips	: 2594.69
TLB size	: 1024 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate

processor	: 1
vendor_id	: AuthenticAMD
cpu family	: 20
model		: 2
model name	: AMD E-300 APU with Radeon(tm) HD Graphics
stepping	: 0
microcode	: 0x5000119
cpu MHz		: 1300.000
cache size	: 512 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 2
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 6
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt 
pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid 
aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic 
cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt hw_pstate 
vmmcall arat npt lbrv svm_lock nrip_save pausefilter
bugs		: fxsave_leak sysret_ss_attrs
bogomips	: 2594.69
TLB size	: 1024 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate


> Then, keep that *whole* changelog above when sending v2 of the patch
What do you mean? It is not clear to me, Do you mean all the info we 
wrote on the e-mail, your comments or both?

We have many AMD machines and we will need your help next week to patch 
our Phenom(tm) II X6. Let's finish this
patch first and we will fix that too but it appears to be much more 
difficult...

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2016-10-31 22:59 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-19 13:58 [PATCH] x86/AMD: Apply erratum 688 on machines without a BIOS fix sonofagun
2016-10-19 15:00 ` Borislav Petkov
2016-10-21 16:19 sonofagun
2016-10-21 16:47 ` Borislav Petkov
2016-10-21 21:51   ` sonofagun
2016-10-21 23:01     ` Borislav Petkov
2016-10-22 11:16       ` sonofagun
2016-10-22 14:12         ` Borislav Petkov
2016-10-23  9:39           ` sonofagun
2016-10-23  9:57             ` Borislav Petkov
2016-10-23 17:06               ` sonofagun
2016-10-23 17:25                 ` Borislav Petkov
2016-10-23 21:02                   ` sonofagun
2016-10-23 21:39                     ` Borislav Petkov
2016-10-24 11:38                       ` sonofagun
2016-10-24  9:35                         ` Borislav Petkov
2016-10-24 13:13                           ` sonofagun
2016-10-24 17:14                             ` Borislav Petkov
2016-10-24 20:39                               ` sonofagun
2016-10-25  9:29                                 ` Borislav Petkov
2016-10-25 13:16                                   ` sonofagun
2016-10-28 16:21                               ` Borislav Petkov
2016-10-31 21:54                                 ` sonofagun
2016-10-31 22:59                                   ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).