Commit Graph

3133 Commits

Author SHA1 Message Date
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
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
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
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
zhangwenjian c49e5bffc6 perf:support host(perf report) to show symbol name
copy the file(perf.data) to host from device,before use (perf report)
need use the "perfaddmmap.py -e elffile" to add the mmapinfo.

Signed-off-by: zhangwenjian <zhangwenjian@xiaomi.com>
2026-04-21 01:14:57 +08:00
hujun5 7bb536845c Revert "system: pthread_barrierwait should be moved to kernel space"
reason:
new implementation does not requires the use of enter_critical_section,
so the source code needs to be moved to user space

This reverts commit d189a86a35482fc20951031e2b9bcb39929deef9.
2026-04-21 01:14:23 +08:00
YAMAMOTO Takashi 295a69730d move readv/writev to the kernel
currently, nuttx implements readv/writev on the top of read/write.
while it might work for the simplest cases, it's broken by design.
for example, it's impossible to make it work correctly for files
which need to preserve data boundaries without allocating a single
contiguous buffer. (udp socket, some character devices, etc)

this change is a start of the migration to a better design.
that is, implement read/write on the top of readv/writev.

to avoid a single huge change, following things will NOT be done in
this commit:

* fix actual bugs caused by the original readv-based-on-read design.
  (cf. https://github.com/apache/nuttx/pull/12674)

* adapt filesystems/drivers to actually benefit from the new interface.
  (except a few trivial examples)

* eventually retire the old interface.

* retire read/write syscalls. implement them in libc instead.

* pread/pwrite/preadv/pwritev (except the introduction of struct uio,
  which is a preparation to back these variations with the new
  interface.)
2026-04-21 01:13:26 +08:00
Xiang Xiao 66995e369b libc: Refine the arc4random_buf implementation
fill the buffer with getrandom instead random pool
and move the implementation to from crypto to libc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-04-21 01:12:48 +08:00
openvela-robot 3f5efb76a6 cmake/add_library: enable library install by default
enable library install by default to support nuttx export for cmake

nuttx$ cmake --install build  --prefix $PWD/build/staging/
-- Install configuration: ""
-- Installing: nuttx/build/staging/lib/libarch.a
-- Installing: nuttx/build/staging/lib/libbinfmt.a
-- Installing: nuttx/build/staging/lib/libdrivers.a
-- Installing: nuttx/build/staging/lib/libfs.a
...

Signed-off-by: chao an <anchao@lixiang.com>
2026-04-21 01:06:16 +08:00
openvela-robot 83c1f66586 nuttx/qemu: Fix funciton up_idle multiple definition
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2026-04-21 01:06:09 +08:00
openvela-robot 65c91478e5 arm: sync with community
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-04-21 01:06:03 +08:00
openvela-robot 614f4f9672 Contributing and PR template fix.
* Fix CONTRIBUTING.md github link reference.
* Full URL is provided to avoid relative/fork reference issues.
* Minor update on full contributing documentation.

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2026-04-21 01:05:58 +08:00
openvela-robot f5d3c904aa arch/intel64_irq.c: synchronize file with NuttX upstream
move up_trigger_irq() at the same place
rename g_irq_spin to g_irq_spinlock

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2026-04-21 01:05:52 +08:00
openvela-robot d512cd4df8 goldfish: sync with qemu do rpmsg_syslog init at goldfish
Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-04-21 01:05:47 +08:00
openvela-robot f8fa980a97 CMake/preprocess: fix typo PREPROCES -> PREPROCESS
correct the marco define from PREPROCES to PREPROCESS

Signed-off-by: chao an <anchao@lixiang.com>
2026-04-21 01:05:41 +08:00