powerpc: Add set_memory_{p/np}() and remove set_memory_attr()
commit f222ab83df92acf72691a2021e1f0d99880dcdf1 upstream. set_memory_attr() was implemented by commit4d1755b6a7("powerpc/mm: implement set_memory_attr()") because the set_memory_xx() couldn't be used at that time to modify memory "on the fly" as explained it the commit. But set_memory_attr() uses set_pte_at() which leads to warnings when CONFIG_DEBUG_VM is selected, because set_pte_at() is unexpected for updating existing page table entries. The check could be bypassed by using __set_pte_at() instead, as it was the case before commitc988cfd38e("powerpc/32: use set_memory_attr()") but since commit9f7853d760("powerpc/mm: Fix set_memory_*() against concurrent accesses") it is now possible to use set_memory_xx() functions to update page table entries "on the fly" because the update is now atomic. For DEBUG_PAGEALLOC we need to clear and set back _PAGE_PRESENT. Add set_memory_np() and set_memory_p() for that. Replace all uses of set_memory_attr() by the relevant set_memory_xx() and remove set_memory_attr(). Fixes:c988cfd38e("powerpc/32: use set_memory_attr()") Cc: stable@vger.kernel.org Reported-by: Maxime Bizon <mbizon@freebox.fr> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Tested-by: Maxime Bizon <mbizon@freebox.fr> Reviewed-by: Russell Currey <ruscur@russell.cc> Depends-on:9f7853d760("powerpc/mm: Fix set_memory_*() against concurrent accesses") Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/cda2b44b55c96f9ac69fa92e68c01084ec9495c5.1640344012.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a29341e486
commit
f4b0b5a0f3
@@ -6,6 +6,8 @@
|
||||
#define SET_MEMORY_RW 1
|
||||
#define SET_MEMORY_NX 2
|
||||
#define SET_MEMORY_X 3
|
||||
#define SET_MEMORY_NP 4 /* Set memory non present */
|
||||
#define SET_MEMORY_P 5 /* Set memory present */
|
||||
|
||||
int change_memory_attr(unsigned long addr, int numpages, long action);
|
||||
|
||||
@@ -29,6 +31,14 @@ static inline int set_memory_x(unsigned long addr, int numpages)
|
||||
return change_memory_attr(addr, numpages, SET_MEMORY_X);
|
||||
}
|
||||
|
||||
int set_memory_attr(unsigned long addr, int numpages, pgprot_t prot);
|
||||
static inline int set_memory_np(unsigned long addr, int numpages)
|
||||
{
|
||||
return change_memory_attr(addr, numpages, SET_MEMORY_NP);
|
||||
}
|
||||
|
||||
static inline int set_memory_p(unsigned long addr, int numpages)
|
||||
{
|
||||
return change_memory_attr(addr, numpages, SET_MEMORY_P);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user