Skip to content

Commit f5ea64d

Browse files
dgibsonozbenh
authored andcommitted
powerpc: Get USE_STRICT_MM_TYPECHECKS working again
The typesafe version of the powerpc pagetable handling (with USE_STRICT_MM_TYPECHECKS defined) has bitrotted again. This patch makes a bunch of small fixes to get it back to building status. It's still not enabled by default as gcc still generates worse code with it for some reason. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent cd301c7 commit f5ea64d

6 files changed

Lines changed: 24 additions & 22 deletions

File tree

‎arch/powerpc/include/asm/mman.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
4444

4545
static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
4646
{
47-
return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : 0;
47+
return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
4848
}
4949
#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
5050

‎arch/powerpc/include/asm/pgtable-ppc32.h‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,11 @@ extern int icache_44x_need_flush;
431431
#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
432432

433433

434-
#define PAGE_PROT_BITS __pgprot(_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
435-
_PAGE_WRITETHRU | _PAGE_ENDIAN | \
436-
_PAGE_USER | _PAGE_ACCESSED | \
437-
_PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \
438-
_PAGE_EXEC | _PAGE_HWEXEC)
434+
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
435+
_PAGE_WRITETHRU | _PAGE_ENDIAN | \
436+
_PAGE_USER | _PAGE_ACCESSED | \
437+
_PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \
438+
_PAGE_EXEC | _PAGE_HWEXEC)
439439
/*
440440
* Note: the _PAGE_COHERENT bit automatically gets set in the hardware
441441
* PTE if CONFIG_SMP is defined (hash_page does this); there is no need
@@ -570,9 +570,9 @@ static inline pte_t pte_mkyoung(pte_t pte) {
570570
pte_val(pte) |= _PAGE_ACCESSED; return pte; }
571571
static inline pte_t pte_mkspecial(pte_t pte) {
572572
pte_val(pte) |= _PAGE_SPECIAL; return pte; }
573-
static inline unsigned long pte_pgprot(pte_t pte)
573+
static inline pgprot_t pte_pgprot(pte_t pte)
574574
{
575-
return __pgprot(pte_val(pte)) & PAGE_PROT_BITS;
575+
return __pgprot(pte_val(pte) & PAGE_PROT_BITS);
576576
}
577577

578578
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
@@ -688,7 +688,8 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
688688
: "=m" (*ptep), "=m" (*((unsigned char *)ptep+4))
689689
: "r" (pte) : "memory");
690690
#else
691-
*ptep = (*ptep & _PAGE_HASHPTE) | (pte & ~_PAGE_HASHPTE);
691+
*ptep = __pte((pte_val(*ptep) & _PAGE_HASHPTE)
692+
| (pte_val(pte) & ~_PAGE_HASHPTE));
692693
#endif
693694
}
694695

‎arch/powerpc/include/asm/pgtable-ppc64.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@
117117
#define PAGE_AGP __pgprot(_PAGE_BASE | _PAGE_WRENABLE | _PAGE_NO_CACHE)
118118
#define HAVE_PAGE_AGP
119119

120-
#define PAGE_PROT_BITS __pgprot(_PAGE_GUARDED | _PAGE_COHERENT | \
121-
_PAGE_NO_CACHE | _PAGE_WRITETHRU | \
122-
_PAGE_4K_PFN | _PAGE_RW | _PAGE_USER | \
123-
_PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_EXEC)
120+
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | \
121+
_PAGE_NO_CACHE | _PAGE_WRITETHRU | \
122+
_PAGE_4K_PFN | _PAGE_RW | _PAGE_USER | \
123+
_PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_EXEC)
124124
/* PTEIDX nibble */
125125
#define _PTEIDX_SECONDARY 0x8
126126
#define _PTEIDX_GROUP_IX 0x7
@@ -264,9 +264,9 @@ static inline pte_t pte_mkhuge(pte_t pte) {
264264
return pte; }
265265
static inline pte_t pte_mkspecial(pte_t pte) {
266266
pte_val(pte) |= _PAGE_SPECIAL; return pte; }
267-
static inline unsigned long pte_pgprot(pte_t pte)
267+
static inline pgprot_t pte_pgprot(pte_t pte)
268268
{
269-
return __pgprot(pte_val(pte)) & PAGE_PROT_BITS;
269+
return __pgprot(pte_val(pte) & PAGE_PROT_BITS);
270270
}
271271

272272
/* Atomic PTE updates */

‎arch/powerpc/mm/gup.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
4141
page = pte_page(pte);
4242
if (!page_cache_get_speculative(page))
4343
return 0;
44-
if (unlikely(pte != *ptep)) {
44+
if (unlikely(pte_val(pte) != pte_val(*ptep))) {
4545
put_page(page);
4646
return 0;
4747
}
@@ -92,7 +92,7 @@ static noinline int gup_huge_pte(pte_t *ptep, struct hstate *hstate,
9292
*nr -= refs;
9393
return 0;
9494
}
95-
if (unlikely(pte != *ptep)) {
95+
if (unlikely(pte_val(pte) != pte_val(*ptep))) {
9696
/* Could be optimized better */
9797
while (*nr) {
9898
put_page(page);
@@ -237,7 +237,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
237237
pgd_t pgd = *pgdp;
238238

239239
VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, addr)].shift);
240-
pr_debug(" %016lx: normal pgd %p\n", addr, (void *)pgd);
240+
pr_debug(" %016lx: normal pgd %p\n", addr,
241+
(void *)pgd_val(pgd));
241242
next = pgd_addr_end(addr, end);
242243
if (pgd_none(pgd))
243244
goto slow;

‎arch/powerpc/mm/hash_utils_64.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static unsigned long __init htab_get_table_size(void)
541541
void create_section_mapping(unsigned long start, unsigned long end)
542542
{
543543
BUG_ON(htab_bolt_mapping(start, end, __pa(start),
544-
PAGE_KERNEL, mmu_linear_psize,
544+
pgprot_val(PAGE_KERNEL), mmu_linear_psize,
545545
mmu_kernel_ssize));
546546
}
547547

@@ -649,7 +649,7 @@ void __init htab_initialize(void)
649649
mtspr(SPRN_SDR1, _SDR1);
650650
}
651651

652-
prot = PAGE_KERNEL;
652+
prot = pgprot_val(PAGE_KERNEL);
653653

654654
#ifdef CONFIG_DEBUG_PAGEALLOC
655655
linear_map_hash_count = lmb_end_of_DRAM() >> PAGE_SHIFT;

‎arch/powerpc/mm/init_64.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ int __meminit vmemmap_populate(struct page *start_page,
228228
start, p, __pa(p));
229229

230230
mapped = htab_bolt_mapping(start, start + page_size, __pa(p),
231-
PAGE_KERNEL, mmu_vmemmap_psize,
232-
mmu_kernel_ssize);
231+
pgprot_val(PAGE_KERNEL),
232+
mmu_vmemmap_psize, mmu_kernel_ssize);
233233
BUG_ON(mapped < 0);
234234
}
235235

0 commit comments

Comments
 (0)