Commit Graph

229 Commits

Author SHA1 Message Date
Guorui Li
1aef0dba71 [components/lwp]add doxygen comment for lwp futex. (#10763) 2025-10-04 10:02:21 +08:00
ligr
7b8e8c95ba [components/lwp]add doxygen comment for lwp_dbg.c. 2025-09-26 16:52:46 +08:00
ligr
0785e224ce [components/lwp]add doxygen comment for lwp avl implementation. 2025-09-25 13:46:21 +08:00
ligr
a84e75527d [components/lwp]add doxygen comment for lwp_tid. 2025-09-24 18:14:03 +08:00
Yonggang Luo
66b2bcc080 RT_TIMER_CTRL_SET_TIME only accept rt_tick_t, pass rt_tick_t instead int/rt_int32_t 2025-09-24 18:12:36 +08:00
Guorui Li
2cd44e23c0 [components/lwp]add doxygen comment for lwp_pid. #10702 2025-09-19 18:18:26 +08:00
Guorui Li
5455622ad3 [components/lwp]add doxygen comment for lwp_args. (#10696) 2025-09-14 11:26:31 +08:00
Yulong Wang
ee1fe2024e [lwp][rv64] riscv: fix potential signal handler infinite loop 2025-07-23 09:39:17 +08:00
Yulong Wang
e7a40ae6ec [lwp][rv64] restore tp register in arch_thread_signal_enter to fix user-mode memory access 2025-07-23 09:38:35 +08:00
bernard
e00143904f [smart] Optimize error handling after command execution 2025-07-07 09:44:37 +08:00
bernard
172676e115 [smart] rename the Group name to 'lwProcess' and optimize the error handling for vDSO building. 2025-07-07 09:44:37 +08:00
bernard
cb1a58cf37 [vdso] fix the arch/abi flag issue. 2025-06-30 09:52:09 +08:00
BernardXiong
a5359b7223 [vdso] use the default arch/abi flags in risc-v vDSO building. 2025-06-30 09:52:09 +08:00
bernard
83f6747245 [smart] Fix parameter issue when calling the __arch_get_hw_counter function. 2025-05-19 18:29:26 +08:00
bernard
1c46d55ad9 [smart] Enhance build script with additional cleanup steps 2025-05-19 18:29:26 +08:00
bernard
7e2b74a693 [smart] Fix typo in vDSO Kconfig. 2025-05-19 18:29:26 +08:00
bernard
921abdfb41 [smart] move vdso.c to arch/common folder. 2025-05-19 18:29:26 +08:00
bernard
721dfbfe01 [smart] Add vDSO support for RISC-V architecture and refactor related components
- Implemented vDSO functionality for the RISC-V architecture, including the necessary source files and linker scripts.
- Introduced a new `vdso_sys.c` file for RISC-V, containing functions to handle time retrieval using the vDSO mechanism.
- Created architecture-specific linker scripts (`vdso.lds.S`) for both AArch64 and RISC-V.
- Updated the build system to support vDSO compilation for RISC-V, including necessary adjustments in `SConstruct` files.
- Refactored existing vDSO code to improve compatibility and maintainability across architectures.
- Adjusted the maximum number of PTY devices in the terminal configuration from 64 to 32 for better resource management.
- Fixed minor issues in existing code, including correcting the path for the vDSO shared library and ensuring proper function definitions.
2025-05-19 18:29:26 +08:00
Guorui Li
1635fb497a [component/lwp]add annotation for lwp elf. (#10230)
* [component/lwp]add annotation for lwp elf.

* Update components/lwp/lwp_elf.c

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-09 02:55:29 +08:00
wycwyhwyq
12de72a462 add RT_THREAD_CTRL_SET_PRIORITY 2025-04-13 15:25:42 +08:00
wycwyhwyq
da1c5c7882 add RT_THREAD_CTRL_SET_PRIORITY 2025-04-13 15:25:42 +08:00
Shell
9386411d13 feat: mm: added affinity pages allocator
This patch introduces a tagged pages allocator to address the existing problems
of page aliasing on specific platforms and the requirement of page coloring.
It implements an affinity-id aware page manager by separating the runtime page
list into two types: a normal single linked-list and a multi-dimensional affinity-list.

Changes:
- Introduced tagged pages allocator and managing algorithm for affinity pages list
- Modified components to support affinity-id list management
- Updated page allocation and freeing functions to handle tagged pages
- Added configuration options for page affinity block size and debugging
- Modified mmap and elf loading to respect affinity settings
- Enhanced page list management to support multi-dimensional affinity-list

Signed-off-by: Shell <smokewood@qq.com>
2025-02-25 11:26:30 +08:00
heyuanjie87
5206b3ae2d [lwp/riscv]修正用户态参数空间占用堆地址空间的问题 (#10014)
* [lwp/riscv]修正用户态参数空间占用堆空间的问题
2025-02-24 09:17:22 +08:00
Guorui Li
6a792c9df2 [lwp]add comments for lwp system calls. (#9934) 2025-02-18 19:51:10 +08:00
heyuanjie87
4b25b5ed9a [lwp]检查killpg的signo参数的有效性 (#9981)
* [lwp]对检查killpg的signo参数的有效性
2025-02-18 14:33:56 +08:00
heyuanjie87
6e3c9acd39 [lwp]修正kill(pid < -1)时的返回值错误 2025-02-08 14:32:20 +08:00
heyuanjie87
ed3222c2f8 [lwp]修正无法通过文件名查找pid的问题 (#9935) 2025-01-21 13:01:58 +08:00
Chen Wang
d3841c3109 lwp: Kconfig: LWP_DEBUG default as n (#9921)
LWP_DEBUG is debugging related, should be disabled
by default.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
2025-01-16 19:56:44 +08:00
Meco Man
97b9cc5000 fix: add \n for addr2line hint 2025-01-08 17:54:46 -05:00
Shell
b63b388d1f feat: add support for dfs remount functionality
This patch introduces a remount feature for the DFS, allowing for the
modification of mount parameters without unmounting the filesystem,
the remount functionality helps modify certain mount flags (like `MS_RDONLY`) without
requiring an unmount, providing more control over mounted filesystems in the system.

The updates is essential for user space init proc to cleanup the runtime
resource, ensuring clean handling of cached data and enhancing system
robustness during power down processing.

Changes:
- Defined new constants for remount flags in `dfs_fs.h`.
- Added the `dfs_remount()` function in `dfs_fs.c` to handle remount operations.
- Introduced a check for unsupported flags and handle error conditions such as invalid paths
  or non-directory targets.
- Updated the `dfs_mnt` structure in `dfs_mnt.h` to include a read-only flag (`MNT_RDONLY`).
- The `dfs_remount()` function allows changing the read-only status of a mounted filesystem.
- Added `MNT_LAZY_UMNT` and `MNT_RDONLY` flags to `dfs_mnt` structure.
- Introduced `dfs_mnt_setflags` function for dynamic flag management.
- Updated `dfs_remount` to utilize `dfs_mnt_setflags` for flag setting.
- Enhanced unmount operations with `dfs_mnt_umount_iter` and lazy unmounting.
- Added `dfs_pcache_clean` to handle cache cleanup for read-only mounts.
- Improved error reporting in `dfs_umount` for better user feedback.
- Refactored `sys_mount` to streamline parameter handling and support remounts.
- Introduced `_cp_from_usr_string` helper for user-space string operations.
- Updated internal APIs to ensure consistency in reference count management.

Signed-off-by: Shell <smokewood@qq.com>
2025-01-06 19:34:16 +08:00
Shell
944f3d05b5 feat: add system reboot and process teardown support
The patch introduces support for system reboot functionality and process teardown,
allowing for a clean shutdown and unmounting of the root filesystem. This is
necessary for ensuring a proper system shutdown process, especially when dealing
with resource cleanup and ensuring that all processes have exited before system
shutdown.

Changes:
- Added `lwp_teardown()` function to handle process cleanup and system teardown.
- Introduced `lwp_pid_wait_for_empty()` to wait for process ID table emptiness
  before proceeding with shutdown.
- Updated `dfs_mnt_unref()` to trigger callbacks when unmounting a filesystem.
- Added new reboot types (`RB_AUTOBOOT`, `RB_POWER_OFF`) and implemented their
  corresponding actions, including cleanup of processes and unmounting root
  filesystem.
- Extended `sys_reboot()` to handle reboot and power off types with appropriate
  callbacks for process and filesystem teardown.
- Introduced callback mechanism for root filesystem unmount notifications.

Signed-off-by: Shell <smokewood@qq.com>
2025-01-06 19:34:16 +08:00
Shell
972931c991 feat: add universal process runtime service
This change introduces the `lwp_runtime.c` component, which provides the
necessary runtime environment for the init process, including boot scripts,
shutdown, and poweroff functionalities. The initialization logic has been
moved from `lwp.c` to this new file, enhancing modularity and flexibility
in handling LWP runtime tasks.

Changes:
- Moved the `lwp_startup` function from `lwp.c` to `lwp_runtime.c` to handle
  system initialization and runtime environment setup.
- Added `lwp_teardown` placeholder for system shutdown and cleanup tasks in
  the future (though not yet implemented).
- Introduced the `LWP_USING_RUNTIME` configuration option in `Kconfig` to
  conditionally enable the runtime environment.
- Updated the `SConscript` to conditionally include `lwp_runtime.c` based on
  the `LWP_USING_RUNTIME` configuration.
- Removed the old `lwp_startup` code from `lwp.c`, simplifying the file.

Signed-off-by: Shell <smokewood@qq.com>
2025-01-06 19:34:16 +08:00
Shell
dc3270f14e feat: add signal kill all functionality
This change introduces the `lwp_signal_kill_all` function, which allows a
signal to be sent to all processes in the system. The function iterates
over all PIDs and sends the specified signal to each process, except those
that are protected from signals. This enhancement provides a convenient way
to broadcast signals across all processes in the system.

Changes:
- Added `lwp_signal_kill_all` function in `lwp_signal.c` to broadcast a
  signal to all processes by iterating over all PIDs using the existing
  `lwp_pid_for_each` function.
- Introduced a new `kill_all_param` structure to encapsulate the signal
  information needed for killing processes.
- Added internal `_kill_each` helper function for sending the signal to each
  PID.
- Updated `lwp_signal.h` with the new function prototype for `lwp_signal_kill_all`.
- Modified `sys_kill` in `lwp_syscall.c` to call `lwp_signal_kill_all` when
  a process is not specified.

Signed-off-by: Shell <smokewood@qq.com>
2025-01-06 19:34:16 +08:00
Shell
c0b0838892 feat: support PID iteration
This change introduces the `lwp_pid_for_each` function, which provides a
convenient and thread-safe method for iterating over PIDs with a user-
defined callback. This addition is necessary to support cases where
operations must be performed on each PID in the balanced tree, enhancing
flexibility and modularity for PID management.

Changes:
- Added `lwp_pid_for_each` function in `lwp_pid.c` to allow iteration
  over PIDs using a callback function and optional data parameter.
- Defined a new internal `pid_foreach_param` structure to encapsulate
  the callback and data for the iteration.
- Added `_before_cb` helper function for executing the callback on each
  PID node during AVL traversal.
- Ensured thread safety by acquiring and releasing the PID lock around
  the AVL traversal within `lwp_pid_for_each`.
- Updated `lwp_pid.h` with the `lwp_pid_for_each` function prototype and
  included `rtthread.h` for necessary types.

Signed-off-by: Shell <smokewood@qq.com>
2025-01-06 19:34:16 +08:00
Chen Wang
7c7ff6e532 kernel: cleanup debug APIs
- `dbg_log` is a “NOT RECOMMENDED API”, convert the calling of this
  API to LOG_x and remove this API.

- `dbg_here`/`dbg_enter`/`dbg_exit`: no one use these APIs, remove
  them directly.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
2024-12-20 17:50:00 -05:00
zhujiale
e4760364f1 [serial] add bypass testcase in utest 2024-12-17 11:08:14 +08:00
zhujiale
ee5b7f1de9 [lwp] fix TTYSUP_CFLAG did not include CBAUD flag 2024-12-12 18:54:30 -05:00
rcitachi
d9c16efe8f Modify the position of libc_rent definition 2024-11-17 11:59:37 -05:00
Shell
20263be180 fixup: smart: uninitialized buffer on mount(2) (#9636)
The `struct stat` object used inside mount(2) is uninitialized, which
can lead to undefined behavior during running

Changes:
- Set zero to buffer before calling to stat()

Signed-off-by: Shell <smokewood@qq.com>
2024-11-12 21:11:50 +08:00
rcitachi
7c27319521 [libc] modify function names to resolve naming conflicts 2024-11-01 18:44:16 -04:00
Shell
cfe1768815 fixup: smart: sys_mount: UAF vulnerability
This patch addresses a use-after-free (UAF) vulnerability in the
sys_mount. The issue occurred due to improper handling of memory
deallocation, which could lead to crashes or undefined behavior on user
request of mounting.

Changes made:
- Moved the `rt_free(copy_source)` function call to occur after the necessary
  operations are completed, preventing premature deallocation of memory.

Signed-off-by: Shell <smokewood@qq.com>
2024-10-21 17:15:52 +08:00
Shell
9a27de92ae feat: smart: user space context optimization
This patch optimizes the user-space context handling in the ARM64
architecture, specifically improving how the context is saved and
restored during system calls and interrupts. The changes make the
code more efficient and easier to maintain, while ensuring proper
preservation of user context during system transitions.

Changes:
- Introduced a parameter for context saving to improve flexibility.
- Replaced hardcoded stack pointer operations with frame-relative
  references for better readability and code reuse.
- Simplified context restoration, removing redundant operations like
  loading/storing floating-point registers.

Signed-off-by: Shell <smokewood@qq.com>
2024-09-19 23:02:39 -04:00
Shell
210cd71128 fixup: pty: possible memory leaking on close()
The ref_count of the vnode is NOT bound to the resource reference counts
of the ptm device created by opening `dev/ptmx`, so the conditional
release of resource may end up by memory leaking if the multiple user
have open the `dev/ptmx`.

Changes:

- Removed conditional branch on recycling resource

Signed-off-by: Shell <smokewood@qq.com>
2024-09-19 23:02:25 -04:00
Shell
3ca6126efc fixup: smart: remove unnecessary Kconfig option
The `LWP_CONSOLE_INPUT_BUFFER_SIZE` is a legacy config option for TTY
driver used in smart. Since the driver is updated, there's no dependency
of this option any more.

Changes:

- Removed unused Kconfig option `LWP_CONSOLE_INPUT_BUFFER_SIZE`

Signed-off-by: Shell <smokewood@qq.com>
2024-09-14 13:50:36 -04:00
zms123456
fb02e7934d [component][net]add more socket flag 2024-09-13 17:30:24 -04:00
heyuanjie87
6d39cdf836 [lwp] 取消脚本中限制rv的具体cpu类别
此目录中为rv64通用代码
2024-09-13 17:28:47 -04:00
zms123456
b423a6b1e3 [components][lwp]remove extra check in sys_bind 2024-09-11 18:04:05 -04:00
Shell
679761983d fixup: ptyfs: CI reported snprintf type issues 2024-09-01 15:12:34 -04:00
zhuzhuzhu
1be24fc7da 【修复】修复link系统调用返回值问题 2024-08-25 10:57:38 -04:00
zhuzhuzhu
dc232080a0 【修复】修复rmdir系统调用返回值不符合用户预期问题 2024-08-25 10:57:15 -04:00