diff mbox

[v3] ARM: mm: report both sections from PMD

Message ID 20140213195230.GA15275@www.outflux.net (mailing list archive)
State New, archived
Headers show

Commit Message

Kees Cook Feb. 13, 2014, 7:52 p.m. UTC
On 2-level page table systems, the PMD has 2 section entries. Report
these, otherwise ARM_PTDUMP will miss reporting permission changes on
odd section boundaries.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
v3:
 - re-reorganize, drop use of pmd_sect; suggested by Catalin Marinas.
v2:
 - reorganize, suggested by Catalin Marinas.
---
 arch/arm/mm/dump.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Catalin Marinas Feb. 14, 2014, 10:17 a.m. UTC | #1
On Thu, Feb 13, 2014 at 07:52:30PM +0000, Kees Cook wrote:
> On 2-level page table systems, the PMD has 2 section entries. Report
> these, otherwise ARM_PTDUMP will miss reporting permission changes on
> odd section boundaries.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Steve Capper Feb. 14, 2014, 5:05 p.m. UTC | #2
On Thu, Feb 13, 2014 at 11:52:30AM -0800, Kees Cook wrote:
> On 2-level page table systems, the PMD has 2 section entries. Report
> these, otherwise ARM_PTDUMP will miss reporting permission changes on
> odd section boundaries.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> v3:
>  - re-reorganize, drop use of pmd_sect; suggested by Catalin Marinas.
> v2:
>  - reorganize, suggested by Catalin Marinas.
> ---
>  arch/arm/mm/dump.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index 2b342177f5de..61cc78ae9f21 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -264,6 +264,9 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
>  			note_page(st, addr, 3, pmd_val(*pmd));
>  		else
>  			walk_pte(st, pmd, addr);
> +
> +		if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1]))
> +			note_page(st, addr + SECTION_SIZE, 3, pmd_val(pmd[1]));
>  	}
>  }
>  
> -- 
> 1.7.9.5

This picks up an odd megabyte aligned section on my Arndale board with
short descriptors on 3.14-rc2. Behaves as expected with long descriptors
too (does nothing).

FWIW:
Tested-by: Steve Capper <steve.capper@linaro.org>

Cheers,
Kees Cook Feb. 14, 2014, 7:13 p.m. UTC | #3
On Fri, Feb 14, 2014 at 2:17 AM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Thu, Feb 13, 2014 at 07:52:30PM +0000, Kees Cook wrote:
>> On 2-level page table systems, the PMD has 2 section entries. Report
>> these, otherwise ARM_PTDUMP will miss reporting permission changes on
>> odd section boundaries.
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

On Fri, Feb 14, 2014 at 9:05 AM, Steve Capper <steve.capper@linaro.org> wrote:
> Tested-by: Steve Capper <steve.capper@linaro.org>

Thanks to both of you! If you have a moment can you check this other
patch which has additional fixes for the dump code?

https://lkml.org/lkml/2014/2/12/662

Thanks,

-Kees
Russell King - ARM Linux Feb. 14, 2014, 7:23 p.m. UTC | #4
On Fri, Feb 14, 2014 at 11:13:53AM -0800, Kees Cook wrote:
> On Fri, Feb 14, 2014 at 2:17 AM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Thu, Feb 13, 2014 at 07:52:30PM +0000, Kees Cook wrote:
> >> On 2-level page table systems, the PMD has 2 section entries. Report
> >> these, otherwise ARM_PTDUMP will miss reporting permission changes on
> >> odd section boundaries.
> >>
> >> Signed-off-by: Kees Cook <keescook@chromium.org>
> >
> > Acked-by: Catalin Marinas <catalin.marinas@arm.com>
> 
> On Fri, Feb 14, 2014 at 9:05 AM, Steve Capper <steve.capper@linaro.org> wrote:
> > Tested-by: Steve Capper <steve.capper@linaro.org>
> 
> Thanks to both of you! If you have a moment can you check this other
> patch which has additional fixes for the dump code?
> 
> https://lkml.org/lkml/2014/2/12/662

It's not that simple, because APX in section descriptors doesn't exist
on pre-v6 ARMs.  This needs to be conditional upon the CPU arch.
Kees Cook Feb. 14, 2014, 7:31 p.m. UTC | #5
On Fri, Feb 14, 2014 at 11:23 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
>> https://lkml.org/lkml/2014/2/12/662
>
> It's not that simple, because APX in section descriptors doesn't exist
> on pre-v6 ARMs.  This needs to be conditional upon the CPU arch.

Ah! Okay, do we need a single #define to describe the expected masks
and values? What should it look like for pre-v6 ARMs?

-Kees
diff mbox

Patch

diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 2b342177f5de..61cc78ae9f21 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -264,6 +264,9 @@  static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
 			note_page(st, addr, 3, pmd_val(*pmd));
 		else
 			walk_pte(st, pmd, addr);
+
+		if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1]))
+			note_page(st, addr + SECTION_SIZE, 3, pmd_val(pmd[1]));
 	}
 }