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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endifIfitinvolveschangingmorethingsandthisfeaturewillbeaddedtopowerpcinthefuture,wecoulddroptheset_memory_ro()callfromiomap.CC:Darrick(ashesuggestedset_memory_ro()onzeropage),Leroy,Ritesh,ppclist
Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
quoted hunk
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endif
By doing this you will just hide the fact that it didn't work.
See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines")
for details. The linear memory region is not mapped using page tables so
set_memory_ro() will have no effect on it.
You can either use vmalloc'ed pages, or do a const static allocation at
buildtime so that it will be allocated in the kernel static rodata area.
By the way, your code should check the value returned by
set_memory_ro(), there is some work in progress to make it mandatory,
see https://github.com/KSPP/linux/issues/7
Christophe
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
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2024-08-26 20:52:58
On Mon, Aug 26, 2024 at 07:43:20PM +0200, Christophe Leroy wrote:
Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
quoted
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endif
By doing this you will just hide the fact that it didn't work.
See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") for
details. The linear memory region is not mapped using page tables so
set_memory_ro() will have no effect on it.
You can either use vmalloc'ed pages, or do a const static allocation at
buildtime so that it will be allocated in the kernel static rodata area.
By the way, your code should check the value returned by set_memory_ro(),
there is some work in progress to make it mandatory, see
https://github.com/KSPP/linux/issues/7
Our users expect contiguous memory [0] and so we use alloc_pages() here,
so if we're architecture limitted by this I'd rather we just remove the
set_memory_ro() only for PPC, I don't see why other have to skip this.
From: "Darrick J. Wong" <djwong@kernel.org> Date: 2024-08-26 21:10:49
On Mon, Aug 26, 2024 at 01:52:54PM -0700, Luis Chamberlain wrote:
On Mon, Aug 26, 2024 at 07:43:20PM +0200, Christophe Leroy wrote:
quoted
Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
quoted
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endif
By doing this you will just hide the fact that it didn't work.
See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") for
details. The linear memory region is not mapped using page tables so
set_memory_ro() will have no effect on it.
You can either use vmalloc'ed pages, or do a const static allocation at
buildtime so that it will be allocated in the kernel static rodata area.
By the way, your code should check the value returned by set_memory_ro(),
there is some work in progress to make it mandatory, see
https://github.com/KSPP/linux/issues/7
Our users expect contiguous memory [0] and so we use alloc_pages() here,
so if we're architecture limitted by this I'd rather we just remove the
set_memory_ro() only for PPC, I don't see why other have to skip this.
From: Luis Chamberlain <mcgrof@kernel.org> Date: 2024-08-26 21:41:24
On Mon, Aug 26, 2024 at 02:10:49PM -0700, Darrick J. Wong wrote:
On Mon, Aug 26, 2024 at 01:52:54PM -0700, Luis Chamberlain wrote:
quoted
On Mon, Aug 26, 2024 at 07:43:20PM +0200, Christophe Leroy wrote:
quoted
Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
quoted
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endif
By doing this you will just hide the fact that it didn't work.
See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") for
details. The linear memory region is not mapped using page tables so
set_memory_ro() will have no effect on it.
You can either use vmalloc'ed pages, or do a const static allocation at
buildtime so that it will be allocated in the kernel static rodata area.
By the way, your code should check the value returned by set_memory_ro(),
there is some work in progress to make it mandatory, see
https://github.com/KSPP/linux/issues/7
Our users expect contiguous memory [0] and so we use alloc_pages() here,
so if we're architecture limitted by this I'd rather we just remove the
set_memory_ro() only for PPC, I don't see why other have to skip this.
On Mon, Aug 26, 2024 at 02:10:49PM -0700, Darrick J. Wong wrote:
quoted
On Mon, Aug 26, 2024 at 01:52:54PM -0700, Luis Chamberlain wrote:
quoted
On Mon, Aug 26, 2024 at 07:43:20PM +0200, Christophe Leroy wrote:
quoted
Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
quoted
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endif
By doing this you will just hide the fact that it didn't work.
See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") for
details. The linear memory region is not mapped using page tables so
set_memory_ro() will have no effect on it.
You can either use vmalloc'ed pages, or do a const static allocation at
buildtime so that it will be allocated in the kernel static rodata area.
By the way, your code should check the value returned by set_memory_ro(),
there is some work in progress to make it mandatory, see
https://github.com/KSPP/linux/issues/7
Our users expect contiguous memory [0] and so we use alloc_pages() here,
so if we're architecture limitted by this I'd rather we just remove the
set_memory_ro() only for PPC, I don't see why other have to skip this.
Looks like not a standard thing to do for kernel linear memory map
region then and maybe few other archs could be ignoring too?
From: Mike Rapoport <rppt@kernel.org> Date: 2024-08-27 15:41:34
On Mon, Aug 26, 2024 at 01:52:54PM -0700, Luis Chamberlain wrote:
quoted hunk
On Mon, Aug 26, 2024 at 07:43:20PM +0200, Christophe Leroy wrote:
quoted
Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
quoted
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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:
@@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if(!radix_enabled()){intregion=get_region_id(addr);-if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&®ion!=IO_REGION_ID))+if(WARN_ON_ONCE(region!=VMALLOC_REGION_ID&&+region!=IO_REGION_ID&&+region!=LINEAR_MAP_REGION_ID))return-EINVAL;}#endif
By doing this you will just hide the fact that it didn't work.
See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") for
details. The linear memory region is not mapped using page tables so
set_memory_ro() will have no effect on it.
You can either use vmalloc'ed pages, or do a const static allocation at
buildtime so that it will be allocated in the kernel static rodata area.
By the way, your code should check the value returned by set_memory_ro(),
there is some work in progress to make it mandatory, see
https://github.com/KSPP/linux/issues/7
Our users expect contiguous memory [0] and so we use alloc_pages() here,
so if we're architecture limitted by this I'd rather we just remove the
set_memory_ro() only for PPC, I don't see why other have to skip this.
arm64 will return -EINVAL here, their code for changing memory attributes
only works on vmalloc:
* Let's restrict ourselves to mappings created by vmalloc (or vmap).
* Those are guaranteed to consist entirely of page mappings, and
* splitting is never needed.
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2024-08-27 06:28:55
"Pankaj Raghav (Samsung)" [off-list ref] writes:
On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
quoted
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 should probably just turn that into a printk(), WARN is kind of heavy handed.
We call set_memory_ro() on the zero page as a extra security measure.
Or a data integrity measure. But either way it makes sense.
On architectures that do implement set_memory_ro() it potentially breaks
the linear mapping into small pages, which could have a performance impact.
cheers