* [PATCH 0/2] arm64: don't call early_*map() post paging_init()
@ 2015-01-05 18:33 ` Leif Lindholm
0 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-05 18:33 UTC (permalink / raw)
To: msalter, linux-arm-kernel, linux-efi, will.deacon, catalin.marinas
Cc: ard.biesheuvel
This (tiny) series resolves a fairly serious problem with
early_ioremap/iounmap/memremap/memunmap on arm64. These functions
cannot safely be called after paging_init(), but the sanity check
was not triggering.
As a result, a fixmap entry was incorrectly cleared during
early_initcalls on arm64 UEFI systems.
1/2 reworks the arm64 UEFI support code to not attempt these calls
and
2/2 enables the sanity check
Leif Lindholm (2):
arm64: don't make early_*map() calls post paging_init()
arm64: call early_ioremap_reset() in paging_init()
arch/arm64/kernel/efi.c | 12 +++---------
arch/arm64/kernel/setup.c | 2 --
arch/arm64/mm/mmu.c | 1 +
3 files changed, 4 insertions(+), 11 deletions(-)
--
2.1.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 0/2] arm64: don't call early_*map() post paging_init()
@ 2015-01-05 18:33 ` Leif Lindholm
0 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-05 18:33 UTC (permalink / raw)
To: linux-arm-kernel
This (tiny) series resolves a fairly serious problem with
early_ioremap/iounmap/memremap/memunmap on arm64. These functions
cannot safely be called after paging_init(), but the sanity check
was not triggering.
As a result, a fixmap entry was incorrectly cleared during
early_initcalls on arm64 UEFI systems.
1/2 reworks the arm64 UEFI support code to not attempt these calls
and
2/2 enables the sanity check
Leif Lindholm (2):
arm64: don't make early_*map() calls post paging_init()
arm64: call early_ioremap_reset() in paging_init()
arch/arm64/kernel/efi.c | 12 +++---------
arch/arm64/kernel/setup.c | 2 --
arch/arm64/mm/mmu.c | 1 +
3 files changed, 4 insertions(+), 11 deletions(-)
--
2.1.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] arm64: don't make early_*map() calls post paging_init()
2015-01-05 18:33 ` Leif Lindholm
@ 2015-01-05 18:33 ` Leif Lindholm
-1 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-05 18:33 UTC (permalink / raw)
To: msalter, linux-arm-kernel, linux-efi, will.deacon, catalin.marinas
Cc: ard.biesheuvel
arm64 early_ioremap/iounmap/memremap/memunmap are not supported beyond
the call to paging_init(), but arm64_enter_virtual_mode() (an early
initcall) makes one call to unmap the UEFI memory map.
Rearrange the code to unmap this region before paging_init().
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
arch/arm64/kernel/efi.c | 12 +++---------
arch/arm64/kernel/setup.c | 2 --
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 6fac253..790adb5 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -317,15 +317,8 @@ void __init efi_init(void)
return;
reserve_regions();
-}
-
-void __init efi_idmap_init(void)
-{
- if (!efi_enabled(EFI_BOOT))
- return;
- /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
- efi_setup_idmap();
+ early_memunmap(memmap.map, params.mmap_size);
}
static int __init remap_region(efi_memory_desc_t *md, void **new)
@@ -380,7 +373,6 @@ static int __init arm64_enter_virtual_mode(void)
}
mapsize = memmap.map_end - memmap.map;
- early_memunmap(memmap.map, mapsize);
if (efi_runtime_disabled()) {
pr_info("EFI runtime services will be disabled.\n");
@@ -393,6 +385,8 @@ static int __init arm64_enter_virtual_mode(void)
mapsize);
memmap.map_end = memmap.map + mapsize;
+ efi_setup_idmap();
+
efi.memmap = &memmap;
/* Map the runtime regions */
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index b809911..c7eb3c5 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -401,8 +401,6 @@ void __init setup_arch(char **cmdline_p)
paging_init();
request_standard_resources();
- efi_idmap_init();
-
unflatten_device_tree();
psci_init();
--
2.1.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 1/2] arm64: don't make early_*map() calls post paging_init()
@ 2015-01-05 18:33 ` Leif Lindholm
0 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-05 18:33 UTC (permalink / raw)
To: linux-arm-kernel
arm64 early_ioremap/iounmap/memremap/memunmap are not supported beyond
the call to paging_init(), but arm64_enter_virtual_mode() (an early
initcall) makes one call to unmap the UEFI memory map.
Rearrange the code to unmap this region before paging_init().
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
arch/arm64/kernel/efi.c | 12 +++---------
arch/arm64/kernel/setup.c | 2 --
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 6fac253..790adb5 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -317,15 +317,8 @@ void __init efi_init(void)
return;
reserve_regions();
-}
-
-void __init efi_idmap_init(void)
-{
- if (!efi_enabled(EFI_BOOT))
- return;
- /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
- efi_setup_idmap();
+ early_memunmap(memmap.map, params.mmap_size);
}
static int __init remap_region(efi_memory_desc_t *md, void **new)
@@ -380,7 +373,6 @@ static int __init arm64_enter_virtual_mode(void)
}
mapsize = memmap.map_end - memmap.map;
- early_memunmap(memmap.map, mapsize);
if (efi_runtime_disabled()) {
pr_info("EFI runtime services will be disabled.\n");
@@ -393,6 +385,8 @@ static int __init arm64_enter_virtual_mode(void)
mapsize);
memmap.map_end = memmap.map + mapsize;
+ efi_setup_idmap();
+
efi.memmap = &memmap;
/* Map the runtime regions */
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index b809911..c7eb3c5 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -401,8 +401,6 @@ void __init setup_arch(char **cmdline_p)
paging_init();
request_standard_resources();
- efi_idmap_init();
-
unflatten_device_tree();
psci_init();
--
2.1.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] arm64: call early_ioremap_reset() in paging_init()
2015-01-05 18:33 ` Leif Lindholm
@ 2015-01-05 18:33 ` Leif Lindholm
-1 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-05 18:33 UTC (permalink / raw)
To: msalter-H+wXaHxf7aLQT0dZR+AlfA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-efi-u79uwXL29TY76Z2rM5mHXA, will.deacon-5wv7dgnIgG8,
catalin.marinas-5wv7dgnIgG8
Cc: ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A
arm64 does not support early_memremap/memunmap/ioremap/iounmap after
paging_init() has been called. The core early_*remap code handles this
via the after_paging_init variable, which is set by a call to
early_ioremap_reset().
However, arm64 currently does not call early_ioremap_reset(), which
has made it possible to poke around in the fixmap region after kmap
is enabled. Add the required call.
Signed-off-by: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
arch/arm64/mm/mmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 6032f3e..506544f 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -348,6 +348,7 @@ void __init paging_init(void)
{
void *zero_page;
+ early_ioremap_reset();
map_mem();
/*
--
2.1.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] arm64: call early_ioremap_reset() in paging_init()
@ 2015-01-05 18:33 ` Leif Lindholm
0 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-05 18:33 UTC (permalink / raw)
To: linux-arm-kernel
arm64 does not support early_memremap/memunmap/ioremap/iounmap after
paging_init() has been called. The core early_*remap code handles this
via the after_paging_init variable, which is set by a call to
early_ioremap_reset().
However, arm64 currently does not call early_ioremap_reset(), which
has made it possible to poke around in the fixmap region after kmap
is enabled. Add the required call.
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
arch/arm64/mm/mmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 6032f3e..506544f 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -348,6 +348,7 @@ void __init paging_init(void)
{
void *zero_page;
+ early_ioremap_reset();
map_mem();
/*
--
2.1.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] arm64: don't make early_*map() calls post paging_init()
2015-01-05 18:33 ` Leif Lindholm
@ 2015-01-06 9:38 ` Ard Biesheuvel
-1 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2015-01-06 9:38 UTC (permalink / raw)
To: Leif Lindholm
Cc: Catalin Marinas, linux-efi, Will Deacon, linux-arm-kernel, Mark Salter
On 5 January 2015 at 18:33, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> arm64 early_ioremap/iounmap/memremap/memunmap are not supported beyond
> the call to paging_init(), but arm64_enter_virtual_mode() (an early
> initcall) makes one call to unmap the UEFI memory map.
>
> Rearrange the code to unmap this region before paging_init().
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> arch/arm64/kernel/efi.c | 12 +++---------
> arch/arm64/kernel/setup.c | 2 --
> 2 files changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 6fac253..790adb5 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -317,15 +317,8 @@ void __init efi_init(void)
> return;
>
> reserve_regions();
> -}
> -
> -void __init efi_idmap_init(void)
> -{
> - if (!efi_enabled(EFI_BOOT))
> - return;
>
> - /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
> - efi_setup_idmap();
> + early_memunmap(memmap.map, params.mmap_size);
> }
>
> static int __init remap_region(efi_memory_desc_t *md, void **new)
> @@ -380,7 +373,6 @@ static int __init arm64_enter_virtual_mode(void)
> }
>
> mapsize = memmap.map_end - memmap.map;
> - early_memunmap(memmap.map, mapsize);
>
> if (efi_runtime_disabled()) {
> pr_info("EFI runtime services will be disabled.\n");
> @@ -393,6 +385,8 @@ static int __init arm64_enter_virtual_mode(void)
> mapsize);
> memmap.map_end = memmap.map + mapsize;
>
> + efi_setup_idmap();
> +
I think this is incorrect: we may call early_alloc() here which is
only allowed before paging_init()
> efi.memmap = &memmap;
>
> /* Map the runtime regions */
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index b809911..c7eb3c5 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -401,8 +401,6 @@ void __init setup_arch(char **cmdline_p)
> paging_init();
> request_standard_resources();
>
> - efi_idmap_init();
> -
> unflatten_device_tree();
>
> psci_init();
> --
> 2.1.3
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] arm64: don't make early_*map() calls post paging_init()
@ 2015-01-06 9:38 ` Ard Biesheuvel
0 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2015-01-06 9:38 UTC (permalink / raw)
To: linux-arm-kernel
On 5 January 2015 at 18:33, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> arm64 early_ioremap/iounmap/memremap/memunmap are not supported beyond
> the call to paging_init(), but arm64_enter_virtual_mode() (an early
> initcall) makes one call to unmap the UEFI memory map.
>
> Rearrange the code to unmap this region before paging_init().
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> arch/arm64/kernel/efi.c | 12 +++---------
> arch/arm64/kernel/setup.c | 2 --
> 2 files changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 6fac253..790adb5 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -317,15 +317,8 @@ void __init efi_init(void)
> return;
>
> reserve_regions();
> -}
> -
> -void __init efi_idmap_init(void)
> -{
> - if (!efi_enabled(EFI_BOOT))
> - return;
>
> - /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
> - efi_setup_idmap();
> + early_memunmap(memmap.map, params.mmap_size);
> }
>
> static int __init remap_region(efi_memory_desc_t *md, void **new)
> @@ -380,7 +373,6 @@ static int __init arm64_enter_virtual_mode(void)
> }
>
> mapsize = memmap.map_end - memmap.map;
> - early_memunmap(memmap.map, mapsize);
>
> if (efi_runtime_disabled()) {
> pr_info("EFI runtime services will be disabled.\n");
> @@ -393,6 +385,8 @@ static int __init arm64_enter_virtual_mode(void)
> mapsize);
> memmap.map_end = memmap.map + mapsize;
>
> + efi_setup_idmap();
> +
I think this is incorrect: we may call early_alloc() here which is
only allowed before paging_init()
> efi.memmap = &memmap;
>
> /* Map the runtime regions */
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index b809911..c7eb3c5 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -401,8 +401,6 @@ void __init setup_arch(char **cmdline_p)
> paging_init();
> request_standard_resources();
>
> - efi_idmap_init();
> -
> unflatten_device_tree();
>
> psci_init();
> --
> 2.1.3
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] arm64: call early_ioremap_reset() in paging_init()
2015-01-05 18:33 ` Leif Lindholm
@ 2015-01-06 9:39 ` Ard Biesheuvel
-1 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2015-01-06 9:39 UTC (permalink / raw)
To: Leif Lindholm
Cc: Mark Salter, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-efi-u79uwXL29TY76Z2rM5mHXA, Will Deacon, Catalin Marinas
On 5 January 2015 at 18:33, Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> arm64 does not support early_memremap/memunmap/ioremap/iounmap after
> paging_init() has been called. The core early_*remap code handles this
> via the after_paging_init variable, which is set by a call to
> early_ioremap_reset().
>
> However, arm64 currently does not call early_ioremap_reset(), which
> has made it possible to poke around in the fixmap region after kmap
> is enabled. Add the required call.
>
> Signed-off-by: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Perhaps add 'Fixes' and 'Cc: stable' tags as well?
> ---
> arch/arm64/mm/mmu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 6032f3e..506544f 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -348,6 +348,7 @@ void __init paging_init(void)
> {
> void *zero_page;
>
> + early_ioremap_reset();
> map_mem();
>
> /*
> --
> 2.1.3
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/2] arm64: call early_ioremap_reset() in paging_init()
@ 2015-01-06 9:39 ` Ard Biesheuvel
0 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2015-01-06 9:39 UTC (permalink / raw)
To: linux-arm-kernel
On 5 January 2015 at 18:33, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> arm64 does not support early_memremap/memunmap/ioremap/iounmap after
> paging_init() has been called. The core early_*remap code handles this
> via the after_paging_init variable, which is set by a call to
> early_ioremap_reset().
>
> However, arm64 currently does not call early_ioremap_reset(), which
> has made it possible to poke around in the fixmap region after kmap
> is enabled. Add the required call.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Perhaps add 'Fixes' and 'Cc: stable' tags as well?
> ---
> arch/arm64/mm/mmu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 6032f3e..506544f 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -348,6 +348,7 @@ void __init paging_init(void)
> {
> void *zero_page;
>
> + early_ioremap_reset();
> map_mem();
>
> /*
> --
> 2.1.3
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] arm64: don't make early_*map() calls post paging_init()
2015-01-06 9:38 ` Ard Biesheuvel
@ 2015-01-06 13:39 ` Leif Lindholm
-1 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-06 13:39 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Catalin Marinas, linux-efi, Will Deacon, linux-arm-kernel, Mark Salter
On Tue, Jan 06, 2015 at 09:38:24AM +0000, Ard Biesheuvel wrote:
> > diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> > index 6fac253..790adb5 100644
> > --- a/arch/arm64/kernel/efi.c
> > +++ b/arch/arm64/kernel/efi.c
> > @@ -393,6 +385,8 @@ static int __init arm64_enter_virtual_mode(void)
> > mapsize);
> > memmap.map_end = memmap.map + mapsize;
> >
> > + efi_setup_idmap();
> > +
>
> I think this is incorrect: we may call early_alloc() here which is
> only allowed before paging_init()
Hmm...
Technically, the existing code is already breaking this restriction
then - but my patch moved that _way_ later in the boot process (early
initcall instead of setup_arch()).
I'll resend with an alternative solution that leaves the
efi_setup_idmap() ordering vs paging init() in its current state.
Since efi_setup_idmap() goes away with your "stable UEFI virtual
mappings for kexec" series, I don't want to make changes here and for
potential backports too invasive.
/
Leif
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] arm64: don't make early_*map() calls post paging_init()
@ 2015-01-06 13:39 ` Leif Lindholm
0 siblings, 0 replies; 12+ messages in thread
From: Leif Lindholm @ 2015-01-06 13:39 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jan 06, 2015 at 09:38:24AM +0000, Ard Biesheuvel wrote:
> > diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> > index 6fac253..790adb5 100644
> > --- a/arch/arm64/kernel/efi.c
> > +++ b/arch/arm64/kernel/efi.c
> > @@ -393,6 +385,8 @@ static int __init arm64_enter_virtual_mode(void)
> > mapsize);
> > memmap.map_end = memmap.map + mapsize;
> >
> > + efi_setup_idmap();
> > +
>
> I think this is incorrect: we may call early_alloc() here which is
> only allowed before paging_init()
Hmm...
Technically, the existing code is already breaking this restriction
then - but my patch moved that _way_ later in the boot process (early
initcall instead of setup_arch()).
I'll resend with an alternative solution that leaves the
efi_setup_idmap() ordering vs paging init() in its current state.
Since efi_setup_idmap() goes away with your "stable UEFI virtual
mappings for kexec" series, I don't want to make changes here and for
potential backports too invasive.
/
Leif
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-01-06 13:39 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-05 18:33 [PATCH 0/2] arm64: don't call early_*map() post paging_init() Leif Lindholm
2015-01-05 18:33 ` Leif Lindholm
2015-01-05 18:33 ` [PATCH 1/2] arm64: don't make early_*map() calls " Leif Lindholm
2015-01-05 18:33 ` Leif Lindholm
2015-01-06 9:38 ` Ard Biesheuvel
2015-01-06 9:38 ` Ard Biesheuvel
2015-01-06 13:39 ` Leif Lindholm
2015-01-06 13:39 ` Leif Lindholm
[not found] ` <1420482835-6444-1-git-send-email-leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-05 18:33 ` [PATCH 2/2] arm64: call early_ioremap_reset() in paging_init() Leif Lindholm
2015-01-05 18:33 ` Leif Lindholm
[not found] ` <1420482835-6444-3-git-send-email-leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-06 9:39 ` Ard Biesheuvel
2015-01-06 9:39 ` Ard Biesheuvel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.