Commit Graph

188 Commits

Author SHA1 Message Date
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
zhuzhuzhu c4c227e367
【修复】修复symlink系统调用返回值不是预期问题 2024-08-25 10:56:03 -04:00
Shell 564ca848f4 fixup: uninitialized argument vector element
This patch addresses the potential issue of uninitialized elements in
the argument vector returned by `lwp_get_command_line_args()`. The
previous implementation could leave `argv` in an inconsistent state
if certain errors occurred, leading to possible undefined behavior.

Changes:
- Replaced `rt_malloc()` with `rt_calloc()` to ensure `argv` is properly initialized.
- Added a consistent error handling path using `goto error_exit` to handle memory allocation failures and string copy errors.
- Ensured `lwp_free_command_line_args()` is called before returning on error, preventing potential memory leaks.

Signed-off-by: Shell <smokewood@qq.com>
2024-08-24 15:46:35 -04:00
zhujiale afa17ed343 fix_return_err 2024-08-24 14:44:39 +08:00
rcitachi 9a84c13b2e
[lwp] Implementation of setpgrp and fix mmap2 problems (#9308)
* mmap2 failure handling

当传入一个非常大的地址时,offset会计算得到一个值,又因为传入的地址错误,rc会得到错误码,结合offset会得到一个很奇怪的值。

* Implementation of setpgrp

执行setpgrp会走到这一步,在执行getpgrp无法得到创建的group的值

* Modify the return method of mmap
2024-08-22 17:53:18 -04:00
zms123456 9d95ad9b8d
[lwp][tid]add error log when tid depleted, and return correct errno when clone failed (#9327)
add error log when tid depleted, and return correct errno when clone failed
2024-08-22 17:52:45 -04:00
zms123456 fd31965c3c
[components][lwp]fix mount param issue (#9333)
fix mount param issue
2024-08-22 17:52:19 -04:00
Shell 820e80a7f5 fixup: compiler warning on cvitek risc-v cause by unsupport vDSO on rv64
Signed-off-by: Shell <smokewood@qq.com>
2024-07-29 20:18:19 +08:00
Bernard Xiong e955e411b7
Merge pull request #9212 from polarvid/shell/opt-gctx
[libcpu] trimming ARM64 general context
2024-07-24 13:32:11 +08:00
Shell 7138f340b2 [libcpu/arm64] feat: Trimming General Context
This patch focuses on the ARM64 general context handling code.
The modifications are aimed at enhancing performance by simplifying
context save/restore operations.

Changes include:
- Adjusted stack alignment in `arch_set_thread_context` function.
- Updated `lwp_gcc.S` to reset frame pointer and link register.
- Refined `rt_hw_backtrace_frame_unwind` to handle user space address checks.
- Added `GET_THREAD_SELF` macro in `asm-generic.h`.
- Simplified context saving/restoring in `context_gcc.h` and related files.
- Optimized `rt_hw_context_switch_interrupt` and related assembly routines.

Signed-off-by: Shell <smokewood@qq.com>
2024-07-18 17:41:48 +08:00
zhao maosheng a6b2014214 fix exec and mount error code 2024-07-18 13:25:37 +08:00
Shell 1d78d11567
[smart] feat: add unmap for null mapper (#9186)
Do unmap before shrink so we don't see mapped entry on page table
insertion, which is not acceptable for riscv implementation of
architecture porting.

Changes:
- add un-mapping of pte on `_null_shrink()`

Signed-off-by: Shell <smokewood@qq.com>
2024-07-16 20:38:55 +08:00
rcitachi 14fb55933b
[lwp][vdso] Add VDSO functionality under the aarch64 architecture (#9176)
Add VDSO functionality under the aarch64 architecture
2024-07-15 17:58:29 +08:00
Shell 90917cc75a
[format] cleanup libcpu/aarch64 (#8950)
* [dfs] fixup compiler warning

Signed-off-by: Shell <smokewood@qq.com>

* [format] libcpu/arm64: separate context switching codes

Signed-off-by: Shell <smokewood@qq.com>

* [format] libcpu/arm64: separate vector

Signed-off-by: Shell <smokewood@qq.com>

* [format] libcpu/arm64: separate context_gcc.S

Signed-off-by: Shell <smokewood@qq.com>

* [format] libcpu/arm64: moving headers to include directory

Signed-off-by: Shell <smokewood@qq.com>

* style: replace tab with space

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-06-28 00:23:09 +08:00
heyuanjie87 a5a89c439f
[rv]修正signal退出后用户态sp少8的问题 (#9080) 2024-06-24 21:36:32 +08:00
Shell fa2d80679e
[smart] add mprotect config (#9082)
Signed-off-by: Shell <smokewood@qq.com>
2024-06-22 13:30:55 +08:00
heyuanjie87 06ad67d549
[rv]信号处理进入用户态前恢复gp (#9072)
* [rv/virt/stackframe.h]添加GP寄存器保存偏移量宏

* 【rv/c906/stackframe.h]定义GP寄存器存储偏移量

* [rv]信号处理切换到用户态前恢复gp
2024-06-21 09:09:41 +08:00
latercomer d58c29d23e 除了bsp之外的Kconfig使用rsource替代source 2024-06-20 14:40:42 +08:00
Shell 65c9947225
[libcpu] rv64: support for ARCH_REMAP_KERNEL (#9067)
* [libcpu] support for ARCH_REMAP_KERNEL

These changes introduce support for the ARCH_REMAP_KERNEL configuration,
which isolates kernel space in high virtual address regions. This feature
is necessary to enhance memory protection and management by segregating
user and kernel spaces more effectively.

Changes:
- Updated conditional macros to check for ARCH_REMAP_KERNEL instead of
  ARCH_KERNEL_IN_HIGH_VA in board initialization files to reflect the new
  configuration option.
- Modified qemu-virt64-riscv Kconfig and SConstruct files to include and
  utilize ARCH_REMAP_KERNEL.
- Created a new linker script `link_smart.lds` for smart linking in qemu-virt64-riscv.
- Updated rtconfig.py to use a more flexible execution path setup.
- Enhanced user address space definitions in `lwp_arch.h` to support the
  new virtual address mappings.
- Adjusted kernel memory initialization and mapping logic in `c906/mmu.c`
  and `virt64/mmu.c` to account for high virtual address regions.
- Added Kconfig option to enable ARCH_REMAP_KERNEL for RISCV64 architectures.
- Enhanced memory setup functions to support new mapping scheme, including
  updates to early page table setup and address relocation logic.

These modifications ensure that the system can utilize high memory
addresses for the kernel, improving memory isolation and system stability.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: CI run failed

* bsp: default config without using smart

* fixup: static checks

* restore rt_hw_mmu_kernel_map_init for D1

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-06-18 11:15:59 +08:00
Shell f00db6381a
[mm] precise & readable mm fault type (#9047)
* [smart] fixup: precise mm fault type

Also, fixup arm64 read access fault

* arm64: using meaningful macro on trap

* fixup: renaming macro
2024-06-07 21:34:03 +08:00
Shell 6ca327d8ce
[smart] add CPU/thread usage tracing config (#8947)
* [smart] add CPU usage tracing config

This patch introduces following features:

- Added CPU usage tracing functionality, enabled by default, for
  applications like 'top'
- update time as smart independent

Signed-off-by: Shell <smokewood@qq.com>

* fixup: add ump idle thread

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-06-04 00:06:41 +08:00
Shell e5cf86267b
[smart] fixup of script execution (#9009)
This patch fixup the script execution capabilities on argv passing
and adds support for arguments larger than 4k.

According to POSIX, the script parameter is quiet different
from the current implementation. Especially on the way it inserts
the path of executables. At the end, when you execute a script
from `$PATH`, it always fails.

For the script, interpreter will be invoked with the following
arguments: `{interpreter [optional-arg] pathname arg...}`
where pathname is the pathname of the file specified as the first
argument of execve(), and arg...  is the series of words pointed
to by the argv argument of execve(), starting at argv[1].  Note that
there is no way to get the argv[0] that was passed to the
execve() call.

The changes include:

- Separating argument, environment variable, and auxiliary vector
  processing into a new lwp_args.c file.
- Fixing bugs in script argument processing and supporting arguments
  larger than 4k.
- Updating lwp_execve to use the new argscopy function and removing
  the old lwp_argscopy function.
- Making various modifications to lwp_load and elf_aux_fill to work
  with the new argument processing.
- Removing unnecessary code related to dynamic loading and interpreter
  scripts.

Signed-off-by: Shell <smokewood@qq.com>
2024-05-31 17:32:19 +08:00
rcitachi 85b428df42
[lwp]list_process can print tid (#8991)
* list_process can print tid

* fix-ci

* update list_process

* Update lwp_pid.c
2024-05-31 17:30:46 +08:00
Shell 63591d935e
[smart] fixup errno passing on sys_mkdir() (#9007)
Use _SYS_WRAP to fetch errno on return of mkdir to avoiding overriding
of it on other system APIs.

Signed-off-by: Shell <smokewood@qq.com>
2024-05-29 18:06:54 +08:00
Shell f179ce12b7
[smart] update sched_setaffinity() to use thread(task) ID (#9004)
Correct `sched_setaffinity()` to use the thread IDs (TIDs) instead of
process IDs (PIDs). The previous implementation used PIDs, which
caused issues since affinity settings need to be applied at the
thread level.

As the manual documented, the signature is:

>        int sched_setaffinity(pid_t pid, size_t cpusetsize,
>                             const cpu_set_t *mask);

Yes, it's tricky, the identification passing in is called **'PID'**.
But when we talk about 'pid' from GNU libc, it's the **'task-id'**,
aka, `thread->tid` known in kernel.

Changes were made by updating the function signatures and logic in
`lwp.h`, `lwp_pid.c`, and `lwp_syscall.c` to accept TIDs. Specifically,
the `lwp_setaffinity` function and related internal functions now
operate using thread IDs and adjust thread affinity settings accordingly

Signed-off-by: Shell <smokewood@qq.com>
2024-05-29 06:53:22 +08:00
heyuanjie87 326150e2f4
[lwp/riscv]进入libc前初始化用户态sp (#8997) 2024-05-29 06:52:38 +08:00
Shell 952f2c43f8
[smart] add FIONREAD ioctl support for tty (#8996)
Signed-off-by: Shell <smokewood@qq.com>
2024-05-28 09:56:10 +08:00
Shell 5f71da566a
[libcpu] arm: fixup signal handling (#8988)
Signed-off-by: Shell <smokewood@qq.com>
2024-05-26 22:00:48 +08:00
Shell 397cdcd132
[libcpu] discard rt_current_thread (#8976)
* [libcpu] rv64: discard rt_current_thread

* arm: using rt_thread_self to fetch current TCB
2024-05-26 22:00:17 +08:00
Shell 6b12bce22f
[quality] fixup compiler warning (#8961)
Signed-off-by: Shell <smokewood@qq.com>
2024-05-21 19:47:42 +08:00
Shell f2d6325b43
[smart] select console device dynamically (#8949)
* [smart] select console device dynamically

- Fixed compiler warning on terminal subsystem for
  `components/lwp/terminal/terminal.h`
- Updated default console setup to dynamically select an appropriate tty
  device based on the configured console device name.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: remove useless codes

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-17 13:19:00 +08:00
Shell 017b2a5a44
[smart] fixup arm64 aspace switch (#8925)
* [smart] fixup arm64 aspace switch

Signed-off-by: Shell <smokewood@qq.com>

* fixup: arm add arch_kernel_mmu_table_get

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-10 09:17:19 +08:00
xiao-mang b586889216
fix baudrate error (#8873)
* fix baudrate error

* fix baudrate error

* fix baudrate error

* fix baudrate error

* fix baudrate error

* fix baudrate error

* fix baudrate error

* fix baudrate error

* fix baudrate error
2024-04-29 18:00:34 +08:00
xiao-mang 75f41723cb
fix sys_getcwd (#8852) 2024-04-25 18:28:53 +08:00
Shell 5730097296
[smart] fixup devfs porting layer of terminal (#8797)
Signed-off-by: Shell <smokewood@qq.com>
2024-04-15 18:24:19 +08:00
Shell 4b0f42c24a
[drivers/serial] Introduce hooker for TTY (#8733)
In this patch, a hook list has been introduced to address the concerns
regarding coupling issues arising from modifications to the serial code
for integrating TTY logic.

Signed-off-by: Shell <smokewood@qq.com>
2024-04-09 21:36:16 +08:00
Shell 864055bf18
[fixup] aarch64 UMP compiler error (#8677)
Signed-off-by: Shell <smokewood@qq.com>
2024-03-30 17:58:38 +08:00
Shell 83e95bdff4
sync smart & dfs (#8672)
Signed-off-by: xqyjlj <xqyjlj@126.com>
Signed-off-by: Shell <smokewood@qq.com>
Co-authored-by: xqyjlj <xqyjlj@126.com>
2024-03-28 23:42:56 +08:00
Shell 71560bafb5
🎯 Sync smart & scheduler codes (#8537)
Signed-off-by: Shell <smokewood@qq.com>
Co-authored-by: xqyjlj <xqyjlj@126.com>
2024-02-23 17:49:15 +08:00
Yuqiang Wang c6bdee3c50
[ci] open ci check with function declaration warning (#8546) 2024-02-20 22:45:04 -05:00
Meco Man bd228eb9c5 [ci] fix errors under strick compiling mode 2024-02-20 08:39:05 +08:00
rcitachi 0c96b26c23
[sys_bind] [signalfd] update (#8507) 2024-01-26 22:14:02 +08:00