Commit Graph

1486 Commits

Author SHA1 Message Date
Ruihan Li 21365dd0bd Fix some behavior about `seek()` 2025-11-19 10:33:51 +08:00
Ruihan Li 24502ac3d4 Add `InodeIo` to simplify `FileIo` and `Inode` 2025-11-19 10:33:51 +08:00
Ruihan Li 08dfe533c4 Use `Box<FileIo>` instead of `Arc<FileIo>` 2025-11-19 10:33:51 +08:00
jiangjianfeng 63354d670e Support mknod for /dev/full and /dev/tty0 2025-11-18 17:32:34 +08:00
Ruihan Li 7ebee6d8a1 Fix TTY's HUP events 2025-11-18 14:49:19 +08:00
jiangjianfeng 2f568d5e73 Read pty master should block if no pty slave is opened 2025-11-18 09:48:32 +08:00
Wang Siyuan 151d7ab1bf Refactor procfs with `VmPrinter` 2025-11-17 16:42:08 +08:00
Tao Su 83176020f2 Invoke get_report() using private memory 2025-11-17 15:26:45 +08:00
Ruihan Li 0636e1048e Clarify how `Path` inherits methods 2025-11-17 11:25:55 +08:00
Wang Siyuan 35ab40057a Support stopping states in `proc/pid/stat` 2025-11-14 14:34:04 +08:00
Wang Siyuan 7a7e62b318 Support sleeping states in `proc/pid/stat` 2025-11-14 14:34:04 +08:00
Wang Siyuan 3ffa253947 Store `Weak<Task>` in `PosixThread` 2025-11-14 14:34:04 +08:00
Ruihan Li 58070c4107 Introduce `CopyCompat` 2025-11-14 14:20:30 +08:00
Ruihan Li 4af21521af Fix error codes in various `sched_*` syscalls 2025-11-14 14:20:30 +08:00
Zhang Junyang 8148072984 Upgrade the `riscv` crate to fix the ssoft handling
3c61863630
2025-11-14 10:14:03 +08:00
Qingsong Chen bb48b3814f Move DeviceId to separate device-id crate 2025-11-13 11:04:30 +08:00
Wang Siyuan 9c6dbcee79 Minor cleanup 2025-11-13 09:55:53 +08:00
Wang Siyuan 456cafbc8e Add access mode checks for `MemfdFile` 2025-11-13 09:55:53 +08:00
Wang Siyuan 291c42c9fd Enable some gvisor tests of `memfd_test` 2025-11-13 09:55:53 +08:00
Wang Siyuan 805e2a7c89 Remove inode-specific methods from `FileLike` 2025-11-13 09:55:53 +08:00
Wang Siyuan 4d7958c18e Add `PathOrInode` to support looking up an inode without a `Path`
Also supports opening a memfd from `/proc/[pid]/fd/[fd]`
2025-11-13 09:55:53 +08:00
Wang Siyuan 147a622aa1 Add `SymbolicLink` to support symbol links under `/proc` 2025-11-13 09:55:53 +08:00
Wang Siyuan 7f41bd3ba7 Rename `as_inode_or_err` to `as_inode_handle_or_err` 2025-11-13 09:55:53 +08:00
Wang Siyuan e85879025e Add a method `inode` to the trait `FileLike` 2025-11-13 09:55:53 +08:00
Wang Siyuan 0a0ced99e7 Add `PseudoFs` and `PseudoInode` 2025-11-13 09:55:53 +08:00
Wang Siyuan 1a3ab8aaf8 `MemfdInode`s should be linked to a tmpfs 2025-11-13 09:55:53 +08:00
Ruihan Li f57a54aa0d Remove `AccessMode` from `InodeHandle` 2025-11-12 18:19:08 +08:00
Ruihan Li 722efc62ca Remove `inode_handle/static_cap.rs` 2025-11-12 18:19:08 +08:00
Ruihan Li 277b5b5c24 Fix how O_PATH interacts with other flags 2025-11-12 18:19:08 +08:00
Ruihan Li 25beca462d Add regression tests 2025-11-12 18:19:08 +08:00
Ruihan Li eaeba41f5e Refine some access checks 2025-11-12 18:19:08 +08:00
Ruihan Li b4385ddc3d Simplify some memfd code 2025-11-12 18:19:08 +08:00
wyt8 9a0f63b33e Modify the import of modules in kernel to remove dependencies of lib.rs 2025-11-10 10:53:08 +08:00
Tate, Hongliang Tian 06f798908a Extract kernel initialization code into a module 2025-11-10 10:53:08 +08:00
wyt8 05287667c3 Ensure the idle tasks do not sleep or block 2025-11-10 10:53:08 +08:00
jiangjianfeng cef527f372 Open /dev/tty should also increase pty slave count 2025-11-07 20:22:16 +08:00
jiangjianfeng 49485058ec Correct the device major ID for pty slave 2025-11-07 20:22:16 +08:00
jiangjianfeng a41db92b4e Support nonblocking mode for tty and pty 2025-11-07 20:22:16 +08:00
jiangjianfeng c4ee351639 Fix the unlink problem about devpts 2025-11-07 20:22:16 +08:00
jiangjianfeng 601ac76676 Avoid unwrap on devpts when dropping pty master 2025-11-07 20:22:16 +08:00
jiangjianfeng cd981a0a8d Correct the behavior about closing pty 2025-11-07 20:22:16 +08:00
Chen Chengjun b17602693a Add /proc/[pid]/cgroup 2025-11-07 11:47:23 +08:00
Chen Chengjun 77fb73bdd7 Enable the process management for cgroup 2025-11-07 11:47:23 +08:00
Chen Chengjun cda06613f0 Revise the content of root field for the mountinfo file 2025-11-07 11:44:04 +08:00
Wang Siyuan e336882eee Do not drop `Arc<dyn FileLike>` in an incorrect context 2025-11-06 20:24:25 +08:00
Hang Shu e27b16ec4b Remove IntervalSet::find_one unreachable code 2025-11-06 19:36:12 +08:00
Ruihan Li 0bff86582a Handle TID events in procfs 2025-11-06 15:41:13 +08:00
Ruihan Li 9171a0d13f Correct `main_thread()` usages in procfs 2025-11-06 15:41:13 +08:00
Ruihan Li 2d01804d19 Correct lock usages in procfs 2025-11-06 15:41:13 +08:00
Ruihan Li 4e0142b176 Resolve some minor issues 2025-11-06 15:41:13 +08:00
Wang Siyuan ff021e0b89 Make `memfd` a sub module of `ramfs` 2025-11-04 13:02:06 +08:00
Wang Siyuan 6ba1a84ae9 Support sealing memfd files 2025-11-04 13:02:06 +08:00
Wang Siyuan d1506171d2 Count writable mappings of each MemfdInode's VMO
The "writable mappings" refers to shared mappings that may include the `PROT_WRITE` permission.
2025-11-04 13:02:06 +08:00
Wang Siyuan 7aa6a47612 Add `MemfdInode` 2025-11-04 13:02:06 +08:00
jiangjianfeng 6e8dac0c36 Refactor the implementation of signalfd 2025-11-04 11:56:13 +08:00
jiangjianfeng d2b88f48ff Refactor the implementation of kill process 2025-11-04 11:56:13 +08:00
jiangjianfeng 00c79732e6 Re-introduce the process-wide sigqueues 2025-11-04 11:56:13 +08:00
Chen Chengjun 6f8877f252 Rename some variables and let src_name_addr can be NULL for some mount operations 2025-11-03 15:56:05 +08:00
Chen Chengjun d66dbdd3bc Revise some error numbers and messages 2025-11-03 09:57:48 +08:00
Chen Chengjun d42b006e1a Refactor named pipe to correct its opening and blocking behaviors 2025-11-03 09:57:48 +08:00
Chen Chengjun 5eddf21596 Introduce open API for Inode trait to replace as_* APIs 2025-11-03 09:57:48 +08:00
Chen Chengjun 4fe8554d63 Decouple PipeReader/Writer with status flags 2025-11-03 09:57:48 +08:00
Chen Chengjun b447a605ed Introduce PerMountFlags and support MS_REMOUNT 2025-11-02 21:24:50 +08:00
Chen Chengjun 498c2f3c91 Make FsFlags consistent with Linux's super block flags 2025-11-02 21:24:50 +08:00
Chen Chengjun c77edbace8 Provide mem_unit and procs in sysinfo 2025-11-02 14:09:55 +08:00
Tao Su eb4edd25e8 Add TSM module 2025-10-31 08:53:27 +08:00
Ruihan Li d487e42b7c Reunify the style of defining `arch` modules 2025-10-30 17:04:45 +08:00
Zejun Zhao 6af524b451 Support RISC-V Sv39 Paging mode 2025-10-30 14:51:37 +08:00
Zejun Zhao 3353e53577 Add VirtIO device probing code on RISC-V platforms 2025-10-30 10:47:53 +08:00
Zejun Zhao 39a541fdeb Add RISC-V FPU support 2025-10-29 13:24:30 +08:00
Wang Siyuan 89e759894f Remove `Rights` from VMO 2025-10-29 12:22:22 +08:00
Cautreoxit 0126d9b356 Set AT_SECURE value based on ELF's configuration 2025-10-29 09:57:16 +08:00
Cautreoxit 43fc98dc77 Migrate virtio-input to input subsystem API 2025-10-28 17:37:13 +08:00
Cautreoxit ee960c5f45 Migrate i8042 keyboard to input subsystem API 2025-10-28 17:37:13 +08:00
Cautreoxit 329fb4728a Add framebuffer console handler 2025-10-28 17:37:13 +08:00
Cautreoxit 9c062b1350 Add input subsystem
Co-authored-by: TinaZhangZW <ruoyuan.zw@antgroup.com>
2025-10-28 17:37:13 +08:00
Ruihan Li 2d74e69b4b Add KDGKBMODE and KDSKBMODE ioctl support 2025-10-27 16:28:35 +08:00
Wei Zhang 2ba05a1673 Add KDGETMODE and KDSETMODE ioctl support
Add support for virtual console TTY mode management ioctls required by
Xorg and other display servers. The implementation includes:

