diff mbox

[1/2] arm64: mm: dump: fix shift warning

Message ID 1417782895-13657-2-git-send-email-mark.rutland@arm.com
State New
Headers show

Commit Message

Mark Rutland Dec. 5, 2014, 12:34 p.m. UTC
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(-)

Comments

Steve Capper Dec. 5, 2014, 1:39 p.m. UTC | #1
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>
Mark Rutland Dec. 5, 2014, 1:42 p.m. UTC | #2
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.
diff mbox

Patch

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;