From nobody Tue Jun 16 17:01:52 2026 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 129D03D75DB for ; Thu, 30 Apr 2026 07:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777534884; cv=none; b=MLwyebjn0dhwduVVWmzk5r39XLPNzXDQV27bJqKYl6hg9Nh6DmStQU7hpkiYgqfgKbDAkjtnIYoGAwkMhn7/8p9e84MsAUBIR3IKDPAbIOYLmB9tpV/pGLfhjvGxoLQGgSI/tatGspyc0baOzZNHxftktstXYKIKUlyVPB+GPtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777534884; c=relaxed/simple; bh=sszepgGox8yNjq+U78WVIYY/O3P/3k6fk57CLmDvdFM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Li2NUFM1NshNTxGxXPWlEmpWq9pyx1TdMWXDvl0PgydhcFAHG9nSb+csWQDk1yudpB9143YtpdsJiPgLUU3e54kvA5o1tYpEk6FA8+nPLLLBAP0c0CBxOCKFeCIP1QgmiODb7afJJgwdN4RSgJxW8OCGHLGnWUQzPmich9nulLw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (4096-bit key) header.d=canonical.com header.i=@canonical.com header.b=Jkcvv+45; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=canonical.com header.i=@canonical.com header.b="Jkcvv+45" Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id BB2053F9B8 for ; Thu, 30 Apr 2026 07:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1777534871; bh=ODQqFWQ+Nyy1EoDDiIJY4t1vvTxH4z/U+/Jg6s6lDMA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Jkcvv+45Xi3slANXxH5umNKTmHbMrB1Hl5GvLpKEzRPeFjQXDdaN/yqYBFhs5gRkh xZ59F/F7UVUxgXXsoaDgyesDQXjWaTgaFr44n5gVkLlCildykJbN9E/r+iogLJIwKW viSqZ5w75xI/zOF5X775lCMFlRcrc1lTgRLbDuwmM5EW1AwUTk+Gd04pEz99YqPTZQ KsoR55GXAfGRTtLYTNa45lmqjUeBt7hmui/VdScQTc27EYbBAgP2ajMmOXP/oV9Opu I/NpXhen0JzBepKlI7q+GUpB3QaOZgZfPNyRhhLuSTxhBkUtEpJuJgu2Y14GYLkiK+ pb6vkXZ2rksaODxZm4dnrIPJBoCfuW1QZQ9lXf3Ac1X7yMhjGJOTf21Y6m63TfQx3x cbSRP1KTpUsrP7xj5fWzObbCyZ0+LeBwh4uh3P3He0WCpph7DyEDwbzVZ/5X3Zi7c3 5PtaXrSeyANhb0fAIJuihEL8d10bIEtChXzPlTG/zeB+RBPg4Ci6bIyMfBtSGa3yhd HDuRgLSg0XmcRuyLRHpAg/0eoxqXS0Kv9fOk77Bil7kojE1qsFgdlI2ugmu1N6ZK5d QDHTJNhk0CQWo38FkSVNTHfstoU2tJOqVdkqogKgfhER4hs533uZSjajxB/hw8VYTn kEJVqyNDUTnWXrQjJCF4IwUA= Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2b4654f9bb6so7108175ad.2 for ; Thu, 30 Apr 2026 00:41:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777534870; x=1778139670; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ODQqFWQ+Nyy1EoDDiIJY4t1vvTxH4z/U+/Jg6s6lDMA=; b=XWNeOsMwasLGzbhA+K5JRDESY6W32wNC/rwKvtBMES8mWf1HF/a+ansjXV+yaVL5nO 0b88gEmbJTWa//r9u5gkRM0wz2JJoyBi2oBf4UCW0j7Z82WZ83XlF8k5aIA7soVmaYFQ rS9anHDAkLSL0Wj7QT+EI/xRRbRO+frZLPoQ6T0v+R7pi5S29a5ZNK7dJGCPcq0oPGH1 hheHDLKvmURi5K3j01AmWPXl6C9YkCKnfuunNtQnnpOAIaE9PiZMKVdXRxnkBTRaTfgr v+TLCUmmBc/rRDnZelXvjE4HpAPubsDDtTpOTU1+SrugTQCGb4LY4LK8lGoCcw8f+/3v vJ2Q== X-Forwarded-Encrypted: i=1; AFNElJ99LqwI70fxdBU3u79yIEhX3erBzlLHi/KJobF5THxPKazg9d+Xz/9lqDl65Jp0UJY/Eet+JXRoLkU/3H4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2SWMgDkUdxiyylPagOTubf78kUFRPXYL/cj7K+soYlSfA6HY8 EpfqOxisrNNN5LJonFf/YJww2C6ZU4cVo+1GT8U8U7JStcZ3JnSEZQYGrVEiNd+F2S6QztshSTK XNcYPzd0STlPV0OQO2tqWcoyr9LSH8Z+c5g83iFcxK0zICKtcw32gEkWi0HilKPmITWn4VFescY KL/uZd7A== X-Gm-Gg: AeBDiesTSSdSM8BAvVXTJrJso0yrdMi5Zww1AHLiZjz/iezymUPbb33k2BuGCkyW4iJ VTXfCfeNtO2zvmpJAxuLgokma/ZOuTy+abzLiBYx9RzkDqLpS0ygefaj3RDduqgnJLq7UcYfkul w0g+KHHas3zgmhSzjx2tnkrdqJI2r2DNzg/zAnkW+wetoFdyJ3sRRBTdBQOCErxhwgcefBA/uZb R6sIrB1iWZO2Ytft+6O/nAnaCei7xJM5wo0W2Ia7DbruwSV+etPYTgXNNpxTuyWE1lABEodWqFO LTEekMddQJLWhI0kkYKlAR5r2RQDN9Cdtc7lizkv5BJBvcoX3SN1gqnlMHXeDGeay+LiRV3QWWk nl0Y+YMQTZrVvtzdvDrN/GsAcSxSjwIO7Km4wVWr+NA2gtap9yGodUMNsTLSd/vaXDbvONi/tTg == X-Received: by 2002:a17:903:908:b0:2b9:59ea:7eba with SMTP id d9443c01a7336-2b9a2341a18mr17569595ad.13.1777534869941; Thu, 30 Apr 2026 00:41:09 -0700 (PDT) X-Received: by 2002:a17:903:908:b0:2b9:59ea:7eba with SMTP id d9443c01a7336-2b9a2341a18mr17569355ad.13.1777534869574; Thu, 30 Apr 2026 00:41:09 -0700 (PDT) Received: from canonical.com (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98893fbbbsm43706285ad.41.2026.04.30.00.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 00:41:09 -0700 (PDT) From: Ivan Hu To: ardb@kernel.org, ilias.apalodimas@linaro.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, ebiggers@google.com Cc: x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes Date: Thu, 30 Apr 2026 15:41:07 +0800 Message-ID: <20260430074107.27051-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since commit d02198550423 ("x86/fpu: Improve crypto performance by making kernel-mode FPU reliably usable in softirqs"), kernel_fpu_begin() calls fpregs_lock() which uses local_bh_disable() instead of the previous preempt_disable(). This sets SOFTIRQ_OFFSET in preempt_count during the entire EFI runtime service call, causing in_interrupt() to return true in normal task context. The graceful page fault handler efi_crash_gracefully_on_page_fault() uses in_interrupt() to bail out for faults in real interrupt context. With SOFTIRQ_OFFSET now set, the handler always bails out, leaving EFI firmware page faults unhandled. This escalates to die() which also sees in_interrupt() as true and calls panic("Fatal exception in interrupt"), resulting in a hard system freeze. On systems with buggy firmware that triggers page faults during EFI runtime calls (e.g., accessing unmapped memory in GetTime()), this causes an unrecoverable hang instead of the expected graceful EFI_ABORTED recovery. Fix by replacing in_interrupt() with in_hardirq() || in_nmi(). This preserves the original intent of bailing for genuine hardware interrupt or NMI faults, while no longer falsely triggering from the FPU code path's local_bh_disable(). This is safe because softirqs cannot run during EFI calls (they are explicitly blocked by fpregs_lock()), so they can never be the source of a page fault in this context. Fixes: d02198550423 ("x86/fpu: Improve crypto performance by making kernel-= mode FPU reliably usable in softirqs") Signed-off-by: Ivan Hu Acked-by: Ard Biesheuvel --- arch/x86/platform/efi/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index df24ffc6105d..7475405119ce 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -767,10 +767,10 @@ void efi_crash_gracefully_on_page_fault(unsigned long= phys_addr) return; =20 /* - * If we get an interrupt/NMI while processing an EFI runtime service + * If we get a hard IRQ or NMI while processing an EFI runtime service * then this is a regular OOPS, not an EFI failure. */ - if (in_interrupt()) + if (in_hardirq() || in_nmi()) return; =20 /* --=20 2.43.0