From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mga11.intel.com ([192.55.52.93]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fDYzC-0002yJ-4C for speck@linutronix.de; Tue, 01 May 2018 19:22:42 +0200 Subject: [MODERATED] Re: [patch V9 00/16] SSB References: <20180501152420.785133537@linutronix.de> From: Tim Chen Message-ID: <1f9fea0d-12e9-aa51-717e-72f0203a0aae@linux.intel.com> Date: Tue, 1 May 2018 10:22:38 -0700 MIME-Version: 1.0 In-Reply-To: <20180501152420.785133537@linutronix.de> Content-Type: multipart/mixed; boundary="0emOjQzBAuGZQgRCZrRPY4dV28bidyoqP"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --0emOjQzBAuGZQgRCZrRPY4dV28bidyoqP Content-Type: multipart/mixed; boundary="DmEmT8a4PsQtjIjWliAZ0rHrcwDHE7ONq" --DmEmT8a4PsQtjIjWliAZ0rHrcwDHE7ONq Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 05/01/2018 08:24 AM, speck for Thomas Gleixner wrote: > Changes vs. V8: >=20 > Addressed review feed back and added Linus variant of > alternative_write_msr(). >=20 > - Use EINVAL in the prctl >=20 > - Fix the sbb typos >=20 > - Make AMD default to prctl as well (Borislav) >=20 > - Add the not affected CPU types (Tim) >=20 > I've updated the git repository as well >=20 > ssh://git@cvs.ou.linutronix.de/linux/speck/linux master (forced updat= e) >=20 > There are also two stable backport branches now: >=20 > ssh://git@cvs.ou.linutronix.de/linux/speck/linux linux-4.16.y >=20 > ssh://git@cvs.ou.linutronix.de/linux/speck/linux linux-4.14.y >=20 >=20 > Delta patch against V8 below. Git bundle against 4.17-rc3 follows in > separate mail. >=20 > Thanks, >=20 > tglx >=20 This version also has a bug that's in the v8 patch. For whole platform disabling of speculation, only CPU 0 has RDS enabled. root@otc-cfl-s-02:~# cat /sys/devices/system/cpu/vulnerabilities/spec_sto= re_bypass=20 Mitigation: Speculative Store Bypass disabled msr 0x48 cpu 0 val: 4 msr 0x48 cpu 1 val: 0 msr 0x48 cpu 2 val: 0 msr 0x48 cpu 3 val: 0 msr 0x48 cpu 4 val: 0 msr 0x48 cpu 5 val: 0 msr 0x48 cpu 6 val: 0 msr 0x48 cpu 7 val: 0 msr 0x48 cpu 8 val: 0 msr 0x48 cpu 9 val: 0 msr 0x48 cpu 10 val: 0 msr 0x48 cpu 11 val: 0 I used the fix below to take care of Intel CPU. The fix also works for CPU taken offline and back online. AMD cpu has the proper setting of their MSR in boot up via identify_secondary_cpu's call to x86_setup_ap_spec_ctrl. void x86_setup_ap_spec_ctrl(void) { if (boot_cpu_has(X86_FEATURE_IBRS)) x86_set_spec_ctrl(x86_spec_ctrl_base & ~x86_spec_ctrl_mas= k); if (ssb_mode =3D=3D SPEC_STORE_BYPASS_DISABLE) x86_amd_rds_enable(); } But AMD cpu may have issue when CPU is brought offline and back online as= x86_setup_ap_spec_ctrl may not get called then. Tim --- diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index ef3f9c0..c799e48 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -770,6 +770,9 @@ static void init_intel(struct cpuinfo_x86 *c) init_intel_energy_perf(c); =20 init_intel_misc_features(c); + + if (cpu_has(c, X86_FEATURE_SPEC_STORE_BYPASS_DISABLE)) + x86_set_spec_ctrl(SPEC_CTRL_RDS); } =20 #ifdef CONFIG_X86_32 --DmEmT8a4PsQtjIjWliAZ0rHrcwDHE7ONq-- --0emOjQzBAuGZQgRCZrRPY4dV28bidyoqP--