android_kernel_oneplus_msm8998/arch
Tom Lendacky 721a2f80a4 x86/CPU/AMD: Clear RDRAND CPUID bit on AMD family 15h/16h
[ Upstream commit c49a0a80137c7ca7d6ced4c812c9e07a949f6f24 ]

There have been reports of RDRAND issues after resuming from suspend on
some AMD family 15h and family 16h systems. This issue stems from a BIOS
not performing the proper steps during resume to ensure RDRAND continues
to function properly.

RDRAND support is indicated by CPUID Fn00000001_ECX[30]. This bit can be
reset by clearing MSR C001_1004[62]. Any software that checks for RDRAND
support using CPUID, including the kernel, will believe that RDRAND is
not supported.

Update the CPU initialization to clear the RDRAND CPUID bit for any family
15h and 16h processor that supports RDRAND. If it is known that the family
15h or family 16h system does not have an RDRAND resume issue or that the
system will not be placed in suspend, the "rdrand=force" kernel parameter
can be used to stop the clearing of the RDRAND CPUID bit.

Additionally, update the suspend and resume path to save and restore the
MSR C001_1004 value to ensure that the RDRAND CPUID setting remains in
place after resuming from suspend.

Note, that clearing the RDRAND CPUID bit does not prevent a processor
that normally supports the RDRAND instruction from executing it. So any
code that determined the support based on family and model won't #UD.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Chen Yu <yu.c.chen@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: "linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: <stable@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "x86@kernel.org" <x86@kernel.org>
Link: https://lkml.kernel.org/r/7543af91666f491547bd86cebb1e17c66824ab9f.1566229943.git.thomas.lendacky@amd.com
[sl: adjust context in docs]
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-09-06 10:18:14 +02:00
..
alpha alpha: Fix Eiger NR_IRQS to 128 2019-02-20 10:13:22 +01:00
arc ARC: hide unused function unw_hdr_alloc 2019-07-21 09:07:14 +02:00
arm ARM: davinci: fix sleep.S build error on ARMv4 2019-08-25 10:52:49 +02:00
arm64 arm64: compat: Allow single-byte watchpoints on all addresses 2019-08-25 10:53:03 +02:00
avr32 avr32: off by one in at32_init_pio() 2016-10-07 15:23:45 +02:00
blackfin pinctrl: adi2: Fix Kconfig build problem 2017-12-20 10:05:00 +01:00
c6x c6x/ptrace: Remove useless PTRACE_SETREGSET implementation 2017-03-31 09:49:53 +02:00
cris mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
frv futex: Remove duplicated code and fix undefined behaviour 2018-05-26 08:48:50 +02:00
h8300 h8300: use cc-cross-prefix instead of hardcoding h8300-unknown-linux- 2019-04-27 09:33:48 +02:00
hexagon hexagon: modify ffs() and fls() to return int 2018-10-10 08:52:12 +02:00
ia64 bug.h: work around GCC PR82365 in BUG() 2019-07-10 09:56:42 +02:00
m32r m32r: fix __get_user() 2016-09-24 10:07:43 +02:00
m68k bug.h: work around GCC PR82365 in BUG() 2019-07-10 09:56:42 +02:00
metag metag/uaccess: Check access_ok in strncpy_from_user 2017-05-25 14:30:16 +02:00
microblaze microblaze: Fix simpleImage format generation 2018-08-06 16:24:39 +02:00
mips MIPS: kernel: only use i8253 clocksource with periodic clockevent 2019-09-06 10:18:04 +02:00
mn10300 mn10300/misalignment: Use SIGSEGV SEGV_MAPERR to report a failed user copy 2018-02-16 20:09:47 +01:00
nios2 nios2: reserve boot memory for device tree 2017-04-12 12:38:34 +02:00
openrisc kthread: fix boot hang (regression) on MIPS/OpenRISC 2018-09-19 22:48:55 +02:00
parisc parisc: Fix kernel panic due invalid values in IAOQ0 or IAOQ1 2019-08-04 09:34:52 +02:00
powerpc powerpc/tm: Fix oops on sigreturn on systems without TM 2019-08-04 09:35:00 +02:00
s390 s390: fix stfle zero padding 2019-07-21 09:07:15 +02:00
score score: fix copy_from_user() and friends 2016-09-24 10:07:44 +02:00
sh sh: kernel: hw_breakpoint: Fix missing break in switch statement 2019-08-25 10:52:55 +02:00
sparc bug.h: work around GCC PR82365 in BUG() 2019-07-10 09:56:42 +02:00
tile futex: Remove duplicated code and fix undefined behaviour 2018-05-26 08:48:50 +02:00
um um: Silence lockdep complaint about mmap_sem 2019-08-04 09:34:58 +02:00
unicore32 pwm: Changes for v4.4-rc1 2015-11-11 09:16:10 -08:00
x86 x86/CPU/AMD: Clear RDRAND CPUID bit on AMD family 15h/16h 2019-09-06 10:18:14 +02:00
xtensa xtensa: fix return_address 2019-04-27 09:33:56 +02:00
.gitignore
Kconfig