From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9A57204F9B; Thu, 24 Jul 2025 05:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753336231; cv=none; b=UHwalQjO2+sa0TiM5/oLxEWfJYI3097/IOKliZFSYYnsQayHMtMMR69G5B/pjv7yihNR96zRRIqymVbx+qj6La3lUbJFPC7PlfLE7tjefYcwfcoWp/JcDFcCYO+6zKr1CEJ2bshuY71s4fRupj1zyKymNT82rDP8tgaZCFUxFOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753336231; c=relaxed/simple; bh=HjxWaeaCv8M/oL9GQSiYPTHDkhtk+DTRYh358m2uH3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=am33FBjMMm+Bv5wSp55t2msQmNZ20fVTDkcemhrvMJHxT2mbLd8r01AYw6r+WC3CwMA6MwvfS9u/3PjGfMwoNVr2EN1pOjK3/QlrAUq/uGsxwRhmeP3kHbtxwBuEQfc+fjWttOEvp6+EHmjVFYlAcQQNvIYiem7B0y9clfJefJg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s29zubue; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s29zubue" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C87FC4CEF6; Thu, 24 Jul 2025 05:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753336230; bh=HjxWaeaCv8M/oL9GQSiYPTHDkhtk+DTRYh358m2uH3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s29zubuefnI+LBjVqZ9vpCGlu5Y5WvluYyoGkQGyTns5h1ASI0ONXsaMz96AIkRXI cZ6ofUY5AV/ts56FD7h4Y1bDIuQLpyBShwLCqHUW8DfnoPw2vQJCqzlbBvLEe9bAOI kxQ0p30UKRiDezURaIGb+gVISD37zXrkYV5ryEw6lEsNnY69EOXcRhYpYb1D80YLxn I+zACitAelI7J9mGOrR/C6kNqZ5T5TmrV+gQX0mkg7goDAphZEna6azIrtOhh7fcjB Z+KIemqogOSqAlWLzBYa9uUGf/kIwnqbXHcE1N7vHH7V81ftidRhNtlb3B2IzsvdA6 8adJrtZ2w9B2Q== From: Kees Cook To: Arnd Bergmann Cc: Kees Cook , Will Deacon , Ard Biesheuvel , Catalin Marinas , Jonathan Cameron , Gavin Shan , "Russell King (Oracle)" , James Morse , Oza Pawandeep , Anshuman Khandual , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Mike Rapoport , Vitaly Kuznetsov , Henrique de Moraes Holschuh , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Rafael J. Wysocki" , Len Brown , Masami Hiramatsu , Michal Wilczynski , Juergen Gross , Andy Shevchenko , "Kirill A. Shutemov" , Roger Pau Monne , David Woodhouse , Usama Arif , "Guilherme G. Piccoli" , Thomas Huth , Brian Gerst , Marco Elver , Andrey Konovalov , Andrey Ryabinin , Hou Wenlong , Andrew Morton , Masahiro Yamada , "Peter Zijlstra (Intel)" , Luis Chamberlain , Sami Tolvanen , Christophe Leroy , Nathan Chancellor , Nicolas Schier , "Gustavo A. R. Silva" , Andy Lutomirski , Baoquan He , Alexander Graf , Changyuan Lyu , Paul Moore , James Morris , "Serge E. Hallyn" , Nick Desaulniers , Bill Wendling , Justin Stitt , Jan Beulich , Boqun Feng , Viresh Kumar , "Paul E. McKenney" , Bibo Mao , linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org, kexec@lists.infradead.org, linux-security-module@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v4 1/4] arm64: Handle KCOV __init vs inline mismatches Date: Wed, 23 Jul 2025 22:50:25 -0700 Message-Id: <20250724055029.3623499-1-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724054419.it.405-kees@kernel.org> References: <20250724054419.it.405-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2121; i=kees@kernel.org; h=from:subject; bh=HjxWaeaCv8M/oL9GQSiYPTHDkhtk+DTRYh358m2uH3A=; b=owGbwMvMwCVmps19z/KJym7G02pJDBmNJxevUIqUu+2x4F/fOofGOacvWqgmvnqeLJv0JeJDL usnHfXgjlIWBjEuBlkxRZYgO/c4F4+37eHucxVh5rAygQxh4OIUgIn41TAyrHh499h001Vid05L Nkw14RZx7siKejb92THeWXEx6x9PFmT4K1OTc6Ms/eTviZ93fAuV7N800326HO/5hfY1V14Gh4a 0MAEA X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit GCC appears to have kind of fragile inlining heuristics, in the sense that it can change whether or not it inlines something based on optimizations. It looks like the kcov instrumentation being added (or in this case, removed) from a function changes the optimization results, and some functions marked "inline" are _not_ inlined. In that case, we end up with __init code calling a function not marked __init, and we get the build warnings I'm trying to eliminate in the coming patch that adds __no_sanitize_coverage to __init functions: WARNING: modpost: vmlinux: section mismatch in reference: acpi_get_enable_method+0x1c (section: .text.unlikely) -> acpi_psci_present (section: .init.text) This problem is somewhat fragile (though using either __always_inline or __init will deterministically solve it), but we've tripped over this before with GCC and the solution has usually been to just use __always_inline and move on. For arm64 this requires forcing one ACPI function to be inlined with __always_inline. Signed-off-by: Kees Cook --- Cc: Will Deacon Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Jonathan Cameron Cc: Gavin Shan Cc: "Russell King (Oracle)" Cc: James Morse Cc: Oza Pawandeep Cc: Anshuman Khandual Cc: --- arch/arm64/include/asm/acpi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index a407f9cd549e..c07a58b96329 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -150,7 +150,7 @@ acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) {} #endif -static inline const char *acpi_get_enable_method(int cpu) +static __always_inline const char *acpi_get_enable_method(int cpu) { if (acpi_psci_present()) return "psci"; -- 2.34.1