From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E480C433E6 for ; Fri, 5 Feb 2021 08:53:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E951D64E06 for ; Fri, 5 Feb 2021 08:53:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E951D64E06 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=kBBSo4w/+ya8bSnweFTGUCVVTm8t29LluFn+Hlk5u/w=; b=xz+ncB3nKb5hFhYmZ09UjOsg8e ctf50+Bw7CBw8ZLyaUk8pdGzUw2yCKhoOC9WI31YYh6hAhu1CFZmxyRTLGJE3Th6qimRKSdXiI45e KRqOUbPqBOLIIFbYR0EV+IM+oA2UxeY9/oOnErDzAauLOV3nCFO1Jfv812EoluuMzgqzPFB/wZ0ps mfb8apbqtfWr0GF+AQbNJvsxqNeuiwqdUTz9ZoOL2cOziZpXBq3SwhyDa4jVBi25tQMYASrSVVb4f +eQZIWlNi091/ZNx3mK+AWY7CpIcNIqaBHSQW0uY3TRJxIWtvHB/pRTO5Z8GgiqSu35cXRQJ8+9cT RggzvLNA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7wr2-0006BB-LO; Fri, 05 Feb 2021 08:52:41 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7wqw-00068S-GG for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 08:52:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E6C6C64F3C; Fri, 5 Feb 2021 08:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612515153; bh=ISMUUkqbY2bUm1x4RRC6YulVWvz1qa1skmVIJhNKDLc=; h=From:To:Cc:Subject:Date:From; b=QJtTsoU0oBdwvl/KNR1zSYts9WWfBYfWgOAaNX1PwiIdqOg+wt5lJw+8KsGUW4tDQ A/ArLoOe09O6Fjqea9M4G6ryY4fgqkyLnAiQGb1vJpBOvmxu1+xx7w0RzsktX1vy9O icBvf5AwqPburXHIhgApvE8j624DzNzplbR0HvDiw7+v/JgIiNic2Lwzko9+CcJKLb 0Ghu7RZ54hhJKuTZj08GolLnZLJf7jGIclOahctyuwFVbNfuVzs0p53H8YcNKPiW8v JA2powH7fK3Ra0U7OcBBF72k0W5toH/eAaXnwWEK4L/ltayGVU3DYsTvMdtBGEPTEl ZBGgW4rUvQsCA== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: decompressor: fix BSS size calculation for LLVM ld.lld Date: Fri, 5 Feb 2021 09:52:20 +0100 Message-Id: <20210205085220.31232-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_035234_645517_C58F7080 X-CRM114-Status: GOOD ( 12.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nathan Chancellor , Guillaume Tucker , Nick Desaulniers , linux@armlinux.org.uk, Ard Biesheuvel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The LLVM ld.lld linker uses a different symbol type for __bss_start, resulting in the calculation of KBSS_SZ to be thrown off. Up until now, this has gone unnoticed as it only affects the appended DTB case, but pending changes for ARM in the way the decompressed kernel is cleaned from the caches has uncovered this problem. On a ld.lld build: $ nm vmlinux |grep bss_ c1c22034 D __bss_start c1c86e98 B __bss_stop resulting in 433: c1c86e98 0 NOTYPE GLOBAL DEFAULT ABS _kernel_bss_size which is obviously incorrect, and may cause the cache clean to access unmapped memory, or cause the size calculation to wrap, resulting in no cache clean to be performed at all. Fix this by updating the sed regex to take D type symbols into account. Cc: Nick Desaulniers Cc: Nathan Chancellor Cc: Guillaume Tucker Link: https://lore.kernel.org/linux-arm-kernel/6c65bcef-d4e7-25fa-43cf-2c435bb61bb9@collabora.com/ Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index fb521efcc6c2..54307db7854d 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -115,8 +115,8 @@ asflags-y := -DZIMAGE # Supply kernel BSS size to the decompressor via a linker symbol. KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ - sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \ - -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) ) + sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \ + -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) ) LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) # Supply ZRELADDR to the decompressor via a linker symbol. ifneq ($(CONFIG_AUTO_ZRELADDR),y) -- 2.30.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel