Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: a7b9f671f2d14 ("powerpc32: adds handling of _PAGE_RO")
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Christophe Leroy and committed by
Michael Ellerman
6b8cb66a af2e3a00

+9
+2
arch/powerpc/include/asm/book3s/64/pgtable.h
··· 6 6 */ 7 7 #define _PAGE_BIT_SWAP_TYPE 0 8 8 9 + #define _PAGE_RO 0 10 + 9 11 #define _PAGE_EXEC 0x00001 /* execute permission */ 10 12 #define _PAGE_WRITE 0x00002 /* write access allowed */ 11 13 #define _PAGE_READ 0x00004 /* read access allowed */
+7
arch/powerpc/mm/hugetlbpage.c
··· 1019 1019 1020 1020 pte = READ_ONCE(*ptep); 1021 1021 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 + */ 1022 1027 if (write) 1023 1028 mask |= _PAGE_WRITE; 1029 + else 1030 + mask |= _PAGE_RO; 1024 1031 1025 1032 if ((pte_val(pte) & mask) != mask) 1026 1033 return 0;