Skip to content

Commit

Permalink
x86/mce: Annotate mce_rd/wrmsrl() with noinstr
Browse files Browse the repository at this point in the history
[ Upstream commit e100777 ]

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 <bp@suse.de>
Link: https://lkml.kernel.org/r/20200915194020.28807-1-bp@alien8.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Borislav Petkov authored and gregkh committed Oct 29, 2020
1 parent e967ca0 commit 88b7969
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions arch/x86/kernel/cpu/mce/core.c
Expand Up @@ -374,16 +374,25 @@ static int msr_to_offset(u32 msr)
}

/* MSR access wrappers used for error injection */
static u64 mce_rdmsrl(u32 msr)
static noinstr u64 mce_rdmsrl(u32 msr)
{
u64 v;

if (__this_cpu_read(injectm.finished)) {
int offset = msr_to_offset(msr);
int offset;
u64 ret;

instrumentation_begin();

offset = msr_to_offset(msr);
if (offset < 0)
return 0;
return *(u64 *)((char *)this_cpu_ptr(&injectm) + offset);
ret = 0;
else
ret = *(u64 *)((char *)this_cpu_ptr(&injectm) + offset);

instrumentation_end();

return ret;
}

if (rdmsrl_safe(msr, &v)) {
Expand All @@ -399,13 +408,19 @@ static u64 mce_rdmsrl(u32 msr)
return v;
}

static void mce_wrmsrl(u32 msr, u64 v)
static noinstr void mce_wrmsrl(u32 msr, u64 v)
{
if (__this_cpu_read(injectm.finished)) {
int offset = msr_to_offset(msr);
int offset;

instrumentation_begin();

offset = msr_to_offset(msr);
if (offset >= 0)
*(u64 *)((char *)this_cpu_ptr(&injectm) + offset) = v;

instrumentation_end();

return;
}
wrmsrl(msr, v);
Expand Down

0 comments on commit 88b7969

Please sign in to comment.