Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp41305lqo; Wed, 15 May 2024 07:14:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9o3fb7jnqmutXGYHwzeO/bssfG4BDcEm8DMCCTPRqohbjPB6w093dtdCxhV7b0kGj82y0///NHjhab1t62SIz7qTcIE1uSl3Zgptjmg== X-Google-Smtp-Source: AGHT+IHWv33NwMbgUAOr8p6ILSAsHEtJ4hd6xam6tpTshbESEmGa2FE3Iq+/OAfRhyzM6zAkne7o X-Received: by 2002:a05:6a20:3d88:b0:1af:6fe9:5039 with SMTP id adf61e73a8af0-1afde09ebc2mr22403610637.1.1715782448110; Wed, 15 May 2024 07:14:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715782448; cv=pass; d=google.com; s=arc-20160816; b=MNPcmVJJYiduMR9rhfmBxDFMTnxGxcBfYVBsc/Fg+SXNKehg2p4w4/ZRur+49lTnm1 BP0ZaV2SOlGY4LuSnISbY0wy2sLGZC51D2pV1LNxApywck4JaEuhcTR7kA2I5mCXXb7A Njd8XSF0LZIF05VKQl80zuLVoV0yoXNt93XSSBcHtUV4kY/Bg9ze7M3gmlpiJYO/wK7i +Pmw4VTA1zGeCtOzeWuqp96h7WvEFjzb5Pmg4zogL2sbf/4mjY10emZLbn8dxqKz1vif 2Ypcq5N9eGEzIre4sSEIJy56oulcsgcpDI6BCniuahndXPyKixSZgEV98UhMD7zi2scI ep9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=nEPD0l7sNInB7T/CPOK8DqNgSDuIqVoIHeIDNwxGgR4=; fh=6lsVLb8OeSH1F/0B4Jf13Vc827VSz2wlRiAszOULMhM=; b=e3aGwo7uaOg8x/aitj4uZJ/1gdXIvlSXfgVaSwZPeJFCT3tGmW+wQpDjzxhKnKxEN0 hFay4r5fGiztBKxahr4B8Ij5pCRE8+/lKRyiiA7mwfrSNu09NZ/3Qnqh7d4b7ljEpiJH uu0BY4aC1f36vUb1/EJPl52odfsBKH3hOzfa02+qy1GCaoDP0Xv/JyX9r7v53qpDfz+7 8kFbL0YLZAVpjoN1qYsw3uuGBEd64xtefclsYlBeyY8R4P4O4iwsVU2gNty65uP2TQCd XfXLydSEuIGiCAtNlw88ltrm61C4rZ2QUUM0mcyPWfCXywtK+BvCeFWY89MnD1GXUUAi 9CKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-179968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179968-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-634103f550csi13918485a12.389.2024.05.15.07.14.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 07:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-179968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179968-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 320B9B253CE for ; Wed, 15 May 2024 14:02:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B885513F423; Wed, 15 May 2024 14:02:28 +0000 (UTC) Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8A0213F006 for ; Wed, 15 May 2024 14:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781748; cv=none; b=dLCpKExDH5eHJbs8sHqxWz2+82Hrayc6wUkwtHoy5yuxYQaolf8BVQSOz7zatCatsd8N/7KifbI3Pa/WlJpfMRWWofm1A1RmEs5VS4ch1fPyVNWMyFeU+ktjNB6sNqCdzKmCoQ8vQ3IYhVv5ptkBGyQJnsEFlNboFue6R3gT2EQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781748; c=relaxed/simple; bh=PHeG/627dOPWa8LHTtWxDV007SWbZTNzDw4Wof0MrS0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B7yOCWTqbbvPtw58/+8yl9zS1t6w59da1UH3CPtG4KpB3Yo/aV8sACnMxapL1s+5GO4CqFdhhEVoCr/gsmoPDxd0nAM7iF/rxBsP4x+lYgeAi0ENdzjoEzcWxEoSipNvfqXVuQhE37nVuEg/A+TY18QkLSeJWBB6nUjqUjBah6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:b558:3285:d1a8:9c24]) by andre.telenet-ops.be with bizsmtp id PS2G2C0091HiNV501S2Ge7; Wed, 15 May 2024 16:02:20 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1s7FC8-007Obr-CA; Wed, 15 May 2024 16:02:16 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1s7FCy-004hZL-8O; Wed, 15 May 2024 16:02:16 +0200 From: Geert Uytterhoeven To: Russell King , Linus Walleij , Catalin Marinas , Kees Cook , Russell King , Florian Fainelli , Ard Biesheuvel , Arnd Bergmann , Stefan Wahren Cc: linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] ARM: Fix userspace enter on LPAE with CC_OPTIMIZE_FOR_SIZE=y Date: Wed, 15 May 2024 16:02:14 +0200 Message-Id: <200d273a83906a68a1c4a9298c415980737be811.1715781469.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Booting an LPAE-enabled kernel built with CONFIG_CC_OPTIMIZE_FOR_SIZE=y fails when starting userspace: Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 CPU: 1 PID: 1 Comm: init Tainted: G W N 6.9.0-rc1-koelsch-00004-g7af5b901e847 #1930 Hardware name: Generic R-Car Gen2 (Flattened Device Tree) Call trace: unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x78/0xa8 dump_stack_lvl from panic+0x118/0x398 panic from do_exit+0x1ec/0x938 do_exit from sys_exit_group+0x0/0x10 ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 ]--- Add the missing memory clobber to cpu_set_ttbcr(), as suggested by Russell King. Force inlining of uaccess_save_and_enable(), as suggested by Ard Biesheuvel. The latter fixes booting on Koelsch. Fixes: 7af5b901e84743c6 ("ARM: 9358/2: Implement PAN for LPAE by TTBR0 page table walks disablement") Closes: https://lore.kernel.org/r/CAMuHMdWTAJcZ9BReWNhpmsgkOzQxLNb5OhNYxzxv6D5TSh2fwQ@mail.gmail.com/ Signed-off-by: Geert Uytterhoeven --- Feel free to fold into the original commit. Apparently the "From: Catalin Marinas " in https://lore.kernel.org/r/20240312-arm32-lpae-pan-v3-4-532647afcd38@linaro.org is not reflected in commit 7af5b901e84743c6? --- arch/arm/include/asm/proc-fns.h | 2 +- arch/arm/include/asm/uaccess.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h index 9b3105a2a5e0691e..b4986a23d8528a50 100644 --- a/arch/arm/include/asm/proc-fns.h +++ b/arch/arm/include/asm/proc-fns.h @@ -187,7 +187,7 @@ static inline unsigned int cpu_get_ttbcr(void) static inline void cpu_set_ttbcr(unsigned int ttbcr) { - asm("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr)); + asm volatile("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr) : "memory"); } #else /*!CONFIG_MMU */ diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 25d21d7d6e3efee0..6c9c16d767cfd5df 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -47,7 +47,7 @@ static __always_inline void uaccess_restore(unsigned int flags) #elif defined(CONFIG_CPU_TTBR0_PAN) -static inline unsigned int uaccess_save_and_enable(void) +static __always_inline unsigned int uaccess_save_and_enable(void) { unsigned int old_ttbcr = cpu_get_ttbcr(); -- 2.34.1