Skip to content

Commit e100777

Browse files
committed
x86/mce: Annotate mce_rd/wrmsrl() with noinstr
They do get called from the #MC handler which is already marked "noinstr". Commit e2def7d ("x86/mce: Make mce_rdmsrl() panic on an inaccessible MSR") already got rid of the instrumentation in the MSR accessors, fix the annotation now too, in order to get rid of: vmlinux.o: warning: objtool: do_machine_check()+0x4a: call to mce_rdmsrl() leaves .noinstr.text section Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent dc0592b commit e100777

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

arch/x86/kernel/cpu/mce/core.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,25 @@ __visible bool ex_handler_rdmsr_fault(const struct exception_table_entry *fixup,
392392
}
393393

394394
/* MSR access wrappers used for error injection */
395-
static u64 mce_rdmsrl(u32 msr)
395+
static noinstr u64 mce_rdmsrl(u32 msr)
396396
{
397397
DECLARE_ARGS(val, low, high);
398398

399399
if (__this_cpu_read(injectm.finished)) {
400-
int offset = msr_to_offset(msr);
400+
int offset;
401+
u64 ret;
401402

403+
instrumentation_begin();
404+
405+
offset = msr_to_offset(msr);
402406
if (offset < 0)
403-
return 0;
404-
return *(u64 *)((char *)this_cpu_ptr(&injectm) + offset);
407+
ret = 0;
408+
else
409+
ret = *(u64 *)((char *)this_cpu_ptr(&injectm) + offset);
410+
411+
instrumentation_end();
412+
413+
return ret;
405414
}
406415

407416
/*
@@ -437,15 +446,21 @@ __visible bool ex_handler_wrmsr_fault(const struct exception_table_entry *fixup,
437446
return true;
438447
}
439448

440-
static void mce_wrmsrl(u32 msr, u64 v)
449+
static noinstr void mce_wrmsrl(u32 msr, u64 v)
441450
{
442451
u32 low, high;
443452

444453
if (__this_cpu_read(injectm.finished)) {
445-
int offset = msr_to_offset(msr);
454+
int offset;
446455

456+
instrumentation_begin();
457+
458+
offset = msr_to_offset(msr);
447459
if (offset >= 0)
448460
*(u64 *)((char *)this_cpu_ptr(&injectm) + offset) = v;
461+
462+
instrumentation_end();
463+
449464
return;
450465
}
451466

0 commit comments

Comments
 (0)