x86/mce: Prevent severity computation from being instrumented
Mark all the MCE severity computation logic noinstr and allow instrumentation when it "calls out". Fixes vmlinux.o: warning: objtool: do_machine_check()+0xc5d: call to mce_severity() leaves .noinstr.text section Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/20211208111343.8130-7-bp@alien8.de
This commit is contained in:
parent
4fbce464db
commit
0a5b288e85
1 changed files with 21 additions and 9 deletions
|
@ -263,24 +263,36 @@ static bool is_copy_from_user(struct pt_regs *regs)
|
||||||
* distinguish an exception taken in user from from one
|
* distinguish an exception taken in user from from one
|
||||||
* taken in the kernel.
|
* taken in the kernel.
|
||||||
*/
|
*/
|
||||||
static int error_context(struct mce *m, struct pt_regs *regs)
|
static noinstr int error_context(struct mce *m, struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
|
int fixup_type;
|
||||||
|
bool copy_user;
|
||||||
|
|
||||||
if ((m->cs & 3) == 3)
|
if ((m->cs & 3) == 3)
|
||||||
return IN_USER;
|
return IN_USER;
|
||||||
|
|
||||||
if (!mc_recoverable(m->mcgstatus))
|
if (!mc_recoverable(m->mcgstatus))
|
||||||
return IN_KERNEL;
|
return IN_KERNEL;
|
||||||
|
|
||||||
switch (ex_get_fixup_type(m->ip)) {
|
/* Allow instrumentation around external facilities usage. */
|
||||||
|
instrumentation_begin();
|
||||||
|
fixup_type = ex_get_fixup_type(m->ip);
|
||||||
|
copy_user = is_copy_from_user(regs);
|
||||||
|
instrumentation_end();
|
||||||
|
|
||||||
|
switch (fixup_type) {
|
||||||
case EX_TYPE_UACCESS:
|
case EX_TYPE_UACCESS:
|
||||||
case EX_TYPE_COPY:
|
case EX_TYPE_COPY:
|
||||||
if (!regs || !is_copy_from_user(regs))
|
if (!regs || !copy_user)
|
||||||
return IN_KERNEL;
|
return IN_KERNEL;
|
||||||
m->kflags |= MCE_IN_KERNEL_COPYIN;
|
m->kflags |= MCE_IN_KERNEL_COPYIN;
|
||||||
fallthrough;
|
fallthrough;
|
||||||
|
|
||||||
case EX_TYPE_FAULT_MCE_SAFE:
|
case EX_TYPE_FAULT_MCE_SAFE:
|
||||||
case EX_TYPE_DEFAULT_MCE_SAFE:
|
case EX_TYPE_DEFAULT_MCE_SAFE:
|
||||||
m->kflags |= MCE_IN_KERNEL_RECOV;
|
m->kflags |= MCE_IN_KERNEL_RECOV;
|
||||||
return IN_KERNEL_RECOV;
|
return IN_KERNEL_RECOV;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return IN_KERNEL;
|
return IN_KERNEL;
|
||||||
}
|
}
|
||||||
|
@ -315,8 +327,8 @@ static int mce_severity_amd_smca(struct mce *m, enum context err_ctx)
|
||||||
* See AMD Error Scope Hierarchy table in a newer BKDG. For example
|
* See AMD Error Scope Hierarchy table in a newer BKDG. For example
|
||||||
* 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
|
* 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
|
||||||
*/
|
*/
|
||||||
static int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant,
|
static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant,
|
||||||
char **msg, bool is_excp)
|
char **msg, bool is_excp)
|
||||||
{
|
{
|
||||||
enum context ctx = error_context(m, regs);
|
enum context ctx = error_context(m, regs);
|
||||||
|
|
||||||
|
@ -368,8 +380,8 @@ static int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant,
|
||||||
return MCE_KEEP_SEVERITY;
|
return MCE_KEEP_SEVERITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mce_severity_intel(struct mce *m, struct pt_regs *regs,
|
static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs,
|
||||||
int tolerant, char **msg, bool is_excp)
|
int tolerant, char **msg, bool is_excp)
|
||||||
{
|
{
|
||||||
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
|
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
|
||||||
enum context ctx = error_context(m, regs);
|
enum context ctx = error_context(m, regs);
|
||||||
|
@ -405,8 +417,8 @@ static int mce_severity_intel(struct mce *m, struct pt_regs *regs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mce_severity(struct mce *m, struct pt_regs *regs, int tolerant, char **msg,
|
int noinstr mce_severity(struct mce *m, struct pt_regs *regs, int tolerant, char **msg,
|
||||||
bool is_excp)
|
bool is_excp)
|
||||||
{
|
{
|
||||||
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
|
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
|
||||||
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
|
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
|
||||||
|
|
Loading…
Add table
Reference in a new issue