Re: [PATCH v2 04/14] x86: Handle KCOV __init vs inline mismatches

Kees Cook
2025-05-27T03:30:56Z

On Mon, May 26, 2025 at 12:53:13AM +0300, Ilpo Järvinen wrote:
> On Thu, 22 May 2025, Kees Cook wrote:
>
> > When KCOV is enabled all functions get instrumented, unless the
> > __no_sanitize_coverage attribute is used. To prepare for
> > __no_sanitize_coverage being applied to __init functions, we have to
> > handle differences in how GCC's inline optimizations get resolved. For
> > x86 this means forcing several functions to be inline with
> > __always_inline.
> >
> > Signed-off-by: Kees Cook <kees@kernel.org>
> > ---
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > Cc: <x86@kernel.org>
> > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> > Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Cc: Ard Biesheuvel <ardb@kernel.org>
> > Cc: Mike Rapoport <rppt@kernel.org>
> > Cc: Michal Wilczynski <michal.wilczynski@intel.com>
> > Cc: Juergen Gross <jgross@suse.com>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> > Cc: Roger Pau Monne <roger.pau@citrix.com>
> > Cc: David Woodhouse <dwmw@amazon.co.uk>
> > Cc: Usama Arif <usama.arif@bytedance.com>
> > Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
> > Cc: Thomas Huth <thuth@redhat.com>
> > Cc: Brian Gerst <brgerst@gmail.com>
> > Cc: <kvm@vger.kernel.org>
> > Cc: <ibm-acpi-devel@lists.sourceforge.net>
> > Cc: <platform-driver-x86@vger.kernel.org>
> > Cc: <linux-acpi@vger.kernel.org>
> > Cc: <linux-trace-kernel@vger.kernel.org>
> > Cc: <linux-efi@vger.kernel.org>
> > Cc: <linux-mm@kvack.org>
> > ---
>
> > diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> > index e7350c9fa3aa..0518d5b1f4ec 100644
> > --- a/drivers/platform/x86/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/thinkpad_acpi.c
> > @@ -559,12 +559,12 @@ static unsigned long __init tpacpi_check_quirks(
> > return 0;
> > }
> >
> > -static inline bool __pure __init tpacpi_is_lenovo(void)
> > +static __always_inline bool __pure tpacpi_is_lenovo(void)
> > {
> > return thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO;
> > }
> >
> > -static inline bool __pure __init tpacpi_is_ibm(void)
> > +static __always_inline bool __pure tpacpi_is_ibm(void)
> > {
> > return thinkpad_id.vendor == PCI_VENDOR_ID_IBM;
> > }
>
> Hi Kees,
>
> What's your plan on upstreaming route/timeline for this? I'd prefer to
> retain full control over this file as we were planning on some
> reorganization of files into lenovo/ subdir.

I'm not in a big rush. I'm hoping to have this all in place for v6.17,
but the Clang feature won't be in a released compiler version until
September. :) I can send this bit separately for your tree.

Thanks for taking a look!

--
Kees Cook