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.0 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 2B322C433E0 for ; Tue, 16 Feb 2021 18:17:27 +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 E5C4864E08 for ; Tue, 16 Feb 2021 18:17:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5C4864E08 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=ttaOp6Sgsk0lIj3ZRrFbMHEWzQrrjlnrFqRwHK5aHHU=; b=bfVLC5p/VJrwM/gD/sOqlrTcZ4 WEB0C9JOxcJ8iKDPcZYHSuFQoWoK9U759RAWG7t4chPicEUtj+xgzFUJrcpHG12gS1qEzjTPk+8To zed/jWRNRDxW9UkiuMz+RbKcNQUgYZ36Ta1fwRxZDwgyd3nYEqrM4+ww68lBxxz/tEmJOxHCh4SfF q3dEKz47jvS7+qRG7f73rFwsU4K223Vve1fz9FG9jNhqlwTwXtI+X37yoyub03xTdLCGY6J/+iNBx 75INkzYqOywaU1tvtm9UrNruJBdVWuqSZ2gzsB5H3gZr+8v3JY5FXs5gruF3G93suTlWuoTIQP7e1 WQKauhPA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lC4sZ-0005Jm-2V; Tue, 16 Feb 2021 18:15:19 +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 1lC4sW-0005JN-Ga for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2021 18:15:17 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6927D614A7; Tue, 16 Feb 2021 18:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613499315; bh=DQ8R6IKR70d1i1o7WdbY1EWPa0BNdUuJPlFD24vKUfM=; h=From:To:Cc:Subject:Date:From; b=s27feAngam5WRSPMVUWOS7dPX2LWbfOrbRC+pKm/QSSc9d4H24QfKuFGXzUabECZW A+WOTmwiA+WwSeMqNjJsvqpBWjaMchEbjj4FXQBdMdjmWEWkI6al4pZXU7GJLxU15P Err93UYZ15l5PDMimI6gb9KBHgcOkkSVg8bE96GqzxI+kTbSjbFjF2knHn9PymI0TL i6FuDJDqsn8v72kgd/NJgTGDxTN/RciqkCsU2knPBFH4melTg6kmfHcoQwS+NndNOh SQfF7CmNO947W9cyf1YJ9tXpJYSwRUoELMd2g8Qf1IdtfqtY82uvV6o+vtve3AMgFr RujOLDSsZ/2hQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: mm: reduce maximum number of CPUs if DEBUG_KMAP_LOCAL is enabled Date: Tue, 16 Feb 2021 19:14:59 +0100 Message-Id: <20210216181459.46390-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-20210216_131516_650419_D7D2C24E X-CRM114-Status: GOOD ( 15.99 ) 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: Ard Biesheuvel , linus.walleij@linaro.org, linux@armlinux.org.uk, pbrobinson@gmail.com 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 debugging code for kmap_local() doubles the number of fixmap slots allocated for kmap_local(), in order to use half of them as guard regions. This causes the fixmap region to grow downwards and collide with the newly added virtual DT mapping, which is obviously not good. One manifestation of this is EFI boot on a kernel built with NR_CPUS=32, which may pass the FDT in highmem, resulting in block entries that the fixmap code misidentifies as table entries, and subsequently tries to dereference using a phys-to-virt translation that is only valid for lowmem. This results in a cryptic splat such as the one below. ftrace: allocating 45548 entries in 89 pages 8<--- cut here --- Unable to handle kernel paging request at virtual address fc6006f0 pgd = (ptrval) [fc6006f0] *pgd=80000040207003, *pmd=00000000 Internal error: Oops: a06 [#1] SMP ARM Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 5.11.0+ #382 Hardware name: Generic DT based system PC is at cpu_ca15_set_pte_ext+0x24/0x30 LR is at __set_fixmap+0xe4/0x118 pc : [] lr : [] psr: 400000d3 sp : c1601ed8 ip : 00400000 fp : 00800000 r10: 0000071f r9 : 00421000 r8 : 00c00000 r7 : 00c00000 r6 : 0000071f r5 : ffade000 r4 : 4040171f r3 : 00c00000 r2 : 4040171f r1 : c041ac78 r0 : fc6006f0 Flags: nZcv IRQs off FIQs off Mode SVC_32 ISA ARM Segment none Control: 30c5387d Table: 40203000 DAC: 00000001 Process swapper (pid: 0, stack limit = 0x(ptrval)) So let's limit the supported number of CPUs to 16 when CONFIG_DEBUG_KMAP_LOCAL is in effect. Reported-by: Peter Robinson Signed-off-by: Ard Biesheuvel --- arch/arm/Kconfig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 138248999df7..3d2c684eab77 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1310,9 +1310,15 @@ config KASAN_SHADOW_OFFSET config NR_CPUS int "Maximum number of CPUs (2-32)" - range 2 32 + range 2 16 if DEBUG_KMAP_LOCAL + range 2 32 if !DEBUG_KMAP_LOCAL depends on SMP default "4" + help + The maximum number of CPUs that the kernel can support. + Up to 32 CPUs can be supported, or up to 16 if kmap_local() + debugging is enabled, which uses half of the per-CPU fixmap + slots as guard regions. config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" -- 2.30.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel