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>
This commit is contained in:
Daniel Leung 2021-07-22 13:13:17 -07:00 committed by Christopher Friedt
commit 7ad00b9e47
2 changed files with 6 additions and 0 deletions

View file

@ -14,6 +14,7 @@
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
#include <linker/sections.h>
#ifdef __cplusplus
extern "C" {
@ -110,6 +111,7 @@ static ALWAYS_INLINE bool z_syscall_trap(void)
*
* @return true if the CPU is currently running with user permissions
*/
__pinned_func
static inline bool k_is_user_context(void)
{
#ifdef CONFIG_USERSPACE

View file

@ -80,6 +80,8 @@ syscall_template = """
#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 @@ def wrapper_defs(func_name, func_type, args):
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"