powerpc/mm: Invalidate partition table cache on host proc tbl base update
PATCH 1/1 powerpc/mm: Invalidate partition table cache on host proc tbl base update
The host process table base is stored in the partition table by calling the function native_register_process_table(). Currently this just sets the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a cache invalidation instruction specifying invalidation of the caching of any partition table entries (RIC = 2, PRS = 0).
We already have a function to update the partition table with the required cache invalidation instructions - mmu_partition_table_set_entry(). Update the native_register_process_table() function to call mmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.
--- arch/powerpc/mm/pgtable-radix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/pgtable-radix.c +2 -1
@@ -33,7 +33,8 @@ static int native_register_process_table(unsigned long base, unsigned long pg_sz {unsigned long patb1 = base | table_size |PATB_GR ; - partition_tb->patb1 =cpu_to_be64 (patb1); +mmu_partition_table_set_entry (0 ,be64_to_cpu (partition_tb->patb0), + patb1);return 0 ; }
Signature · 1 line
2.9.4
Michael Ellerman
reviewerQuoted 7 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling the function
native_register_process_table(). Currently this just sets the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a cache invalidation instruction specifying invalidation of the caching of any partition table entries (RIC = 2, PRS = 0).
Quoted 5 lines
We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry(). Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.
Without this patch the kernel will:
[ ] work normally
[ ] randomly crash
[ ] catch fire
?
cheers
Quoted 15 lines · Michael Ellerman
Quoted 7 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling the function
native_register_process_table(). Currently this just sets the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a cache invalidation instruction specifying invalidation of the caching of any partition table entries (RIC = 2, PRS = 0).Quoted 5 lines
We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry(). Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.
Quoted 4 lines
Without this patch the kernel will:
[ ] work normally
[ ] randomly crash
[ ] catch fire
I think we get lucky because OPAL added a "flush the whole world" to opal_reinit_cpus() but this patch seems to improve general code "correctness".
Cheers,
Ben.
Quoted 27 lines · Benjamin Herrenschmidt
Quoted 21 lines · Michael Ellerman
Quoted 12 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling
the functionnative_register_process_table(). Currently this just sets
the entry in memory and is missing a proceeding cache invalidation
instruction. Any update to the partition table should be followed by a
cache invalidation instruction specifying invalidation of the caching of
any partition table entries (RIC = 2, PRS = 0).Quoted 6 lines
We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry().
Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.Quoted 4 lines
Without this patch the kernel will:
[ ] work normally
[ ] randomly crash
[ ] catch fire
Quoted 7 lines
I think we get lucky because OPAL added a "flush the whole world" to
opal_reinit_cpus()but this patch seems to improve general code "correctness".Cheers,
Ben.
I guess there's the possibility of:
[x] randomly crash
This is required to run a powernv kernel as a guest because we need to know when it's updated its process table location.
Quoted 6 lines · Suraj Jitindar Singh
I guess there's the possibility of:
[x] randomly crashThis is required to run a powernv kernel as a guest because we need to know when it's updated its process table location.
You mean in qemu full emu ? powernv kernels don't run as guest do they ?
Cheers,
Ben.
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 4 lines · Suraj Jitindar Singh
I guess there's the possibility of:
[x] randomly crash
Quoted 7 lines
Quoted 3 lines
This is required to run a powernv kernel as a guest because we need to
know when it's updated its process table location.You mean in qemu full emu ? powernv kernels don't run as guest do they
?
For now they don't... :p
Quoted 4 lines
Cheers,
Ben.
Michael Ellerman
reviewerQuoted 27 lines · Suraj Jitindar Singh
Quoted 26 lines · Benjamin Herrenschmidt
Quoted 25 lines · Michael Ellerman
Suraj Jitindar Singh <[email protected]> writes:
=20Quoted 10 lines
The host process table base is stored in the partition table by calling
the functionnative_register_process_table(). Currently this just sets
the entry in memory and is missing a proceeding cache invalidation
instruction. Any update to the partition table should be followed by a
cache invalidation instruction specifying invalidation of the caching ofQuoted 8 lines
any partition table entries (RIC =3D 2, PRS =3D 0).
=20
We already have a function to update the partition table with the required cache invalidation instructions -mmu_partition_table_set_entry().
Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.=20
Without this patch the kernel will:
=C2=A0[ ] work normally
=C2=A0[ ] randomly crash
=C2=A0[ ] catch fire
Quoted 7 lines
Quoted 4 lines
=20
I think we get lucky because OPAL added a "flush the whole world" toopal_reinit_cpus()but this patch seems to improve general code "correctness".I guess there's the possibility of:
[x] randomly crash
But you haven't actually see any right?
Quoted 2 lines
This is required to run a powernv kernel as a guest because we need to know when it's updated its process table location.
Which doesn't currently work for other reasons :)
cheers
Quoted 7 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling the function
native_register_process_table(). Currently this just sets the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a cache invalidation instruction specifying invalidation of the caching of any partition table entries (RIC = 2, PRS = 0).
Quoted 6 lines
We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry(). Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.
Quoted 21 lines
Signed-off-by Suraj Jitindar Singh <[email protected]>--- arch/powerpc/mm/pgtable-radix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/mm/pgtable-radix.c +2
-1@@ -33,7 +33,8 @@ static int native_register_process_table(unsigned long base, unsigned long pg_sz {unsigned long patb1 = base | table_size |PATB_GR ; - partition_tb->patb1 =cpu_to_be64 (patb1); +mmu_partition_table_set_entry (0 ,be64_to_cpu (partition_tb->patb0), + patb1);return 0 ; }Signature · 1 line
2.9.4
Michael Ellerman
reviewerQuoted 23 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling the function
native_register_process_table(). Currently this just sets the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a cache invalidation instruction specifying invalidation of the caching of any partition table entries (RIC = 2, PRS = 0).We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry(). Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.Signed-off-by Suraj Jitindar Singh <[email protected]>--- arch/powerpc/mm/pgtable-radix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/mm/pgtable-radix.c +0
-0
arch/powerpc/mm/pgtable-radix.c static int native_register_process_table(unsigned long base, unsigned long pg_sz · line 37
Quoted 6 lines
arch/powerpc/mm/pgtable-radix.c +2
-1@@ -33,7 +33,8 @@ static int native_register_process_table(unsigned long base, unsigned long pg_sz {unsigned long patb1 = base | table_size |PATB_GR ; - partition_tb->patb1 =cpu_to_be64 (patb1); +mmu_partition_table_set_entry (0 ,be64_to_cpu (partition_tb->patb0), + patb1);
This is really a bit gross.
Can we agree on whether partition_tb is an array or not?
How about ...
cheers
arch/powerpc/mm/pgtable-radix.c +6 -2
@@ -28,9 +28,13 @@static int native_register_process_table (unsigned long base,unsigned long pg_sz,unsigned long table_size) { -unsigned long patb1 = base | table_size |PATB_GR ; +unsigned long patb0, patb1; + + patb0 =be64_to_cpu (partition_tb[0 ].patb0); + patb1 = base | table_size |PATB_GR ; + +mmu_partition_table_set_entry (0 , patb0, patb1); - partition_tb->patb1 =cpu_to_be64 (patb1);return 0 ; }
Quoted 37 lines · Michael Ellerman
Quoted 35 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling
the functionnative_register_process_table(). Currently this just sets
the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a
cache invalidation instruction specifying invalidation of the caching of
any partition table entries (RIC = 2, PRS = 0).We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry().
Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.Signed-off-by Suraj Jitindar Singh <[email protected]>---
arch/powerpc/mm/pgtable-radix.c | 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/mm/pgtable-radix.c +0
-0@@ -33,7 +33,8 @@ static int native_register_process_table(unsignedlong base, unsigned long
pg_sz
{
unsigned long patb1 = base |table_size|PATB_GR;arch/powerpc/mm/pgtable-radix.c +1
-1- partition_tb->patb1 =cpu_to_be64 (patb1); + mmu_partition_table_set_entry(0, be64_to_cpu(partition_tb-
Quoted 6 lines
arch/powerpc/mm/pgtable-radix.c
Quoted 2 lines
Quoted 1 line
patb0),
arch/powerpc/mm/pgtable-radix.c +1
-0+ patb1);This is really a bit gross.
Can we agree on whether
partition_tbis an array or not?
Well it is an array, it's just we only ever want the first element in this function. That being said we might as well access it as an array to make that clear.
Quoted 22 lines
How about ...
cheers
arch/powerpc/mm/pgtable-radix.c +6
-1@@ -28,9 +28,13 @@ static int native_register_process_table(unsigned long base,unsigned long pg_sz, unsigned long table_size) { - unsigned long patb1 = base | table_size | PATB_GR; + unsigned long patb0, patb1; + + patb0 = be64_to_cpu(partition_tb[0].patb0); + patb1 = base | table_size | PATB_GR; + + mmu_partition_table_set_entry(0, patb0, patb1);
Quoted 4 lines
- partition_tb->patb1 =cpu_to_be64(patb1);
return 0;
}
Looks good :)
Michael Ellerman
AppliedQuoted 7 lines · Suraj Jitindar Singh
The host process table base is stored in the partition table by calling the function
native_register_process_table(). Currently this just sets the entry in memory and is missing a proceeding cache invalidation instruction. Any update to the partition table should be followed by a cache invalidation instruction specifying invalidation of the caching of any partition table entries (RIC = 2, PRS = 0).
Quoted 8 lines
We already have a function to update the partition table with the required cache invalidation instructions -
mmu_partition_table_set_entry(). Update thenative_register_process_table()function to callmmu_partition_table_set_entry(), this ensures all appropriate invalidation will be performed.Signed-off-by Suraj Jitindar Singh <[email protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/7cd2a8695ef9c31e8f51773f0de9e6
cheers