[PATCH 0/3] x86/mce: Fix more noinstr fun

Borislav Petkov posted 3 patches 4 years, 4 months ago
arch/x86/include/asm/cpumask.h     | 10 ++++++
arch/x86/include/asm/ptrace.h      |  2 +-
arch/x86/kernel/cpu/mce/core.c     | 58 ++++++++++--------------------
arch/x86/kernel/cpu/mce/internal.h | 23 ++++++++++--
arch/x86/kernel/cpu/mce/severity.c |  2 +-
include/linux/cpumask.h            |  4 +--
6 files changed, 54 insertions(+), 45 deletions(-)
[PATCH 0/3] x86/mce: Fix more noinstr fun
Posted by Borislav Petkov 4 years, 4 months ago
From: Borislav Petkov <bp@suse.de>

Hi all,

here's a second small set of fixes for objtool noinstr validation issues
in the MCE code.

It goes ontop of tip:locking/core where there are some more commits
changing generic helpers to be always inlined.

As always, comments and suggestions are appreciated.

Thx.

Borislav Petkov (3):
  cpumask: Add a x86-specific cpumask_clear_cpu() helper
  x86/ptrace: Always inline v8086_mode() for instrumentation
  x86/mce: Use arch atomic and bit helpers

 arch/x86/include/asm/cpumask.h     | 10 ++++++
 arch/x86/include/asm/ptrace.h      |  2 +-
 arch/x86/kernel/cpu/mce/core.c     | 58 ++++++++++--------------------
 arch/x86/kernel/cpu/mce/internal.h | 23 ++++++++++--
 arch/x86/kernel/cpu/mce/severity.c |  2 +-
 include/linux/cpumask.h            |  4 +--
 6 files changed, 54 insertions(+), 45 deletions(-)

-- 
2.29.2

Re: [PATCH 0/3] x86/mce: Fix more noinstr fun
Posted by Marco Elver 4 years, 4 months ago
On Fri, 4 Feb 2022 at 09:30, Borislav Petkov <bp@alien8.de> wrote:
>
> From: Borislav Petkov <bp@suse.de>
>
> Hi all,
>
> here's a second small set of fixes for objtool noinstr validation issues
> in the MCE code.
>
> It goes ontop of tip:locking/core where there are some more commits
> changing generic helpers to be always inlined.
>
> As always, comments and suggestions are appreciated.
>
> Thx.
>
> Borislav Petkov (3):
>   cpumask: Add a x86-specific cpumask_clear_cpu() helper
>   x86/ptrace: Always inline v8086_mode() for instrumentation
>   x86/mce: Use arch atomic and bit helpers

I guess to solve noinstr "calling" something else the only solution is
to make the other function noinstr as well, or __always_inline.

Have you considered making some of these other functions 'noinstr' as
well? I guess __always_inline works, esp. if there's just 1 caller.
And by the looks of it you're getting a net .text reduction, so

Acked-by: Marco Elver <elver@google.com>
Re: [PATCH 0/3] x86/mce: Fix more noinstr fun
Posted by Borislav Petkov 4 years, 4 months ago
On Fri, Feb 04, 2022 at 12:24:00PM +0100, Marco Elver wrote:
> I guess to solve noinstr "calling" something else the only solution is
> to make the other function noinstr as well, or __always_inline.
> 
> Have you considered making some of these other functions 'noinstr' as
> well? I guess __always_inline works, esp. if there's just 1 caller.
> And by the looks of it you're getting a net .text reduction, so

Yeah, I started doing that and the savings were the persuasive
argument.

Even more so if the function has one caller only and gets inlined,
normally. I guess it doesn't get inlined when there's KASAN
instrumentation or so but I haven't verified it fully why.

Because even for oneliners like v8086_mode() which should get inlined
trivially, the compiler ends up doing this constprop thing - I guess
some constants folding optimization thing... it probably doesn't even
matter so much whether oneliners get inlined in KASAN-enabled builds so
I guess we might just as well force-inline them for the other configs.

> Acked-by: Marco Elver <elver@google.com>

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette