Skip to content

Commit 09ca1b1

Browse files
chleroympe
authored andcommitted
powerpc: Implement set_memory_rox()
Same as x86 and s390, add set_memory_rox() to avoid doing one pass with set_memory_ro() and a second pass with set_memory_x(). See commit 6046362 ("x86/mm: Implement native set_memory_rox()") and commit 22e99fa ("s390/mm: implement set_memory_rox()") for more information. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/dc9a794f82ab62572d7d0be5cb4b8b27920a4f78.1708078316.git.christophe.leroy@csgroup.eu
1 parent d5835fb commit 09ca1b1

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

arch/powerpc/include/asm/set_memory.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define SET_MEMORY_X 3
99
#define SET_MEMORY_NP 4 /* Set memory non present */
1010
#define SET_MEMORY_P 5 /* Set memory present */
11+
#define SET_MEMORY_ROX 6
1112

1213
int change_memory_attr(unsigned long addr, int numpages, long action);
1314

@@ -41,4 +42,10 @@ static inline int set_memory_p(unsigned long addr, int numpages)
4142
return change_memory_attr(addr, numpages, SET_MEMORY_P);
4243
}
4344

45+
static inline int set_memory_rox(unsigned long addr, int numpages)
46+
{
47+
return change_memory_attr(addr, numpages, SET_MEMORY_ROX);
48+
}
49+
#define set_memory_rox set_memory_rox
50+
4451
#endif

arch/powerpc/mm/pageattr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ static int change_page_attr(pte_t *ptep, unsigned long addr, void *data)
3838
/* Don't clear DIRTY bit */
3939
pte_update_delta(ptep, addr, _PAGE_KERNEL_RW & ~_PAGE_DIRTY, _PAGE_KERNEL_RO);
4040
break;
41+
case SET_MEMORY_ROX:
42+
/* Don't clear DIRTY bit */
43+
pte_update_delta(ptep, addr, _PAGE_KERNEL_RW & ~_PAGE_DIRTY, _PAGE_KERNEL_ROX);
44+
break;
4145
case SET_MEMORY_RW:
4246
pte_update_delta(ptep, addr, _PAGE_KERNEL_RO, _PAGE_KERNEL_RW);
4347
break;

0 commit comments

Comments
 (0)