kernel: syscall: pin generated inline functions
Although they are marked as an inline functions, the compiler
may decide not to inline them which would result in them being
outside the pinned text section. Since these functions are
required for userspace to work correctly, pin them in physical
memory. This also applies to k_is_user_context().
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
diff --git a/include/syscall.h b/include/syscall.h
index 3f24f62..871c244 100644
--- a/include/syscall.h
+++ b/include/syscall.h
@@ -14,6 +14,7 @@
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
+#include <linker/sections.h>
#ifdef __cplusplus
extern "C" {
@@ -110,6 +111,7 @@
*
* @return true if the CPU is currently running with user permissions
*/
+__pinned_func
static inline bool k_is_user_context(void)
{
#ifdef CONFIG_USERSPACE
diff --git a/scripts/gen_syscalls.py b/scripts/gen_syscalls.py
index d08a0d7..f060034 100755
--- a/scripts/gen_syscalls.py
+++ b/scripts/gen_syscalls.py
@@ -80,6 +80,8 @@
#include <syscall_list.h>
#include <syscall.h>
+#include <linker/sections.h>
+
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#endif
@@ -174,6 +176,8 @@
decl_arglist = ", ".join([" ".join(argrec) for argrec in args]) or "void"
wrap = "extern %s z_impl_%s(%s);\n" % (func_type, func_name, decl_arglist)
+ wrap += "\n"
+ wrap += "__pinned_func\n"
wrap += "static inline %s %s(%s)\n" % (func_type, func_name, decl_arglist)
wrap += "{\n"
wrap += "#ifdef CONFIG_USERSPACE\n"