Commit Graph

299 Commits

Author SHA1 Message Date
Xiang Xiao 819fbd22cc sched: Implement tkill/tgkill
https://linux.die.net/man/2/tgkill

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-26 08:11:56 +02:00
Xiang Xiao 43e7b13697 assert: Log the assertion expression in case of fail
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-24 15:00:19 -03:00
Jukka Laitinen b09581f736 Add shm_open and shm_unlink to syscalls
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-18 11:01:20 +08:00
Xiang Xiao 695f42f8d2 net: Move accept to libc after https://github.com/apache/nuttx/pull/8083
since accept can simply forward to kernel accept4 function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-13 11:23:42 +02:00
zhanghongyu 48c9d10336 net_socket: add accept4 function
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-11 23:28:08 +08:00
Jukka Laitinen 0a885da434 syscall: Always add munmap into syscalls
Munmap interface is always enabled just like mmap is

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-11 03:11:11 +08:00
Ville Juven 172b209f2d sched/assert: Re-implement assert() into user space
_assert is a kernel procedure, entered via system call to make the core
dump in privileged mode.

Running exit() from this context is not OK as it runs the registered
exit functions and flushes streams, which must not be done
from privileged mode as it is a security hole.

Thus, implement assert() into user space (again) and remove the exit()
call from the kernel procedure.
2022-12-22 21:07:47 +08:00
Ville Juven 2ed51d026c fs/streams: Move the file streams from the group structure into TLS
This is preparation for flushing streams from user space, like it should
be done.

- Move tg_streamlist (group, kernel space) ->
       ta_streamlist (TLS, user space)
- Access stream list via tg_info in kernel
- Access stream list via TLS in user space
- Remove / rename nxsched_get_streams -> lib_getstreams
- Remove system call for nxsched_get_streams
2022-12-22 20:16:11 +08:00
田昕 2719869ab2 Move _assert to kernel space.
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-12-06 18:33:21 +08:00
Michael Jung b401db5ca4 prctl syscall is present unconditionally
I had a link problem regarding prctl while CONFIG_TASK_NAME_SIZE was
defined 0 and building in protected mode.  Turns out in monolithic
build prctl is present no matter what CONFIG_TASK_NAME_SIZE, but in
protected mode build its only present if CONFIG_TASK_NAME_SIZE > 0.
So, bring protected mode build in sync with the monolithic one.

Signed-off-by: Michael Jung <michael.jung@secore.ly>
2022-11-09 01:21:16 +08:00
Xiang Xiao 19bded4738 fs: Remove the unused nx_pipe to prefer file_pipe for kernel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 23:14:25 +02:00
Xiang Xiao ee82f7b5ca Fix error: proxies/PROXY_socketpair.c:9:55: error: argument 4 of type 'int *' declared as a pointer [-Werror=array-parameter=]
9 | int socketpair(int parm1, int parm2, int parm3, int * parm4)
      |                                                 ~~~~~~^~~~~
In file included from proxies/PROXY_socketpair.c:4:
/github/workspace/sources/nuttx/include/sys/socket.h:373:56: note: previously declared as an array 'int[2]'
  373 | int socketpair(int domain, int type, int protocol, int sv[2]);
      |

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-23 12:08:30 +08:00
yangxuan8282 c77743c463 syscall: fix task_testcancel header file 2022-08-24 16:47:19 +08:00
Jiuzhu Dong aeec797511 syscall: remove directory syscall
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-10 13:33:08 +08:00
Masayuki Ishikawa d96c87f666 syscall: Add socketpair to syscall.csv
Summary:
- This commit adds socketpair to syscall.csv

Impact:
- None

Testing:
- Tested with adb (not merged net)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-07-15 13:31:58 +08:00
Masayuki Ishikawa a384b05aa4 syscall: Fix task_tls_alloc in syscall.csv
Summary:
- This commit fixes comiple error for task_tls_alloc

Impact:
- None

Testing:
- Tested with sabre-6quad:netknsh (not merged yet)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-07-11 09:32:52 -03:00
Ville Juven ba4277bb13 syscall: Remove exit() call gate
exit() is a userspace function, no need for call gate
2022-06-20 14:14:28 +03:00
Ville Juven a54c3d13f9 sched: Remove SCHED_ATEXIT / SCHED_ONEXIT
Remove the kernel side implementations altogether. These will be
replaced by user land implementations.
2022-05-25 15:28:43 +08:00
Ville Juven 5bcd1dbb64 sched: Remove task_restart in case of CONFIG_BUILD_KERNEL
Same treatment as task_delete, this is not usable in kernel build
either.
2022-05-12 22:08:19 +08:00
Ville Juven b1d92159fa sched: Remove task_delete in case of CONFIG_BUILD_KERNEL
Deleting a task from another task's context will not do, so shut
this gate down for BUILD_KERNEL. In this case if a task wants another
task to terminate, it must ask the other task to politely kill itself.

Note: kthreads still need this, also, the kernel can delete a task
without asking.
2022-05-12 03:27:25 +08:00
Ville Juven cf90e3f66b syscall: Fix prototype of exec() to syscall.csv 2022-04-22 14:34:42 +03:00
Xiang Xiao 55b5561fdb sched/task: Implement execle and execve
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 10:40:31 +03:00
Ville Juven d6ef4849a9 syscall: Add call gate for get_environ_ptr
Now that the environment strings are stored as an array of strings,
they can be passed from the application via char **environ, which
is really defined as a function call to get_environ_ptr().

