* Patch "arm64: mm: use correct mapping granularity under DEBUG_RODATA" has been added to the 4.1-stable tree
@ 2016-01-27 6:54 gregkh
2016-01-28 8:18 ` Ard Biesheuvel
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2016-01-27 6:54 UTC (permalink / raw)
To: ard.biesheuvel; +Cc: stable, stable-commits
This is a note to let you know that I've just added the patch titled
arm64: mm: use correct mapping granularity under DEBUG_RODATA
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm64-mm-use-correct-mapping-granularity-under-debug_rodata.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From 4fee9f364b9b99f76732f2a6fd6df679a237fa74 Mon Sep 17 00:00:00 2001
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Date: Mon, 16 Nov 2015 11:18:14 +0100
Subject: arm64: mm: use correct mapping granularity under DEBUG_RODATA
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
commit 4fee9f364b9b99f76732f2a6fd6df679a237fa74 upstream.
When booting a 64k pages kernel that is built with CONFIG_DEBUG_RODATA
and resides at an offset that is not a multiple of 512 MB, the rounding
that occurs in __map_memblock() and fixup_executable() results in
incorrect regions being mapped.
The following snippet from /sys/kernel/debug/kernel_page_tables shows
how, when the kernel is loaded 2 MB above the base of DRAM at 0x40000000,
the first 2 MB of memory (which may be inaccessible from non-secure EL1
or just reserved by the firmware) is inadvertently mapped into the end of
the module region.
---[ Modules start ]---
0xfffffdffffe00000-0xfffffe0000000000 2M RW NX ... UXN MEM/NORMAL
---[ Modules end ]---
---[ Kernel Mapping ]---
0xfffffe0000000000-0xfffffe0000090000 576K RW NX ... UXN MEM/NORMAL
0xfffffe0000090000-0xfffffe0000200000 1472K ro x ... UXN MEM/NORMAL
0xfffffe0000200000-0xfffffe0000800000 6M ro x ... UXN MEM/NORMAL
0xfffffe0000800000-0xfffffe0000810000 64K ro x ... UXN MEM/NORMAL
0xfffffe0000810000-0xfffffe0000a00000 1984K RW NX ... UXN MEM/NORMAL
0xfffffe0000a00000-0xfffffe00ffe00000 4084M RW NX ... UXN MEM/NORMAL
The same issue is likely to occur on 16k pages kernels whose load
address is not a multiple of 32 MB (i.e., SECTION_SIZE). So round to
SWAPPER_BLOCK_SIZE instead of SECTION_SIZE.
Fixes: da141706aea5 ("arm64: add better page protections to arm64")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/mm/mmu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -307,8 +307,8 @@ static void __init __map_memblock(phys_a
* for now. This will get more fine grained later once all memory
* is mapped
*/
- unsigned long kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
- unsigned long kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
+ unsigned long kernel_x_start = round_down(__pa(_stext), SWAPPER_BLOCK_SIZE);
+ unsigned long kernel_x_end = round_up(__pa(__init_end), SWAPPER_BLOCK_SIZE);
if (end < kernel_x_start) {
create_mapping(start, __phys_to_virt(start),
@@ -396,18 +396,18 @@ void __init fixup_executable(void)
{
#ifdef CONFIG_DEBUG_RODATA
/* now that we are actually fully mapped, make the start/end more fine grained */
- if (!IS_ALIGNED((unsigned long)_stext, SECTION_SIZE)) {
+ if (!IS_ALIGNED((unsigned long)_stext, SWAPPER_BLOCK_SIZE)) {
unsigned long aligned_start = round_down(__pa(_stext),
- SECTION_SIZE);
+ SWAPPER_BLOCK_SIZE);
create_mapping(aligned_start, __phys_to_virt(aligned_start),
__pa(_stext) - aligned_start,
PAGE_KERNEL);
}
- if (!IS_ALIGNED((unsigned long)__init_end, SECTION_SIZE)) {
+ if (!IS_ALIGNED((unsigned long)__init_end, SWAPPER_BLOCK_SIZE)) {
unsigned long aligned_end = round_up(__pa(__init_end),
- SECTION_SIZE);
+ SWAPPER_BLOCK_SIZE);
create_mapping(__pa(__init_end), (unsigned long)__init_end,
aligned_end - __pa(__init_end),
PAGE_KERNEL);
Patches currently in stable-queue which might be from ard.biesheuvel@linaro.org are
queue-4.1/arm-arm64-kvm-test-properly-for-a-pte-s-uncachedness.patch
queue-4.1/arm64-mm-use-correct-mapping-granularity-under-debug_rodata.patch
queue-4.1/arm-arm64-kvm-correct-pte-uncachedness-check.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch "arm64: mm: use correct mapping granularity under DEBUG_RODATA" has been added to the 4.1-stable tree
2016-01-27 6:54 Patch "arm64: mm: use correct mapping granularity under DEBUG_RODATA" has been added to the 4.1-stable tree gregkh
@ 2016-01-28 8:18 ` Ard Biesheuvel
2016-01-31 19:22 ` gregkh
0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2016-01-28 8:18 UTC (permalink / raw)
To: gregkh; +Cc: stable, stable-commits
On 27 January 2016 at 07:54, <gregkh@linuxfoundation.org> wrote:
>
> This is a note to let you know that I've just added the patch titled
>
> arm64: mm: use correct mapping granularity under DEBUG_RODATA
>
> to the 4.1-stable tree which can be found at:
> http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
>
> The filename of the patch is:
> arm64-mm-use-correct-mapping-granularity-under-debug_rodata.patch
> and it can be found in the queue-4.1 subdirectory.
>
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.
>
Apologies for the late notice: as mentioned in the other thread, this
will fail to build due to a missing #define of SWAPPER_BLOCK_SIZE. I
will submit a new version specific to -stable (which just adds the
#define locally)
Thanks,
Ard.
>
> From 4fee9f364b9b99f76732f2a6fd6df679a237fa74 Mon Sep 17 00:00:00 2001
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Date: Mon, 16 Nov 2015 11:18:14 +0100
> Subject: arm64: mm: use correct mapping granularity under DEBUG_RODATA
>
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> commit 4fee9f364b9b99f76732f2a6fd6df679a237fa74 upstream.
>
> When booting a 64k pages kernel that is built with CONFIG_DEBUG_RODATA
> and resides at an offset that is not a multiple of 512 MB, the rounding
> that occurs in __map_memblock() and fixup_executable() results in
> incorrect regions being mapped.
>
> The following snippet from /sys/kernel/debug/kernel_page_tables shows
> how, when the kernel is loaded 2 MB above the base of DRAM at 0x40000000,
> the first 2 MB of memory (which may be inaccessible from non-secure EL1
> or just reserved by the firmware) is inadvertently mapped into the end of
> the module region.
>
> ---[ Modules start ]---
> 0xfffffdffffe00000-0xfffffe0000000000 2M RW NX ... UXN MEM/NORMAL
> ---[ Modules end ]---
> ---[ Kernel Mapping ]---
> 0xfffffe0000000000-0xfffffe0000090000 576K RW NX ... UXN MEM/NORMAL
> 0xfffffe0000090000-0xfffffe0000200000 1472K ro x ... UXN MEM/NORMAL
> 0xfffffe0000200000-0xfffffe0000800000 6M ro x ... UXN MEM/NORMAL
> 0xfffffe0000800000-0xfffffe0000810000 64K ro x ... UXN MEM/NORMAL
> 0xfffffe0000810000-0xfffffe0000a00000 1984K RW NX ... UXN MEM/NORMAL
> 0xfffffe0000a00000-0xfffffe00ffe00000 4084M RW NX ... UXN MEM/NORMAL
>
> The same issue is likely to occur on 16k pages kernels whose load
> address is not a multiple of 32 MB (i.e., SECTION_SIZE). So round to
> SWAPPER_BLOCK_SIZE instead of SECTION_SIZE.
>
> Fixes: da141706aea5 ("arm64: add better page protections to arm64")
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> Acked-by: Laura Abbott <labbott@redhat.com>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> ---
> arch/arm64/mm/mmu.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -307,8 +307,8 @@ static void __init __map_memblock(phys_a
> * for now. This will get more fine grained later once all memory
> * is mapped
> */
> - unsigned long kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
> - unsigned long kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
> + unsigned long kernel_x_start = round_down(__pa(_stext), SWAPPER_BLOCK_SIZE);
> + unsigned long kernel_x_end = round_up(__pa(__init_end), SWAPPER_BLOCK_SIZE);
>
> if (end < kernel_x_start) {
> create_mapping(start, __phys_to_virt(start),
> @@ -396,18 +396,18 @@ void __init fixup_executable(void)
> {
> #ifdef CONFIG_DEBUG_RODATA
> /* now that we are actually fully mapped, make the start/end more fine grained */
> - if (!IS_ALIGNED((unsigned long)_stext, SECTION_SIZE)) {
> + if (!IS_ALIGNED((unsigned long)_stext, SWAPPER_BLOCK_SIZE)) {
> unsigned long aligned_start = round_down(__pa(_stext),
> - SECTION_SIZE);
> + SWAPPER_BLOCK_SIZE);
>
> create_mapping(aligned_start, __phys_to_virt(aligned_start),
> __pa(_stext) - aligned_start,
> PAGE_KERNEL);
> }
>
> - if (!IS_ALIGNED((unsigned long)__init_end, SECTION_SIZE)) {
> + if (!IS_ALIGNED((unsigned long)__init_end, SWAPPER_BLOCK_SIZE)) {
> unsigned long aligned_end = round_up(__pa(__init_end),
> - SECTION_SIZE);
> + SWAPPER_BLOCK_SIZE);
> create_mapping(__pa(__init_end), (unsigned long)__init_end,
> aligned_end - __pa(__init_end),
> PAGE_KERNEL);
>
>
> Patches currently in stable-queue which might be from ard.biesheuvel@linaro.org are
>
> queue-4.1/arm-arm64-kvm-test-properly-for-a-pte-s-uncachedness.patch
> queue-4.1/arm64-mm-use-correct-mapping-granularity-under-debug_rodata.patch
> queue-4.1/arm-arm64-kvm-correct-pte-uncachedness-check.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch "arm64: mm: use correct mapping granularity under DEBUG_RODATA" has been added to the 4.1-stable tree
2016-01-28 8:18 ` Ard Biesheuvel
@ 2016-01-31 19:22 ` gregkh
0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2016-01-31 19:22 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: stable, stable-commits
On Thu, Jan 28, 2016 at 09:18:26AM +0100, Ard Biesheuvel wrote:
> On 27 January 2016 at 07:54, <gregkh@linuxfoundation.org> wrote:
> >
> > This is a note to let you know that I've just added the patch titled
> >
> > arm64: mm: use correct mapping granularity under DEBUG_RODATA
> >
> > to the 4.1-stable tree which can be found at:
> > http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> >
> > The filename of the patch is:
> > arm64-mm-use-correct-mapping-granularity-under-debug_rodata.patch
> > and it can be found in the queue-4.1 subdirectory.
> >
> > If you, or anyone else, feels it should not be added to the stable tree,
> > please let <stable@vger.kernel.org> know about it.
> >
>
> Apologies for the late notice: as mentioned in the other thread, this
> will fail to build due to a missing #define of SWAPPER_BLOCK_SIZE. I
> will submit a new version specific to -stable (which just adds the
> #define locally)
Now dropped, and I'll pick this up for the next round of kernels.
thanks,
greg k-h-
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-31 19:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-27 6:54 Patch "arm64: mm: use correct mapping granularity under DEBUG_RODATA" has been added to the 4.1-stable tree gregkh
2016-01-28 8:18 ` Ard Biesheuvel
2016-01-31 19:22 ` gregkh
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.