- KDGETMODE: Query the current virtual console mode
- KDSETMODE: Switch between text and graphics modes

Virtual consoles utilize the framebuffer with two distinct modes:
- Text mode (default): Kernel renders text characters to framebuffer
- Graphics mode: User space applications gain full framebuffer control

Xorg requires KDSETMODE during initialization to switch to graphics
mode, preventing conflicts where both the kernel and Xorg would
simultaneously attempt to write to the framebuffer. This ensures
proper display handling and eliminates rendering artifacts.

Co-authored-by: Ruihan Li <lrh2000@pku.edu.cn>
2025-10-27 16:28:35 +08:00
Ruihan Li 38a217d201 Enhance `TtyDriver` to get the console 2025-10-27 16:28:35 +08:00
Wei Zhang 66d9dd41b9 Correct /dev/tty1 major number to 4
The major number for /dev/tty1 must be 4, as this value is hardcoded
in Linux and Linux syscall-compatible operating systems. Xorg uses
this major number directly, and incorrect values lead to confusion
and operational failures.

This change ensures compatibility with Xorg's expectations and
maintains system consistency.
2025-10-27 16:28:35 +08:00
Zejun Zhao f02c37dc2f Make writable pages readable on RISC-V platforms 2025-10-27 11:25:59 +08:00
Zejun Zhao 51767b519b Generate fault signal for RISC-V exceptions 2025-10-27 11:25:59 +08:00
Zejun Zhao 1e183825d3 Refactor RISC-V exception-related code 2025-10-27 11:25:59 +08:00
Zejun Zhao fe90e3051b Add fallback for RTC device 2025-10-27 09:50:46 +08:00
Ruihan Li 8a16aa3b86 Refine the `ProcessVm` structure 2025-10-26 10:14:00 +08:00
Ruihan Li badad44b54 Fix a small bug in remote memory access 2025-10-26 10:14:00 +08:00
Ruihan Li 54f2a25a3a Move remote memory access to the VM module 2025-10-26 10:14:00 +08:00
Ruihan Li b07d06170b Remove `Rights` from VMAR 2025-10-26 10:14:00 +08:00
Arthur Paulino 6a67807fd0 Implement `IdSet::iter_in`
This patch enables more expressive ways to slice and iterate over
the `Id`s in an `IdSet` with `IdSet::iter_in`, which takes an arbitrary
`IdSetSlicer`.

