diff mbox

[3/5] efi arm64: do not enter virtual mode in case booting with efi=noruntime or noefi

Message ID 1407823822-23829-3-git-send-email-dyoung@redhat.com
State Accepted
Headers show

Commit Message

Dave Young Aug. 12, 2014, 6:10 a.m. UTC
In case efi runtime disabled via noefi kernel cmdline arm64_enter_virtual_mode
should error out.

At the same time move early_memunmap(memmap.map, mapsize) to the beginning of
the function or it will leak early mem.

Signed-off-by: Dave Young <dyoung@redhat.com>
---
 arch/arm64/kernel/efi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Will Deacon Aug. 12, 2014, 10:46 a.m. UTC | #1
On Tue, Aug 12, 2014 at 07:10:20AM +0100, Dave Young wrote:
> In case efi runtime disabled via noefi kernel cmdline arm64_enter_virtual_mode
> should error out.
> 
> At the same time move early_memunmap(memmap.map, mapsize) to the beginning of
> the function or it will leak early mem.
> 
> Signed-off-by: Dave Young <dyoung@redhat.com>
> ---
>  arch/arm64/kernel/efi.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index e72f310..324cdd1 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -386,7 +386,10 @@ static int __init arm64_enter_virtual_mode(void)
>  	int count = 0;
>  	unsigned long flags;
>  
> -	if (!efi_enabled(EFI_BOOT)) {
> +	mapsize = memmap.map_end - memmap.map;
> +	early_memunmap(memmap.map, mapsize);
> +
> +	if (!efi_enabled(EFI_BOOT) || efi_runtime_disabled()) {

Hmm, is this right? We only set EFI_BOOT if we find EFI parameters in the
DT (see efi_init -> uefi_init), so you run the risk of unmapping something
we never mapped here.

Furthermore, there seems to be a leak in uefi_init anyway, as we return
-EINVAL if the signature of the EFI table doesn't match without unmapping it
first.

Will
diff mbox

Patch

diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index e72f310..324cdd1 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -386,7 +386,10 @@  static int __init arm64_enter_virtual_mode(void)
 	int count = 0;
 	unsigned long flags;
 
-	if (!efi_enabled(EFI_BOOT)) {
+	mapsize = memmap.map_end - memmap.map;
+	early_memunmap(memmap.map, mapsize);
+
+	if (!efi_enabled(EFI_BOOT) || efi_runtime_disabled()) {
 		pr_info("EFI services will not be available.\n");
 		return -1;
 	}
@@ -394,8 +397,6 @@  static int __init arm64_enter_virtual_mode(void)
 	pr_info("Remapping and enabling EFI services.\n");
 
 	/* replace early memmap mapping with permanent mapping */
-	mapsize = memmap.map_end - memmap.map;
-	early_memunmap(memmap.map, mapsize);
 	memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
 						   mapsize);
 	memmap.map_end = memmap.map + mapsize;