Commit Graph

3700 Commits

Author SHA1 Message Date
anjiahao 4a01a723d2 Revert "[BUGFIX]:Syscall parameter and return value truncation"
This reverts commit a9cb604f0cede2bb785af1a9da9ed27986ac7c80.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:38 +08:00
anjiahao 4a2970f652 wraps:remove unnecessary sed entries and directly define --wrap=xxx
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:31 +08:00
anjiahao 6d9849b204 wrapsymbol:support build with Cmake and Makefile
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:35:06 +08:00
Bowen Wang 5fd7cf4dc1 syscall: remove the SYSCALL_LOOKUP1 because it's not needed
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-04-21 01:34:47 +08:00
anjiahao 0822f073b6 syscall:Decouple SCHED_INSTRUMENTATION_SYSCALL and LIB_SYSCALL_WRAPPER
SCHED_INSTRUMENTATION_SYSCALL:enable note
LIB_SYSCALL_WRAPPER: generate wrap for syscall

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:34:20 +08:00
xuxingliang 8afc5ce3b9 note: change tag and level to 8bit
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:15 +08:00
xuxingliang 2de6bebd48 sched_note: add event level
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:12 +08:00
xuxingliang c587bac878 Revert tricore coredump register handling changes
Revert two commits that introduced special register handling for tricore
architecture:
- f0006bec "coredump.c:make the registers saved by active assert
  consistent with those in the coredump"
- 5835c0ed "coredump: fix tricore coredump not working"

Reason:
Tricore has an ordinary register context layout similar to other
architectures and doesn't require up_copyusercontext. The current
implementation where tcb->xcp.regs points to the upper register causes
the lower CSA to be lost (the last CSA is located 0x40 bytes above
the upper CSA).

Treating tricore consistently with other architectures allows all
registers to be accessed correctly via g_reginfo.toffset, providing
a unified solution.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2026-04-21 01:34:04 +08:00
guoshichao 2c27af036b environ: move the environ from sched/environ to libc/environ
change the environ implementation from sched/environ to
libc/environ, thus we can access the environ related API can vai libc
directl, which could improve the access speed in kernel build.
And in order to support this modification, we change the
struct task_info_s's ta_lock from nxmutex_t to nxrmutex_t,
this is because the env_*-related APIs require the ta_lock
to be reentrant.
If recursive locks are not supported, it may lead to deadlocks
in certain scenarios. For example, during initialization on the
qemu-miwear platform, it is necessary to call getenv while already
holding the ta_lock. To support such cases, we need to change
the ta_lock from nxmutex_t to nxrmutex_t.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-04-21 01:34:01 +08:00
zhengyu16 89af2157b1 fs: rename PSEUDOFS_SOFTLINKS to FS_LINKS
Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
2026-04-21 01:33:21 +08:00
hujun5 26979b88b6 sem: Avoid multiple conversions between time and tick
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:32:56 +08:00
hujun5 0357df0c93 sem: make the following interfaces inline and avoid syscall when fastpath
int nxsem_clockwait
int nxsem_tickwait
int nxsem_timedwait
int nxsem_tickwait_uninterruptible
int nxsem_clockwait_uninterruptible
int nxsem_timedwait_uninterruptible

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:32:30 +08:00
hujun5 93832e828f sem: remove nxsem_tickwait syscall
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:32:30 +08:00
guoshichao a68df88c19 signal: make the signal comply with the POSIX standard
1. for sigevent struct that defined in signal.h
For UNIX98 mode:
   When the header file <mqueue.h> is included, the sigevent
   structure is defined and contains the member sigev_notify of type
   int.
For POSIX01 and UNIX03 modes:
   If the implementation supports the Message Passing option for
   compilation:
   When the header file <mqueue.h> is included, the sigevent
   structure is defined and contains the member sigev_notify of
   type int.
For UNIX98 mode:
   When the header file <mqueue.h> is included, the sigevent
   structure shall be defined and contain the member sigev_signo of
   type int.
For POSIX01 and UNIX03 modes:
   If the implementation supports the Message Passing option for
   compilation:
   When the header file <mqueue.h> is included, the sigevent
   structure shall be defined and contain the member sigev_signo
   of type int.
2. for signal.h function prototype declaration
For UNIX98 mode:
   When the header <signal.h> is included, the function prototype int
   sigqueue(pid_t, int, const union sigval) is declared.
For POSIX08 and UNIX10 modes:
   When the header <signal.h> is included, the function prototype int
   sigqueue(pid_t, int, union sigval) is declared.
For other test modes:
   If _POSIX_REALTIME_SIGNALS is not defined as -1 in <unistd.h>:
   When the header <signal.h> is included, the function prototype
   int sigqueue(pid_t, int, const union sigval) is declared.
