scs: add CONFIG_MMU dependency for vfree_atomic()

Message ID 20240122175204.2371009-1-samuel.holland@sifive.com
State New
Headers
Series scs: add CONFIG_MMU dependency for vfree_atomic() |

Commit Message

Samuel Holland Jan. 22, 2024, 5:52 p.m. UTC
  The shadow call stack implementation fails to build without CONFIG_MMU:

  ld.lld: error: undefined symbol: vfree_atomic
  >>> referenced by scs.c
  >>>               kernel/scs.o:(scs_free) in archive vmlinux.a

Fixes: a2abe7cbd8fe ("scs: switch to vmapped shadow stacks")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Sami Tolvanen Jan. 22, 2024, 7:21 p.m. UTC | #1
Hi Samuel,

On Mon, Jan 22, 2024 at 9:52 AM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> The shadow call stack implementation fails to build without CONFIG_MMU:
>
>   ld.lld: error: undefined symbol: vfree_atomic
>   >>> referenced by scs.c
>   >>>               kernel/scs.o:(scs_free) in archive vmlinux.a
>
> Fixes: a2abe7cbd8fe ("scs: switch to vmapped shadow stacks")
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
>  arch/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index c91917b50873..a5af0edd3eb8 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -673,6 +673,7 @@ config SHADOW_CALL_STACK
>         bool "Shadow Call Stack"
>         depends on ARCH_SUPPORTS_SHADOW_CALL_STACK
>         depends on DYNAMIC_FTRACE_WITH_ARGS || DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER
> +       depends on MMU
>         help
>           This option enables the compiler's Shadow Call Stack, which
>           uses a shadow stack to protect function return addresses from

Looks good to me. Thanks for the patch!

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>

Sami
  
Christoph Hellwig Jan. 26, 2024, 1:53 p.m. UTC | #2
On Mon, Jan 22, 2024 at 09:52:01AM -0800, Samuel Holland wrote:
> The shadow call stack implementation fails to build without CONFIG_MMU:
> 
>   ld.lld: error: undefined symbol: vfree_atomic
>   >>> referenced by scs.c
>   >>>               kernel/scs.o:(scs_free) in archive vmlinux.a

Well, please just provide vfree_atomic for nommu then.  vfree maps
to kfree which can be called from atomic context, so vfree_atomic
can do the same.
  

Patch

diff --git a/arch/Kconfig b/arch/Kconfig
index c91917b50873..a5af0edd3eb8 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -673,6 +673,7 @@  config SHADOW_CALL_STACK
 	bool "Shadow Call Stack"
 	depends on ARCH_SUPPORTS_SHADOW_CALL_STACK
 	depends on DYNAMIC_FTRACE_WITH_ARGS || DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER
+	depends on MMU
 	help
 	  This option enables the compiler's Shadow Call Stack, which
 	  uses a shadow stack to protect function return addresses from