`IdSet::iter_in` efficiently slices out unintended inner parts and
then, within the remaining parts, skips inactive bits by using
`BitSlice::iter_ones` from the `bitvec` crate.

It also delivers several implementations of `IdSetSlicer` so OSTD
consumers can represent `Id` ranges ergonomically.

In the Asterinas kernel, `CpuSet::iter_in` enables a cleaner way to
define an interator that cycles over the CPUs.
2025-10-25 11:23:13 +08:00
Arthur Paulino 01d9b61337 Enhanced per-CPU load stats
This patch creates a `PerCpuLoadStats` with slightly enhanced, enough
to serve load stats and the load-balancing algorithm. This struct can
be further enhanced for more elaborated load-balancing algorithms in
the future.

The load stats report has been fixed, as `SchedulerStats::nr_queued_and_running`
no longer includes idle threads in the queued total nor in the running
threads.

Furthemore, the load-balancing algorithm has been improved because it
no longer accounts with the idle threads when they're enqueued.
2025-10-25 10:38:59 +08:00
jiangjianfeng fe39a6803d Unshare VM during execve 2025-10-25 10:36:30 +08:00
jiangjianfeng caeec3cdc1 Unshare signal handler during execve 2025-10-25 10:36:30 +08:00
jiangjianfeng 207bfe30e2 Support multithreaded execve 2025-10-25 10:36:30 +08:00
Zejun Zhao 8251d48bf2 Add RISC-V PLIC support 2025-10-24 16:28:41 +08:00
Chen Chengjun 0a80d55c95 Support mount bind a file 2025-10-24 11:13:09 +08:00
Chen Chengjun 53a1268e19 Add mountinfo files to proc filesystem 2025-10-24 11:12:16 +08:00
Chen Chengjun 7b68571290 Support generating the mount infomation 2025-10-24 11:12:16 +08:00
Tate, Hongliang Tian c44e45ea78 Add the `IdSet<I>` utility type 2025-10-22 14:29:52 +08:00
Ruihan Li 7e7ba43cdf Revise some error messages 2025-10-22 14:05:38 +08:00
Ruihan Li 9ac0e31981 Implement better FS path APIs 2025-10-22 14:05:38 +08:00
Chen Chengjun a22935f4c6 Correct the errno of waitid when the input pidfd is negative 2025-10-20 21:07:28 +08:00
Ruihan Li 8be8397a67 Make network callbacks and names related 2025-10-20 20:56:55 +08:00
Ruihan Li 582812ac92 Reorder `new_loopback` and `new_virtio` 2025-10-20 20:56:55 +08:00
Ruihan Li 74f23ce23d Fix some `kill`-related behavior 2025-10-20 14:05:45 +08:00
Ruihan Li 75edabc557 Construct `SignalSenderIds` from `Context` 2025-10-20 14:05:45 +08:00
Ruihan Li 43f50c5e2a Fix futex return values 2025-10-20 11:24:48 +08:00
Ruihan Li 52ddbeaff8 Use the `Arc<Waker>` address as the futex ID 2025-10-20 11:24:48 +08:00
Ruihan Li 34b4ad5e9b Clean up visibility in `futex.rs` 2025-10-20 11:24:48 +08:00
jiangjianfeng 600446e9e1 Cleanup ThreadName related code 2025-10-20 10:52:07 +08:00
Chen Chengjun 782301c239 Remove open-related APIs from FsResolver 2025-10-17 16:18:56 +08:00
Chen Chengjun c2ab393d57 Cleanup the lookup APIs of FsResolver 2025-10-17 16:18:56 +08:00
Ruihan Li bc6ef5231b Reorangize `ostd::arch::irq` 2025-10-16 21:46:40 +09:00
Wang Siyuan 3f2c319e00 Support `/proc/[pid]/mem` and `/proc/[pid]/task/[tid]/mem` 2025-10-15 16:34:32 +08:00
Wang Siyuan ef5e0060d7 Support reading `InitStack` across pages 2025-10-15 16:34:32 +08:00
Wang Siyuan c2adcf9944 Support accessing user spaces of other processes 2025-10-15 16:34:32 +08:00
Qingsong Chen 257b0c63b1 Fix ext2 block groups count 2025-10-14 13:20:06 +09:00
Ruihan Li 0be36ee2c1 Fix virtio-mmio interrupt handling 2025-10-14 00:48:09 +09:00
Ruihan Li 7b212a6a25 Check capabilities instead of the root 2025-10-13 14:21:27 +08:00
Chen Chengjun 07d2d1db02 Support MS_PRIVATE flag for mount 2025-10-13 13:30:06 +08:00
Chen Chengjun 2b18c893a8 Implement fixed_point module to replace the usage of fixed crate 2025-10-13 12:34:01 +08:00
Chen Chengjun d2b4664078 Add a configfs usage example in ktest 2025-10-09 17:38:08 +08:00
Chen Chengjun fc69af3e95 Support the basic configfs 2025-10-09 17:38:08 +08:00
Chen Chengjun 537f08d7cf Make the cgroup systree independent 2025-10-09 17:38:08 +08:00
Chen Chengjun 6dd4899d4a Supports multiple systree instances 2025-10-09 17:38:08 +08:00
Ruihan Li 7319a7b173 Add wakeups after moving children 2025-10-07 11:43:02 +08:00
Ruihan Li d50155661c Lock run queues with IRQ disabled 2025-10-07 11:43:02 +08:00
Ruihan Li 56d78ab649 Fix some minor style issues 2025-10-06 14:46:23 +08:00
Ruihan Li b4f66ab379 Fix free memory value in `meminfo` 2025-10-06 14:46:23 +08:00
Ruihan Li 78ff1a689b Fix wrong formats in `{uid,gid}_map` 2025-10-06 14:46:23 +08:00
jiangjianfeng d75a2481bb Support /proc/pid/uid_map and /proc/pid/gid_map 2025-09-30 16:42:54 +08:00
Ruihan Li d43fbd8f89 Fix some `getrandom` behavior 2025-09-30 11:36:37 +08:00
Ruihan Li 36a38c3f04 Bump `rand` version to 0.9.2 2025-09-30 11:36:37 +08:00
Ruihan Li 75f95cc1da Remove some unnecessary `cfg_if` uses 2025-09-30 11:36:37 +08:00
Ruihan Li b606e3456c Don't panic if `set_child_tid` is invalid 2025-09-30 09:54:40 +08:00
Ruihan Li 6336bb9fc8 Fix races when finding the reaper 2025-09-30 09:54:40 +08:00
Ruihan Li 8be5465ace Add more checks for `clone` 2025-09-30 09:54:40 +08:00
Zejun Zhao 294c55d0df Fix `semid_ds`'s layout on non-x86_64 platforms 2025-09-29 23:46:01 +08:00
jiangjianfeng 702aa7d9ee Support CLONE_PARENT flag 2025-09-29 13:27:22 +08:00
Zejun Zhao 899db770f6 Fix parameter passing of `preadv/pwritev`-family syscalls 2025-09-28 22:18:53 +08:00
Zejun Zhao b183f9c06d Fix `epoll_event`'s layout on non-x86_64 platforms 2025-09-28 22:16:19 +08:00
jiangjianfeng 6c544053af Set the default domainname as `(none)` 2025-09-28 09:35:39 +08:00
jiangjianfeng 882dea6125 Add syscall setdomainname 2025-09-28 09:35:39 +08:00
jiangjianfeng 87091aa19c Add syscall sethostname 2025-09-28 09:35:39 +08:00
Yang Zhichao 66356e133d Add support for `/proc/stat` and `/proc/uptime` 2025-09-27 21:02:23 +08:00
Yang Zhichao a13d2703fb Add context switch counting. 2025-09-27 21:02:23 +08:00
Yang Zhichao b921675426 Complete fork, vfork and clone counting.
This change primarily provides statistical data for the `processes` field in `/proc/stat`.
This field represents the total count of all processes and threads created since system boot,
rather than just processes as the name might imply.
2025-09-27 21:02:23 +08:00
Yang Zhichao a9673282e6 Complete the counting for Softirq and IRQ. 2025-09-27 21:02:23 +08:00
Yang Zhichao 6a662a0d85 Add the `CpuTimeStats` module for CPU time statistics. 2025-09-27 21:02:23 +08:00
Yang Zhichao f869ed508f Move `PerCpuCounter` to `aster-util` to broaden its scope of use,
and add/modify some methods to improve readability.
2025-09-27 21:02:23 +08:00
Chen Chengjun 9a99af1170 Fix some set uid behaviors 2025-09-26 15:14:29 +08:00
Chen Chengjun 728b8d1b5a Bypass some permission checks with DAC_OVERRIDE 2025-09-26 15:14:29 +08:00
Zejun Zhao 6a42bb3b4a Make syscall restart mechanism work across all architectures 2025-09-26 15:10:34 +08:00
Ruihan Li 4c26a7a7c5 Fix a typo in the PCI bar detection 2025-09-24 15:41:07 +08:00
Ruihan Li 472edcf795 Clean up unnecessary features 2025-09-24 15:41:07 +08:00
Ruihan Li 5a117bc859 Rewrite some error messages 2025-09-24 14:29:16 +08:00
Ruihan Li 89959d07df Fix/clarify problems about mount namespaces 2025-09-24 14:29:16 +08:00
Wang Siyuan 57d3d9ded1 Fix some `mprotect` issues 2025-09-24 11:14:13 +08:00
Chen Chengjun 4552fdb830 Introduce AtomicFileCreationMask 2025-09-24 08:07:25 +08:00
Chen Chengjun c56089309b Support CLONE_NEWNS for related syscalls 2025-09-24 08:07:25 +08:00
Chen Chengjun bacbe58ff3 Modify the related logics in the initial phase 2025-09-24 08:07:25 +08:00
Chen Chengjun 3de56817fe Introduce MountNamespace 2025-09-24 08:07:25 +08:00
jiangjianfeng 754ab5537c Add /dev/full device 2025-09-22 10:20:56 +08:00
Wang Siyuan 6dec3a6712 Replace `InodeMode::from_bits_trunucated` with `mkmod` 2025-09-22 10:20:36 +08:00
Wang Siyuan 51a055c467 Add macros `chmod` and `mkmod` 2025-09-22 10:20:36 +08:00
Yuke Peng 701b8f6f92 pci: Refactor ptr alignment 2025-09-21 10:32:23 +08:00
Yuke Peng ecdc8c3fe7 Remove unsafe in x86 PCI code 2025-09-21 10:32:23 +08:00
Yuke Peng a8070a62b6 Extract platform-specific code from ostd into PCI component 2025-09-21 10:32:23 +08:00
Yuke Peng bb15d4591a Extract `PciDeviceLocation` in ostd into PCI component 2025-09-21 10:32:23 +08:00
Yuke Peng f34c37f6c4 Acquire IoMem only when r/w happened 2025-09-21 10:32:23 +08:00
Yuke Peng d60e2e2a6b Align cap_ptr in PCI 2025-09-21 10:32:23 +08:00
Yuke Peng 48376efa52 Extract MSIX in ostd into PCI component 2025-09-21 10:32:23 +08:00
Yuke Peng 1e324d2228 Fix import error in PCI component 2025-09-21 10:32:23 +08:00
Yuke Peng 28d4d0e3ad Use `IoMem::acquire` to get the MemoryBar access 2025-09-21 10:32:23 +08:00
Yuke Peng faee9e9808 Disable IoPort read/write in IoBar 2025-09-21 10:32:23 +08:00
Yuke Peng 1a86bd2471 Move PCI bus in OSTD into PCI component 2025-09-21 10:32:23 +08:00
Yuke Peng f2d1cbdf57 Init PCI compoment 2025-09-21 10:32:23 +08:00
Ruihan Li 391f11f1aa Make per-CPU callbacks explicit 2025-09-20 11:50:50 +08:00
Ruihan Li 421f36cc26 Make timer callbacks arch-agnostic 2025-09-20 11:50:50 +08:00
Tate, Hongliang Tian 4b87dab86e Unify CPU arch-specific logic that determines if the kernel is interrupted 2025-09-19 15:05:50 +08:00
Tate, Hongliang Tian ee21f2bdb6 Refactor OSTD irq module for improved clarity 2025-09-19 15:05:50 +08:00
Tate, Hongliang Tian c485d512f6 Rename ostd::trap to ostd::irq 2025-09-19 15:05:50 +08:00
Zejun Zhao 2e46edb68d Register some timer callbacks on all CPUs 2025-09-19 14:40:33 +08:00
Zejun Zhao cf9c45a46c Implement renameat2 system call 2025-09-19 12:00:01 +08:00
Wang Siyuan 70b26f824d Support `RUSAGE_CHILDREN` option for `getrusage` 2025-09-18 17:20:07 +08:00
Ruihan Li c90c081e86 Fix bugs due to bad `ReadCString` APIs
Co-authored-by: Wang Siyuan <wsy@stu.pku.edu.cn>
2025-09-18 17:19:51 +08:00
Ruihan Li 3acdc1e8b0 Move `ReadCString` to `util/`
Co-authored-by: Wang Siyuan <wsy@stu.pku.edu.cn>
2025-09-18 17:19:51 +08:00
Ruihan Li d7334118f3 Respond error segments for netlink parse errors 2025-09-18 17:19:51 +08:00
Qingsong Chen 8bc0013801 Add stage support for init_component macro 2025-09-18 12:11:44 +08:00
Tate, Hongliang Tian 8d2fec7873 Introduce ASCII art representations of the Asterinas logo 2025-09-17 22:44:40 +08:00
Qingsong Chen f6a55e0af3 Handle 8-bit/24-bit ANSI color codes for framebuffer 2025-09-17 22:43:22 +08:00
Wang Siyuan 46aa437c87 Add `/proc/pid/oom_score_adj` 2025-09-15 13:28:23 +08:00
Wang Siyuan b42605af6b Support configurable file modes within procfs 2025-09-15 13:28:23 +08:00
Chen Chengjun c2a224e757 Fix the bug in is_mount_root method 2025-09-12 17:06:58 +08:00
Qingsong Chen 96adc3dc82 Add /proc/cmdline support 2025-09-12 08:45:32 +08:00
Chen Chengjun 8c36964bb9 Introduce VmPrinter to write kernel generated data 2025-09-10 21:07:14 +08:00
Chen Chengjun 12f2f6bb54 Correct the misuse of some AttributeErrors 2025-09-10 21:07:14 +08:00
Ruihan Li fe1d4fe15f Support UNIX datagram sockets 2025-09-10 20:01:30 +08:00
Ruihan Li 87640d4b27 Drop `UnixSocketAddrBound` on `close()` 2025-09-10 20:01:30 +08:00
Ruihan Li 286d4d4466 Reorder methods and fix minor issues 2025-09-10 20:01:30 +08:00
Ruihan Li 9de70e38de Add the `arch::cpu::cpuid` module 2025-09-10 12:10:40 +08:00
Ruihan Li 652657fba5 Drop duplicate public re-exports 2025-09-10 12:10:40 +08:00
Ruihan Li c1b80f0f0f Use `'static` for FS types 2025-09-08 14:40:08 +08:00
Ruihan Li ef5318c000 Rename `*FS` to `*Fs` 2025-09-08 14:40:08 +08:00
Ruihan Li bb6069d5bb Clean up some FS APIs 2025-09-08 14:40:08 +08:00
Ruihan Li c289f96d23 Report `ENOBUFS` if netlink messages overrun 2025-09-05 10:51:48 +08:00
Ruihan Li b57c94d05d Unpack `MessageQueue` 2025-09-05 10:51:48 +08:00
zhuowei shao f0935beb18 Extract futex double bucket locking operation 2025-09-05 10:49:45 +08:00
Zhe Tang 2796c8d1ad Add unit tests for the newly implemented methods related to `IoMem` 2025-09-05 10:47:43 +08:00
Zhe Tang b94ea9f174 Add kernel support for mapping via files 2025-09-05 10:47:43 +08:00
Zhe Tang 5022cadef1 Add the file-specific `mmap` interface
Co-authored-by: Wei Zhang <ruoyuan.zw@antgroup.com>
2025-09-05 10:47:43 +08:00
Zhe Tang 5a38c61c49 Ensure that OSTD users cannot modify the `PrivilegedPageFlags` in `PageProperty` 2025-09-05 10:47:43 +08:00
Ruihan Li 3b606f5b6c Use `size_of`/`align_of` in the prelude 2025-09-04 09:26:56 +08:00
Zhang Junyang 9e2d8e9f08 Use device addresses instead of physical addresses 2025-09-02 17:53:55 +08:00
Zhang Junyang 4e2bdc65de Refactor implicit `Arc` APIs for DMA 2025-09-02 17:53:55 +08:00
Zhang Junyang a6520880ab Unify memory object slicing 2025-09-02 17:53:55 +08:00
Zhang Junyang eb69aa4fb9 Unify address and size APIs for memory objects 2025-09-02 17:53:55 +08:00
Ruihan Li 419f31397f Move checks from `syscall/` to `iovec.rs` 2025-09-02 15:43:09 +08:00
Ruihan Li 4e27e9d90b Use "I/O" instead "IO" 2025-09-02 15:43:09 +08:00
jiangjianfeng ef099996fc Fix the unshare logic in syscall close_range 2025-09-02 09:47:41 +08:00
jiangjianfeng b43047eedb Add syscall setns 2025-09-02 09:47:41 +08:00
jiangjianfeng cca73480c2 Add syscall unshare 2025-09-02 09:47:41 +08:00
jiangjianfeng 83b6e2da5c Add basic namespace framework 2025-09-02 09:47:41 +08:00
jiangjianfeng 3cbc9b4bf7 openat should return ENOENT if path is empty 2025-09-02 09:45:42 +08:00
jiangjianfeng 09886fc15b Write the supported cap version to user if capget version is unsupported 2025-09-02 09:45:42 +08:00
jiangjianfeng 6c5bcc420a Don't panic on MADV_NOHUGEPAGE 2025-09-02 09:45:42 +08:00
Arthur Paulino f56d2f3bad `context.rs` enhancements
* Improve the phrasing of some docstrings and comments
* Add warning comments about attempts to validate memory addresses
  at reader/writer instantiation time