3. for signal.h, the siginfo_t struct:
When the header file <signal.h> is included, the siginfo_t structure
type shall contain the member si_signo of type int.
When the header file <signal.h> is included, the siginfo_t structure
type shall contain the member si_code of type int.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-04-21 01:32:24 +08:00
v-tangmeng 37fd05542a fix the compile error
exec_symtab.c:1129:38: error: 'sched_lock' undeclared here (not in a function); did you mean 'g_schedlock'?
   1129 |   { "sched_lock", (FAR const void *)&sched_lock },
        |                                      ^~~~~~~~~~
        |                                      g_schedlock
  exec_symtab.c:1143:40: error: 'sched_unlock' undeclared here (not in a function); did you mean 'nxsched_unlock'?
   1143 |   { "sched_unlock", (FAR const void *)&sched_unlock },
        |                                        ^~~~~~~~~~~~
        |                                        nxsched_unlock

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-04-21 01:32:19 +08:00
anjiahao dee6d3ae0a Revert "libs/libc: Put posix_spawn into libc"
We use USERSPACE to get builtin data,so don't need this patch

This reverts commit ef1f5ba351eb4a35ea31b84be92d6ce58e072a31.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:32:17 +08:00
hujun5 b8a9e785a2 sched: move sched_lock/sched_unlock from sched/sched.h to nuttx/sched.h
The scope of application of the inline version of sched_lock in the kernel can be expanded.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:32:03 +08:00
wangmingrong1 9a0eca03e5 syscall: add coredump to syscall
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-04-21 01:31:53 +08:00
guoshichao 5863c8d868 add support for CONFIG_DISABLE_SIGNALS
1. add the DISABLE_SIGNALS build option
2. make the sleep/usleep/nanosleep function can work with signal
   function disabled
3. make the driver/fs/sched/libc kernel module can decouple from signal
   module

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-04-21 01:31:32 +08:00
yinshengkai 94efbec0a8 note: note_printf supports 29 parameters when NOTE_STRIP_FORMAT is enabled
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-04-21 01:28:51 +08:00
anjiahao 7fe3632c4f syslog:setlogmask to pre task
setlogmask for a task
nx_setlogmask for all system syslog.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:28:46 +08:00
makejian d838289d9f libc/mutex: fix Fix MISRA delay overflow
Signed-off-by: makejian <makejian@xiaomi.com>
2026-04-21 01:28:32 +08:00
yangsong8 3f53cbe281 libs/libc: Put posix_spawn into libc
When protect building mode, posix_spawn only enters the kernel space to
find the buildin executable file, but some executable files are in user
space. So first execute posix_spawn. If it is not found in kernel
space, then execute task_spawn to start it.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-04-21 01:28:02 +08:00
yinshengkai 1065a53393 arch: Added ARCH_PERF_EVENTS_USER_ACCESS config
Make this feature optional and only available in non-flat builds

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-04-21 01:26:16 +08:00
anjiahao 86bf503101 Use macro replacement function to implement up_assert
avoid two syscall in protect build and kernel build

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:26:13 +08:00
Gao Jiawei 1b7fb802c8 Support extending custom syscalls without hacking libc syscalls
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2026-04-21 01:25:22 +08:00
Gao Jiawei 795450ee59 Implement several cmake syscall utility functions
1. parse a given syscall csv file into a list of syscall files
2. generate stub/proxy/wraps syscall files accordingly

Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2026-04-21 01:25:22 +08:00
ligd d6582cca9c syscall: fix compile filed when use kernel mode
smartspeaker-knsh/libs/libc/libc.a(lib_mutex.c.o): in function `nxmutex_clocklock':
libs/libc/misc/lib_mutex.c:203:(.text.nxrmutex_clocklock+0x40): undefined reference to `nxsem_clockwait_uninterruptible'

Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-04-21 01:25:17 +08:00
wushenhui c68ab25d42 syscall: add clock_getres() to syscall
Signed-off-by: wushenhui <wushenhui@xiaomi.com>
2026-04-21 01:25:13 +08:00
hujun5 e377a05820 pthread: move pthread_cond to userspace
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:24:18 +08:00
anjiahao a3dac2bdba [BUGFIX]:Syscall parameter and return value truncation
bug find:
if use CONFIG_LARGE_FILE, sizeof(off_t) > sizeof(uinptr_t)
so, in PROXY_lseek

```
off_t lseek(int parm1, off_t parm2, int parm3)
{
  return (off_t)syscall4((unsigned int)SYS_lseek, (uinptr_t)parm1, (uinptr_t)parm2, (uinptr_t)parm3)
}
```

param1 will be truncate!, so bug happend!, and in STUB also have it bug
on return value

how to fix:

add -r option to mark what type need use pointer, like off_t

before fix generate code like:

