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

Kees Cook kees at kernel.org
Tue May 27 03:30:52 UTC 2025


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 at kernel.org>
> > ---
> > Cc: Thomas Gleixner <tglx at linutronix.de>
> > Cc: Ingo Molnar <mingo at redhat.com>
> > Cc: Borislav Petkov <bp at alien8.de>
> > Cc: Dave Hansen <dave.hansen at linux.intel.com>
> > Cc: <x86 at kernel.org>
> > Cc: "H. Peter Anvin" <hpa at zytor.com>
> > Cc: Paolo Bonzini <pbonzini at redhat.com>
> > Cc: Vitaly Kuznetsov <vkuznets at redhat.com>
> > Cc: Henrique de Moraes Holschuh <hmh at hmh.eng.br>
> > Cc: Hans de Goede <hdegoede at redhat.com>
> > Cc: "Ilpo Järvinen" <ilpo.jarvinen at linux.intel.com>
> > Cc: "Rafael J. Wysocki" <rafael at kernel.org>
> > Cc: Len Brown <lenb at kernel.org>
> > Cc: Masami Hiramatsu <mhiramat at kernel.org>
> > Cc: Ard Biesheuvel <ardb at kernel.org>
> > Cc: Mike Rapoport <rppt at kernel.org>
> > Cc: Michal Wilczynski <michal.wilczynski at intel.com>
> > Cc: Juergen Gross <jgross at suse.com>
> > Cc: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
> > Cc: "Kirill A. Shutemov" <kirill.shutemov at linux.intel.com>
> > Cc: Roger Pau Monne <roger.pau at citrix.com>
> > Cc: David Woodhouse <dwmw at amazon.co.uk>
> > Cc: Usama Arif <usama.arif at bytedance.com>
> > Cc: "Guilherme G. Piccoli" <gpiccoli at igalia.com>
> > Cc: Thomas Huth <thuth at redhat.com>
> > Cc: Brian Gerst <brgerst at gmail.com>
> > Cc: <kvm at vger.kernel.org>
> > Cc: <ibm-acpi-devel at lists.sourceforge.net>
> > Cc: <platform-driver-x86 at vger.kernel.org>
> > Cc: <linux-acpi at vger.kernel.org>
> > Cc: <linux-trace-kernel at vger.kernel.org>
> > Cc: <linux-efi at vger.kernel.org>
> > Cc: <linux-mm at 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



More information about the Linux-security-module-archive mailing list