From patchwork Wed Aug 6 14:01:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 4686691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 47AB4C0338 for ; Wed, 6 Aug 2014 14:04:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 119AE20138 for ; Wed, 6 Aug 2014 14:04:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3D6B20125 for ; Wed, 6 Aug 2014 14:04:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XF1nK-0001Ke-C5; Wed, 06 Aug 2014 14:02:22 +0000 Received: from mail-wi0-f182.google.com ([209.85.212.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XF1nI-0001Fh-IA for linux-arm-kernel@lists.infradead.org; Wed, 06 Aug 2014 14:02:21 +0000 Received: by mail-wi0-f182.google.com with SMTP id d1so3253096wiv.3 for ; Wed, 06 Aug 2014 07:01:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=DaRxIiHXgrPVAssVA8pd7VkQs7N0n4wdR+oc9m8aRWk=; b=WjZFfSZf6HTHxg6uK1EzIRp07v0DpF/7hoYUL0Sa/uUicR2fXkovZuI4RTuXDfwuAQ g0V26eUSN1u3RfP618nK0OFQgKfbgQM7VUEtivS9GsA3vPsOzsi7wYJ59vFmTt0gVFji JydwI3pbSyU72fQ8d5IOrhP/JHo5F2Vb5NV99Bpt+Azh4zpEu6WHM8YpNvNbpcKUKABa uUwA64SNRe9aL/c3O3Hh+nJMGkLF+9oLvatjI7TSDSgI1QY9BoCs9mzdky288nFU/shT YEY9tRSNJ1jM/M0qdYRBu8TCtMpOl9wBSpwGE+PQilldHK5M+cIPOk2MMLOqeUO2iyr6 GXHw== X-Gm-Message-State: ALoCoQkJkrTwNpARE23B26U6O0OUlAhdnaRIPpnadr7+x2qRy4FZefQlX/kEWF2oL747GVmWumbP X-Received: by 10.180.99.65 with SMTP id eo1mr16950279wib.12.1407333717921; Wed, 06 Aug 2014 07:01:57 -0700 (PDT) Received: from localhost (054142ff.skybroadband.com. [5.65.66.255]) by mx.google.com with ESMTPSA id sa4sm2697389wjb.45.2014.08.06.07.01.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Aug 2014 07:01:57 -0700 (PDT) Date: Wed, 6 Aug 2014 15:01:55 +0100 From: Matt Fleming To: Leif Lindholm Subject: Re: [PATCH 1/2] UEFI arm64: add noefi boot param Message-ID: <20140806140155.GC15082@console-pimps.org> References: <20140806083825.GA31711@dhcp-16-198.nay.redhat.com> <20140806130623.GI4179@bivouac.eciton.net> <20140806132021.GB15082@console-pimps.org> <20140806132941.GJ4179@bivouac.eciton.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140806132941.GJ4179@bivouac.eciton.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140806_070220_752744_D2B3363A X-CRM114-Status: GOOD ( 28.40 ) X-Spam-Score: -0.7 (/) Cc: matt.fleming@intel.com, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, msalter@redhat.com, Dave Young , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 06 Aug, at 02:29:41PM, Leif Lindholm wrote: > On Wed, Aug 06, 2014 at 02:20:21PM +0100, Matt Fleming wrote: > > > Since this is really turning an x86-specific feature into a generic > > > one, could it be moved to core code? > > > Maybe an efi.mask, reusing the efi_enabled defines, with an > > > efi_disabled macro? > > > > Why the new efi_disabled() and efi.mask? This is all achievable with > > efi_enabled() and efi.flags, in fact, this kind of thing is exactly why > > they were invented. > > Because this flag is indicating which facilities we should not try to > enable, rather than which facilities we have enabled. > > The EFI_RUNTIME_SERVICES flag is set after successful call to > set_virtual_address_map. The apparent intent of "noefi" is to prevent > that call from being made in the first place. > > Anyway, it was just a suggestion - main point was it would make sense > to share the code. Definitely. Dave, below is the kind of thing that I had in mind. Please Cc the Xen and SGI folks when you submit your next version because they're likely to be hit the hardest by any changes to EFI_RUNTIME_SERVICES and "noefi". Obviously the addition of "efi=noruntime" is needed on top, but that's about 6 lines of code. --- arch/arm64/kernel/efi.c | 4 ++-- arch/x86/kernel/setup.c | 4 +++- arch/x86/platform/efi/efi.c | 33 +++++++++------------------------ drivers/firmware/efi/efi.c | 7 +++++++ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index e72f3100958f..9fdedb721a4e 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -83,6 +83,7 @@ static int __init uefi_init(void) set_bit(EFI_BOOT, &efi.flags); set_bit(EFI_64BIT, &efi.flags); + set_bit(EFI_RUNTIME_SERVICES, &efi.flags); /* * Verify the EFI Table @@ -386,7 +387,7 @@ static int __init arm64_enter_virtual_mode(void) int count = 0; unsigned long flags; - if (!efi_enabled(EFI_BOOT)) { + if (!efi_enabled(EFI_BOOT) || !efi_enabled(EFI_RUNTIME_SERVICES)) { pr_info("EFI services will not be available.\n"); return -1; } @@ -461,7 +462,6 @@ static int __init arm64_enter_virtual_mode(void) /* Set up runtime services function pointers */ runtime = efi.systab->runtime; efi_native_runtime_setup(); - set_bit(EFI_RUNTIME_SERVICES, &efi.flags); return 0; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 41ead8d3bc0b..3e2f820b6007 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -932,8 +932,10 @@ void __init setup_arch(char **cmdline_p) set_bit(EFI_64BIT, &efi.flags); } - if (efi_enabled(EFI_BOOT)) + if (efi_enabled(EFI_BOOT)) { efi_memblock_x86_reserve_range(); + set_bit(EFI_RUNTIME_SERVICES, &efi.flags); + } #endif x86_init.oem.arch_setup(); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index a1f745b0bf1d..bac12cae2a80 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -70,14 +70,6 @@ static efi_config_table_type_t arch_tables[] __initdata = { u64 efi_setup; /* efi setup_data physical address */ -static bool disable_runtime __initdata = false; -static int __init setup_noefi(char *arg) -{ - disable_runtime = true; - return 0; -} -early_param("noefi", setup_noefi); - int add_efi_memmap; EXPORT_SYMBOL(add_efi_memmap); @@ -397,20 +389,12 @@ static int __init efi_runtime_init(void) * hypercall which executes relevant EFI functions) and that is why * they are always enabled. */ + if (efi_enabled(EFI_64BIT)) + rv = efi_runtime_init64(); + else + rv = efi_runtime_init32(); - if (!efi_enabled(EFI_PARAVIRT)) { - if (efi_enabled(EFI_64BIT)) - rv = efi_runtime_init64(); - else - rv = efi_runtime_init32(); - - if (rv) - return rv; - } - - set_bit(EFI_RUNTIME_SERVICES, &efi.flags); - - return 0; + return rv; } static int __init efi_memmap_init(void) @@ -489,10 +473,11 @@ void __init efi_init(void) * that doesn't match the kernel 32/64-bit mode. */ - if (!efi_runtime_supported()) + if (!efi_runtime_supported()) { pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n"); - else { - if (disable_runtime || efi_runtime_init()) + clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); + } else { + if (!efi_enabled(EFI_RUNTIME_SERVICES) || efi_runtime_init()) return; } if (efi_memmap_init()) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 36ffa1747e84..e7584ac22be1 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -415,3 +415,10 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose) return of_scan_flat_dt(fdt_find_uefi_params, &info); } #endif /* CONFIG_EFI_PARAMS_FROM_FDT */ + +static int __init setup_noefi(char *arg) +{ + clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); + return 0; +} +early_param("noefi", setup_noefi);