1
0
Fork 0
alistair23-linux/arch/x86/kernel/cpu/mce
Borislav Petkov 6827d62a86 x86/mce: Make mce_rdmsrl() panic on an inaccessible MSR
[ Upstream commit e2def7d49d ]

If an exception needs to be handled while reading an MSR - which is in
most of the cases caused by a #GP on a non-existent MSR - then this
is most likely the incarnation of a BIOS or a hardware bug. Such bug
violates the architectural guarantee that MCA banks are present with all
MSRs belonging to them.

The proper fix belongs in the hardware/firmware - not in the kernel.

Handling an #MC exception which is raised while an NMI is being handled
would cause the nasty NMI nesting issue because of the shortcoming of
IRET of reenabling NMIs when executed. And the machine is in an #MC
context already so <Deity> be at its side.

Tracing MSR accesses while in #MC is another no-no due to tracing being
inherently a bad idea in atomic context:

  vmlinux.o: warning: objtool: do_machine_check()+0x4a: call to mce_rdmsrl() leaves .noinstr.text section

so remove all that "additional" functionality from mce_rdmsrl() and
provide it with a special exception handler which panics the machine
when that MSR is not accessible.

The exception handler prints a human-readable message explaining what
the panic reason is but, what is more, it panics while in the #GP
handler and latter won't have executed an IRET, thus opening the NMI
nesting issue in the case when the #MC has happened while handling
an NMI. (#MC itself won't be reenabled until MCG_STATUS hasn't been
cleared).

Suggested-by: Andy Lutomirski <luto@kernel.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
[ Add missing prototypes for ex_handler_* ]
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lkml.kernel.org/r/20200906212130.GA28456@zn.tnic
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29 09:58:03 +01:00
..
Makefile
amd.c x86/mce/amd: Fix kobject lifetime 2020-02-28 17:22:18 +01:00
apei.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
core.c x86/mce: Make mce_rdmsrl() panic on an inaccessible MSR 2020-10-29 09:58:03 +01:00
dev-mcelog.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
genpool.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 437 2019-06-05 17:37:17 +02:00
inject.c x86/mce/inject: Fix a wrong assignment of i_mce.status 2020-08-19 08:15:53 +02:00
intel.c x86/mce: Fix logic and comments around MSR_PPIN_CTL 2020-03-18 07:17:54 +01:00
internal.h x86/mce: Make mce_rdmsrl() panic on an inaccessible MSR 2020-10-29 09:58:03 +01:00
p5.c
severity.c x86/mce: Add Skylake quirk for patrol scrub reported errors 2020-10-29 09:58:01 +01:00
therm_throt.c x86/mce: Lower throttling MCE messages' priority to warning 2019-12-31 16:44:09 +01:00
threshold.c Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-12-26 17:03:51 -08:00
winchip.c