* Create the `reader_writer` method for ergonomically instantiate
  a reader/writer pair covering the same memory region. This method
  is also slightly more efficient than calling `reader` and `writer`
  separately
* Clean up `check_vaddr` for clarity and rename it to `check_vaddr_lowerbound`
  for explicity
* Include the data length check before calling `check_vaddr_lowerbound`
  in `atomic_load` and `atomic_fetch_update` for further consistency
  with the delayed buffer validation
2025-09-01 11:16:37 +08:00
Zejun Zhao f4b05597cd Init vDSO singleton in the first kthread 2025-08-31 23:57:17 +08:00
Chen Chengjun f8e4aefcca Add tmpfs support by wrapping ramfs 2025-08-29 15:45:20 +08:00
Yang Zhichao d84ad988d4 Implement `EnvironFileOps` to handle `/proc/[pid]/environ` 2025-08-29 10:07:29 +08:00
Zejun Zhao d3e27ae03a Use vDSO for fallback of user-provided sa_restorer on RISC-V platforms 2025-08-28 17:35:55 +08:00
jiangjianfeng 2098b11b68 Unify the implementation of /proc/[pid] and /proc/[pid]/task/[tid] 2025-08-27 15:22:08 +08:00
Arthur Paulino 888eecb350 Patch a futex vulnerability
If the futex wait operation was interrupted by a signal or timed out, the
`FutexItem` must be dequeued and dropped. Otherwise, malicious user programs
could repeatedly issue futex wait operations to exhaust kernel memory.

