Skip to content

Commit 3b1f7a4

Browse files
chleroympe
authored andcommitted
powerpc/mm: Fix return type of pgd_val()
Commit 6b0e827 ("powerpc/e500: switch to 64 bits PGD on 85xx (32 bits)") switched PGD entries to 64 bits, but pgd_val() returns an unsigned long which is 32 bits on PPC32. This is not a problem for regular PMD entries because the upper part is always NULL, but when PMD entries are leaf they contain 64 bits values, so pgd_val() must return an unsigned long long instead of an unsigned long. Also change the condition to CONFIG_PPC_85xx instead of CONFIG_PPC_E500 as the change was meant for 32 bits only. Allthough this should be harmless on PPC64, it generates a warning with pgd_ERROR print. Fixes: 6b0e827 ("powerpc/e500: switch to 64 bits PGD on 85xx (32 bits)") Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/45f8fdf298ec3df7573b66d21b03a5cda92e2cb1.1724313510.git.christophe.leroy@csgroup.eu
1 parent 6114139 commit 3b1f7a4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

arch/powerpc/include/asm/nohash/32/pgtable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
5353

5454
#define pgd_ERROR(e) \
55-
pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
55+
pr_err("%s:%d: bad pgd %08llx.\n", __FILE__, __LINE__, (unsigned long long)pgd_val(e))
5656

5757
/*
5858
* This is the bottom of the PKMAP area with HIGHMEM or an arbitrary
@@ -170,7 +170,7 @@ static inline void pmd_clear(pmd_t *pmdp)
170170
#define pmd_pfn(pmd) (pmd_val(pmd) >> PAGE_SHIFT)
171171
#else
172172
#define pmd_page_vaddr(pmd) \
173-
((const void *)(pmd_val(pmd) & ~(PTE_TABLE_SIZE - 1)))
173+
((const void *)((unsigned long)pmd_val(pmd) & ~(PTE_TABLE_SIZE - 1)))
174174
#define pmd_pfn(pmd) (__pa(pmd_val(pmd)) >> PAGE_SHIFT)
175175
#endif
176176

arch/powerpc/include/asm/pgtable-types.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,22 @@ static inline unsigned long pud_val(pud_t x)
4949
#endif /* CONFIG_PPC64 */
5050

5151
/* PGD level */
52-
#if defined(CONFIG_PPC_E500) && defined(CONFIG_PTE_64BIT)
52+
#if defined(CONFIG_PPC_85xx) && defined(CONFIG_PTE_64BIT)
5353
typedef struct { unsigned long long pgd; } pgd_t;
54+
55+
static inline unsigned long long pgd_val(pgd_t x)
56+
{
57+
return x.pgd;
58+
}
5459
#else
5560
typedef struct { unsigned long pgd; } pgd_t;
56-
#endif
57-
#define __pgd(x) ((pgd_t) { (x) })
61+
5862
static inline unsigned long pgd_val(pgd_t x)
5963
{
6064
return x.pgd;
6165
}
66+
#endif
67+
#define __pgd(x) ((pgd_t) { (x) })
6268

6369
/* Page protection bits */
6470
typedef struct { unsigned long pgprot; } pgprot_t;

0 commit comments

Comments
 (0)