This works as is for flat build, but protected mode and kernel mode
require a call gate, which is added here.
2022-04-21 18:38:37 +08:00
Xiang Xiao 9f7ecbd5b7 syscall: Fix Makefile:69: target 'syscall_names.o' given more than once in the same rule
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-04 08:44:50 +02:00
chao.an ea42981cc6 syscall/names: export the syscall name in STUB module
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-14 21:37:53 +02:00
Xiang Xiao 4deaa6d29d syscal: Remove .context form .gitignore
since it is already added in the top level of .gitignore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 10:42:05 +01:00
Xiang Xiao 44bd3212d4 arch: Remove SYS_RESERVED from Kconfg
let's arch define the correct value instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-27 22:54:13 +08:00
Huang Qi e516c6247e sched: Implement task local storage
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-23 22:05:02 +08:00
Huang Qi c0a0de97ce Revert "libc: Call pthread_exit in user-space by up_pthread_exit"
This reverts commit f4a0b7aedd.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Xiang Xiao 0000e61da6 task: Always implement posix_spawnp as macro
Since there is no benefit to implement it as
function when CONFIG_LIBC_ENVPATH equals y

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-09 20:09:11 +08:00
Xiang Xiao ab3b0d0162 sched: Implement sysinfo function
specify here:
https://man7.org/linux/man-pages/man2/sysinfo.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-08 10:27:38 +08:00
Xiang Xiao 86684105f9 serial: Move tcdrain implementation from drivers/serial to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 08:11:08 -03:00
Xiang Xiao dd942f0b04 sched/backtrace: Dump the complete stack regardless the depth
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 12:09:54 +08:00
Petro Karashchenko d445282566 fs/vfs: Add file descriptor based timers support
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-20 04:00:20 -06:00
Xiang Xiao c562263205 net: Move if_nametoindex and if_indextoname to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 10:08:57 -06:00
chao.an 1060953567 sched/backtrace: add sched_backtrace support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 01:30:50 -07:00
Xiang Xiao 6c61d032db fs: Add utimens and lutimens
https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html
https://www.daemon-systems.org/man/utimens.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-08-09 17:55:44 -03:00
Xiang Xiao b12f588140 Rename CONFIG_LIB_BOARDCTL to CONFIG_BOARDCTL
since boardctl isn't a libc feature

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-08-06 13:58:26 +02:00
Xiang Xiao 5025fbef8d Rename LIB_ to LIBC_ for all libc Kconfig
follow other libc component naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-08-05 19:45:24 +02:00
Xiang Xiao 307cc61893 fs: Add fchstat and chstat callback into mountpt_operations
and implement all status related change function. the individual
file system change will provide in other upcoming patchset.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8fde9db8eba9586e9c8da078b67e020c26623cf4
2021-07-29 06:33:49 -03:00
Xiang Xiao 663104a2e9 fs: Simplify sendfile implementation
and avoid call nx_ file API in the kernel space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id951ca161df2c2ee267dc4b5a0d7dfa67df4c1e6
2021-07-17 07:39:15 -03:00
Huang Qi 50c08bf45b libc: Move pthread_key_destructor to task_info_s
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-07-04 07:36:44 -05:00
YAMAMOTO Takashi b3e8535ad6 Revert "tls: Move pthread key destructor to libc"
This reverts commit cc514d7791.

* It introduced a regression.
  https://github.com/apache/incubator-nuttx/issues/3868

* It seems conceptually wrong to have per-process data in
  the main thread's stack.
2021-06-09 07:59:44 -05:00
Huang Qi cc514d7791 tls: Move pthread key destructor to libc
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-06-06 15:25:56 -06:00
Xiang Xiao ae216cf9e9 sched/task: Simplify the syscall handling of task_spawn
It's better to save one argument by returning pid directly.
This change also follow the convention of task_create.
BTW, it is reasonable to adjust the function prototype a
little bit from both implementation and consistency since
task_spawn is NuttX specific API.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 12:45:10 +09:00
Gregory Nutt b991f30b82 syscall/syscall.csv: Correct ordering of entries
OS functions in syscall.csv are ordered alphabetically.  However, two recently added functions are not in the correct location.  This PR simply corrects that ordering.

The ordering of one entry was also corrected in libs/libc/libc.csv.  Same issue.

This change is only cosmetic.

Verified only by CI
2021-05-31 21:15:36 -05:00
Huang Qi d374d55926 pthread: Implement destructor of pthread_key_create
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: I6aafba9680257cba071bf1f72ae2ec2c475f5fb0
2021-05-21 22:46:52 -06:00
Huang Qi f4a0b7aedd libc: Call pthread_exit in user-space by up_pthread_exit
Drop to user-space in kernel/protected build with up_pthread_exit,
now all pthread_cleanup functions executed in user mode.

* A new syscall SYS_pthread_exit added
* A new tcb flag TCB_FLAG_CANCEL_DOING added
* up_pthread_exit implemented for riscv/arm arch

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Huang Qi f1a92e9cbb libc: Move pthread_cleanup to user space
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Huang Qi 54eef9f639 libc: Move pthread_exit to userspace
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00