Due to asynchronicity, this removal can't be done by queue position nor by
futex key match up:
* The position might have changed during the pause as some earlier futex might
  have been dequeued
* If two futexes with the same key are enqueued and then one of them times out
  or is interrupted, a removal by key would likely dequeue the wrong futex

Therefore, we need to perform a removal by unique global futex ID.
2025-08-26 18:04:34 +08:00
Ruihan Li a6d37f0e79 Mark all kernel modules as private 2025-08-26 18:02:56 +08:00
Ruihan Li f35ae6fe1c Adjust visibility in `sem{,_set}.rs` 2025-08-26 18:02:56 +08:00
Ruihan Li 5c49142515 Remove `base` and `size` in `Vmar` 2025-08-26 18:02:56 +08:00
Ruihan Li a84897097e Remove `RangeLockItemBuilder` 2025-08-26 18:02:56 +08:00
Ruihan Li c9ac58e8df Remove unused "unregister" methods 2025-08-26 18:02:56 +08:00
Ruihan Li b2f17d11c6 Remove common enum suffixes 2025-08-26 18:02:56 +08:00
Ruihan Li 09e7355d87 Remove dead code in `file_table.rs` 2025-08-26 18:02:56 +08:00
Chen Chengjun b1bbd6c3fe Optimize the initialization logic during Asterinas init phase 2025-08-26 14:36:59 +08:00
Chen Chengjun a5c4566485 Include the VDSO library directly 2025-08-24 19:09:40 +08:00
Zejun Zhao 0a126a0c8c Set correct default value for VdsoData::mask 2025-08-23 12:38:22 +08:00
Zejun Zhao 47b05143cf Correct vDSO data segment's permission 2025-08-23 12:38:22 +08:00
Zejun Zhao e68631d1b6 Implement arch-aware vDSO 2025-08-23 12:38:22 +08:00
Ruihan Li a4aa745de1 Refine the lock usage in the vDSO module 2025-08-22 16:20:01 +08:00
Ruihan Li f457acdb8b Rewrite documentations in the vDSO module 2025-08-22 16:20:01 +08:00
Tao Su 226ea2865c Resolve `semget01` failure by fixing key limit and adding `IPC_STAT` 2025-08-20 19:57:14 +08:00
Ruihan Li 6b6c64c591 Rename `atomic_update` to `atomic_fetch_update` 2025-08-20 13:17:57 +08:00
Arthur Paulino a73f210c7a Make `wake_robust_futex` atomic
Replace `VmWriter::atomic_update` with `VmWriter::atomic_compare_exchange`,
which takes the old value for comparison and new value instead of a
closure to compute it. This version has one less unsafe call.

Then use `atomic_compare_exchange` to reimplement the looping logic
of `wake_robust_futex` and make it atomic.
2025-08-19 19:22:12 +08:00
Chen Chengjun fc5a12356a Fix LOONGARCH clippy warnings 2025-08-19 19:20:54 +08:00