* [PATCH] arm64/efi: handle potential failure to remap memory map
@ 2015-01-15 12:01 Ard Biesheuvel
[not found] ` <1421323266-30973-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2015-01-15 12:01 UTC (permalink / raw)
To: mark.rutland-5wv7dgnIgG8, msalter-H+wXaHxf7aLQT0dZR+AlfA,
matt.fleming-ral2JQCrhuEAvxtiuMwx3w,
leif.lindholm-QSEj5FYQhm4dnm+yROfE0A,
roy.franz-QSEj5FYQhm4dnm+yROfE0A,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-efi-u79uwXL29TY76Z2rM5mHXA
Cc: Ard Biesheuvel
When remapping the UEFI memory map using ioremap_cache(), we
have to deal with potential failure. Note that, even if the
common case is for ioremap_cache() to return the existing linear
mapping of the memory map, we cannot rely on that to be always the
case, e.g., in the presence of a mem= kernel parameter.
At the same time, remove a stale comment and move the memmap code
together.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
arch/arm64/kernel/efi.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index a98415b5979c..c9cb0fbe7aa4 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -229,19 +229,21 @@ static int __init arm64_enable_runtime_services(void)
return -1;
}
- mapsize = memmap.map_end - memmap.map;
-
if (efi_runtime_disabled()) {
pr_info("EFI runtime services will be disabled.\n");
return -1;
}
pr_info("Remapping and enabling EFI services.\n");
- /* replace early memmap mapping with permanent mapping */
+
+ mapsize = memmap.map_end - memmap.map;
memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
mapsize);
+ if (!memmap.map) {
+ pr_err("Failed to remap EFI memory map\n");
+ return -1;
+ }
memmap.map_end = memmap.map + mapsize;
-
efi.memmap = &memmap;
efi.systab = (__force void *)ioremap_cache(efi_system_table,
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <1421323266-30973-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH] arm64/efi: handle potential failure to remap memory map [not found] ` <1421323266-30973-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2015-01-15 16:40 ` Mark Rutland 2015-01-16 16:23 ` Catalin Marinas 2015-01-15 16:50 ` Mark Salter 1 sibling, 1 reply; 4+ messages in thread From: Mark Rutland @ 2015-01-15 16:40 UTC (permalink / raw) To: Ard Biesheuvel, catalin.marinas-5wv7dgnIgG8 Cc: msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, Jan 15, 2015 at 12:01:06PM +0000, Ard Biesheuvel wrote: > When remapping the UEFI memory map using ioremap_cache(), we > have to deal with potential failure. Note that, even if the > common case is for ioremap_cache() to return the existing linear > mapping of the memory map, we cannot rely on that to be always the > case, e.g., in the presence of a mem= kernel parameter. > > At the same time, remove a stale comment and move the memmap code > together. > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Acked-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> This should probably be picked up before my mem= patch, which I will be resending shortly. I'll mention that when posting. I guess Catalin should pick this up given the other portions are in the arm64 tree, and this falls under arch/arm64. Thanks, Mark. > --- > arch/arm64/kernel/efi.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c > index a98415b5979c..c9cb0fbe7aa4 100644 > --- a/arch/arm64/kernel/efi.c > +++ b/arch/arm64/kernel/efi.c > @@ -229,19 +229,21 @@ static int __init arm64_enable_runtime_services(void) > return -1; > } > > - mapsize = memmap.map_end - memmap.map; > - > if (efi_runtime_disabled()) { > pr_info("EFI runtime services will be disabled.\n"); > return -1; > } > > pr_info("Remapping and enabling EFI services.\n"); > - /* replace early memmap mapping with permanent mapping */ > + > + mapsize = memmap.map_end - memmap.map; > memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map, > mapsize); > + if (!memmap.map) { > + pr_err("Failed to remap EFI memory map\n"); > + return -1; > + } > memmap.map_end = memmap.map + mapsize; > - > efi.memmap = &memmap; > > efi.systab = (__force void *)ioremap_cache(efi_system_table, > -- > 1.8.3.2 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64/efi: handle potential failure to remap memory map 2015-01-15 16:40 ` Mark Rutland @ 2015-01-16 16:23 ` Catalin Marinas 0 siblings, 0 replies; 4+ messages in thread From: Catalin Marinas @ 2015-01-16 16:23 UTC (permalink / raw) To: Mark Rutland Cc: Ard Biesheuvel, msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, Jan 15, 2015 at 04:40:11PM +0000, Mark Rutland wrote: > On Thu, Jan 15, 2015 at 12:01:06PM +0000, Ard Biesheuvel wrote: > > When remapping the UEFI memory map using ioremap_cache(), we > > have to deal with potential failure. Note that, even if the > > common case is for ioremap_cache() to return the existing linear > > mapping of the memory map, we cannot rely on that to be always the > > case, e.g., in the presence of a mem= kernel parameter. > > > > At the same time, remove a stale comment and move the memmap code > > together. > > > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > Acked-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> > > This should probably be picked up before my mem= patch, which I will be > resending shortly. I'll mention that when posting. > > I guess Catalin should pick this up given the other portions are in the > arm64 tree, and this falls under arch/arm64. I picked both up. Thanks. -- Catalin ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64/efi: handle potential failure to remap memory map [not found] ` <1421323266-30973-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-01-15 16:40 ` Mark Rutland @ 2015-01-15 16:50 ` Mark Salter 1 sibling, 0 replies; 4+ messages in thread From: Mark Salter @ 2015-01-15 16:50 UTC (permalink / raw) To: Ard Biesheuvel Cc: mark.rutland-5wv7dgnIgG8, matt.fleming-ral2JQCrhuEAvxtiuMwx3w, leif.lindholm-QSEj5FYQhm4dnm+yROfE0A, roy.franz-QSEj5FYQhm4dnm+yROfE0A, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-efi-u79uwXL29TY76Z2rM5mHXA On Thu, 2015-01-15 at 12:01 +0000, Ard Biesheuvel wrote: > When remapping the UEFI memory map using ioremap_cache(), we > have to deal with potential failure. Note that, even if the > common case is for ioremap_cache() to return the existing linear > mapping of the memory map, we cannot rely on that to be always the > case, e.g., in the presence of a mem= kernel parameter. > > At the same time, remove a stale comment and move the memmap code > together. > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > arch/arm64/kernel/efi.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c > index a98415b5979c..c9cb0fbe7aa4 100644 > --- a/arch/arm64/kernel/efi.c > +++ b/arch/arm64/kernel/efi.c > @@ -229,19 +229,21 @@ static int __init arm64_enable_runtime_services(void) > return -1; > } > > - mapsize = memmap.map_end - memmap.map; > - > if (efi_runtime_disabled()) { > pr_info("EFI runtime services will be disabled.\n"); > return -1; > } > > pr_info("Remapping and enabling EFI services.\n"); > - /* replace early memmap mapping with permanent mapping */ > + > + mapsize = memmap.map_end - memmap.map; > memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map, > mapsize); > + if (!memmap.map) { > + pr_err("Failed to remap EFI memory map\n"); > + return -1; > + } > memmap.map_end = memmap.map + mapsize; > - > efi.memmap = &memmap; > > efi.systab = (__force void *)ioremap_cache(efi_system_table, Somewhat unrelated but we should unmap memmap.map if the efi.systab mapping fails. Acked-by: Mark Salter <msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-16 16:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-15 12:01 [PATCH] arm64/efi: handle potential failure to remap memory map Ard Biesheuvel
[not found] ` <1421323266-30973-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-15 16:40 ` Mark Rutland
2015-01-16 16:23 ` Catalin Marinas
2015-01-15 16:50 ` Mark Salter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox