Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B486606A329 for ; Mon, 30 Nov 2026 15:57:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=zRtgqE5E; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=fN7GlsHq 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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=9XANQ93Tq7lLv/LjSETip9oyO6MBWnavpjbl+bdPF4c=; b=zRtgqE5E9Jx1ao XAmhBdcXBL4DjQoMHMPvyMiYXZ+iUfOaueUX1MVglOmSNAb0p8nsfyFwZ1DjOxwMDi4YVEh5vFpk0 geWfIYLHzWnODS3cVqUjtRiuhVgY/VXAwANBBqCYU8cYEaSV1Yp065HA98PURwYCLefMBBPMixpEy ZceuT37vVfZttbOO4VjS+TRBFYqD2rRZuSefFy6QveW77jWwF8H/CiQ5KcG5Mvgfj7BeZPeedEB7B CJD6Q2XtHxFWDQtD80A5cbecaVQibZzLA5Br0ChWHpIXzNsVo456lOqxJAhmFimdRzUSxwBvbznvV 2WbSqKQB5Yb2s8ahyK6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY3kr-0000000576s-13yL; Mon, 30 Nov 2026 15:57:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY3jt-000000056Wy-3w8Q for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 15:56:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9F8C31650; Mon, 30 Nov 2026 07:56:22 -0800 (PST) Received: from login2.euhpc2.arm.com (login2.euhpc2.arm.com [10.58.100.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7685B3F86F; Mon, 30 Nov 2026 07:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796054185; bh=Zq0FtJTmQdw2QD+8c97j1U6sG0t/gelNmIVgcyKpaSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fN7GlsHqhIBcZ1DycuMkEjBp0lfhZ3ae97/xMX8ytoyT2puBnDPdfVMe+o8q3lXVg aHzwu3VFGczTnMbgla8V4GYXqd/2jzhwWOf5WozGO7OsYrGglppr9+u1UdaZUj+IwX XEPo9B9ncLCKQTkargdn2ThvxfOLDcAdfAUw64uQ= From: Vladimir Murzin To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, lpieralisi@kernel.org, ruanjinjie@huawei.com, liaochang1@huawei.com, ashok.raj@oss.qualcomm.com, maz@kernel.org, kas@kernel.org Subject: [PATCH v3 22/44] arm64/efi: Implement override for IRQ flags checks Date: Mon, 30 Nov 2026 15:54:44 +0000 Message-Id: <20261130155506.118408-23-vladimir.murzin@arm.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20261130155506.118408-1-vladimir.murzin@arm.com> References: <20261130155506.118408-1-vladimir.murzin@arm.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_075626_085392_7403A0E1 X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Take advantage of the recent changes to the way arm64 represents IRQ flags and implement an architecture-specific override for the EFI IRQ flags check. IRQ flags now carry both DAIF and PMR state. EFI is not expected to modify either of them, so check both when verifying that IRQ state is preserved across EFI runtime calls. Signed-off-by: Vladimir Murzin Reviewed-by: Jinjie Ruan Tested-by: Jinjie Ruan --- arch/arm64/include/asm/efi.h | 40 ++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index e8a9783235cb..98a6af56478f 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -48,18 +49,45 @@ void arch_efi_call_virt_teardown(void); (efi_rt_stack_top != NULL && \ on_task_stack(current, READ_ONCE(efi_rt_stack_top[-1]), 1)) -#define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) - /* * Even when Linux uses IRQ priorities for IRQ disabling, EFI does not. * And EFI shouldn't really play around with priority masking as it is not aware * which priorities the OS has assigned to its interrupts. */ #define arch_efi_save_flags(state_flags) \ - ((void)((state_flags) = read_sysreg(daif))) - -#define arch_efi_restore_flags(state_flags) write_sysreg(state_flags, daif) - + ((void)((state_flags) = arch_local_save_flags())) + +#define arch_efi_restore_flags(state_flags) \ +do { \ + arm64_exc_hwstate_t __st = {.flags=state_flags}; \ + \ + arm64_update_exc_hwstate(__st); \ +} while(0) + +#define arch_efi_check_flags(state_flags, caller) \ +do { \ + arm64_exc_hwstate_t __actual = {.flags = arch_local_save_flags() }; \ + arm64_exc_hwstate_t __expected = {.flags=state_flags}; \ + \ + if (__expected.flags == __actual.flags) \ + break; \ + \ + arch_efi_restore_flags(state_flags); \ + \ + WARN_ON_ONCE(1); \ + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_NOW_UNRELIABLE); \ + \ + if (system_uses_irq_prio_masking()) { \ + pr_err_ratelimited(FW_BUG "DAIF+PMR corrupted (0x%x + 0x%x=>0x%x + 0x%x) by EFI call from %pS\n", \ + __expected.daif, __expected.pmr, __actual.daif, __actual.pmr, \ + caller ?: __builtin_return_address(0)); \ + } else { \ + pr_err_ratelimited(FW_BUG "DAIF corrupted (0x%x=>0x%x) by EFI call from %pS\n", \ + __expected.daif, __actual.daif, \ + caller ?: __builtin_return_address(0)); \ + } \ + \ +} while(0) /* arch specific definitions used by the stub code */ -- 2.34.1