PROXY
```
off_t lseek(int parm1, off_t parm2, int parm3)
{
  off_t ret;
  sys_call4((unsigned int)SYS_lseek, (uintptr_t)parm1, (uintptr_t)&parm2, (uintptr_t)parm3, (uintptr_t)&ret);
  return ret;
}

```

STUB

```
uintptr_t STUB_lseek(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t ret)
{
  *(FAR off_t *) ret = lseek((int)parm1, *(off_t *)parm2, (int)parm3);
  return 0;
}
```

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:24:13 +08:00
xuxin19 112e55bb43 cmake(bugfix):add missing syscall wrap ldcmd cmake support
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-21 01:24:11 +08:00
hujun5 4e152646d6 pthread: remove syscall for pthread
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:24:07 +08:00
Yanfeng Liu e62258bcab note/syscall: adapt to perf user access
The `perf_gettime` syscall should be disabled when userland
PMU access is enabled.

As `perf_gettime()` may not always be syscall, note drivers
also need use the right one adaptively.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2026-04-21 01:23:49 +08:00
hujun5 7e90357a2a sched/getpid: Move process ID to TLS
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:23:45 +08:00
Jukka Laitinen ce8ee1a8b4 Clean up the nxmutex library
- Remove the redundant holder, as nxsem now manages hoder TID
- Remove DEBUGASSERTIONS which are managed in nxsem
- Remove the "reset" handling logic, as it is now managed in nxsem
- Inline the simplest functions

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:23:18 +08:00
Ville Juven d9578509eb sched/gettid: Move thread ID to TLS
There is no need for a gettid() syscall, as the thread ID is stable through
the life of the process. It is safe to put a copy of TID to TLS. This way
a user processes can access TID quickly via its own stack, instead of
having to use an expensive syscall.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:23:16 +08:00
Jukka Laitinen 1f44e05f60 libc/semaphore: Move fast mutex wait/post paths to libc
This avoids unnecessary syscalls in memory protected builds, when mutex
lock/unlock can be done with only atomic counter access

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:23:16 +08:00
anjiahao 8f0d8724c3 syscall:remove unnecessary syscall
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:23:01 +08:00
yukangzhi 7a5a8daad5 syscall: export 'sched_note_event_ip' as a syscall
The DFX framework needs to use the sched_note_event_ip
interface to output event-type logs, and the log type
is NOTE_DUMP_BINARY.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-04-21 01:22:28 +08:00
yukangzhi 3b9fca183b syscall: Fix compilation error when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Add compilation condition for 'nx_vsyslog' syscall.
Export 'sched_note_printf_ip' syscall when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Put the implementation of sched_note_printf_ip in libc/misc/lib_note.c

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-04-21 01:22:28 +08:00
Yanfeng Liu 7b5be030be syscall/perf: add perf_xxx() API
This adds perf_gettime() and perf_convert() APIs to syscall so that
to use them from userspace of PROTECTED or KERNEL builds.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2026-04-21 01:21:54 +08:00
dongjiuzhu1 4221609d5c syscall/adjtime: fix minior issue about adjtime and add clock_adjtime to syscall
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-04-21 01:21:53 +08:00
xuxin19 999cf471b2 cmake(bugfix):rename host tools binary dir to host_bin
we will use CMAKE_BINARY_DIR/bin for apps elf
so we need to change host tools to bin_host

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-04-21 01:21:12 +08:00
hujun5 28629cbb28 sched: remove csection and reduce the interrupt disabling time in sched_[un]lock
reason:
1 Accelerated the implementation of sched_lock, remove enter_critical_section in sched_lock and
only enter_critical_section when task scheduling is required.
2 we add sched_lock_wo_note/sched_unlock_wo_note and it does not perform instrumentation logic

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:19:40 +08:00
buxiasen 4824683c94 syscall: add missing epoll API
Add missing epoll syscall API for kernelbuild
epoll_create, epoll_pwait, epoll_close

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-04-21 01:19:36 +08:00
anjiahao 8442057a47 up_assert:up_assert need add to SYSCALL_LOOKUP
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:19:29 +08:00
anjiahao 6d1b8aa4fc add up_assert using syscall to trigger _assert
use syscall to trigger assert

irq can stop all task running, and we can use irq stack to do assert,
reduce thread task

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:19:25 +08:00
guoshichao 0da6e3863b net: make the sendmsg param type consistent with posix specification
To ensure consistency, in all places where the "sendmsg" function is used
either directly or indirectly, the type of the "struct msghdr *msg" parameter
needs to be modified to "const struct msghdr *msg".

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-04-21 01:19:18 +08:00
anjiahao 312a82803b Kconfig:add ARCH_HAVE_SYSCALL option
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-04-21 01:16:08 +08:00