syscall: Export all emitted syscalls, enabling them for extensions

Linkable loadable extensions can only use syscalls if they are exported
via EXPORT_SYSCALL (or EXPORT_SYMBOL). Instead of enabling used syscalls
one by one, this patch exports all of them automatically via
`gen_syscalls.py`. If CONFIG_LLEXT=n, the section where the exported
symbols live is discarded, so it should be a non-op when llext is not
enabled.

This patch also removes the now redundant EXPORT_SYSCALL macro. Note
that EXPORT_SYMBOL is still useful on different situations (and is
indeed used by the code generated by `gen_syscalls.py`).

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
This commit is contained in:
Ederson de Souza 2024-03-15 14:51:39 -07:00 committed by Fabio Baltieri
parent 1680223003
commit 67bb6db3f8
4 changed files with 9 additions and 14 deletions

View file

@ -83,16 +83,6 @@ struct llext_symtable {
struct llext_symbol Z_GENERIC_SECTION(".exported_sym") __used \
symbol_##x = {STRINGIFY(x), (void *)&x}
/**
* @brief Export a system call to a table of symbols
*
* Takes a system call name and uses @a EXPORT_SYMBOL() to export the respective
* function.
*
* @param x System call to export
*/
#define EXPORT_SYSCALL(x) EXPORT_SYMBOL(z_impl_ ## x)
/**
* @}
*/

View file

@ -196,7 +196,6 @@ int z_impl_k_mutex_lock(struct k_mutex *mutex, k_timeout_t timeout)
return -EAGAIN;
}
EXPORT_SYSCALL(k_mutex_lock);
#ifdef CONFIG_USERSPACE
static inline int z_vrfy_k_mutex_lock(struct k_mutex *mutex,
@ -282,7 +281,6 @@ k_mutex_unlock_return:
return 0;
}
EXPORT_SYSCALL(k_mutex_unlock);
#ifdef CONFIG_USERSPACE
static inline int z_vrfy_k_mutex_unlock(struct k_mutex *mutex)

View file

@ -52,6 +52,8 @@ noweak = ["z_mrsh_k_object_release",
table_template = """/* auto-generated by gen_syscalls.py, don't edit */
#include <zephyr/llext/symbol.h>
/* Weak handler functions that get replaced by the real ones unless a system
* call is not implemented due to kernel configuration.
*/
@ -60,6 +62,8 @@ table_template = """/* auto-generated by gen_syscalls.py, don't edit */
const _k_syscall_handler_t _k_syscall_table[K_SYSCALL_LIMIT] = {
\t%s
};
/* Export syscalls for extensions */
%s
"""
list_template = """/* auto-generated by gen_syscalls.py, don't edit */
@ -460,8 +464,12 @@ def main():
weak_defines += "\n".join(["extern uintptr_t %s(uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6, void *ssf);"
% s for s in noweak])
# Export symbols for emitted syscalls
exported_symbols = "\n".join("EXPORT_SYMBOL(%s);" % e for e in emit_list)
fp.write(table_template % (weak_defines,
",\n\t".join(table_entries)))
",\n\t".join(table_entries),
exported_symbols))
# Listing header emitted to stdout
ids_emit.sort()

View file

@ -329,7 +329,6 @@ void z_impl_z_log_msg_static_create(const void *source,
z_log_msg_finalize(msg, source, out_desc, data);
}
EXPORT_SYSCALL(z_log_msg_static_create);
#ifdef CONFIG_USERSPACE
static inline void z_vrfy_z_log_msg_static_create(const void *source,