]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/AMD: Apply erratum 665 on machines without a BIOS fix
authorEmanuel Czirai <icanrealizeum@gmail.com>
Fri, 2 Sep 2016 05:35:50 +0000 (07:35 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 20 Nov 2016 01:17:22 +0000 (01:17 +0000)
commit d1992996753132e2dafe955cccb2fb0714d3cfc4 upstream.

AMD F12h machines have an erratum which can cause DIV/IDIV to behave
unpredictably. The workaround is to set MSRC001_1029[31] but sometimes
there is no BIOS update containing that workaround so let's do it
ourselves unconditionally. It is simple enough.

[ Borislav: Wrote commit message. ]

Signed-off-by: Emanuel Czirai <icanrealizeum@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Yaowu Xu <yaowu@google.com>
Link: http://lkml.kernel.org/r/20160902053550.18097-1-bp@alien8.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bwh: Backported to 3.16:
 - Add an if-statement to init_amd() in place of the switch
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/x86/kernel/cpu/amd.c

index edefacacc2cc7e62d3aa50007c8a376e05a22055..80e35e8522e4b70a9dbda02f498a0bf7e22bca8f 100644 (file)
@@ -522,6 +522,17 @@ static const int amd_erratum_383[];
 static const int amd_erratum_400[];
 static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
 
+#define MSR_AMD64_DE_CFG       0xC0011029
+
+static void init_amd_ln(struct cpuinfo_x86 *c)
+{
+       /*
+        * Apply erratum 665 fix unconditionally so machines without a BIOS
+        * fix work.
+        */
+       msr_set_bit(MSR_AMD64_DE_CFG, 31);
+}
+
 static void init_amd(struct cpuinfo_x86 *c)
 {
        u32 dummy;
@@ -614,6 +625,9 @@ static void init_amd(struct cpuinfo_x86 *c)
                }
        }
 
+       if (c->x86 == 0x12)
+               init_amd_ln(c);
+
        /* re-enable TopologyExtensions if switched off by BIOS */
        if ((c->x86 == 0x15) &&
            (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&