From patchwork Wed Jun 29 08:32:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12899601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75C29C433EF for ; Wed, 29 Jun 2022 08:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Y3JmLrvmyrWfrTrEg0CLLFRCagWersTeDS/wLlkliZo=; b=yeGhtmQjOp4iHc UUg9vJtiydoBCZ0BjdBVQZj9ro3fHLADSPKfsGaiTkSSUIQMl7OIPNyD807SUjlU22GIO7NplVcN3 cW02YYolFk7Vq7FGOh1wynITPs/TfPFWtSZRjAn3Xs+qFHf1NwxAgN0wou8Yto24Nc5mdYRWghNSc xnlEH6p8uH2cpFSLP+hdkfhukgaj11BsXih6fWaEAYsy+cHPgTbmdtlDBgZAdcYOlu2uUx+SrvMJa cvswaIlI3CHTF43/L+1Mcy7OZdes1bXd7+Z6wax/2/rVaR+1GnOkmMlbrSz34sH84hGk1ZGTvDivD K21nMQbd5ltC4Nksb3Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6T8D-00AQUm-3E; Wed, 29 Jun 2022 08:33:05 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6T89-00AQTe-JX for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2022 08:33:03 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2DFB4B8213D; Wed, 29 Jun 2022 08:33:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6D2EC34114; Wed, 29 Jun 2022 08:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656491578; bh=3gTwZNg23xWzVUEnegi9cUlNvUYqrlE52dpHLHBGJb4=; h=From:To:Cc:Subject:Date:From; b=R51qCJ3tjEOkQq6IAkuc8B8GdI90Zrxm40gt6ia6orarhPeVfAq9+bmK+j9DbOF9b p43h7/gQtQFtpseWfcptczss+xY7wYsoJbRAxGzcbhqcsZaO43a4bvAE1I9QLcgnqg Qt2tRtr+9N6CnL2Wz5FfVls4MO6NdHkSIFpyMOwcbG2+PiDE989Z5HhtMenk59YkWc VMtaCz3saYpM1MVZ0YxSpDPt5wcMbM8B8J+UwiqfO3THu8JwGSIFuMv6aZmwPeXwpP G74lgQ6ceCxWl9ZhkgYhDhE0L9f2MbP7oZ1CeifUCZL4EOWH8u9IxSoQGz0C7RlM0R gPY/XcCPH3Zvw== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: will@kernel.org, catalin.marinas@arm.com, Ard Biesheuvel , kernel test robot Subject: [PATCH] arm64: lds: use PROVIDE instead of conditional definitions Date: Wed, 29 Jun 2022 10:32:46 +0200 Message-Id: <20220629083246.3729177-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3957; h=from:subject; bh=3gTwZNg23xWzVUEnegi9cUlNvUYqrlE52dpHLHBGJb4=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBivA4t9RxqDKwhWhk6bvyXKIf2Duf/M/RxMbNzRiof L/FOuZqJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYrwOLQAKCRDDTyI5ktmPJFoLC/ 4+tKIBK+Udg8hX+mfwu4rpcb08H0bY/wYBde6ps0RXgFzQ6bY5KYO6D5+ZM5FlpClsftSN+F+Ghrc+ 07ud5CqAJVuhr78MO7liWfMAOUvm+R33D051V1Tie10L/6q+5zU5XskYcHCMMBss9fQzWu87A+WcHD EUHtYPLt+r8Zb6OlyuLdbznsySmj8qzxnf91vcrVLMiFruJYZS4260IeKYV9rtMdfOvoyOsv2R5wwL y+JvGXNnyjMGjl1Zv1sEkPjqF54OB6qOb/qFCouybqkpjoAtnnQvMSK9Dvz9DJTucxb2yiNi4DEmZl uAR6otTX8Gpq/SFVAkln9fpEyYJE0sc0aWg5CKrJY1AlkdVX5Rzed1PhuFuNYCv8sKjrfAe5PYgizf 6ORQkenpP0cgl1UhMF4fy0zjR/aDBUTmOsEnj/HIfBpXegb2RUP6B3D6cR+I4O8GGGeHblsuP1EARS V4ClYjONLbuY6o7x5O4DtFQ+035aoBYOHSz3jBJ9K0GJY= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220629_013301_987377_F97E2E29 X-CRM114-Status: GOOD ( 14.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, a build with CONFIG_EFI=n and CONFIG_KASAN=y will not complete successfully because of missing symbols. This is due to the fact that the __pi_ prefixed aliases for __memcpy/__memmove were put inside a #ifdef CONFIG_EFI block inadvertently, and are therefore missing from the build in question. These definitions should only be provided when needed, as they will otherwise clutter up the symbol table, kallsyms etc for no reason. Fortunately, instead of using CPP conditionals, we can achieve the same result by using the linker's PROVIDE() directive, which only defines a symbol if it is required to complete the link. So let's use that for all symbols alias definitions. Reported-by: kernel test robot Signed-off-by: Ard Biesheuvel --- This applies onto arm64/for-next/boot arch/arm64/kernel/image-vars.h | 63 ++++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h index 0c381a405bf0..afa69e04e75e 100644 --- a/arch/arm64/kernel/image-vars.h +++ b/arch/arm64/kernel/image-vars.h @@ -10,11 +10,8 @@ #error This file should only be included in vmlinux.lds.S #endif -#ifdef CONFIG_EFI - -__efistub_kernel_size = _edata - _text; -__efistub_primary_entry_offset = primary_entry - _text; - +PROVIDE(__efistub_kernel_size = _edata - _text); +PROVIDE(__efistub_primary_entry_offset = primary_entry - _text); /* * The EFI stub has its own symbol namespace prefixed by __efistub_, to @@ -25,35 +22,37 @@ __efistub_primary_entry_offset = primary_entry - _text; * linked at. The routines below are all implemented in assembler in a * position independent manner */ -__efistub_memcmp = __pi_memcmp; -__efistub_memchr = __pi_memchr; -__efistub_memcpy = __pi_memcpy; -__efistub_memmove = __pi_memmove; -__efistub_memset = __pi_memset; -__efistub_strlen = __pi_strlen; -__efistub_strnlen = __pi_strnlen; -__efistub_strcmp = __pi_strcmp; -__efistub_strncmp = __pi_strncmp; -__efistub_strrchr = __pi_strrchr; -__efistub_dcache_clean_poc = __pi_dcache_clean_poc; - -#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) -__efistub___memcpy = __pi_memcpy; -__efistub___memmove = __pi_memmove; -__efistub___memset = __pi_memset; - -__pi___memcpy = __pi_memcpy; -__pi___memmove = __pi_memmove; -__pi___memset = __pi_memset; -#endif +PROVIDE(__efistub_memcmp = __pi_memcmp); +PROVIDE(__efistub_memchr = __pi_memchr); +PROVIDE(__efistub_memcpy = __pi_memcpy); +PROVIDE(__efistub_memmove = __pi_memmove); +PROVIDE(__efistub_memset = __pi_memset); +PROVIDE(__efistub_strlen = __pi_strlen); +PROVIDE(__efistub_strnlen = __pi_strnlen); +PROVIDE(__efistub_strcmp = __pi_strcmp); +PROVIDE(__efistub_strncmp = __pi_strncmp); +PROVIDE(__efistub_strrchr = __pi_strrchr); +PROVIDE(__efistub_dcache_clean_poc = __pi_dcache_clean_poc); + +PROVIDE(__efistub__text = _text); +PROVIDE(__efistub__end = _end); +PROVIDE(__efistub__edata = _edata); +PROVIDE(__efistub_screen_info = screen_info); +PROVIDE(__efistub__ctype = _ctype); -__efistub__text = _text; -__efistub__end = _end; -__efistub__edata = _edata; -__efistub_screen_info = screen_info; -__efistub__ctype = _ctype; +/* + * The __ prefixed memcpy/memset/memmove symbols are provided by KASAN, which + * instruments the conventional ones. Therefore, any references from the EFI + * stub or other position independent, low level C code should be redirected to + * the non-instrumented versions as well. + */ +PROVIDE(__efistub___memcpy = __pi_memcpy); +PROVIDE(__efistub___memmove = __pi_memmove); +PROVIDE(__efistub___memset = __pi_memset); -#endif +PROVIDE(__pi___memcpy = __pi_memcpy); +PROVIDE(__pi___memmove = __pi_memmove); +PROVIDE(__pi___memset = __pi_memset); #ifdef CONFIG_KVM