Skip to content

Commit 6b8cb66

Browse files
chleroympe
authored andcommitted
powerpc: Fix usage of _PAGE_RO in hugepage
On some CPUs like the 8xx, _PAGE_RW hence _PAGE_WRITE is defined as 0 and _PAGE_RO has to be set when a page is not writable _PAGE_RO is defined by default in pte-common.h, however BOOK3S/64 doesn't include that file so _PAGE_RO has to be defined explicitly in book3s/64/pgtable.h Fixes: a7b9f67 ("powerpc32: adds handling of _PAGE_RO") Signed-off-by: Christophe Leroy <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent af2e3a0 commit 6b8cb66

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
#define _PAGE_BIT_SWAP_TYPE 0
88

9+
#define _PAGE_RO 0
10+
911
#define _PAGE_EXEC 0x00001 /* execute permission */
1012
#define _PAGE_WRITE 0x00002 /* write access allowed */
1113
#define _PAGE_READ 0x00004 /* read access allowed */

arch/powerpc/mm/hugetlbpage.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,15 @@ int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
10191019

10201020
pte = READ_ONCE(*ptep);
10211021
mask = _PAGE_PRESENT | _PAGE_READ;
1022+
1023+
/*
1024+
* On some CPUs like the 8xx, _PAGE_RW hence _PAGE_WRITE is defined
1025+
* as 0 and _PAGE_RO has to be set when a page is not writable
1026+
*/
10221027
if (write)
10231028
mask |= _PAGE_WRITE;
1029+
else
1030+
mask |= _PAGE_RO;
10241031

10251032
if ((pte_val(pte) & mask) != mask)
10261033
return 0;

0 commit comments

Comments
 (0)