Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932099AbdHYIdC (ORCPT ); Fri, 25 Aug 2017 04:33:02 -0400 Received: from mail-db5eur01on0042.outbound.protection.outlook.com ([104.47.2.42]:44352 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754926AbdHYIcy (ORCPT ); Fri, 25 Aug 2017 04:32:54 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Florent.Revest@arm.com; From: Florent Revest To: linux-arm-kernel@lists.infradead.org Cc: matt@codeblueprint.co.uk, ard.biesheuvel@linaro.org, pbonzini@redhat.com, rkrcmar@redhat.com, christoffer.dall@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, marc.zyngier@arm.com, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, leif.lindholm@arm.com, revestflo@gmail.com, Florent Revest Subject: [RFC 09/11] EFI, arm, arm64: Enable EFI Runtime Services later Date: Fri, 25 Aug 2017 09:31:39 +0100 Message-Id: <1503649901-5834-10-git-send-email-florent.revest@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503649901-5834-1-git-send-email-florent.revest@arm.com> References: <1503649901-5834-1-git-send-email-florent.revest@arm.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: HE1PR09CA0051.eurprd09.prod.outlook.com (2603:10a6:7:3c::19) To HE1PR08MB0812.eurprd08.prod.outlook.com (2a01:111:e400:59b1::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1d3e354-a3a4-4c87-424e-08d4eb93d37c X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:HE1PR08MB0812; X-Microsoft-Exchange-Diagnostics: 1;HE1PR08MB0812;3:wpBa9TGsIVMIhMhB+sENVHgBg1dq9Lr1gidSj2bV0q6vtCduSo78oDPCweWw9ZtHZXzVmm7uJcuWi4zWYqdVV/UWzzrtV41OnVr4lKY8SvtON47DY9s2t8+ospGiVBd0VCYFG7BvRjli0Lyb0gMhfcT6ys41WSC3BGDHZnbkvc78awHO981+om2wWQz4wjdk5jOikhHBsyVkv5klCHFGW7IJugo3iwsPbivmK/dIJzS7Gthh5LIY9H3Aso0peNBj;25:wThpCSSvoTfz7bmI5BWcV0hncNXt/+E0Omnfu+teXFQMXMG7SU2gMFK8+5t3030yADxw15AkqlTmAqnt8i8a08Ed1yRjgiJk0/Xo7FQJIVvuPih1aKQbOh0NTtkvMaJPA0kmC+fbGcy8jn06KHxqJHvgb2VlAtHq910/fD5gQf7G/3iUeATT939XDTi8Ymct83rPnQkuQGwnaNRIMKF8G/6CybITc5d5C0kdKPIzq8pt0Y51P8+M+pZiJYTEMm7X5oGxrzDob0rWTKMGNxFcpYAylWcvbwn98laiRZ0RzFKzjlNCYTf321BHdwjgvb0vAJtnRJgOvSOQy88eqcvm0A==;31:A2oBT7jyqtYOjOjsnrpHnZGcatNsNy/WegTn0s9R7jRN0PNIgUwOnJGk7j7PI2fx8lcDbw7JHtx4Uolb1AxKlS08buj341JT+hsczFBTjhr1lJdaEqc+P+rBCdgpC6X7pb4Mkc2AngG4nZROM+kkIy+Nal6AYLs2M8kul9EURKPIzd4eKrHajev73Tgo+GY1koP7oRRsCL8/jWAj1XjkvjOr5v8FbONasNBtI7rxLWU= X-MS-TrafficTypeDiagnostic: HE1PR08MB0812: X-Microsoft-Exchange-Diagnostics: 1;HE1PR08MB0812;20:5N8tiME5009bYyKOLu2o/UJTeR0hDjoHOHwLXZAivi6XRinbYqQQh3pCdpv0f+QUmm55IH3/VHJ8Cos7R09S7o5Lz9aiKndLxhMlqrGEAMcUua8yU/HRfg7O17sv8hyCUbf3jhvsRPbXFV6eBBJcofBJ1Plou9fPu2NoxhcRBJ80Sk2xXsUyLCCltg/2JIL/1T1i8PIYkgJTyU1gJJTUYKUbGAj8QTYviZljk3/VWHhbj+GeeRmOII0TUDCCx5lCHe0r9ltjPIF4TpN/eL/Hz1BnTN99Q3pMJ6/Igtk6FgVfhGKv0bCcOXIedCFZCJEt8wJNDyvGTA1jl7FLEYhYyLc50EN16hAmFy4iyjMG0JaCAICiZ0LCcdKLslBDdMMzfezZFpQQNx2JU2VQsU3QkU137fhJH3tn8jbCYEy420Ay+Jg27DSqxtqeyall+65ssM1PTeO6dkVpwSJsLM+6WNjGgfxYTbWWxS0/D4Z23OuWgWKQP6c8S+yHDe5q9ejh;4:mcE4Br72usIDBS+UPVTwUqNcKzDXrFRTrH2CTbTII21hJcnJx5YfNpTWlq6cwKjOJoLwRRtMdGvTMaUxNjjLViY+zxwNDfdwMNOoZbs1gOw757DwSF43Bp11uwFXg62UDGQetW+0v+8vQaO8ntUXULcVZC7Fto0OMETjgb0DqHqrxzl0lj6hvKZzkEi1ausFVm25pmhGcbX4c4FNGBRt+YYtmzXDIgPBgE43vQLH9JIlagMlgolhCD9eyuKPihW49mcpVFP5mVQ68akrG1unev9yZBvFqNm8pLHsl8stGQw= X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR08MB0812;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR08MB0812; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(40434004)(189002)(478600001)(68736007)(76176999)(25786009)(5660300001)(97736004)(36756003)(6486002)(50226002)(47776003)(50986999)(50466002)(4326008)(48376002)(7350300001)(110136004)(66066001)(7416002)(8676002)(189998001)(305945005)(5890100001)(6916009)(2351001)(105586002)(42186005)(6116002)(2361001)(8746002)(3846002)(86362001)(2906002)(72206003)(81156014)(81166006)(2950100002)(106356001)(6666003)(7736002)(33646002)(101416001)(5003940100001)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR08MB0812;H:e106757-lin.cambridge.arm.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR08MB0812;23:8ecjpVcdon52TgXZzauyuRgfQLmkFga7iFSlgsBSD?= =?us-ascii?Q?O2eYlEPEKaX7BdMIVPbGUCPOMm1wNxAyh1/XZf/wb+PjkXa8eUYT27HDrI20?= =?us-ascii?Q?/S5uhSVUu4yMZqqSccNWXVx6G6cmR96XLrmNcPEGHuR26ovlRRvLYBbKDLMA?= =?us-ascii?Q?RHddLawD9c41qwBcTHn9EADRUOTh8UJHduiD7C3sgNf/OjwpX7JqbqxlwH5R?= =?us-ascii?Q?SuZxb94gcqEAckb+/YGrERRrgmf/j0NcpxwHC+p5sXejk0C+pqHpKtCxRvLN?= =?us-ascii?Q?4AGSDEgHGlVeUKxfKXbaXyk+HuetWT4F8lcqyRHa/6YNBnJ9tEcgVtmAohqa?= =?us-ascii?Q?TOsQkYjEPPOatDXSmDoTVOvZ33CZ9WgA3OYC5XrBAO7M3I/BZ1GitJadV5K0?= =?us-ascii?Q?kJHiz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zw1ez0rSglMw1DJHxbtnHnTrVAAnLTtBJzmvvmyrPwN2pedAVNu8FCATmc3VMgc3vFszVi3ojUjCKe6JL2PXri2cN/Wj3UvrjNoltND9Cvp5qV1V+x6uMPeBn7A1JHkzfmjcq1Smwg0ccgmMqBMN9fQy1XlXpkjrZaRGamFqGvevfQEB0HJSdTWnrEn6kkHZEROEZQzxa7wI7+t4eyI4ALzyG5ww7KgQD1+iICd+0PwQypRzom539wWtlpaBEQQFBGh+w9crfQy4wXvjED0V+8NVzl6m8w7zhC68G613khesa66tKWARILVublTxVFH1cjUDr6YywLFWrA==;5:cPFJdGrQ5W4hBy9g+wQohd+yFi3kAAghEG9P7XfePjKQ8zvlnowrsvsBlVs4IqaKrorKXHQb+7RLsPKY3NGsaiON95VuRhMyfaUg6Act2FqzGVVkSsev04WahMqacp8O7vlPeZm/vQ1gh7TIF2UwhQ==;24:JfSzNoT6fCdzLvlKIRoTxDCcooLEN20VYgdc8f0NobamzE8tFcgnfSHCNlGrvo8kIuXIwIqHO2k5hHCTU6X5mZbINzvNb2vfNNX0RwW6mMQ=;7:4NEg/hOaq1dnvxH09gDSsep/GX05OylqpZMp2jZ/dctNUCpttB3burjGTt+tMfp1otN0QLjsPC9CkF66XbrW6SaszklagnpPPoOBujM14aaKCHGNIV535twQuYuawfZo8k8akzgLd/13+reP2uwe1ajT3arEVq1fd6+N2EVyd2LObMRKlADK83y/DdfCzw7hi2Xluw2KtlajAramiTWkcrCCIfjZ6AJRrh2HbllBYKw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 08:32:29.6313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB0812 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7P8X6RM009939 Content-Length: 3831 Lines: 104 EFI Runtime Services on ARM are enabled very early in the boot process although they aren't used until substantially later. This patch modifies the efi initialization sequence on ARM to enable runtime services just before they are effectively needed (in a subsys target instead of early). The reason behind this change is that eventually, a late Runtime Services initialization could take advantage of KVM's internal virtual machines to sandbox firmware code execution. Since KVM's core is only available starting from the subsys target, this reordering would be compulsory. Signed-off-by: Florent Revest --- arch/arm/include/asm/efi.h | 2 ++ arch/arm64/include/asm/efi.h | 2 ++ arch/x86/include/asm/efi.h | 2 ++ drivers/firmware/efi/arm-runtime.c | 3 +-- drivers/firmware/efi/efi.c | 3 +++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 17f1f1a..ed575ae 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h @@ -35,6 +35,8 @@ __f(args); \ }) +int efi_arch_late_enable_runtime_services(void); + #define ARCH_EFI_IRQ_FLAGS_MASK \ (PSR_J_BIT | PSR_E_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | \ PSR_T_BIT | MODE_MASK) diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index 8f3043a..373d94d 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -37,6 +37,8 @@ kernel_neon_end(); \ }) +int efi_arch_late_enable_runtime_services(void); + #define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) /* arch specific definitions used by the stub code */ diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 796ff6c..869efbb 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -233,6 +233,8 @@ static inline bool efi_is_64bit(void) extern bool efi_reboot_required(void); +int __init efi_arch_late_enable_runtime_services(void) {} + #else static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} static inline bool efi_reboot_required(void) diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 1cc41c3..d94d240 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -115,7 +115,7 @@ static bool __init efi_virtmap_init(void) * non-early mapping of the UEFI system table and virtual mappings for all * EFI_MEMORY_RUNTIME regions. */ -static int __init arm_enable_runtime_services(void) +int __init efi_arch_late_enable_runtime_services(void) { u64 mapsize; @@ -154,7 +154,6 @@ static int __init arm_enable_runtime_services(void) return 0; } -early_initcall(arm_enable_runtime_services); void efi_virtmap_load(void) { diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 045d6d3..2b447b4 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -33,6 +33,7 @@ #include #include +#include struct efi __read_mostly efi = { .mps = EFI_INVALID_TABLE_ADDR, @@ -304,6 +305,8 @@ static int __init efisubsys_init(void) { int error; + efi_arch_late_enable_runtime_services(); + if (!efi_enabled(EFI_BOOT)) return 0; -- 1.9.1 IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.