powerpc: fix ioremap_flags() with book3e pte definition
PATCH 1/1 powerpc: fix ioremap_flags() with book3e pte definition
We can't just clear the user read permission in book3e pte, because that will also clear supervisor read permission. This surely isn't desired. Fix the problem by adding the supervisor read back.
--- arch/powerpc/mm/pgtable_32.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
arch/powerpc/mm/pgtable_32.c +5 -0
@@ -144,6 +144,11 @@ ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags)/* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */ flags &= ~(_PAGE_USER | _PAGE_EXEC); +#if defined(CONFIG_FSL_BOOKE ) && defined(CONFIG_PTE_64BIT ) +/* supervisor read permission has just been cleared, add back */ + flags |= _PAGE_BAP_SR; +#endif +return __ioremap_caller (addr, size, flags,__builtin_return_address (0 )); }EXPORT_SYMBOL (ioremap_flags);
Signature · 1 line
1.6.6-rc1.GIT
Quoted 14 lines · Li Yang
We can't just clear the user read permission in book3e pte, because that will also clear supervisor read permission. This surely isn't desired. Fix the problem by adding the supervisor read back.
Signed-off-by Li Yang <[email protected]>--- arch/powerpc/mm/pgtable_32.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)arch/powerpc/mm/pgtable_32.c +0
-0
arch/powerpc/mm/pgtable_32.c ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags) · line 151
Quoted 8 lines
arch/powerpc/mm/pgtable_32.c +5
-0@@ -144,6 +144,11 @@ ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags)/* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */ flags &= ~(_PAGE_USER | _PAGE_EXEC); +#if defined(CONFIG_FSL_BOOKE ) && defined(CONFIG_PTE_64BIT ) +/* supervisor read permission has just been cleared, add back */ + flags |= _PAGE_BAP_SR; +#endif +
So this is a bit fishy indeed. pgtable_64.c seems to have the same problem in fact.
It boils down to the "hack" I have in the new PTE format which consists of having _SR be part of _PAGE_USER. I wonder if I should change that instead. Kumar, what do you reckon ?
_Maybe_ an option is to have _PAGE_NO_USER that defaults to be ~_PAGE_USER in pte-common.h and can be set in pte-book3e.h to only strip out UR and UW ?
Cheers,
Ben.
Quoted 11 lines · Benjamin Herrenschmidt
=
Quoted 10 lines · Li Yang
We can't just clear the user read permission in book3e pte, because that will also clear supervisor read permission. This surely isn't desired. Fix the problem by adding the supervisor read back. =20
Signed-off-by Li Yang <[email protected]>---
arch/powerpc/mm/pgtable_32.c| 5 +++++1 files changed, 5 insertions(+), 0 deletions(-)=20
= renamed from arch/powerpc/mm/pgtable_32.c +0
-0
b/arch/powerpc/mm/pgtable_32.c
Quoted 4 lines
arch/powerpc/mm/pgtable_32.c ioremap_flags(phys_addr_t addr, unsigned long =
Quoted 4 lines
index cb96cb2..aff7c04 100644
arch/powerpc/mm/pgtable_32.c +0
-0@@ -144,6 +144,11 @@ ioremap_flags(phys_addr_t addr, unsigned long =
size, unsigned long flags)
Quoted 5 lines
Quoted 5 lines
arch/powerpc/mm/pgtable_32.c +0
-0/* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */ flags &=3D ~(_PAGE_USER | _PAGE_EXEC);=20
arch/powerpc/mm/pgtable_32.c +2
-0+#if defined(CONFIG_FSL_BOOKE ) && defined(CONFIG_PTE_64BIT ) +/* supervisor read permission has just been cleared, add back */
Quoted 8 lines
arch/powerpc/mm/pgtable_32.c ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags) · line 151
Quoted 3 lines
arch/powerpc/mm/pgtable_32.c +3
-0+ flags |=3D _PAGE_BAP_SR; +#endif +=20
So this is a bit fishy indeed.pgtable_64.cseems to have the same problem in fact.
=20
It boils down to the "hack" I have in the new PTE format which =
consists
Quoted 6 lines
of having
_SRbe part of_PAGE_USER. I wonder if I should change that instead. Kumar, what do you reckon ?
=20
_Maybe_ an option is to have_PAGE_NO_USERthat defaults to be ~_PAGE_USER inpte-common.hand can be set inpte-book3e.hto only strip out UR and UW ?
We never closed on this. I think lets add _PAGE_NO_USER
- k=