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 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 5F394CA9ED0 for ; Mon, 12 Oct 2026 08:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Subject:References:In-Reply-To:Message-Id:Cc:To:From:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KaTDNeGIs4Eya8Iq0e/D24HTq8sf7hkN0/Y704r7Hpo=; b=bEHJ6et3OG45nWL2yXOYI5ZQgW luH6JVZwe9+18dk5AzjP5kijGSKCO2mJ2CKKOLwbPsPNmxPc3L9nsiGaHvq47i27oWT771gSGnDsS ewryUY3MTfYSVnOgWYU80Rh8vvB3mqJhrzbhQYD/lGzUrxFU6HgZoIlkyC+9pQuTv1Cwr77SLjmGo r5EXC7mmKyBXYnAGrMo3x+WME2zavgoM1F3Ct+jGRFrAXZ0Agk7qS5KmqH5lHsgXqpk/IaTP3mLbJ VzIqoSXyLBiKEULpcDpuRr9fQLicrZ6PKBssDKeih5iiC8eOve0Fq5sROqhgXxNM6Nr2MptYcw+58 0a5i9CTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xGBWt-00000009xDZ-0pEU; Mon, 12 Oct 2026 08:37:07 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xGBWs-00000009xDR-0sPK for linux-arm-kernel@lists.infradead.org; Mon, 12 Oct 2026 08:37:06 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A671F60DB7; Mon, 12 Oct 2026 08:37:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBECB1F0089C; Mon, 12 Oct 2026 08:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791794225; bh=KaTDNeGIs4Eya8Iq0e/D24HTq8sf7hkN0/Y704r7Hpo=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=XjfnxLQL1JzyLJJ+aJCNe8mgOI3NMLP/wrtu8mpwo04hq7G5J7iRzlA8yBa9BUorz D/7zYyGyGZnc7DVknS5lRiNHvl6vm3TgjwinQ2E6LVZRc9AqcBVy/DBF7Wt800Sj9O 0DcHfEqr6q9nJwZXo1tAAFnROyBeQBZxzMli60Fa22KpK6xCNsMLELkgf2cmZAwMXb PBRk2hAyxVxBtO3BXfLf0F96S3uQTKH+OY+LirVFnTukKPnLuc0GQfy6VVxmzmmyPu vmVDRyTYQ4qgpY2gqjN1EjlcJ8RggjhaiJO424FolrCRSMQfSdU9tTUUvIysakXq6g qDmRfKoRZtHIg== Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfauth.ams.internal (Postfix) with ESMTP id 4BAD7198003A; Mon, 12 Oct 2026 04:37:03 -0400 (EDT) Received: from ams-imap-11 ([10.64.2.31]) by ams-compute-02.internal (MEProxy); Mon, 12 Oct 2026 04:37:03 -0400 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTEThxgyF43rNUF63WV4bfNwDlYm6E/t3DdUkJCiSwT9/QwWB1XnBUrlCTGx97rh1I npz2tTJ4a0lrG8k4Oz0TTr50lcfntge9RrFesknLGLVm3Z5sD1122TDLKaJ8XrcAuCG9Ce MWBqR9l+GV5c7yrLZU/XzlqBLHbapJ/xDrzzH277B4CK9igCgegAb9COr44/dmo5BVOBXr 6x5a17wXNSBgkNc8kJZqiZvsCet6DptiUbWF9fKonF3aiqe3Zq4x6vJ5nRPno+DIeJ2s1z Vql+lpbk9tIcrTdMTGRCUtMiy45MOhetpXQbCLz8Qm1tJpgBjf8rt4eFeDfpQRWv4EOndC /g/ij8LClT5b5XLIiDbKG0ZeDFsqe8Z+cC5svW/8oxrWeym5x0ZF/uZCqI62GLdSMHcHDy lfNlDmYSW64uWCu0CMqEOY7G0b5yjA+8upIoAj3+EY7qL2gU4OTRC8lFuBUUfq/OhDM5t/ HlVKz0zogM401WHfUzd7Yn2GZ+vIaNlrU+4GqCoQ43JxdhdW/6ixX3FaTLXpUrCBTLvtAB 0bVObwDEhG6triZyke+hGmVMbW7GtjbFP4y9Xm+ZPEjvuO+GFaGerdl6t1k9qpAeXR+bEY AbATUY479uH6ATOaR/S3r7KRrHGY6zLZwKxrYADWgrmno9b2C1rhvdXe9TYQ X-ME-Proxy: Feedback-ID: ice86485a:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id 6AD4BF80086; Mon, 12 Oct 2026 04:37:01 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Mon, 12 Oct 2026 10:36:41 +0200 From: "Ard Biesheuvel" To: "Ard Biesheuvel" , linux-arm-kernel@lists.infradead.org Cc: linux-efi@vger.kernel.org, "Will Deacon" , "Catalin Marinas" , "Mark Rutland" Message-Id: In-Reply-To: <20261009143438.330265-2-ardb+git@google.com> References: <20261009143438.330265-2-ardb+git@google.com> Subject: Re: [PATCH] arm64/mm: Route faults taken by EFI runtime firmware to no_context Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 On Fri, 9 Oct 2026, at 16:34, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > When EFI runtime services are invoked from a preemptible kthread, the > kthread runs with efi_mm installed via kthread_use_mm() and preemption > enabled, so neither faulthandler_disabled() nor !mm applies in > do_page_fault(). A permission fault taken by the firmware on one of its > own (TTBR0) mappings then hits the 'access to user memory outside > uaccess routines' check and oopses, without efi_runtime_fixup_exception() > ever being consulted. > > efi_mm has no VMAs, so there is nothing for the mm to resolve. Send such > faults to no_context directly, so that __do_kernel_fault() can recover > from them as it does when the call is made with preemption disabled. > > Fixes: a5baf582f4c0 ("arm64/efi: Call EFI runtime services without > disabling preemption") > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/mm/fault.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > index 0b52557652be..db308fe01c4f 100644 > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -621,6 +622,17 @@ static int __kprobes do_page_fault(unsigned long > far, unsigned long esr, > if (faulthandler_disabled() || !mm) > goto no_context; > > + /* > + * Faults taken by EFI runtime services firmware are never resolved by > + * the mm (efi_mm has no VMAs), and must reach __do_kernel_fault() so > + * that efi_runtime_fixup_exception() can recover from them. When EFI > + * runtime services are invoked from a preemptible kthread, neither of > + * the conditions above applies, so check for this explicitly. > + */ > + if (IS_ENABLED(CONFIG_EFI) && !user_mode(regs) && > + is_ttbr0_addr(regs->pc) && current_in_efi()) > + goto no_context; > + Looking at this again, I wonder if we should just add a comparison with &efi_mm to the preceding if() condition.