* [PATCH 1/2] arm64: mm: dump: fix shift warning
2014-12-05 12:34 [PATCH 0/2] arm64: mm: dump: a couple of fixes Mark Rutland
@ 2014-12-05 12:34 ` Mark Rutland
2014-12-05 13:39 ` Steve Capper
2014-12-05 12:34 ` [PATCH 2/2] arm64: mm: dump: don't skip final region Mark Rutland
2014-12-10 17:56 ` [PATCH 0/2] arm64: mm: dump: a couple of fixes Laura Abbott
2 siblings, 1 reply; 8+ messages in thread
From: Mark Rutland @ 2014-12-05 12:34 UTC (permalink / raw)
To: linux-arm-kernel
When building with 48-bit VAs, it's possible to get the following
warning when building the arm64 page table dumping code:
arch/arm64/mm/dump.c: In function ?walk_pgd?:
arch/arm64/mm/dump.c:266:2: warning: right shift count >= width of type
pgd_t *pgd = pgd_offset(mm, 0);
^
As pgd_offset is a macro and the second argument is not cast to any
particular type, the zero will be given integer type by the compiler.
As pgd_offset passes the pargument to pgd_index, we then try to shift
the 32-bit integer by at least 39 bits (for 4k pages).
Elsewhere the pgd_offset is passed a second argument of unsigned long
type, so let's do the same here by passing '0UL' rather than '0'.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Steve Capper <steve.capper@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/mm/dump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
index bf69601..a546776 100644
--- a/arch/arm64/mm/dump.c
+++ b/arch/arm64/mm/dump.c
@@ -272,7 +272,7 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)
static void walk_pgd(struct pg_state *st, struct mm_struct *mm, unsigned long start)
{
- pgd_t *pgd = pgd_offset(mm, 0);
+ pgd_t *pgd = pgd_offset(mm, 0UL);
unsigned i;
unsigned long addr;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/2] arm64: mm: dump: fix shift warning
2014-12-05 12:34 ` [PATCH 1/2] arm64: mm: dump: fix shift warning Mark Rutland
@ 2014-12-05 13:39 ` Steve Capper
2014-12-05 13:42 ` Mark Rutland
0 siblings, 1 reply; 8+ messages in thread
From: Steve Capper @ 2014-12-05 13:39 UTC (permalink / raw)
To: linux-arm-kernel
On 5 December 2014 at 12:34, Mark Rutland <mark.rutland@arm.com> wrote:
> When building with 48-bit VAs, it's possible to get the following
> warning when building the arm64 page table dumping code:
>
> arch/arm64/mm/dump.c: In function ?walk_pgd?:
> arch/arm64/mm/dump.c:266:2: warning: right shift count >= width of type
> pgd_t *pgd = pgd_offset(mm, 0);
> ^
>
> As pgd_offset is a macro and the second argument is not cast to any
> particular type, the zero will be given integer type by the compiler.
> As pgd_offset passes the pargument to pgd_index, we then try to shift
> the 32-bit integer by at least 39 bits (for 4k pages).
>
> Elsewhere the pgd_offset is passed a second argument of unsigned long
> type, so let's do the same here by passing '0UL' rather than '0'.
>
Hi Mark,
Thanks, I must not have spotted that warning earlier.
Acked-by: Steve Capper <steve.capper@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] arm64: mm: dump: fix shift warning
2014-12-05 13:39 ` Steve Capper
@ 2014-12-05 13:42 ` Mark Rutland
0 siblings, 0 replies; 8+ messages in thread
From: Mark Rutland @ 2014-12-05 13:42 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Dec 05, 2014 at 01:39:56PM +0000, Steve Capper wrote:
> On 5 December 2014 at 12:34, Mark Rutland <mark.rutland@arm.com> wrote:
> > When building with 48-bit VAs, it's possible to get the following
> > warning when building the arm64 page table dumping code:
> >
> > arch/arm64/mm/dump.c: In function ?walk_pgd?:
> > arch/arm64/mm/dump.c:266:2: warning: right shift count >= width of type
> > pgd_t *pgd = pgd_offset(mm, 0);
> > ^
> >
> > As pgd_offset is a macro and the second argument is not cast to any
> > particular type, the zero will be given integer type by the compiler.
> > As pgd_offset passes the pargument to pgd_index, we then try to shift
> > the 32-bit integer by at least 39 bits (for 4k pages).
> >
> > Elsewhere the pgd_offset is passed a second argument of unsigned long
> > type, so let's do the same here by passing '0UL' rather than '0'.
> >
>
> Hi Mark,
> Thanks, I must not have spotted that warning earlier.
Me neither, I'd tested on this configuration but somehow missed the
build warning.
> Acked-by: Steve Capper <steve.capper@linaro.org>
Cheers!
Mark.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] arm64: mm: dump: don't skip final region
2014-12-05 12:34 [PATCH 0/2] arm64: mm: dump: a couple of fixes Mark Rutland
2014-12-05 12:34 ` [PATCH 1/2] arm64: mm: dump: fix shift warning Mark Rutland
@ 2014-12-05 12:34 ` Mark Rutland
2014-12-05 16:08 ` Steve Capper
2014-12-10 17:56 ` [PATCH 0/2] arm64: mm: dump: a couple of fixes Laura Abbott
2 siblings, 1 reply; 8+ messages in thread
From: Mark Rutland @ 2014-12-05 12:34 UTC (permalink / raw)
To: linux-arm-kernel
If the final page table entry we walk is a valid mapping, the page table
dumping code will not log the region this entry is part of, as the final
note_page call in ptdump_show will trigger an early return. Luckily this
isn't seen on contemporary systems as they typically don't have enough
RAM to extend the linear mapping right to the end of the address space.
In note_page, we log a region when we reach its end (i.e. we hit an
entry immediately afterwards which has different prot bits or is
invalid). The final entry has no subsequent entry, so we will not log
this immediately. We try to cater for this with a subsequent call to
note_page in ptdump_show, but this returns early as 0 < LOWEST_ADDR, and
hence we will skip a valid mapping if it spans to the final entry we
note.
Unlike 32-bit ARM, the pgd with the kernel mapping is never shared with
user mappings, so we do not need the check to ensure we don't log user
page tables. Due to the way addr is constructed in the walk_* functions,
it can never be less than LOWEST_ADDR when walking the page tables, so
it is not necessary to avoid dereferencing invalid table addresses. The
existing checks for st->current_prot and st->marker[1].start_address are
sufficient to ensure we will not print and/or dereference garbage when
trying to log information.
This patch removes the unnecessary check against LOWEST_ADDR, ensuring
we log all regions in the kernel page table, including those which span
right to the end of the address space.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
---
arch/arm64/mm/dump.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
index a546776..cf33f33 100644
--- a/arch/arm64/mm/dump.c
+++ b/arch/arm64/mm/dump.c
@@ -182,9 +182,6 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
static const char units[] = "KMGTPE";
u64 prot = val & pg_level[level].mask;
- if (addr < LOWEST_ADDR)
- return;
-
if (!st->level) {
st->level = level;
st->current_prot = prot;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] arm64: mm: dump: don't skip final region
2014-12-05 12:34 ` [PATCH 2/2] arm64: mm: dump: don't skip final region Mark Rutland
@ 2014-12-05 16:08 ` Steve Capper
0 siblings, 0 replies; 8+ messages in thread
From: Steve Capper @ 2014-12-05 16:08 UTC (permalink / raw)
To: linux-arm-kernel
On 5 December 2014 at 12:34, Mark Rutland <mark.rutland@arm.com> wrote:
> If the final page table entry we walk is a valid mapping, the page table
> dumping code will not log the region this entry is part of, as the final
> note_page call in ptdump_show will trigger an early return. Luckily this
> isn't seen on contemporary systems as they typically don't have enough
> RAM to extend the linear mapping right to the end of the address space.
>
> In note_page, we log a region when we reach its end (i.e. we hit an
> entry immediately afterwards which has different prot bits or is
> invalid). The final entry has no subsequent entry, so we will not log
> this immediately. We try to cater for this with a subsequent call to
> note_page in ptdump_show, but this returns early as 0 < LOWEST_ADDR, and
> hence we will skip a valid mapping if it spans to the final entry we
> note.
>
> Unlike 32-bit ARM, the pgd with the kernel mapping is never shared with
> user mappings, so we do not need the check to ensure we don't log user
> page tables. Due to the way addr is constructed in the walk_* functions,
> it can never be less than LOWEST_ADDR when walking the page tables, so
> it is not necessary to avoid dereferencing invalid table addresses. The
> existing checks for st->current_prot and st->marker[1].start_address are
> sufficient to ensure we will not print and/or dereference garbage when
> trying to log information.
>
> This patch removes the unnecessary check against LOWEST_ADDR, ensuring
> we log all regions in the kernel page table, including those which span
> right to the end of the address space.
>
Acked-by: Steve Capper <steve.capper@linaro.org>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Laura Abbott <lauraa@codeaurora.org>
> Cc: Steve Capper <steve.capper@linaro.org>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm64/mm/dump.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
> index a546776..cf33f33 100644
> --- a/arch/arm64/mm/dump.c
> +++ b/arch/arm64/mm/dump.c
> @@ -182,9 +182,6 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
> static const char units[] = "KMGTPE";
> u64 prot = val & pg_level[level].mask;
>
> - if (addr < LOWEST_ADDR)
> - return;
> -
> if (!st->level) {
> st->level = level;
> st->current_prot = prot;
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/2] arm64: mm: dump: a couple of fixes
2014-12-05 12:34 [PATCH 0/2] arm64: mm: dump: a couple of fixes Mark Rutland
2014-12-05 12:34 ` [PATCH 1/2] arm64: mm: dump: fix shift warning Mark Rutland
2014-12-05 12:34 ` [PATCH 2/2] arm64: mm: dump: don't skip final region Mark Rutland
@ 2014-12-10 17:56 ` Laura Abbott
2014-12-11 18:20 ` Mark Rutland
2 siblings, 1 reply; 8+ messages in thread
From: Laura Abbott @ 2014-12-10 17:56 UTC (permalink / raw)
To: linux-arm-kernel
On 12/5/2014 4:34 AM, Mark Rutland wrote:
> While using the mm dump code, I spotted a couple of issues; one build warning
> and one theoretical failure on systems endowed with plenty of RAM (as with ARM
> [1], though arm64 requires a slightly different resolution). These patches
> (based on next-20141205), fix those issues.
>
> Mark.
>
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/308952.html
>
> Mark Rutland (2):
> arm64: mm: dump: fix shift warning
> arm64: mm: dump: don't skip final region
>
> arch/arm64/mm/dump.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
If they haven't been picked up yet:
Acked-by: Laura Abbott <lauraa@codeaurora.org>
--
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/2] arm64: mm: dump: a couple of fixes
2014-12-10 17:56 ` [PATCH 0/2] arm64: mm: dump: a couple of fixes Laura Abbott
@ 2014-12-11 18:20 ` Mark Rutland
0 siblings, 0 replies; 8+ messages in thread
From: Mark Rutland @ 2014-12-11 18:20 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Dec 10, 2014 at 05:56:13PM +0000, Laura Abbott wrote:
> On 12/5/2014 4:34 AM, Mark Rutland wrote:
> > While using the mm dump code, I spotted a couple of issues; one build warning
> > and one theoretical failure on systems endowed with plenty of RAM (as with ARM
> > [1], though arm64 requires a slightly different resolution). These patches
> > (based on next-20141205), fix those issues.
> >
> > Mark.
> >
> > [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/308952.html
> >
> > Mark Rutland (2):
> > arm64: mm: dump: fix shift warning
> > arm64: mm: dump: don't skip final region
> >
> > arch/arm64/mm/dump.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
>
> If they haven't been picked up yet:
>
> Acked-by: Laura Abbott <lauraa@codeaurora.org>
Thanks!
Mark.
^ permalink raw reply [flat|nested] 8+ messages in thread