mm: Enable CONFIG_PT_RECLAIM on all architectures
Subsystems (3)
RFC PATCH 1/1 mm: Enable CONFIG_PT_RECLAIM on all architectures
The implementation of CONFIG_PT_RECLAIM is completely contained in generic mm code. It depends on the RCU callback which will reclaim the pagetables - there is nothing arch-specific about that. So, enable this config for all architectures.
--- arch/x86/Kconfig | 1 - mm/Kconfig | 5 +---- mm/pt_reclaim.c | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/Kconfig +0 -1
@@ -327,7 +327,6 @@ config X86 select FUNCTION_ALIGNMENT_4B imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE - select ARCH_SUPPORTS_PT_RECLAIM if X86_64 select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMP
mm/Kconfig +1 -4
@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACK The architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -config ARCH_SUPPORTS_PT_RECLAIM - def_bool n - config PT_RECLAIM bool "reclaim empty user page table pages" default y - depends on ARCH_SUPPORTS_PT_RECLAIM && MMU && SMP + depends on MMU && SMP select MMU_GATHER_RCU_TABLE_FREE help Try to reclaim empty user page table pages in paths other than munmap
mm/pt_reclaim.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
Signature · 1 line
2.30.2
Hi Dev,
Quoted 4 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic mm code. It depends on the RCU callback which will reclaim the pagetables - there is nothing arch-specific about that. So, enable this config for all architectures.
Thanks for doing this!
But unfortunately, not all architectures call tlb_remove_ptdesc() in __pte_free_tlb(). Some architectures directly call pte_free() to free PTE pages (without RCU).
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in pte_free_defer().
Enabling PT_RECLAIM on all architecture has always been on my TODO list, but it's been blocked by other things. :(
Thanks,
Qi
Quoted 51 lines
Signed-off-by Dev Jain <[email protected]>--- arch/x86/Kconfig | 1 - mm/Kconfig | 5 +---- mm/pt_reclaim.c | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-1@@ -327,7 +327,6 @@ config X86 select FUNCTION_ALIGNMENT_4B imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE - select ARCH_SUPPORTS_PT_RECLAIM if X86_64 select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +1
-4@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACK The architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -config ARCH_SUPPORTS_PT_RECLAIM - def_bool n - config PT_RECLAIM bool "reclaim empty user page table pages" default y - depends on ARCH_SUPPORTS_PT_RECLAIM && MMU && SMP + depends on MMU && SMP select MMU_GATHER_RCU_TABLE_FREE help Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
Quoted 8 lines · Qi Zheng
Hi Dev,
Quoted 4 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic mm code. It depends on the RCU callback which will reclaim the pagetables - there is nothing arch-specific about that. So, enable this config for all architectures.
Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting __pte_free_tlb to tlb_remove_ptdesc
or pte_free_defer?
I am looking to enable this config at least on arm64 by default, I believe it will be legal
to do this at least here.
Quoted 61 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 49 lines
Signed-off-by Dev Jain <[email protected]>---
arch/x86/Kconfig| 1 -
mm/Kconfig | 5 +----
mm/pt_reclaim.c | 2 +-3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-0@@ -327,7 +327,6 @@ config X86select
FUNCTION_ALIGNMENT_4B
imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI selectHAVE_DYNAMIC_FTRACE_NO_PATCHABLE- select ARCH_SUPPORTS_PT_RECLAIM ifX86_64select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACKThe architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -config
ARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages"
default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP
+ depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
Hi Dev,
Quoted 16 lines · Dev Jain
Quoted 8 lines · Qi Zheng
Hi Dev,
Quoted 4 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic mm code. It depends on the RCU callback which will reclaim the pagetables - there is nothing arch-specific about that. So, enable this config for all architectures.Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).
Quoted 5 lines
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting
__pte_free_tlbtotlb_remove_ptdesc
Some architectures have special handling in __pte_free_tlb(), and cannot simple redirect __pte_free_tlb() to tlb_remove_ptdesc(), such as m68k, powerpc, etc.
For those architectures that call pte_free() in __pte_free_tlb(), it should be easy to modify them.
If you're not in a rush, I can take the time to finish the above tasks.
Quoted 7 lines
or
pte_free_defer?I am looking to enable this config at least on arm64 by default, I believe it will be legal
to do this at least here.
IIRC, arm64 can directly enable CONFIG_PT_RECLAIM, as it is supported at the architecture level.
Thanks,
Qi
Quoted 63 lines
Quoted 63 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 49 lines
Signed-off-by Dev Jain <[email protected]>---
arch/x86/Kconfig| 1 -
mm/Kconfig | 5 +----
mm/pt_reclaim.c | 2 +-3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-0@@ -327,7 +327,6 @@ config X86select
FUNCTION_ALIGNMENT_4B
imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI selectHAVE_DYNAMIC_FTRACE_NO_PATCHABLE- select ARCH_SUPPORTS_PT_RECLAIM ifX86_64select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACKThe architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -config
ARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages"
default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP
+ depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
Quoted 25 lines · Qi Zheng
Hi Dev,
Quoted 16 lines · Dev Jain
Quoted 8 lines · Qi Zheng
Hi Dev,
Quoted 4 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic mm code. It depends on the RCU callback which will reclaim the pagetables - there is nothing arch-specific about that. So, enable this config for all architectures.Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).Quoted 5 lines
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting
__pte_free_tlbtotlb_remove_ptdesc
Quoted 8 lines
Some architectures have special handling in
__pte_free_tlb(), and cannot simple redirect__pte_free_tlb()totlb_remove_ptdesc(), such as m68k, powerpc, etc.For those architectures that call
pte_free()in__pte_free_tlb(), it should be easy to modify them.If you're not in a rush, I can take the time to finish the above tasks.
Right then, I'll leave that up to you!
Quoted 79 lines
Quoted 8 lines
or
pte_free_defer?I am looking to enable this config at least on arm64 by default, I believe it will be legal
to do this at least here.
IIRC, arm64 can directly enable
CONFIG_PT_RECLAIM, as it is supported at the architecture level.Thanks,
QiQuoted 63 lines
Quoted 63 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 49 lines
Signed-off-by Dev Jain <[email protected]>---
arch/x86/Kconfig| 1 -
mm/Kconfig | 5 +----
mm/pt_reclaim.c | 2 +-3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-0@@ -327,7 +327,6 @@ config X86select
FUNCTION_ALIGNMENT_4B
imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI selectHAVE_DYNAMIC_FTRACE_NO_PATCHABLE- select ARCH_SUPPORTS_PT_RECLAIM ifX86_64select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACKThe architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -config
ARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages"
default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP
+ depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
Quoted 31 lines · Dev Jain
Quoted 29 lines · Qi Zheng
Hi Dev,
Quoted 16 lines · Dev Jain
Quoted 8 lines · Qi Zheng
Hi Dev,
Quoted 4 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic mm code. It depends on the RCU callback which will reclaim the pagetables - there is nothing arch-specific about that. So, enable this config for all architectures.Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).Quoted 5 lines
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting
__pte_free_tlbtotlb_remove_ptdescSome architectures have special handling in
__pte_free_tlb(), and cannot simple redirect__pte_free_tlb()totlb_remove_ptdesc(), such as m68k, powerpc, etc.
Quoted 6 lines
Quoted 4 lines
For those architectures that call
pte_free()in__pte_free_tlb(), it should be easy to modify them.If you're not in a rush, I can take the time to finish the above tasks.
Right then, I'll leave that up to you!
OK, I will do it ASAP.
Quoted 81 lines
Quoted 81 lines
Quoted 10 lines
or
pte_free_defer?I am looking to enable this config at least on arm64 by default, I believe it will be legal
to do this at least here.
IIRC, arm64 can directly enable
CONFIG_PT_RECLAIM, as it is supported at the architecture level.Thanks,
QiQuoted 63 lines
Quoted 63 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 49 lines
Signed-off-by Dev Jain <[email protected]>---
arch/x86/Kconfig| 1 -
mm/Kconfig | 5 +----
mm/pt_reclaim.c | 2 +-3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-0@@ -327,7 +327,6 @@ config X86select
FUNCTION_ALIGNMENT_4B
imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI selectHAVE_DYNAMIC_FTRACE_NO_PATCHABLE- select ARCH_SUPPORTS_PT_RECLAIM ifX86_64select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACKThe architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -config
ARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages"
default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP
+ depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
From: Lance Yang <[email protected]>
Quoted 38 lines · Qi Zheng
Quoted 35 lines · Dev Jain
Quoted 33 lines · Qi Zheng
Hi Dev,
Quoted 18 lines · Dev Jain
Quoted 10 lines · Qi Zheng
Hi Dev,
Quoted 6 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic
mm code. It depends on the RCU callback which will reclaim the pagetables -
there is nothing arch-specific about that. So, enable this config for all architectures.Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).Quoted 7 lines
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting
__pte_free_tlbtotlb_remove_ptdescSome architectures have special handling in
__pte_free_tlb(), and cannot simple redirect__pte_free_tlb()totlb_remove_ptdesc(), such as m68k, powerpc, etc.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
For those architectures that call
pte_free()in__pte_free_tlb(), it should be easy to modify them.If you're not in a rush, I can take the time to finish the above tasks.
Right then, I'll leave that up to you!
OK, I will do it ASAP.
Cool! Looking forward to seeing that land ;p
Cheers,
Lance
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
or
pte_free_defer?I am looking to enable this config at least on arm64 by default, I believe it will be legal
Great proposal, Dev! That looks like a very useful feature. Let's make it happen on arm64 ;)
Quoted 77 lines
Quoted 75 lines
Quoted 75 lines
Quoted 2 lines
to do this at least here.
IIRC, arm64 can directly enable
CONFIG_PT_RECLAIM, as it is supported at the architecture level.Thanks,
QiQuoted 65 lines
Quoted 65 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 51 lines
Signed-off-by Dev Jain <[email protected]>---
arch/x86/Kconfig| 1 -
mm/Kconfig | 5 +----
mm/pt_reclaim.c | 2 +-3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-0@@ -327,7 +327,6 @@ config X86select
FUNCTION_ALIGNMENT_4B
imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI selectHAVE_DYNAMIC_FTRACE_NO_PATCHABLE- select ARCH_SUPPORTS_PT_RECLAIM ifX86_64select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACKThe architecture has hardware support for userspace shadow call
stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -configARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages" default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP + depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
Quoted 48 lines · Lance Yang
From: Lance Yang <[email protected]>
Quoted 32 lines · Qi Zheng
Quoted 30 lines · Dev Jain
Quoted 29 lines · Qi Zheng
Hi Dev,
Quoted 15 lines · Dev Jain
Quoted 9 lines · Qi Zheng
Hi Dev,
Quoted 6 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic
mm code. It depends on the RCU callback which will reclaim the pagetables -
there is nothing arch-specific about that. So, enable this config for all architectures.Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).Quoted 7 lines
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting
__pte_free_tlbtotlb_remove_ptdescSome architectures have special handling in
__pte_free_tlb(), and cannot simple redirect__pte_free_tlb()totlb_remove_ptdesc(), such as m68k, powerpc, etc.Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
For those architectures that call
pte_free()in__pte_free_tlb(), it should be easy to modify them.If you're not in a rush, I can take the time to finish the above tasks.
Right then, I'll leave that up to you!
OK, I will do it ASAP.
Cool! Looking forward to seeing that land ;p
Cheers,
LanceQuoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
or
pte_free_defer?I am looking to enable this config at least on arm64 by default, I believe it will be legal
Great proposal, Dev! That looks like a very useful feature. Let's make it happen on arm64 ;)
Yup, but not sure whether an arm64 enabling patch, only for that to go away when Qi implements the feature generically, is worth the trouble!
Quoted 70 lines
Quoted 70 lines
Quoted 69 lines
Quoted 69 lines
Quoted 2 lines
to do this at least here.
IIRC, arm64 can directly enable
CONFIG_PT_RECLAIM, as it is supported at the architecture level.Thanks,
QiQuoted 61 lines
Quoted 61 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 50 lines
Signed-off-by Dev Jain <[email protected]>--- arch/x86/Kconfig | 1 - mm/Kconfig | 5 +---- mm/pt_reclaim.c | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-1@@ -327,7 +327,6 @@ config X86 select FUNCTION_ALIGNMENT_4B imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE - select ARCH_SUPPORTS_PT_RECLAIM if X86_64 select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACK The architecture has hardware support for userspace shadowcall
stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -configARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages" default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP + depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other
than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"
From: Lance Yang <[email protected]>
Quoted 38 lines · Qi Zheng
Quoted 35 lines · Dev Jain
Quoted 33 lines · Qi Zheng
Hi Dev,
Quoted 18 lines · Dev Jain
Quoted 10 lines · Qi Zheng
Hi Dev,
Quoted 6 lines · Dev Jain
The implementation of
CONFIG_PT_RECLAIMis completely contained in generic
mm code. It depends on the RCU callback which will reclaim the pagetables -
there is nothing arch-specific about that. So, enable this config for all architectures.Quoted 5 lines
Thanks for doing this!
But unfortunately, not all architectures call
tlb_remove_ptdesc()in__pte_free_tlb(). Some architectures directly callpte_free()to free PTE pages (without RCU).Quoted 7 lines
Thanks! This was not obvious to figure out.
Is there an arch bottleneck because of which they do this? I mean to say,
is something stopping us from simply redirecting
__pte_free_tlbtotlb_remove_ptdescSome architectures have special handling in
__pte_free_tlb(), and cannot simple redirect__pte_free_tlb()totlb_remove_ptdesc(), such as m68k, powerpc, etc.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
For those architectures that call
pte_free()in__pte_free_tlb(), it should be easy to modify them.If you're not in a rush, I can take the time to finish the above tasks.
Right then, I'll leave that up to you!
OK, I will do it ASAP.
Cool! Looking forward to seeing that land ;p
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
or
pte_free_defer?I am looking to enable this config at least on arm64 by default, I believe it will be legal
Great proposal, Dev! That looks like a very useful feature. Let's make it happen on arm64 ;)
Quoted 77 lines
Quoted 75 lines
Quoted 75 lines
Quoted 2 lines
to do this at least here.
IIRC, arm64 can directly enable
CONFIG_PT_RECLAIM, as it is supported at the architecture level.Thanks,
QiQuoted 65 lines
Quoted 65 lines
We need to modify these architectures first, otherwise it will lead to UAF. This approach is feasible because Hugh provides similar support in
pte_free_defer().Enabling
PT_RECLAIMon all architecture has always been on my TODO list, but it's been blocked by other things. :(Thanks,
QiQuoted 51 lines
Signed-off-by Dev Jain <[email protected]>---
arch/x86/Kconfig| 1 -
mm/Kconfig | 5 +----
mm/pt_reclaim.c | 2 +-3 files changed, 2 insertions(+), 6 deletions(-)arch/x86/Kconfig +0
-0@@ -327,7 +327,6 @@ config X86select
FUNCTION_ALIGNMENT_4B
imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI selectHAVE_DYNAMIC_FTRACE_NO_PATCHABLE- select ARCH_SUPPORTS_PT_RECLAIM ifX86_64select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMPmm/Kconfig +0
-0@@ -1355,13 +1355,10 @@ config ARCH_HAS_USER_SHADOW_STACKThe architecture has hardware support for userspace shadow call
stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). -configARCH_SUPPORTS_PT_RECLAIM
-def_booln
-
configPT_RECLAIM
bool "reclaim empty user page table pages" default y
- depends onARCH_SUPPORTS_PT_RECLAIM&& MMU && SMP + depends on MMU && SMP
selectMMU_GATHER_RCU_TABLE_FREE
help
Try to reclaim empty user page table pages in paths other than munmapmm/pt_reclaim.c +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <linux/hugetlb.h> -#include <asm-generic/tlb.h> +#include <asm/tlb.h> #include <asm/pgalloc.h> #include "internal.h"