Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6360385imu; Mon, 21 Jan 2019 07:36:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UBAFiHhFMmfna/qGWpZ+Y3zEQpzo5ZMFEOJWYmA10Uw3SRhj/PVyQNLNsLSJcWxFyvEtF X-Received: by 2002:a17:902:6b87:: with SMTP id p7mr31040774plk.282.1548084978027; Mon, 21 Jan 2019 07:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548084977; cv=none; d=google.com; s=arc-20160816; b=t+SOVER97P3mL9ZSP2R299h2MuyQ7IaCxmPzvjq/IctEC9TA6eYf09F8HFvHPfRSH0 wwEoA2haio8A6A2cdP74q+8EqgjaJWuCkIX2Y/R12PH/H7cLFRTm2N59YFugHrUIAFEf VMZsRfb7tOwvEAs0ggr+DcOh7SvQVPOHKSGeyMi/mT5H/rm9vBW3153L2usL87YlUzca 5YMMN9v6GIp/jZJAde0sO+riJyd8Muzsge2D0MeT7JHB7mgNEoFK+lPF0iSq6rd0ciH/ lDBpGqlAp/EZnwz87P9MUDhhmewKlhs5nKSWXztqwGavJFzzZ6zC8muHdvbPFu0mSWdn Qo9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=h9HPU930hd8YayF+VJ+Mfbt5rHdt+4yAWXYghk3xSBY=; b=cZPh6vqCSUWPv11Fif34+in5GdasD03/Sb5VambrpHDX2WRIOziSvuw1vjnhZwMFV6 2VCM26ybUgyvemDovXM7xuvvrJ8LUtAanC6xQmfCYcPxjXEy06hzVVQNrL/heXhUd4Z8 /bbkoEzdTaqPrCKJvV9FvkDZP1YwjE5ll84y2XT7bIS7uNhlAWS8nk1eqPJltv6M9jUL mBYCIQGlhD3+pnKiAboK6chPCwRbKYa4AYRZXLiRFrFTz2Ku4f0mxZ+Km/0kToilfuws hMM0e0FNcM36fV6Jnu3YMmmDgdROKm6G3CDwUHdQfwORj/PYzawa6BKuUVCRl22qtNDn Fqjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7si12592421pfb.237.2019.01.21.07.36.01; Mon, 21 Jan 2019 07:36:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730198AbfAUPea (ORCPT + 99 others); Mon, 21 Jan 2019 10:34:30 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36504 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730135AbfAUPe1 (ORCPT ); Mon, 21 Jan 2019 10:34:27 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B93A19BF; Mon, 21 Jan 2019 07:34:27 -0800 (PST) Received: from e112298-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BE54C3F5C1; Mon, 21 Jan 2019 07:34:24 -0800 (PST) From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, Julien Thierry , Ard Biesheuvel , linux-efi@vger.kernel.org Subject: [PATCH v9 11/26] efi: Let architectures decide the flags that should be saved/restored Date: Mon, 21 Jan 2019 15:33:30 +0000 Message-Id: <1548084825-8803-12-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> References: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, irqflags are saved before calling runtime services and checked for mismatch on return. Provide a pair of overridable macros to save and restore (if needed) the state that need to be preserved on return from a runtime service. This allows to check for flags that are not necesarly related to irqflags. Signed-off-by: Julien Thierry Acked-by: Catalin Marinas Cc: Ard Biesheuvel Cc: linux-efi@vger.kernel.org --- drivers/firmware/efi/runtime-wrappers.c | 17 +++++++++++++++-- include/linux/efi.h | 5 +++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c index 8903b9c..2f4b68b 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -89,11 +89,24 @@ efi_rts_work.status; \ }) +#ifndef arch_efi_save_flags +#define arch_efi_save_flags(state_flags) local_save_flags(state_flags) +#define arch_efi_restore_flags(state_flags) local_irq_restore(state_flags) +#endif + +inline unsigned long efi_call_virt_save_flags(void) +{ + unsigned long flags; + + arch_efi_save_flags(flags); + return flags; +} + void efi_call_virt_check_flags(unsigned long flags, const char *call) { unsigned long cur_flags, mismatch; - local_save_flags(cur_flags); + cur_flags = efi_call_virt_save_flags(); mismatch = flags ^ cur_flags; if (!WARN_ON_ONCE(mismatch & ARCH_EFI_IRQ_FLAGS_MASK)) @@ -102,7 +115,7 @@ void efi_call_virt_check_flags(unsigned long flags, const char *call) add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_NOW_UNRELIABLE); pr_err_ratelimited(FW_BUG "IRQ flags corrupted (0x%08lx=>0x%08lx) by EFI %s\n", flags, cur_flags, call); - local_irq_restore(flags); + arch_efi_restore_flags(flags); } /* diff --git a/include/linux/efi.h b/include/linux/efi.h index 45ff763..bd80b7e 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1607,6 +1607,7 @@ efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, bool efi_runtime_disabled(void); extern void efi_call_virt_check_flags(unsigned long flags, const char *call); +extern unsigned long efi_call_virt_save_flags(void); enum efi_secureboot_mode { efi_secureboot_mode_unset, @@ -1652,7 +1653,7 @@ enum efi_secureboot_mode { \ arch_efi_call_virt_setup(); \ \ - local_save_flags(__flags); \ + __flags = efi_call_virt_save_flags(); \ __s = arch_efi_call_virt(p, f, args); \ efi_call_virt_check_flags(__flags, __stringify(f)); \ \ @@ -1667,7 +1668,7 @@ enum efi_secureboot_mode { \ arch_efi_call_virt_setup(); \ \ - local_save_flags(__flags); \ + __flags = efi_call_virt_save_flags(); \ arch_efi_call_virt(p, f, args); \ efi_call_virt_check_flags(__flags, __stringify(f)); \ \ -- 1.9.1