On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
Hi all,
After merging the vfs-brauner tree, today's linux-next boot test (powerpc
pseries_le_defconfig) produced this warning:
iomap dio calls set_memory_ro() on the page that is used for sub block
zeroing.
But looking at powerpc code, they don't support set_memory_ro() for
memory region that belongs to the kernel(LINEAR_MAP_REGION_ID).
/*
* On hash, the linear mapping is not in the Linux page table so
* apply_to_existing_page_range() will have no effect. If in the future
* the set_memory_* functions are used on the linear map this will need
* to be updated.
*/
if (!radix_enabled()) {
int region = get_region_id(addr);
if (WARN_ON_ONCE(region != VMALLOC_REGION_ID && region != IO_REGION_ID))
return -EINVAL;
}
We call set_memory_ro() on the zero page as a extra security measure.
I don't know much about powerpc, but looking at the comment, is it just
adding the following to support it in powerpc:
diff --git a/arch/powerpc/mm/pageattr.c b/arch/powerpc/mm/pageattr.c
index ac22bf28086fa..e6e0b40ba6db4 100644
--- a/arch/powerpc/mm/pageattr.c
+++ b/arch/powerpc/mm/pageattr.c
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)
if (!radix_enabled()) {
int region = get_region_id(addr);
- if (WARN_ON_ONCE(region != VMALLOC_REGION_ID && region != IO_REGION_ID))
+ if (WARN_ON_ONCE(region != VMALLOC_REGION_ID &&
+ region != IO_REGION_ID &&
+ region != LINEAR_MAP_REGION_ID))
return -EINVAL;
}
#endif
If it involves changing more things and this feature will be added to
powerpc in the future, we could drop the set_memory_ro() call from
iomap.
CC: Darrick(as he suggested set_memory_ro() on zero page), Leroy,
Ritesh, ppc list