Compare commits

...

381 Commits

Author SHA1 Message Date
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
Tao Su 878ff925d1 Add `futex`, `lseek` and `newfstatat` syscall limitation to the book 2025-09-28 18:03:33 +08:00
Ruihan Li fcadc24a5c Fix `EACCES` errno in UNIX socket tests 2025-09-28 10:56:35 +08:00
Tate, Hongliang Tian d221342aa7 Revise the writing for the Linux system call table 2025-09-28 09:51:59 +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
Yang Zhichao b76f11f7b3 Add an `irq_num` parameter to `bottom_half_handler` for IRQ counting statistics. 2025-09-27 21:02:23 +08:00
Tate, Hongliang Tian 4471b9fc01 Add a new reference for the recommended Rust API style 2025-09-27 20:59:12 +08:00
Chen Chengjun 08e51cc0c8 Fix a problem of using INITRAMFS_SKIP_GZIP=1 2025-09-27 20:53:05 +08:00
Chen Chengjun 2c456709b6 Block a setuid ltp test for exfat test 2025-09-26 16:41:04 +08:00
Tao Su fc114019d6 Recompile bzImage if payload is changed 2025-09-26 15:35:14 +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
Qingsong Chen 30b43ca5be Fix schbench benchmark result extraction pattern 2025-09-26 15:12:22 +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
Yuke Peng 48c7c37f50 Bump version to 0.16.1 2025-09-24 13:55:48 +08:00
Wang Siyuan 57d3d9ded1 Fix some `mprotect` issues 2025-09-24 11:14:13 +08:00
Chen Chengjun c007ac90e9 Add tests for mount namespace 2025-09-24 08:07:25 +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
Yuke Peng eb9edbd67f Bump the Docker image to 0.16.1 2025-09-23 14:55:50 +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 37479383da Assign pci code owner 2025-09-21 10:32:23 +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 bb4c532b4e Use custom `PciDeviceLocation` in x86 iommu 2025-09-21 10:32:23 +08:00
Yuke Peng 67050f3a8f Change the position of debug log in `IoMemAllocator::acquire` 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 011e2398af Remove broken no-APIC support 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 bd0ab0b8aa Fix an outdated example in Rust doc 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 3501ec72ee Move disabled IRQ guards to a submodule 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
Ruihan Li 561ee206f5 Make metadata repurposing sound 2025-09-19 11:27:14 +08:00
Ruihan Li c7429a7a5c Allow to repurpose `?Sized` metadata 2025-09-19 11:27:14 +08:00
Wang Siyuan 70b26f824d Support `RUSAGE_CHILDREN` option for `getrusage` 2025-09-18 17:20:07 +08:00
Ruihan Li 6d64db8b61 Add tests for netlink parse errors 2025-09-18 17:19:51 +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
Hsy-Intel 07ae3a55fc Switch to a new Docker image 2025-09-18 12:14:06 +08:00
Qingsong Chen 8bc0013801 Add stage support for init_component macro 2025-09-18 12:11:44 +08:00
Hsy-Intel 2894ae1ce0 Bump the Docker image version 2025-09-18 10:06:46 +08:00
Hsy-Intel 2b653cc169 Upgrade Linux TDX command line 2025-09-18 10:06:46 +08:00
Hsy-Intel bcba238072 Upgrade Linux kernel version to 6.16.0 in Docker images 2025-09-18 10:06:46 +08:00
Tate, Hongliang Tian d73890c6b9 Keep the list of NON_OSDK_CRATES sorted in Makefile 2025-09-17 22:44:40 +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
Ruihan Li bf6efbabc7 Remove unused `has_guard_page` boolean 2025-09-14 22:42:48 +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
Ruihan Li 44145cdb53 Set CR0.WP/NE/MP explicitly to fix AP behavior 2025-09-12 08:43:35 +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 75ca7e0377 Add the `arch::cpu::extension` module 2025-09-10 12:10:40 +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
Tate, Hongliang Tian d4d84f18b7 Remove the outdated Github issue template for RFC 2025-09-05 17:40:05 +08:00
Tate, Hongliang Tian f9425865b0 Add the first RFC, "RFC-0001 RFC process" 2025-09-05 17:40:05 +08:00
Tate, Hongliang Tian e7733e94ee Remove a placeholder RFC page 2025-09-05 17:40:05 +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 877581f1a6 Add OSTD support for mapping `IoMem` in userspace 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
Zhe Tang e11227c8da Move the `AVAIL1` flag from `PageFlags` to `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
Ruihan Li 45b5bd39f1 Disable I/O APIC entries in initialization 2025-09-02 18:03:24 +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
Tao Su 89dfcbb569 Add `prctl`, `capget` and `capset` syscall limitation to the book 2025-09-02 17:40:56 +08:00
Tao Su 7c4b2899cc Add clock and misc related syscall limitation to the book 2025-09-02 17:40:56 +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
Zejun Zhao 4b26eb05aa Configure kernel stack size for release build based on architecture 2025-08-29 17:10:48 +08:00
Zejun Zhao b9a0878d53 Add comment about .eh_frame_hdr in riscv64 linker script 2025-08-29 17:10:48 +08:00
Zejun Zhao bf25806fca Add an explicit end of call stack for x86_64 and loongarch64 2025-08-29 17:10:48 +08:00
Zejun Zhao 3b0666449f Use rust-analyzer for riscv64 and loongarch64 target 2025-08-29 16:57:06 +08:00
Chen Chengjun f8e4aefcca Add tmpfs support by wrapping ramfs 2025-08-29 15:45:20 +08:00
Zejun Zhao fc61f4d1b8 Use `IrqLine` abstraction for RISC-V timer interrupt 2025-08-29 10:49:48 +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
Zejun Zhao aeaf103166 Add an explicit end of call stack for x86_64 2025-08-28 17:26:23 +08:00
Zejun Zhao 920ec7f521 Enable RISC-V stack unwinding on panic 2025-08-28 17:26:23 +08:00
Tao Su 05f053c56d Add signal & timer related syscall limitations to the book 2025-08-28 16:17:14 +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 3882eb4000 Update docker version reference 2025-08-24 19:09:40 +08:00
Chen Chengjun a5c4566485 Include the VDSO library directly 2025-08-24 19:09:40 +08:00
Chen Chengjun 65344a187f Remove vDSO install in Nix 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
Hsy-Intel 7fad653992 Use 6.16.0 Linux kernel for benchmark tests & Add Linux TDX benchmark tests 2025-08-22 17:20:14 +08:00
Chen Chengjun 8686d2b799 Bump the docker version for vDSO again 2025-08-22 17:16:40 +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
Tate, Hongliang Tian 9ab035c654 Rename the docs directory to book 2025-08-21 19:16:12 +08:00
Qingsong Chen 1e675d4387 Replace stdenv with stdenvNoCC to optimize CI workflows 2025-08-21 17:34:39 +08:00
Chen Chengjun 92f36751d0 Bump the docker version for VDSO 2025-08-21 17:26:07 +08:00
Tao Su 605605cfc5 Add I/O control related syscall limitation to the book 2025-08-21 15:15:02 +08:00
Tao Su 9fe04c2294 Add mount-related syscall limitations to the book 2025-08-21 15:15:02 +08:00
Ruihan Li 924d87398a Introduce `first_context_switch` 2025-08-20 20:12:38 +08:00
Ruihan Li 2d3cfb53e0 Swap `context_switch` arguments 2025-08-20 20:12:38 +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 85f17ff159 Replace `parse_u32` with `u32::from_str_radix` 2025-08-20 13:19:50 +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
Chen Chengjun 9507475102 Fix RISCV clippy warnings 2025-08-19 19:20:54 +08:00
Chen Chengjun a049717813 Add documents for environment variables in the Book 2025-08-19 19:20:54 +08:00
Chen Chengjun bf5360d721 Enable arch-aware make check 2025-08-19 19:20:54 +08:00
Zhang Junyang 1452aab69c Optimize the space for `TlbFlushOp`s 2025-08-16 22:09:29 +08:00
Zhang Junyang d0b98130cf Don't use `map` to return values 2025-08-16 22:09:29 +08:00
Hsy-Intel e725bf4ab8 Update Docker image references to remove '-tdx' suffix for consistency 2025-08-16 09:17:44 +08:00
Hsy-Intel a67df5fa3b Switch to a new Docker image 2025-08-16 09:17:44 +08:00
Arthur Paulino c31c6110f6 chore: use `jhash` to compute the `FutexKey` hash
This patch pays the price of making the instantiation of `FutexKey`
more expensive to achieve two goals:
* Minor: make `match_up` slightly faster
* Major: make futex bucket allocation balancing more robust
2025-08-16 09:16:50 +08:00
Arthur Paulino 91351e338f fix: avoid distribution skew in `FutexBucketVec::get_bucket`
Doing `addr / self.size()` before masking with `(self.size() - 1)`
removes the low bits entirely, which causes adjacent addresses
(modulo `self.size()`) to map to the same bucket, entailing bad
load balance. This patch solves that.

Further, make `FutexBucketVec::new` and `FutexBucketVec::get_bucket`
private, as they only make sense within the scope of `futex.rs`,
where the invariant of `size` being a power of two is guaranteed to
hold via `get_bucket_count` (which is also private).
2025-08-16 09:16:50 +08:00
Arthur Paulino c345876bc0 chore: avoid several `FutexKey` copies
Use shared references instead of copied objects on some functions
that don't necessarily require ownership of `FutexKey`.

Remove the `Copy` derivation of `FutexKey` to discourage suboptimal
copies.
2025-08-16 09:16:50 +08:00
Hsy-Intel 35ac8a407b Bump the Docker image version 2025-08-15 15:27:09 +08:00
Hsy-Intel de9f0da58f Clean up TDX-specific Docker images 2025-08-15 15:27:09 +08:00
Hsy-Intel 7301cb8c36 Upgrade QEMU version 2025-08-15 15:27:09 +08:00
Tao Su c15106734a Align `MS_ASYNC` and `MS_SYNC` flags with Linux behavior 2025-08-14 20:01:36 +08:00
Tao Su 18456a10d9 Add memory-related syscall limitations to the book 2025-08-14 20:01:36 +08:00
Ruihan Li 5b91064316 Add a method that disables page fault handlers 2025-08-14 11:59:05 +08:00
Ruihan Li e4fafb13b1 Add atomic operations for VM readers/writers 2025-08-14 11:59:05 +08:00
Ruihan Li 6e6465942c Clean up comments and visibility 2025-08-12 19:19:34 +08:00
Ruihan Li bb279e6313 Clarify who loads the user TLS pointer 2025-08-12 19:19:34 +08:00
Ruihan Li 086a80c05f Drop unsound TLS methods from `Task` 2025-08-12 19:19:34 +08:00
Ruihan Li 923982c2e5 Remove `user_ctx` from `Task` 2025-08-12 19:19:34 +08:00
Zejun Zhao 60bc63b0e2 Refine system call tables 2025-08-12 17:03:44 +08:00
Chen Chengjun 25d217397a Rename MountNode to Mount 2025-08-12 15:20:17 +08:00
Chen Chengjun 32ee4a41f1 Refine visibility 2025-08-12 15:20:17 +08:00
Chen Chengjun e155057d55 Move all mount operation interfaces to Path 2025-08-12 15:20:17 +08:00
Chen Chengjun aea4013a43 Fix the mountpoint state maintaining for Dentry 2025-08-12 15:20:17 +08:00
Chen Chengjun ae32062e77 Avoid passing self when calling internal mount methods within Path 2025-08-12 15:20:17 +08:00
Chen Chengjun 9985d64535 Complete some remaining rename tasks 2025-08-12 15:20:17 +08:00
Ruihan Li 695bb1a0a7 Synchronize `{pci,io}.rs` between architectures 2025-08-12 14:00:28 +08:00
Tao Su 2b6533cdff Add semaphore-related syscall limitations to the book
Signed-off-by: Tao Su <taosu.linux@gmail.com>
2025-08-12 13:36:44 +08:00
jiangjianfeng 9a56028afc Support parsing shebang with multiple arguments in intepreter line 2025-08-12 11:23:30 +08:00
Tate, Hongliang Tian d481b10f63 Polish the Rust doc of OSTD's logger module 2025-08-12 10:55:24 +08:00
Ruihan Li 53bb7ea8ae Assign keyboard code owners 2025-08-11 19:43:38 +08:00
Zejun Zhao 597b0b5f25 Disable kernel traps before going to userspace 2025-08-10 17:09:22 +08:00
Ruihan Li cdd28787ed Replace `write_vals` by `fill_zeros` in `VmIo` 2025-08-10 16:40:11 +08:00
Ruihan Li 2700d88bef Provide efficient `VmIo` with VM readers/writers 2025-08-10 16:40:11 +08:00
Ruihan Li 894b942a79 Avoid all `Pod::new_uninit`s in OSTD 2025-08-10 16:40:11 +08:00
Ruihan Li 275fd21650 Retire missing `ptr::sub` in `mm/io.rs` 2025-08-10 16:40:11 +08:00
Ruihan Li aa7aca3dde Add `VmWriter::fill_zeros` 2025-08-10 16:40:11 +08:00
Ruihan Li d99c18d0be Remove `VmWriter::fill` 2025-08-10 16:40:11 +08:00
Ruihan Li db79aa2453 Remove `VmReader::collect` 2025-08-10 16:40:11 +08:00
Ruihan Li 6e597b40af Remove unsafe code in `mm/test.rs` 2025-08-10 16:40:11 +08:00
Tate, Hongliang Tian f2ead0b3ed Remove O_TMPFILE flag because it is not really supported 2025-08-09 16:26:50 +08:00
Tate, Hongliang Tian 5f47febe42 Add a new "Limitations on System Calls" section to the book 2025-08-09 16:26:50 +08:00
jiangjianfeng f6478d62cc Refactor the implementation about sigstack 2025-08-08 12:06:26 +08:00
jiangjianfeng 69c48f1ede Add regression test about sigstack 2025-08-08 12:06:26 +08:00
Ruihan Li 05990e743e Reimplement PCI BAR detection methods 2025-08-08 09:02:34 +08:00
Ruihan Li cfa4a6fba3 Specify SCHEME in Makefile for LoongArch 2025-08-07 18:41:30 +08:00
Hsy-Intel 3752689a54 Adjust benchmark schedule timing 2025-08-07 18:40:01 +08:00
Ruihan Li db66946e22 Re-enable several debug runs in CI 2025-08-06 17:17:34 +08:00
Ruihan Li c19c7765d8 Fix race conditions in `pause_timeout` 2025-08-06 17:17:34 +08:00
Ruihan Li 20893be80e Allow to receive empty SEQPACKET packets 2025-08-06 17:17:34 +08:00
Chen Chengjun c6a6e66aac Rename Dentry to Path in the other modules and rename some local variables 2025-08-06 14:06:39 +08:00
Chen Chengjun 6aa516e2bf Move Path to mod.rs of the path module 2025-08-06 14:06:39 +08:00
Chen Chengjun 34dac93175 Rename Dentry and Dentry_ in the path module 2025-08-06 14:06:39 +08:00
jiangjianfeng de97644b4c Move `ThreadFsInfo` from `PosixThread` to `ThreadLocal` 2025-08-06 13:38:42 +08:00
Zejun Zhao b20d8461fd Fix discovery and access of PCIe (MMIO) configuration space 2025-08-06 02:11:21 +08:00
Zejun Zhao 19f7eea68b Don't assume SVPBMT's existence 2025-08-06 02:11:21 +08:00
Zejun Zhao 26b7428c8e Construct `IoMemAllocator` on RISC-V platforms 2025-08-06 02:11:21 +08:00
Zhang Junyang afe63e7123 Fix ELF loading when shebang/loader path is too long/far 2025-08-05 15:42:13 +08:00
jiangjianfeng 4e78653b5b Bump project version to 0.16.0 2025-08-05 14:24:14 +08:00
jiangjianfeng c84baa6cf6 Update references to the Docker image version to 0.16.0-20250802 2025-08-05 14:24:14 +08:00
Wang Siyuan ffdfd01925 Refactor the core scheduling logic in OSTD 2025-08-05 13:37:01 +08:00
Wang Siyuan 3ebb5a25b2 Refactor task schedulers to conform with the new semantics 2025-08-05 13:37:01 +08:00
Tate, Hongliang Tian 4d949b99a3 Assign the code owner for RELEASES.md 2025-08-05 09:11:17 +08:00
Tate, Hongliang Tian 1cc83971c1 Add the release notes for version 0.16.0 2025-08-05 09:11:17 +08:00
Zejun Zhao b76d61d268 Show function name in panic stack trace 2025-08-04 11:03:16 +08:00
Tate, Hongliang Tian ab5448619c Bump the Docker image version 0.16.0-20250802 2025-08-02 11:40:01 +08:00
Wang Siyuan 48fa40bbf2 Support the system call `memfd_create` 2025-07-31 09:29:12 +08:00
Wang Siyuan 59ceb6d27c Add a method `inode` for `FileLike` 2025-07-31 09:29:12 +08:00
Tate, Hongliang Tian 659f079c2d Revise the doc of OSTD's scheduling module 2025-07-29 21:58:23 +08:00
Ruihan Li 3e88b92ddd Remove useless target features 2025-07-29 11:13:59 +08:00
Ruihan Li d73f1016a1 Set softfloat targets for ARM/LoongArch/RISC-V 2025-07-29 11:13:59 +08:00
Wei Zhang 8a801676ab Disallow masking SIGKILL and SIGSTOP in user space
According to the Linux man pages[1], "It is not possible to block SIGKILL
or SIGSTOP. Attempts to do so are silently ignored." This patch ensures
compliance by explicitly removing SIGKILL and SIGSTOP from the signal
mask in the `MaskOp::SetMask` operation of the `rt_sigprocmask` syscall.

[1]: https://www.man7.org/linux/man-pages/man2/sigprocmask.2.html
2025-07-28 17:08:10 +08:00
Yuke Peng 2154124dc4 Format the user exception log 2025-07-28 15:01:49 +08:00
Ruihan Li e52634cb78 Add some references for signal-related types 2025-07-28 10:50:38 +08:00
Ruihan Li 83b0564c99 Remove TLS-related stuffs from `LinuxABI` 2025-07-28 10:50:38 +08:00
jiangjianfeng 28d5d94c8c Support setting reuseaddr for UDP socket 2025-07-28 10:20:50 +08:00
jiangjianfeng ff39f6df75 Correct the reuseaddr behavior 2025-07-28 10:20:50 +08:00
jiangjianfeng 9d9633e3d2 Add reuseaddr regression test 2025-07-28 10:20:50 +08:00
王英泰 345cc9d055 Save FPU context on signal stack for LoongArch 2025-07-25 17:37:24 +08:00
王英泰 ae633ee0c0 Modify the test Makefile to fit LoongArch 2025-07-25 17:37:24 +08:00
王英泰 9ab0e04e75 Add GitHub Actions workflow for LoongArch64 lint & compile tests 2025-07-25 17:37:24 +08:00
王英泰 0370f8fdf3 Update the init of pci device for LoongArch 2025-07-25 17:37:24 +08:00
王英泰 3391863312 Add the partial support for interrupt in LoongArch 2025-07-25 17:37:24 +08:00
王英泰 434d75c0f0 Cancel the use of floating-point instructions in kernel log 2025-07-25 17:37:24 +08:00
王英泰 fc72398fbc Change the method to identify the legacy virtio device 2025-07-25 17:37:24 +08:00
王英泰 cc280272cc Add the RTC time comps for LoongArch 2025-07-25 17:37:24 +08:00
王英泰 5c4b3fdd19 Finish the arch section for LoongArch in kernel 2025-07-25 17:37:24 +08:00
王英泰 4562361ef0 Add the random support for LoongArch in kernel 2025-07-25 17:37:24 +08:00
王英泰 5ca18b31ad Add the syscall support for LoongArch in kernel 2025-07-25 17:37:24 +08:00
王英泰 5c590f0c6b Add the process support for LoongArch in kernel 2025-07-25 17:37:24 +08:00
王英泰 7bf716162a Finish the arch section for LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 8b8bbad996 Add the pci section for LoongArch in OSTD and kernel 2025-07-25 17:37:24 +08:00
王英泰 369c8656ee Add the io section for LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 7e9f418caa Add the qemu exit method for LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 25bbdd991f Add the irq section for LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 3824af8c89 Add the trap section for LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 b5c3eb8be8 Add the timer section of LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 93c562f5d2 Add the task section of LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 e4db73e1a0 Add the mm section of LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 d3538ec6df Add the iommu section of LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 c81ed0162c Add the device section of LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 91e7785915 Add the cpu section of LoongArch in OSTD and kernel 2025-07-25 17:37:24 +08:00
王英泰 ce22374b50 Add the boot section of LoongArch in OSTD 2025-07-25 17:37:24 +08:00
王英泰 b0b242edbc Add the temporary panic support for LoongArch 2025-07-25 17:37:24 +08:00
王英泰 ef1d26d81b Add the support for LoongArch in OSDK 2025-07-25 17:37:24 +08:00
Qingsong Chen f528eb1ec0 Switch Docker image to version 0.15.2-20250722 2025-07-25 10:08:37 +08:00
jiangjianfeng 9219207b97 Add CLONE_PIDFD & pidfd_open support 2025-07-24 21:11:24 +08:00
jiangjianfeng e75cbb0545 Add pidfd regression test 2025-07-24 21:11:24 +08:00
jiangjianfeng dbc6e7c71a Add support for `/proc/sys/kernel/pid_max` 2025-07-24 21:11:24 +08:00
Qingsong Chen 5b5edcbe86 Bump Docker image version to 0.15.2-20250722 2025-07-23 20:03:39 +08:00
Qingsong Chen 3eeee67cc4 Move init.sh to /etc/profile.d 2025-07-23 20:03:39 +08:00
Qingsong Chen 171b9803ad Let Github runners reuse caches for Rust and Nixpkgs 2025-07-23 20:03:39 +08:00
Qingsong Chen edbab2093a Add prebuilt apps test in docker image 2025-07-23 20:03:39 +08:00
Qingsong Chen 12c40de5a9 Set nixpkgs cache TTL duration 2025-07-23 20:03:39 +08:00
Qingsong Chen 54b1782a2f Make apps test optional 2025-07-23 20:03:39 +08:00
Ruihan Li 5ccadb6253 Support SOCK_SEQPACKET 2025-07-23 20:02:15 +08:00
Ruihan Li c3572e9548 Support SCM_CREDENTIALS 2025-07-23 20:02:15 +08:00
Ruihan Li ab897ccd2f Support SO_PASSCRED
Co-authored-by: Jianfeng Jiang <jiangjianfeng.jjf@antgroup.com>
2025-07-23 20:02:15 +08:00
Tate, Hongliang Tian deb60415a6
Update README.md for SOSP'25 news 2025-07-23 19:23:55 +08:00
Qingsong Chen e86f7584a3 Fix atomic mode issue when VMO commit needs IO 2025-07-23 11:23:03 +08:00
Qingsong Chen eb64ca1cea Fix VMO commit address when needs IO 2025-07-23 11:23:03 +08:00
Cautreoxit 6ecccad3ee Add sys_ioprio_set and sys_ioprio_get 2025-07-22 17:22:52 +08:00
Hsy-Intel 24d56cfde7 adjust feature enabling sequence and fix xsave size function 2025-07-22 17:15:53 +08:00
Cautreoxit 2e3d8ea867 Add extension support for keyboard 2025-07-22 15:16:12 +08:00
Cautreoxit b8b9d8bff6 Add release support for keyboard 2025-07-22 15:16:12 +08:00
Marsman1996 b04d62ae71 Use official minicov and add unit test for coverage feature 2025-07-22 10:31:56 +08:00
YanWQ-monad 79335b272f Add coverage support
Co-authored-by: Marsman1996 <lqliuyuwei@outlook.com>
2025-07-22 10:31:56 +08:00
Chen Chengjun 03fc309b95 Enable more waitid LTP tests 2025-07-21 21:31:32 +08:00
Chen Chengjun ef0382b164 Enhance waitid syscall support 2025-07-21 21:31:32 +08:00
Chen Chengjun 4d52241c6c Fix some definition errors of siginfo_t 2025-07-21 21:31:32 +08:00
Cautreoxit c6011b9650 Add fadvise64 syscall 2025-07-21 21:29:17 +08:00
Yang Zhichao 9570f14d80 Add AMD support for cache_size and tlb_size 2025-07-21 20:08:42 +08:00
Yang Zhichao d09c6c7584 Add a fallback to RDTSC estimation when TSC info is unavailable 2025-07-21 20:08:42 +08:00
Yang Zhichao 496c50f296 Fix get_cpuid_level function to directly return the CPUID 0x0 EAX value instead of TSC denominator 2025-07-21 20:08:42 +08:00
Yang Zhichao 85e605250b Fix cache line size calculation in get_clflush_size function 2025-07-21 20:08:42 +08:00
Zhang Junyang 6a4d8d113f Fix missing updates of page table `Entry::pte`
Co-authored-by: Xungan2 <2100012996@stu.pku.edu.cn>
2025-07-21 13:42:38 +08:00
Marsman1996 62d426d9b7 Add check for empty directory and more forms of root directory in `rmdir` 2025-07-21 11:33:14 +08:00
Ruihan Li 4d8078166e Send and receive UNIX control messages 2025-07-21 10:46:08 +08:00
Ruihan Li bc7515389b Create a RISC-V boot code and data section 2025-07-21 10:01:02 +08:00
Ruihan Li e475009fe7 Optimize the x86 binary size 2025-07-21 10:01:02 +08:00
jiangjianfeng 424fcda239 Use iret instead of sysret if the context is not clean 2025-07-20 22:22:20 +08:00
Ruize Tang d083aef690 Add a simple test for checking FPU state in signal 2025-07-18 11:40:16 +08:00
Qingsong Chen f1299d4b8d Save FPU context on signal stack 2025-07-18 11:40:16 +08:00
Qingsong Chen 6cd53fbb8a Refactor FPU context using pre_schedule_handler 2025-07-18 11:40:16 +08:00
Marsman1996 ab5e1999fc Apply the docker version bump for related files 2025-07-17 20:58:27 +08:00
Chen Chengjun 749fe77591 Add an initial script to mount several file systems 2025-07-17 13:51:45 +08:00
Chen Chengjun df69af324e Forbid creating a directory in sysfs 2025-07-17 13:51:45 +08:00
Chen Chengjun 16292742d2 Leverage FsRegistry to remove the hardcode in mount syscall 2025-07-17 13:51:45 +08:00
Chen Chengjun 9783bbddda Implement FsType for exsiting file systems 2025-07-17 13:51:45 +08:00
Chen Chengjun cb1732706a Introduce FsType and FsRegistry 2025-07-17 13:51:45 +08:00
王英泰 92fb51b99b Add LoongArch QEMU to the docker image and bump versions 2025-07-16 21:57:25 +08:00
Marsman1996 e1870fde9a Install clang into the OSDK docker image 2025-07-16 21:35:19 +08:00
Ruihan Li cdd7950d2e Remove some variants in `ostd::Error` 2025-07-15 23:05:30 +08:00
Chen Chengjun d02202dc73 Support the basic cgroupfs 2025-07-14 20:35:05 +08:00
Chen Chengjun 19a3f5576d Introduce the FsManager 2025-07-14 20:35:05 +08:00
Chen Chengjun b90b79810c Provide more powerful macros to assist in implementing the SysTree-related traits 2025-07-14 20:35:05 +08:00
Chen Chengjun a8b4c23319 Add SysTreeInodeTy trait to abstract the view part of MVC arch 2025-07-14 20:35:05 +08:00
Chen Chengjun 774291611c Add two error types in aster_systree::Error 2025-07-14 20:35:05 +08:00
Chen Chengjun 9c68d96fa2 Attach SysPerms to systree nodes and attributes 2025-07-14 20:35:05 +08:00
Chen Chengjun e229eb379b Enable getting path through SysObj 2025-07-14 20:35:05 +08:00
Ruihan Li a5e927b675 Make the framebuffer backspace work 2025-07-14 20:24:29 +08:00
Ruihan Li b1079c2bc5 Add support for font setting 2025-07-14 20:24:29 +08:00
Ruihan Li 9f82a0c89f Clean up the console crate 2025-07-14 20:24:29 +08:00
jiangjianfeng d317ce3246 Adjust `max_len` to avoid EFAULT when reading CString 2025-07-14 15:43:34 +08:00
jiangjianfeng 010da31b3e Align execve argument limits with Linux 2025-07-14 15:43:34 +08:00
Ruihan Li e5c5bc7992 Clarify safety comments in `dyn_cpu_local.rs` 2025-07-11 14:10:46 +08:00
yuankunzhang a4c918efd7 fs: validate workdir when creating overlayfs instance
The workdir needs to be an empty directory on the same filesystem
as upperdir.
2025-07-11 09:26:31 +08:00
Hsy-Intel 48b160e33a Use default process name in TDX QEMU configuration 2025-07-10 10:13:51 +08:00
jiangjianfeng 665de6bd35 Make RISC-V code compile under new exception APIs 2025-07-09 10:49:43 +08:00
jiangjianfeng 7f3ca86467 Refactor x86 exception related code 2025-07-09 10:49:43 +08:00
Qingsong Chen 4736004cff Fix lmbench by adding delay to ensure lmhttp starts 2025-07-08 16:29:52 +08:00
Chen Chengjun 2a34a041c4 Fix the mask set in the signalfd 2025-07-08 15:50:41 +08:00
Qingsong Chen 20c2e967fe Fix benchmark CI errors 2025-07-07 13:34:32 +08:00
js2xxx 1a12080c58 Fix integer overflow when updating vruntime after pending weight update 2025-07-05 18:23:17 +08:00
Ruihan Li 801ab865b7 Make paths of `TrapFrame` unique 2025-07-05 18:19:26 +08:00
Ruihan Li 0fce977b40 Clean up `trapframe` items 2025-07-05 18:19:26 +08:00
Ruihan Li 6f2725419f Always clear the need-preempt flag 2025-07-04 19:14:31 +08:00
Qingsong Chen 05a325c61f Reassign test code owner 2025-07-04 18:52:26 +08:00
Qingsong Chen aca1339d77 Add README.md for test directory 2025-07-04 18:52:26 +08:00
Qingsong Chen 7118124fc2 Use nix to build initramfs 2025-07-04 18:52:26 +08:00
Qingsong Chen 490eaf6c81 Restructure the test directory 2025-07-04 18:52:26 +08:00
Qingsong Chen 8d56238b4d Switch to a new Docker image 2025-07-04 18:52:26 +08:00
Wang Siyuan 37cc54f2aa Store `offset` in `MappedVmo` instead of `range` 2025-07-03 18:54:53 +08:00
Ruihan Li 706f62e299 Support ANSI escape sequences 2025-07-03 17:47:56 +08:00
Ruihan Li abbf152d74 Re-enable framebuffer 2025-07-03 17:47:56 +08:00
Ruihan Li d73cbb5008 Clarify the `DeviceId` encoding 2025-07-03 14:30:14 +08:00
Wang Siyuan a13297ae4c Add fields in `/proc/*/stat` and `/proc/*/status` 2025-07-02 20:13:47 +08:00
Wei Zhang 513532fe95 Correctly handle partial writes and reads in writev and readv
When using writev or readv, if data is partially written or read, the
written or read bytes number should be returned instead of error.
2025-07-02 17:14:10 +08:00
Chen Chengjun f274af17de Add a regression test 2025-07-02 16:08:00 +08:00
Chen Chengjun fe24c2d8ae Ensure proper handling of out-of-bounds VMO access during page fault processing 2025-07-02 16:08:00 +08:00
Qingsong Chen 3d11849ce8 Bump Docker image version to 0.15.2-20250702 2025-07-02 15:39:53 +08:00
Qingsong Chen 7c68b36957 Install nix packages in docker image 2025-07-02 15:39:53 +08:00
js2xxx 4571fabc7a Fix integer overflow due to fair weight change 2025-07-02 11:00:34 +08:00
Ruihan Li ac0d92d878 Fix minor issues of the CPU extension module 2025-07-02 07:54:40 +08:00
jiangjianfeng 49ef0e9f7a Change the documentation website of OSTD 2025-07-01 17:07:28 +08:00
jiangjianfeng 2e09957ef9 Fix documentation check errors 2025-07-01 17:07:28 +08:00
jiangjianfeng 0d46c4323c Update RUSTDOCFLAGS for `cargo osdk doc` 2025-07-01 17:07:28 +08:00
jiangjianfeng 105ed3fd3c Add workflows to publish API documentation to self-hosted website 2025-07-01 17:07:28 +08:00
jiangjianfeng dc26e18310 Depend on int-to-c-enum instead of num crate 2025-06-30 15:48:40 +08:00
Ruihan Li 6146434f15 Unify the styles of the `arch` modules 2025-06-30 15:43:41 +08:00
Qingsong Chen 5e3e23bf7c Add basic i8042 keyboard support 2025-06-27 12:56:55 +08:00
Ruihan Li 3f1bf99b2a Make `mremap` behavior consistent with Linux 2025-06-26 11:41:56 +08:00
Ruihan Li 079be2f30f Enable syscall tests for UNIX sockets 2025-06-26 11:11:03 +08:00
Ruihan Li bef9304c85 Fix minor problems of UNIX sockets 2025-06-26 11:11:03 +08:00
Wang Siyuan 810580bda5 Fix underflow when merging VMAs 2025-06-26 11:10:38 +08:00
1237 changed files with 32677 additions and 12277 deletions

View File

@ -1,46 +0,0 @@
---
name: RFC Submission
about: Propose a new idea or significant change for consideration
title: Concise description of the proposal
labels: C-rfc
---
<!-- Thank you for taking the time to propose a new idea or significant change. Please provide a comprehensive overview of the concepts and motivations at play. -->
### Summary
<!-- Briefly summarize the idea, change, or feature you are proposing. What is it about, and what does it aim to achieve? -->
### Context and Problem Statement
<!-- Describe the problem or inadequacy of the current situation/state that your proposal is addressing. This is a key aspect of putting your RFC into context. -->
### Proposal
<!-- Clearly and comprehensively describe your proposal including high-level technical specifics, any new interfaces or APIs, and how it should integrate into the existing system. -->
### Motivation and Rationale
<!-- Elaborate on why this proposal is important. Provide justifications for why it should be considered and what benefits it brings. Include use cases, user stories, and pain points it intends to solve. -->
### Detailed Design
<!-- Dive into the nitty-gritty details of your proposal. Discuss possible implementation strategies, potential issues, and how the proposal would alter workflows, behaviors, or structures. Include pseudocode, diagrams, or mock-ups if possible. -->
### Alternatives Considered
<!-- Detail any alternative solutions or features you've considered. Why were they discarded in favor of this proposal? -->
### Additional Information and Resources
<!-- Offer any additional information, context, links, or resources that stakeholders might find helpful for understanding the proposal. -->
### Open Questions
<!-- List any questions that you have that might need further discussion. This can include areas where you are seeking feedback or require input to finalize decisions. -->
### Future Possibilities
<!-- If your RFC is likely to lead to subsequent changes, provide a brief outline of what those might be and how your proposal may lay the groundwork for them. -->
<!-- We appreciate your effort in contributing to the evolution of our system and look forward to reviewing and discussing your ideas! -->

View File

@ -41,7 +41,7 @@ runs:
shell: bash
run: |
make install_osdk
bash test/benchmark/bench_linux_and_aster.sh "${{ matrix.benchmarks }}" "${{ inputs.platform }}"
bash test/src/benchmark/bench_linux_and_aster.sh "${{ matrix.benchmarks }}" "${{ inputs.platform }}"
BENCHMARK_ARTIFACT=results_$(echo "${{ matrix.benchmarks }}" | tr '/' '-')
echo "BENCHMARK_ARTIFACT=$BENCHMARK_ARTIFACT" >> $GITHUB_ENV
@ -76,8 +76,8 @@ runs:
BENCHMARK_DIR=$(echo "$benchmark_id" | sed 's/-/\//g')
BENCHMARK_SUITE=$(echo "$BENCHMARK_DIR" | awk -F'/' '{print $1}')
BENCHMARK_NAME=$(echo "$BENCHMARK_DIR" | sed -E 's|^[^/]+/||; s|/bench_results||g; s|/|_|g')
BENCH_RESULT_YAML="test/benchmark/${BENCHMARK_DIR}/bench_result.yaml"
[ -f "$BENCH_RESULT_YAML" ] || BENCH_RESULT_YAML="test/benchmark/${BENCHMARK_DIR}.yaml"
BENCH_RESULT_YAML="test/src/benchmark/${BENCHMARK_DIR}/bench_result.yaml"
[ -f "$BENCH_RESULT_YAML" ] || BENCH_RESULT_YAML="test/src/benchmark/${BENCHMARK_DIR}.yaml"
if [ ! -f "$BENCH_RESULT_YAML" ]; then
echo "Warning: YAML file not found for $benchmark_id at $BENCH_RESULT_YAML. Skipping config generation."
@ -91,9 +91,9 @@ runs:
DESCRIPTION=$(yq -r '.chart.description // "No description provided"' "$BENCH_RESULT_YAML")
# Generate summary JSON if needed (only once per suite)
SUMMARY_JSON="test/benchmark/$BENCHMARK_SUITE/summary.json"
SUMMARY_JSON="test/src/benchmark/$BENCHMARK_SUITE/summary.json"
if [ ! -f "$SUMMARY_JSON" ]; then
SUMMARY_YAML="test/benchmark/$BENCHMARK_SUITE/summary.yaml"
SUMMARY_YAML="test/src/benchmark/$BENCHMARK_SUITE/summary.yaml"
if [ -f "$SUMMARY_YAML" ]; then
yq . "$SUMMARY_YAML" > "$SUMMARY_JSON"
echo "Generated $SUMMARY_JSON"

View File

@ -31,7 +31,7 @@ inputs:
# Test Parameters
arch:
description: 'Architecture (x86_64/riscv64)'
description: 'Architecture (x86_64/riscv64/loongarch64)'
required: false
extra_blocklists:
description: 'Extra blocklists directories'
@ -70,7 +70,7 @@ runs:
[[ "${{ matrix.id }}" == "compile" ]] && CMD+="make build FEATURES=all"
[[ "${{ matrix.id }}" == "usermode_test" ]] && CMD+="make test"
[[ "${{ matrix.id }}" == "ktest" ]] && CMD+="make ktest NETDEV=tap"
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
[[ -n "${{ inputs.arch }}" ]] && CMD+=" OSDK_TARGET_ARCH=${{ inputs.arch }}"
echo "Executing: $CMD"
eval $CMD
@ -86,7 +86,7 @@ runs:
[[ -n "${{ inputs.smp }}" ]] && CMD+=" SMP=${{ inputs.smp }}"
[[ -n "${{ inputs.netdev }}" ]] && CMD+=" NETDEV=${{ inputs.netdev }}"
[[ -n "${{ inputs.scheme }}" ]] && CMD+=" SCHEME=${{ inputs.scheme }}"
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
[[ -n "${{ inputs.arch }}" ]] && CMD+=" OSDK_TARGET_ARCH=${{ inputs.arch }}"
[[ -n "${{ inputs.extra_blocklists }}" ]] && CMD+=" EXTRA_BLOCKLISTS_DIRS=${{ inputs.extra_blocklists }}"
[[ -n "${{ inputs.syscall_test_suite }}" ]] && CMD+=" SYSCALL_TEST_SUITE=${{ inputs.syscall_test_suite }}"
[[ -n "${{ inputs.syscall_test_workdir }}" ]] && CMD+=" SYSCALL_TEST_WORKDIR=${{ inputs.syscall_test_workdir }}"

View File

@ -3,8 +3,8 @@ on:
# In case of manual trigger, use workflow_dispatch
workflow_dispatch:
schedule:
# Schedule to run on every day at 20:00 UTC (04:00 Beijing Time)
- cron: '0 20 * * *'
# Schedule to run on every day at 17:00 UTC (01:00 Beijing Time)
- cron: '0 17 * * *'
jobs:
Benchmarks:
@ -107,7 +107,7 @@ jobs:
max-parallel: 1
timeout-minutes: 60
container:
image: asterinas/asterinas:0.15.2-20250613
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
steps:

View File

@ -3,8 +3,8 @@ on:
# In case of manual trigger, use workflow_dispatch
workflow_dispatch:
schedule:
# Schedule to run on every day at 20:00 UTC (04:00 Beijing Time)
- cron: '0 18 * * *'
# Schedule to run on every day at 16:00 UTC (00:00 Beijing Time)
- cron: '0 16 * * *'
jobs:
Benchmarks:
@ -108,7 +108,7 @@ jobs:
max-parallel: 1
timeout-minutes: 60
container:
image: asterinas/asterinas:0.15.2-20250613-tdx
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
steps:

48
.github/workflows/publish_api_docs.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Publish API Docs
on:
# Manally run
workflow_dispatch:
# Pull request events for checking API docs
pull_request:
# Scheduled events for nightly API docs
schedule:
# UTC 00:00 everyday
- cron: "0 0 * * *"
# Events for API docs of new release
push:
branches:
- main
paths:
- VERSION
jobs:
check_api_docs:
runs-on: ubuntu-latest
timeout-minutes: 15
container: asterinas/asterinas:0.16.1-20250922
steps:
- uses: actions/checkout@v4
- name: Check API docs
if: github.event_name == 'pull_request'
run: ./tools/github_workflows/publish_api_docs.sh --dry-run
- name: Build & Upload Nightly API Docs
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
env:
API_DOCS_NIGHTLY_PUBLISH_KEY: ${{ secrets.API_DOCS_NIGHTLY_PUBLISH_KEY }}
run: |
KEY_FILE=./api_docs_nightly_publish_key
echo "$API_DOCS_NIGHTLY_PUBLISH_KEY\n" > ${KEY_FILE}
./tools/github_workflows/publish_api_docs.sh nightly ${KEY_FILE}
- name: Build & Upload Release API Docs
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
env:
API_DOCS_PUBLISH_KEY: ${{ secrets.API_DOCS_PUBLISH_KEY }}
run: |
KEY_FILE=./api_docs_publish_key
echo "$API_DOCS_PUBLISH_KEY\n" > ${KEY_FILE}
./tools/github_workflows/publish_api_docs.sh release ${KEY_FILE}

View File

@ -30,7 +30,7 @@ jobs:
build-args: |
ASTER_RUST_VERSION=${{ steps.prepare-for-docker-build-and-push.outputs.rust_version }}
publish_osdk_tdx_image:
publish_nix_image:
needs: publish_osdk_image
runs-on: ubuntu-latest
steps:
@ -38,22 +38,22 @@ jobs:
- name: Prepare for Docker build and push
id: prepare-for-docker-build-and-push
run: |
./tools/github_workflows/prepare_for_docker_build_and_push.sh ${{ secrets.DOCKERHUB_USERNAME }} ${{ secrets.DOCKERHUB_TOKEN }} osdk-tdx
./tools/github_workflows/prepare_for_docker_build_and_push.sh ${{ secrets.DOCKERHUB_USERNAME }} ${{ secrets.DOCKERHUB_TOKEN }} nix
- name: Build and push the OSDK development image for Intel TDX
- name: Build and push the Nix image
if: ${{ steps.prepare-for-docker-build-and-push.outputs.is_existed == 'false' }}
uses: docker/build-push-action@v4
with:
context: .
file: ./osdk/tools/docker/tdx/Dockerfile
file: ./tools/docker/nix/Dockerfile
platforms: linux/amd64
push: true
tags: asterinas/osdk:${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}-tdx
tags: asterinas/nix:${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}
build-args: |
BASE_VERSION=${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}
publish_asterinas_image:
needs: publish_osdk_image
needs: publish_nix_image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -73,25 +73,3 @@ jobs:
tags: asterinas/asterinas:${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}
build-args: |
BASE_VERSION=${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}
publish_asterinas_tdx_image:
needs: publish_asterinas_image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare for Docker build and push
id: prepare-for-docker-build-and-push
run: |
./tools/github_workflows/prepare_for_docker_build_and_push.sh ${{ secrets.DOCKERHUB_USERNAME }} ${{ secrets.DOCKERHUB_TOKEN }} asterinas-tdx
- name: Build and push the Asterinas development image for Intel TDX
if: ${{ steps.prepare-for-docker-build-and-push.outputs.is_existed == 'false' }}
uses: docker/build-push-action@v4
with:
context: .
file: ./tools/docker/tdx/Dockerfile
platforms: linux/amd64
push: true
tags: asterinas/asterinas:${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}-tdx
build-args: |
BASE_VERSION=${{ steps.prepare-for-docker-build-and-push.outputs.image_version }}

View File

@ -17,7 +17,7 @@ jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 10
container: asterinas/asterinas:0.15.2-20250613
container: asterinas/asterinas:0.16.1-20250922
steps:
- uses: actions/checkout@v4

View File

@ -4,20 +4,20 @@ on:
workflow_dispatch:
pull_request:
paths:
- docs/**
- book/**
- .github/workflows/update-website.yml
push:
branches:
- main
paths:
- docs/**
- book/**
- .github/workflows/update-website.yml
jobs:
build_and_deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
container: asterinas/asterinas:0.15.2-20250613
container: asterinas/asterinas:0.16.1-20250922
steps:
- uses: actions/checkout@v2
with:
@ -26,7 +26,7 @@ jobs:
- name: Build the website
run: |
cd asterinas/docs
cd asterinas/book
mdbook build
- name: Deploy website
@ -45,7 +45,7 @@ jobs:
cd temp_book
git checkout --orphan newBranch
git rm -rf *
cp -r ../asterinas/docs/book/* ./
cp -r ../asterinas/book/book/* ./
git add -A
git commit -am "Update website"
git branch -D main

View File

@ -18,4 +18,4 @@ jobs:
uses: pxpm/github-tag-action@1.0.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
tag: v0.15.2
tag: v0.16.1

View File

@ -23,7 +23,7 @@ jobs:
run: |
docker run \
--privileged --network=host --device=/dev/kvm \
-v ./:/root/asterinas asterinas/asterinas:0.15.2-20250613 \
-v ./:/root/asterinas asterinas/asterinas:0.16.1-20250922 \
make run AUTO_TEST=vsock ENABLE_KVM=0 SCHEME=microvm RELEASE_MODE=1 &
- name: Run Vsock Client on Host
id: host_vsock_client

27
.github/workflows/test_loongarch.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: "Test loongarch64 "
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
basic-test:
runs-on: ubuntu-latest
container:
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
strategy:
matrix:
id: ['lint', 'compile']
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Run basic tests
uses: ./.github/actions/test
with:
auto_test: 'general'
runs_on: 'ubuntu-latest'
arch: 'loongarch64'

View File

@ -11,7 +11,7 @@ jobs:
basic-test:
runs-on: ubuntu-latest
container:
image: asterinas/asterinas:0.15.2-20250613
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
strategy:
matrix:

View File

@ -11,7 +11,7 @@ jobs:
basic-test:
runs-on: ubuntu-latest
container:
image: asterinas/asterinas:0.15.2-20250613
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
strategy:
matrix:
@ -28,7 +28,7 @@ jobs:
integration-test:
runs-on: ubuntu-latest
container:
image: asterinas/asterinas:0.15.2-20250613
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
strategy:
matrix:
@ -66,8 +66,9 @@ jobs:
boot_protocol: 'multiboot2'
smp: 4
# General Test (Linux EFI Handover)
- test_id: 'general-handover64'
# General Test (Linux EFI Handover) (Debug Build)
- test_id: 'general-handover64-debug'
release: false
boot_protocol: 'linux-efi-handover64'
# SMP General Test (Multiboot2)
- test_id: 'general-multiboot2-smp4'
@ -81,8 +82,8 @@ jobs:
with:
auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') ||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'test' }}
release: ${{ matrix.release || true }}
enable_kvm: ${{ matrix.enable_kvm || true }}
release: ${{ !contains(matrix.release, 'false') }}
enable_kvm: ${{ !contains(matrix.enable_kvm, 'false') }}
smp: ${{ matrix.smp }}
netdev: ${{ matrix.netdev || 'tap' }}
scheme: ${{ matrix.scheme }}
@ -96,8 +97,8 @@ jobs:
with:
auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') ||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'test' }}
release: ${{ matrix.release || true }}
enable_kvm: ${{ matrix.enable_kvm || true }}
release: ${{ !contains(matrix.release, 'false') }}
enable_kvm: ${{ !contains(matrix.enable_kvm, 'false') }}
smp: ${{ matrix.smp }}
netdev: ${{ matrix.netdev || 'tap' }}
scheme: ${{ matrix.scheme }}
@ -110,7 +111,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
image: ['asterinas/asterinas:0.15.2-20250613', 'asterinas/osdk:0.15.2-20250613']
image: ['asterinas/asterinas:0.16.1-20250922', 'asterinas/osdk:0.16.1-20250922']
fail-fast: false
container:
image: ${{ matrix.image }}

View File

@ -10,7 +10,7 @@ jobs:
integration-test:
runs-on: self-hosted
container:
image: asterinas/asterinas:0.15.2-20250613-tdx
image: asterinas/asterinas:0.16.1-20250922
options: --device=/dev/kvm --privileged
strategy:
matrix:
@ -58,7 +58,7 @@ jobs:
runs-on: self-hosted
strategy:
matrix:
image: ['asterinas/asterinas:0.15.2-20250613-tdx', 'asterinas/osdk:0.15.2-20250613-tdx']
image: ['asterinas/asterinas:0.16.1-20250922', 'asterinas/osdk:0.16.1-20250922']
fail-fast: false
container:
image: ${{ matrix.image }}

View File

@ -13,6 +13,8 @@ TME = "TME"
BA = "BA"
ND = "ND"
Fo = "Fo"
pn = "pn"
sme = "sme"
Inh = "Inh"
DELET = "DELET"
wrk = "wrk"
@ -28,8 +30,8 @@ check-file = false
# Files listed below are ignored to check.
[files]
extend-exclude = [
"test/syscall_test/gvisor/blocklists/pty_test",
"test/src/syscall/gvisor/blocklists/pty_test",
"test/build/initramfs/opt/gvisor/blocklists/pty_test",
"test/syscall_test/gvisor/blocklists/sync_test",
"test/src/syscall/gvisor/blocklists/sync_test",
"test/build/initramfs/opt/gvisor/blocklists/sync_test",
]

View File

@ -12,6 +12,10 @@
"kernel/Cargo.toml",
"--target",
"x86_64-unknown-none",
"--target",
"riscv64imac-unknown-none-elf",
"--target",
"loongarch64-unknown-none-softfloat",
"-Zbuild-std=core,alloc,compiler_builtins",
"-Zbuild-std-features=compiler-builtins-mem"
],

View File

@ -45,9 +45,11 @@
# Component code owners
/kernel/comps/block/ @lucassong-mh
/kernel/comps/framebuffer/ @cqs21 @lrh2000
/kernel/comps/keyboard/ @cqs21 @lrh2000
/kernel/comps/logger/ @cchanging
/kernel/comps/mlsdisk/ @cqs21 @lucassong-mh
/kernel/comps/network/ @StevenJiang1110 @lrh2000
/kernel/comps/pci/ @sdww0
/kernel/comps/softirq/ @cchanging
/kernel/comps/time/ @cchanging
/kernel/comps/virtio/ @sdww0
@ -71,7 +73,6 @@
/ostd/ @lrh2000 @junyang-zh @sdww0
# Module code owners
/ostd/src/bus/ @sdww0
/ostd/src/logger.rs @cchanging
/ostd/src/timer/ @cchanging
@ -81,7 +82,7 @@
/.github/ @grief8
/osdk/tools/docker/ @grief8
/test/ @grief8
/test/ @cqs21
/tools/ @grief8
/triagebot.toml @grief8
@ -91,3 +92,4 @@
# The following critical files are singled out
/CODEOWNERS @tatetian
/VERSION @tatetian
/RELEASES @tatetian

272
Cargo.lock generated
View File

@ -95,6 +95,7 @@ name = "aster-block"
version = "0.1.0"
dependencies = [
"align_ext",
"aster-util",
"bitvec",
"component",
"int-to-c-enum",
@ -108,6 +109,7 @@ name = "aster-console"
version = "0.1.0"
dependencies = [
"component",
"font8x8",
"ostd",
"spin",
]
@ -117,8 +119,8 @@ name = "aster-framebuffer"
version = "0.1.0"
dependencies = [
"aster-console",
"aster-keyboard",
"component",
"font8x8",
"log",
"ostd",
"spin",
@ -134,6 +136,18 @@ dependencies = [
"spin",
]
[[package]]
name = "aster-keyboard"
version = "0.1.0"
dependencies = [
"aster-input",
"bitflags 2.9.1",
"component",
"log",
"ostd",
"spin",
]
[[package]]
name = "aster-logger"
version = "0.1.0"
@ -187,6 +201,7 @@ dependencies = [
"aster-console",
"aster-framebuffer",
"aster-input",
"aster-keyboard",
"aster-logger",
"aster-mlsdisk",
"aster-network",
@ -212,10 +227,13 @@ dependencies = [
"inherit-methods-macro",
"int-to-c-enum",
"intrusive-collections",
"jhash",
"keyable-arc",
"lending-iterator",
"libflate",
"log",
"logo-ascii-art",
"loongArch64",
"lru",
"osdk-frame-allocator",
"osdk-heap-allocator",
@ -233,6 +251,20 @@ dependencies = [
"xmas-elf",
]
[[package]]
name = "aster-pci"
version = "0.1.0"
dependencies = [
"align_ext",
"bitflags 1.3.2",
"cfg-if",
"component",
"fdt",
"log",
"ostd",
"spin",
]
[[package]]
name = "aster-rights"
version = "0.1.0"
@ -256,6 +288,7 @@ dependencies = [
name = "aster-softirq"
version = "0.1.0"
dependencies = [
"aster-util",
"component",
"intrusive-collections",
"ostd",
@ -266,6 +299,7 @@ dependencies = [
name = "aster-systree"
version = "0.1.0"
dependencies = [
"aster-util",
"bitflags 2.9.1",
"component",
"inherit-methods-macro",
@ -292,6 +326,7 @@ dependencies = [
"aster-rights",
"aster-rights-proc",
"inherit-methods-macro",
"osdk-heap-allocator",
"ostd",
"typeflags-util",
]
@ -305,6 +340,7 @@ dependencies = [
"aster-console",
"aster-input",
"aster-network",
"aster-pci",
"aster-rights",
"aster-softirq",
"aster-systree",
@ -418,6 +454,15 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -1031,11 +1076,11 @@ dependencies = [
[[package]]
name = "linux-boot-params"
version = "0.15.2"
version = "0.16.1"
[[package]]
name = "linux-bzimage-builder"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"align_ext",
"bitflags 1.3.2",
@ -1047,7 +1092,7 @@ dependencies = [
[[package]]
name = "linux-bzimage-setup"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"cfg-if",
"core2",
@ -1077,6 +1122,23 @@ version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "logo-ascii-art"
version = "0.1.0"
dependencies = [
"owo-colors 4.2.2",
]
[[package]]
name = "loongArch64"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c9f0d275c70310e2a9d2fc23250c5ac826a73fa828a5f256401f85c5c554283"
dependencies = [
"bit_field",
"bitflags 2.9.1",
]
[[package]]
name = "lru"
version = "0.12.5"
@ -1123,6 +1185,16 @@ dependencies = [
"autocfg",
]
[[package]]
name = "minicov"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b"
dependencies = [
"cc",
"walkdir",
]
[[package]]
name = "multiboot2"
version = "0.24.0"
@ -1174,75 +1246,12 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "num"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
"num-traits",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-derive"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.101",
]
[[package]]
name = "num-integer"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
dependencies = [
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@ -1266,7 +1275,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
[[package]]
name = "osdk-frame-allocator"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"log",
"ostd",
@ -1275,7 +1284,7 @@ dependencies = [
[[package]]
name = "osdk-heap-allocator"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"log",
"ostd",
@ -1283,15 +1292,15 @@ dependencies = [
[[package]]
name = "osdk-test-kernel"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"ostd",
"owo-colors 4.2.0",
"owo-colors 4.2.2",
]
[[package]]
name = "ostd"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"acpi",
"align_ext",
@ -1309,9 +1318,9 @@ dependencies = [
"intrusive-collections",
"linux-boot-params",
"log",
"loongArch64",
"minicov",
"multiboot2",
"num",
"num-derive",
"num-traits",
"ostd-macros",
"ostd-pod",
@ -1329,7 +1338,7 @@ dependencies = [
[[package]]
name = "ostd-macros"
version = "0.15.2"
version = "0.16.1"
dependencies = [
"proc-macro2",
"quote",
@ -1357,7 +1366,7 @@ dependencies = [
[[package]]
name = "ostd-test"
version = "0.15.2"
version = "0.16.1"
[[package]]
name = "owo-colors"
@ -1367,9 +1376,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
name = "owo-colors"
version = "4.2.0"
version = "4.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564"
checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e"
[[package]]
name = "paste"
@ -1583,6 +1592,15 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "sbi-rt"
version = "0.0.3"
@ -1639,6 +1657,12 @@ dependencies = [
"serde",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "smallvec"
version = "1.15.0"
@ -1934,12 +1958,104 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8ca9a5d4debca0633e697c88269395493cebf2e10db21ca2dbde37c1356452"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi-util"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winnow"
version = "0.5.40"

View File

@ -17,6 +17,7 @@ members = [
"kernel/comps/console",
"kernel/comps/framebuffer",
"kernel/comps/input",
"kernel/comps/keyboard",
"kernel/comps/network",
"kernel/comps/softirq",
"kernel/comps/systree",
@ -24,6 +25,7 @@ members = [
"kernel/comps/mlsdisk",
"kernel/comps/time",
"kernel/comps/virtio",
"kernel/comps/pci",
"kernel/libs/cpio-decoder",
"kernel/libs/int-to-c-enum",
"kernel/libs/int-to-c-enum/derive",
@ -33,6 +35,7 @@ members = [
"kernel/libs/aster-bigtcp",
"kernel/libs/jhash",
"kernel/libs/keyable-arc",
"kernel/libs/logo-ascii-art",
"kernel/libs/typeflags",
"kernel/libs/typeflags-util",
"kernel/libs/atomic-integer-wrapper",

View File

@ -12,6 +12,8 @@ framebuffer = { name = "aster-framebuffer" }
network = { name = "aster-network" }
mlsdisk = { name = "aster-mlsdisk" }
systree = { name = "aster-systree" }
keyboard = { name = "aster-keyboard" }
pci = { name = "aster-pci" }
[whitelist]
[whitelist.nix.main]

View File

@ -1 +1 @@
0.15.2-20250613
0.16.1-20250922

View File

@ -3,7 +3,7 @@
# =========================== Makefile options. ===============================
# Global build options.
ARCH ?= x86_64
OSDK_TARGET_ARCH ?= x86_64
BENCHMARK ?= none
BOOT_METHOD ?= grub-rescue-iso
BOOT_PROTOCOL ?= multiboot2
@ -20,6 +20,8 @@ SMP ?= 1
OSTD_TASK_STACK_SIZE_IN_PAGES ?= 64
FEATURES ?=
NO_DEFAULT_FEATURES ?= 0
COVERAGE ?= 0
ENABLE_BASIC_TEST ?= false
# End of global build options.
# GDB debugging and profiling options.
@ -50,7 +52,7 @@ SHELL := /bin/bash
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
# Common arguments for `cargo osdk` `build`, `run` and `test` commands.
CARGO_OSDK_COMMON_ARGS := --target-arch=$(ARCH)
CARGO_OSDK_COMMON_ARGS := --target-arch=$(OSDK_TARGET_ARCH)
# The build arguments also apply to the `cargo osdk run` command.
CARGO_OSDK_BUILD_ARGS := --kcmd-args="ostd.log_level=$(LOG_LEVEL)"
CARGO_OSDK_TEST_ARGS :=
@ -62,13 +64,16 @@ CARGO_OSDK_BUILD_ARGS += --kcmd-args="SYSCALL_TEST_WORKDIR=$(SYSCALL_TEST_WORKDI
CARGO_OSDK_BUILD_ARGS += --kcmd-args="EXTRA_BLOCKLISTS_DIRS=$(EXTRA_BLOCKLISTS_DIRS)"
CARGO_OSDK_BUILD_ARGS += --init-args="/opt/syscall_test/run_syscall_test.sh"
else ifeq ($(AUTO_TEST), test)
ENABLE_BASIC_TEST := true
ifneq ($(SMP), 1)
CARGO_OSDK_BUILD_ARGS += --kcmd-args="BLOCK_UNSUPPORTED_SMP_TESTS=1"
endif
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_general_test.sh"
else ifeq ($(AUTO_TEST), boot)
ENABLE_BASIC_TEST := true
CARGO_OSDK_BUILD_ARGS += --init-args="/test/boot_hello.sh"
else ifeq ($(AUTO_TEST), vsock)
ENABLE_BASIC_TEST := true
export VSOCK=on
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_vsock_test.sh"
endif
@ -78,8 +83,15 @@ CARGO_OSDK_COMMON_ARGS += --profile release-lto
OSTD_TASK_STACK_SIZE_IN_PAGES = 8
else ifeq ($(RELEASE), 1)
CARGO_OSDK_COMMON_ARGS += --release
ifeq ($(OSDK_TARGET_ARCH), riscv64)
# FIXME: Unwinding in RISC-V seems to cost more stack space, so we increase
# the stack size for it. This may need further investigation.
# See https://github.com/asterinas/asterinas/pull/2383#discussion_r2307673156
OSTD_TASK_STACK_SIZE_IN_PAGES = 16
else
OSTD_TASK_STACK_SIZE_IN_PAGES = 8
endif
endif
# If the BENCHMARK is set, we will run the benchmark in the kernel mode.
ifneq ($(BENCHMARK), none)
@ -100,8 +112,10 @@ BOOT_METHOD = qemu-direct
OVMF = off
endif
ifeq ($(ARCH), riscv64)
ifeq ($(OSDK_TARGET_ARCH), riscv64)
SCHEME = riscv
else ifeq ($(OSDK_TARGET_ARCH), loongarch64)
SCHEME = loongarch
endif
ifneq ($(SCHEME), "")
@ -110,6 +124,10 @@ else
CARGO_OSDK_COMMON_ARGS += --boot-method="$(BOOT_METHOD)"
endif
ifeq ($(COVERAGE), 1)
CARGO_OSDK_COMMON_ARGS += --coverage
endif
ifdef FEATURES
CARGO_OSDK_COMMON_ARGS += --features="$(FEATURES)"
endif
@ -130,14 +148,14 @@ CARGO_OSDK_COMMON_ARGS += --grub-boot-protocol=$(BOOT_PROTOCOL)
endif
ifeq ($(ENABLE_KVM), 1)
ifeq ($(ARCH), x86_64)
ifeq ($(OSDK_TARGET_ARCH), x86_64)
CARGO_OSDK_COMMON_ARGS += --qemu-args="-accel kvm"
endif
endif
# Skip GZIP to make encoding and decoding of initramfs faster
ifeq ($(INITRAMFS_SKIP_GZIP),1)
CARGO_OSDK_INITRAMFS_OPTION := --initramfs=$(realpath test/build/initramfs.cpio)
CARGO_OSDK_INITRAMFS_OPTION := --initramfs=$(abspath test/build/initramfs.cpio)
CARGO_OSDK_COMMON_ARGS += $(CARGO_OSDK_INITRAMFS_OPTION)
endif
@ -156,16 +174,17 @@ NON_OSDK_CRATES := \
ostd/libs/linux-bzimage/boot-params \
ostd/libs/ostd-macros \
ostd/libs/ostd-test \
kernel/libs/aster-rights \
kernel/libs/aster-rights-proc \
kernel/libs/atomic-integer-wrapper \
kernel/libs/cpio-decoder \
kernel/libs/int-to-c-enum \
kernel/libs/int-to-c-enum/derive \
kernel/libs/aster-rights \
kernel/libs/aster-rights-proc \
kernel/libs/jhash \
kernel/libs/keyable-arc \
kernel/libs/logo-ascii-art \
kernel/libs/typeflags \
kernel/libs/typeflags-util \
kernel/libs/atomic-integer-wrapper
kernel/libs/typeflags-util
# In contrast, OSDK crates depend on OSTD (or being `ostd` itself)
# and need to be built or tested with OSDK.
@ -180,6 +199,7 @@ OSDK_CRATES := \
kernel/comps/console \
kernel/comps/framebuffer \
kernel/comps/input \
kernel/comps/keyboard \
kernel/comps/network \
kernel/comps/softirq \
kernel/comps/systree \
@ -187,6 +207,7 @@ OSDK_CRATES := \
kernel/comps/mlsdisk \
kernel/comps/time \
kernel/comps/virtio \
kernel/comps/pci \
kernel/libs/aster-util \
kernel/libs/aster-bigtcp \
kernel/libs/xarray
@ -221,8 +242,19 @@ test_osdk:
OSDK_LOCAL_DEV=1 cargo build && \
OSDK_LOCAL_DEV=1 cargo test
.PHONY: check_vdso
check_vdso:
@# Checking `VDSO_LIBRARY_DIR` environment variable
@if [ -z "$(VDSO_LIBRARY_DIR)" ]; then \
echo "Error: the \$(VDSO_LIBRARY_DIR) environment variable must be given."; \
echo " This variable points to a directory that provides Linux's vDSO files,"; \
echo " which is required to build Asterinas. Search for VDSO_LIBRARY_DIR"; \
echo " in Asterinas's Dockerfile for more information."; \
exit 1; \
fi
.PHONY: initramfs
initramfs:
initramfs: check_vdso
@$(MAKE) --no-print-directory -C test
.PHONY: build
@ -293,8 +325,10 @@ docs: $(CARGO_OSDK)
@for dir in $(OSDK_CRATES); do \
(cd $$dir && cargo osdk doc --no-deps) || exit 1; \
done
@echo "" # Add a blank line
@cd docs && mdbook build # Build mdBook
.PHONY: book
book:
@cd book && mdbook build
.PHONY: format
format:
@ -302,7 +336,6 @@ format:
@$(MAKE) --no-print-directory -C test format
.PHONY: check
# FIXME: Make `make check` arch-aware.
check: initramfs $(CARGO_OSDK)
@# Check formatting issues of the Rust code
@./tools/format_all.sh --check
@ -333,6 +366,9 @@ check: initramfs $(CARGO_OSDK)
done
@for dir in $(OSDK_CRATES); do \
echo "Checking $$dir"; \
# Exclude linux-bzimage-setup since it only supports x86-64 currently and will panic \
# in other architectures. \
[ "$$dir" = "ostd/libs/linux-bzimage/setup" ] && [ "$(OSDK_TARGET_ARCH)" != "x86_64" ] && continue; \
(cd $$dir && cargo osdk clippy -- -- -D warnings) || exit 1; \
done
@
@ -348,8 +384,8 @@ clean:
@cargo clean
@echo "Cleaning up OSDK workspace target files"
@cd osdk && cargo clean
@echo "Cleaning up documentation target files"
@cd docs && mdbook clean
@echo "Cleaning up mdBook output files"
@cd book && mdbook clean
@echo "Cleaning up test target files"
@$(MAKE) --no-print-directory -C test clean
@echo "Uninstalling OSDK"

View File

@ -67,3 +67,23 @@ qemu.args = """\
-device virtio-serial-device \
-device virtconsole,chardev=mux \
"""
[scheme."loongarch"]
boot.method = "qemu-direct"
build.strip_elf = false
qemu.args = """\
-machine virt \
-m 8G \
-smp 1 \
--no-reboot \
-nographic \
-display none \
-serial chardev:mux \
-monitor chardev:mux \
-chardev stdio,id=mux,mux=on,signal=off,logfile=qemu.log \
-device virtio-keyboard-pci \
-device virtio-serial \
-device virtconsole,chardev=mux \
-rtc base=utc
"""

View File

@ -1,8 +1,9 @@
<p align="center">
<img src="docs/src/images/logo_en.svg" alt="asterinas-logo" width="620"><br>
<img src="book/src/images/logo_en.svg" alt="asterinas-logo" width="620"><br>
A secure, fast, and general-purpose OS kernel written in Rust and compatible with Linux<br/>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml/badge.svg?event=push" alt="Test x86-64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml/badge.svg?event=push" alt="Test riscv64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_loongarch.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_loongarch.yml/badge.svg?event=push" alt="Test loongarch64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml/badge.svg" alt="Test Intel TDX" style="max-width: 100%;"></a>
<a href="https://asterinas.github.io/benchmark/x86-64/"><img src="https://github.com/asterinas/asterinas/actions/workflows/benchmark_x86.yml/badge.svg" alt="Benchmark x86-64" style="max-width: 100%;"></a>
<br/>
@ -10,6 +11,8 @@
English | [中文版](README_CN.md) | [日本語](README_JP.md)
**NEWS: [SOSP'25](https://sigops.org/s/conferences/sosp/2025/) accepted yet another research paper on Asterinas: _CortenMM: Efficient Memory Management with Strong Correctness Guarantees_. Congratulations to the Asterinas community🎉🎉🎉**
**NEWS: [USENIX ATC'25](https://www.usenix.org/conference/atc25) accepted two research papers on Asterinas: (1) _Asterinas: A Linux ABI-Compatible, Rust-Based Framekernel OS with a Small and Sound TCB_ and (2) _Converos: Practical Model Checking for Verifying Rust OS Kernel Concurrency_. Congratulations to the Asterinas community🎉🎉🎉**
## Introducing Asterinas
@ -57,7 +60,7 @@ git clone https://github.com/asterinas/asterinas
2. Run a Docker container as the development environment.
```bash
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.15.2-20250613
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.16.1-20250922
```
3. Inside the container, go to the project folder to build and run Asterinas.

View File

@ -1,8 +1,9 @@
<p align="center">
<img src="docs/src/images/logo_cn.svg" alt="asterinas-logo" width="620"><br>
<img src="book/src/images/logo_cn.svg" alt="asterinas-logo" width="620"><br>
一个安全、快速、通用的操作系统内核使用Rust编写并与Linux兼容<br/>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml/badge.svg?event=push" alt="Test x86-64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml/badge.svg?event=push" alt="Test riscv64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_loongarch.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_loongarch.yml/badge.svg?event=push" alt="Test loongarch64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml/badge.svg" alt="Test Intel TDX" style="max-width: 100%;"></a>
<a href="https://asterinas.github.io/benchmark/x86-64/"><img src="https://github.com/asterinas/asterinas/actions/workflows/benchmark_x86.yml/badge.svg" alt="Benchmark x86-64" style="max-width: 100%;"></a>
<br/>
@ -50,7 +51,7 @@ git clone https://github.com/asterinas/asterinas
2. 运行一个作为开发环境的Docker容器。
```bash
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.15.2-20250613
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.16.1-20250922
```
3. 在容器内,进入项目文件夹构建并运行星绽。

View File

@ -1,8 +1,9 @@
<p align="center">
<img src="docs/src/images/logo_en.svg" alt="asterinas-logo" width="620"><br>
<img src="book/src/images/logo_en.svg" alt="asterinas-logo" width="620"><br>
安全で高速、汎用的なOSカーネル。Rustで書かれ、Linuxと互換性があります<br/>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml/badge.svg?event=push" alt="Test x86-64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml/badge.svg?event=push" alt="Test riscv64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_loongarch.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_loongarch.yml/badge.svg?event=push" alt="Test loongarch64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml/badge.svg" alt="Test Intel TDX" style="max-width: 100%;"></a>
<a href="https://asterinas.github.io/benchmark/x86-64/"><img src="https://github.com/asterinas/asterinas/actions/workflows/benchmark_x86.yml/badge.svg" alt="Benchmark x86-64" style="max-width: 100%;"></a>
<br/>
@ -46,7 +47,7 @@ git clone https://github.com/asterinas/asterinas
2. 開発環境としてDockerコンテナを実行します。
```bash
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.15.2-20250613
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.16.1-20250922
```
3. コンテナ内でプロジェクトフォルダに移動し、Asterinasをビルドして実行します。

86
RELEASES.md Normal file
View File

@ -0,0 +1,86 @@
# Version 0.16.0 (2025-08-04)
This release introduces initial support for the **LoongArch CPU architecture**, a major milestone for the project. Version 0.16.0 also significantly expands our Linux ABI compatibility with the addition of **nine new system calls** such as `memfd_create` and `pidfd_open`.
Key enhancements include expanded functionality for **UNIX sockets (file descriptor passing and the `SOCK_SEQPACKET` socket type)**, partial support for **netlink sockets of the `NETLINK_KOBJECT_UEVENT` type**, the initial implementation of **CgroupFS**, and a major testing improvement with the integration of system call tests from the **Linux Test Project (LTP)**. We've also adopted **[Nix](https://nix.dev/manual/nix/2.28/introduction)** for building the initramfs, streamlining our cross-compilation and testing workflow.
## Asterinas Kernel
We have made the following key changes to the Asterinas kernel:
* New system calls or features:
* Memory:
* [Add the `mremap` system call](https://github.com/asterinas/asterinas/pull/2162)
* [Add the `msync` system call based on an inefficient implementation](https://github.com/asterinas/asterinas/pull/2154)
* [Add the `memfd_create` system call](https://github.com/asterinas/asterinas/pull/2149)
* Processes and IPC:
* [Add the `pidfd_open` system call along with the `CLONE_PIDFD` flag](https://github.com/asterinas/asterinas/pull/2151)
* File systems and I/O in general:
* [Add the `close_range` system call](https://github.com/asterinas/asterinas/pull/2128)
* [Add the `fadvise64` system call (dummy implementation)](https://github.com/asterinas/asterinas/pull/2125)
* [Add the `ioprio_get` and `ioprio_set` system calls (dummy implementation)](https://github.com/asterinas/asterinas/pull/2126)
* [Add the `epoll_pwait2` system call](https://github.com/asterinas/asterinas/pull/2123)
* Enhanced system calls or features:
* Processes:
* [Add `FUTEX_WAKE_OP` support for the `futex` system call](https://github.com/asterinas/asterinas/pull/2146)
* [Add `WSTOPPED` and `WCONTINUED` support to the `wait4` and `waitpid` system calls](https://github.com/asterinas/asterinas/pull/2166)
* [Add more fields in `/proc/*/stat` and `/proc/*/status`](https://github.com/asterinas/asterinas/pull/2215)
* File systems and I/O in general:
* [Add a few more features for the `statx` system call](https://github.com/asterinas/asterinas/pull/2127)
* [Fix partial writes and reads in writev and readv](https://github.com/asterinas/asterinas/pull/2230)
* [Introduce `FsType` and `FsRegistry`](https://github.com/asterinas/asterinas/pull/2267)
* Sockets and network:
* [Enable UNIX sockets to send and receive file descriptors](https://github.com/asterinas/asterinas/pull/2176)
* [Support `SO_PASSCRED` & `SCM_CREDENTIALS` & `SOCK_SEQPACKET` for UNIX sockets](https://github.com/asterinas/asterinas/pull/2268)
* [Add `NETLINK_KOBJECT_UEVENT` support for netlink sockets (a partial implementation)](https://github.com/asterinas/asterinas/pull/2109)
* [Support some missing socket options for UNIX stream sockets](https://github.com/asterinas/asterinas/pull/2192)
* [Truncate netlink messages when the user-space buffer is full](https://github.com/asterinas/asterinas/pull/2155)
* [Fix the networking address reusing behavior (`SO_REUSEADDR`)](https://github.com/asterinas/asterinas/pull/2277)
* Security:
* [Add basic cgroupfs implementation](https://github.com/asterinas/asterinas/pull/2121)
* New device support:
* [Add basic i8042 keyboard support](https://github.com/asterinas/asterinas/pull/2054)
* Enhanced device support:
* TTY
* [Refactor the TTY abstraction to support multiple I/O devices correctly](https://github.com/asterinas/asterinas/pull/2108)
* [Enhance the framebuffer console to support ANSI escape sequences](https://github.com/asterinas/asterinas/pull/2210)
* Test infrastructure:
* [Introduce the system call tests from LTP](https://github.com/asterinas/asterinas/pull/2053)
* [Use Nix to build initramfs](https://github.com/asterinas/asterinas/pull/2101)
## OSTD & OSDK
We have made the following key changes to OSTD:
* CPU architectures:
* x86-64:
* [Refactor floating-point context management in context switching and signal handling](https://github.com/asterinas/asterinas/pull/2219)
* [Use iret instead of sysret if the context is not clean](https://github.com/asterinas/asterinas/pull/2271)
* [Don't treat APIC IDs as CPU IDs](https://github.com/asterinas/asterinas/pull/2091)
* [Fix some CPUID problems and add support for AMD CPUs](https://github.com/asterinas/asterinas/pull/2273)
* RISC-V:
* [Add RISC-V timer support](https://github.com/asterinas/asterinas/pull/2044)
* [Parse device tree for RISC-V ISA extensions](https://github.com/asterinas/asterinas/pull/2113)
* LoongArch:
* [Add the initial LoongArch support](https://github.com/asterinas/asterinas/pull/2260)
* CPU:
* [Add support for dynamically-allocated CPU-local objects](https://github.com/asterinas/asterinas/pull/2036)
* [Require `T: Send` for `CpuLocal<T, S>`](https://github.com/asterinas/asterinas/pull/2171)
* Memory management:
* [Adopt a two-phase locking scheme for page tables](https://github.com/asterinas/asterinas/pull/1948)
* Trap handling:
* [Create `IrqChip` abstraction](https://github.com/asterinas/asterinas/pull/2107)
* Task and scheduling:
* [Rewrite the Rust doc of OSTD's scheduling module](https://github.com/asterinas/asterinas/pull/2284)
* [Fix the race between enabling IRQs and halting CPU](https://github.com/asterinas/asterinas/pull/2052)
* Test infrastructure:
* [Add CI to check documentation and publish API documentation to a self-host website](https://github.com/asterinas/asterinas/pull/2218)
We have made the following key changes to OSDK:
* [Add OSDK's code coverage feature](https://github.com/asterinas/asterinas/pull/2203)
* [Support `cargo osdk test` for RISC-V](https://github.com/asterinas/asterinas/pull/2168)
# Before 0.16.0
Release notes were not kept for versions prior to 0.16.0.

View File

@ -1 +1 @@
0.15.2
0.16.1

View File

View File

@ -8,7 +8,20 @@
* [Advanced Build and Test Instructions](kernel/advanced-instructions.md)
* [Intel TDX](kernel/intel_tdx.md)
* [The Framekernel Architecture](kernel/the-framekernel-architecture.md)
* [Linux Compatibility](kernel/linux-compatibility.md)
* [Linux Compatibility](kernel/linux-compatibility/README.md)
* [Limitations on System Calls](kernel/linux-compatibility/limitations-on-system-calls/README.md)
* [System Call Matching Language (SCML)](kernel/linux-compatibility/limitations-on-system-calls/system-call-matching-language.md)
* [Process and thread management](kernel/linux-compatibility/limitations-on-system-calls/process-and-thread-management.md)
* [Memory management](kernel/linux-compatibility/limitations-on-system-calls/memory-management.md)
* [File & directory operations](kernel/linux-compatibility/limitations-on-system-calls/file-and-directory-operations.md)
* [File systems & mount control](kernel/linux-compatibility/limitations-on-system-calls/file-systems-and-mount-control.md)
* [File descriptor & I/O control](kernel/linux-compatibility/limitations-on-system-calls/file-descriptor-and-io-control.md)
* [Inter-process communication](kernel/linux-compatibility/limitations-on-system-calls/inter-process-communication.md)
* [Networking & sockets](kernel/linux-compatibility/limitations-on-system-calls/networking-and-sockets.md)
* [Signals & timers](kernel/linux-compatibility/limitations-on-system-calls/signals-and-timers.md)
* [Namespaces, cgroups & security](kernel/linux-compatibility/limitations-on-system-calls/namespaces-cgroups-and-security.md)
* [System information & misc](kernel/linux-compatibility/limitations-on-system-calls/system-information-and-misc.md)
* [Limitations on File Systems]()
* [Roadmap](kernel/roadmap.md)
# Asterinas OSTD
@ -36,6 +49,7 @@
* [cargo osdk debug](osdk/reference/commands/debug.md)
* [cargo osdk profile](osdk/reference/commands/profile.md)
* [Manifest](osdk/reference/manifest.md)
* [Environment Variables](osdk/reference/environment-variables.md)
# How to Contribute
@ -50,8 +64,8 @@
* [Community]()
* [Code of Conduct]()
# Request for Comments (RFC)
# Request for Comments (RFCs)
* [RFC Overview]()
* [RFC-0001: RFC Process]()
* [RFC-0002: Operating System Development Kit (OSDK)]()
* [RFC Overview](rfcs/README.md)
* [RFC-0001: RFC Process](rfcs/0001-rfc-process.md)
* [RFC Template](rfcs/rfc-template.md)

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -48,7 +48,7 @@ docker run -it --privileged \
--network=host \
--device=/dev/kvm \
-v $(pwd)/asterinas:/root/asterinas \
asterinas/asterinas:0.15.2-20250613
asterinas/asterinas:0.16.1-20250922
```
3. Inside the container, go to the project folder to build and run Asterinas.

View File

@ -34,7 +34,7 @@ cargo osdk test
### General Test
The following command builds and runs the test binaries in `test/apps` directory on Asterinas.
The following command builds and runs the test binaries in `test/src/apps` directory on Asterinas.
```bash
make run AUTO_TEST=test

View File

@ -66,7 +66,7 @@ git clone https://github.com/asterinas/asterinas
2. Run a Docker container as the development environment.
```bash
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.15.2-20250613-tdx
docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.16.1-20250922
```
3. Inside the container,

View File

@ -0,0 +1,384 @@
# Linux Compatibility
> "We don't break user space."
>
> --- Linus Torvalds
Asterinas is dedicated to maintaining compatibility with the Linux ABI,
ensuring that applications and administrative tools
designed for Linux can seamlessly operate within Asterinas.
While we prioritize compatibility,
it is important to note that Asterinas does not,
nor will it in the future,
support the loading of Linux kernel modules.
## System Calls
At the time of writing,
Asterinas supports over 220 Linux system calls for the x86-64 architecture,
which are summarized in the table below.
| Numbers | Names | Supported | Limitations |
| ------- | ---------------------- | -------------- | --- |
| 0 | read | ✅ | |
| 1 | write | ✅ | |
| 2 | open | ✅ | [⚠️](limitations-on-system-calls/file-and-directory-operations.md#open-and-openat) |
| 3 | close | ✅ | |
| 4 | stat | ✅ | |
| 5 | fstat | ✅ | |
| 6 | lstat | ✅ | |
| 7 | poll | ✅ | |
| 8 | lseek | ✅ | |
| 9 | mmap | ✅ | [⚠️](limitations-on-system-calls/memory-management.md#mmap-and-munmap) |
| 10 | mprotect | ✅ | [⚠️](limitations-on-system-calls/memory-management.md#mprotect) |
| 11 | munmap | ✅ | |
| 12 | brk | ✅ | |
| 13 | rt_sigaction | ✅ | [⚠️](limitations-on-system-calls/signals-and-timers.md#rt_sigaction) |
| 14 | rt_sigprocmask | ✅ | |
| 15 | rt_sigreturn | ✅ | |
| 16 | ioctl | ✅ | |
| 17 | pread64 | ✅ | |
| 18 | pwrite64 | ✅ | |
| 19 | readv | ✅ | |
| 20 | writev | ✅ | |
| 21 | access | ✅ | |
| 22 | pipe | ✅ | |
| 23 | select | ✅ | |
| 24 | sched_yield | ✅ | |
| 25 | mremap | ✅ | |
| 26 | msync | ✅ | [⚠️](limitations-on-system-calls/memory-management.md#msync) |
| 27 | mincore | ❌ | |
| 28 | madvise | ✅ | [⚠️](limitations-on-system-calls/memory-management.md#madvise) |
| 29 | shmget | ❌ | |
| 30 | shmat | ❌ | |
| 31 | shmctl | ❌ | |
| 32 | dup | ✅ | |
| 33 | dup2 | ✅ | |
| 34 | pause | ✅ | |
| 35 | nanosleep | ✅ | |
| 36 | getitimer | ✅ | |
| 37 | alarm | ✅ | |
| 38 | setitimer | ✅ | |
| 39 | getpid | ✅ | |
| 40 | sendfile | ✅ | |
| 41 | socket | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#socket) |
| 42 | connect | ✅ | |
| 43 | accept | ✅ | |
| 44 | sendto | ✅ | |
| 45 | recvfrom | ✅ | |
| 46 | sendmsg | ✅ | |
| 47 | recvmsg | ✅ | |
| 48 | shutdown | ✅ | |
| 49 | bind | ✅ | |
| 50 | listen | ✅ | |
| 51 | getsockname | ✅ | |
| 52 | getpeername | ✅ | |
| 53 | socketpair | ✅ | |
| 54 | setsockopt | ✅ | |
| 55 | getsockopt | ✅ | |
| 56 | clone | ✅ | |
| 57 | fork | ✅ | |
| 58 | vfork | ❌ | |
| 59 | execve | ✅ | |
| 60 | exit | ✅ | |
| 61 | wait4 | ✅ | |
| 62 | kill | ✅ | |
| 63 | uname | ✅ | |
| 64 | semget | ✅ | |
| 65 | semop | ✅ | [⚠️](limitations-on-system-calls/inter-process-communication.md#semop-and-semtimedop) |
| 66 | semctl | ✅ | [⚠️](limitations-on-system-calls/inter-process-communication.md#semctl) |
| 67 | shmdt | ❌ | |
| 68 | msgget | ❌ | |
| 69 | msgsnd | ❌ | |
| 70 | msgrcv | ❌ | |
| 71 | msgctl | ❌ | |
| 72 | fcntl | ✅ | [⚠️](limitations-on-system-calls/file-descriptor-and-io-control.md#fcntl) |
| 73 | flock | ✅ | |
| 74 | fsync | ✅ | |
| 75 | fdatasync | ✅ | |
| 76 | truncate | ✅ | |
| 77 | ftruncate | ✅ | |
| 78 | getdents | ✅ | |
| 79 | getcwd | ✅ | |
| 80 | chdir | ✅ | |
| 81 | fchdir | ✅ | |
| 82 | rename | ✅ | |
| 83 | mkdir | ✅ | |
| 84 | rmdir | ✅ | |
| 85 | creat | ✅ | |
| 86 | link | ✅ | |
| 87 | unlink | ✅ | |
| 88 | symlink | ✅ | |
| 89 | readlink | ✅ | |
| 90 | chmod | ✅ | |
| 91 | fchmod | ✅ | |
| 92 | chown | ✅ | |
| 93 | fchown | ✅ | |
| 94 | lchown | ✅ | |
| 95 | umask | ✅ | |
| 96 | gettimeofday | ✅ | |
| 97 | getrlimit | ✅ | |
| 98 | getrusage | ✅ | [⚠️](limitations-on-system-calls/system-information-and-misc.md#getrusage) |
| 99 | sysinfo | ✅ | |
| 100 | times | ❌ | |
| 101 | ptrace | ❌ | |
| 102 | getuid | ✅ | |
| 103 | syslog | ❌ | |
| 104 | getgid | ✅ | |
| 105 | setuid | ✅ | |
| 106 | setgid | ✅ | |
| 107 | geteuid | ✅ | |
| 108 | getegid | ✅ | |
| 109 | setpgid | ✅ | |
| 110 | getppid | ✅ | |
| 111 | getpgrp | ✅ | |
| 112 | setsid | ✅ | |
| 113 | setreuid | ✅ | |
| 114 | setregid | ✅ | |
| 115 | getgroups | ✅ | |
| 116 | setgroups | ✅ | |
| 117 | setresuid | ✅ | |
| 118 | getresuid | ✅ | |
| 119 | setresgid | ✅ | |
| 120 | getresgid | ✅ | |
| 121 | getpgid | ✅ | |
| 122 | setfsuid | ✅ | |
| 123 | setfsgid | ✅ | |
| 124 | getsid | ✅ | |
| 125 | capget | ✅ | [⚠️](limitations-on-system-calls/namespaces-cgroups-and-security.md#capget-and-capset) |
| 126 | capset | ✅ | [⚠️](limitations-on-system-calls/namespaces-cgroups-and-security.md#capget-and-capset) |
| 127 | rt_sigpending | ✅ | |
| 128 | rt_sigtimedwait | ❌ | |
| 129 | rt_sigqueueinfo | ❌ | |
| 130 | rt_sigsuspend | ✅ | |
| 131 | sigaltstack | ✅ | |
| 132 | utime | ✅ | |
| 133 | mknod | ✅ | |
| 134 | uselib | ❌ | |
| 135 | personality | ❌ | |
| 136 | ustat | ❌ | |
| 137 | statfs | ✅ | |
| 138 | fstatfs | ✅ | |
| 139 | sysfs | ❌ | |
| 140 | getpriority | ✅ | |
| 141 | setpriority | ✅ | |
| 142 | sched_setparam | ✅ | |
| 143 | sched_getparam | ✅ | |
| 144 | sched_setscheduler | ✅ | |
| 145 | sched_getscheduler | ✅ | |
| 146 | sched_get_priority_max | ✅ | |
| 147 | sched_get_priority_min | ✅ | |
| 148 | sched_rr_get_interval | ❌ | |
| 149 | mlock | ❌ | |
| 150 | munlock | ❌ | |
| 151 | mlockall | ❌ | |
| 152 | munlockall | ❌ | |
| 153 | vhangup | ❌ | |
| 154 | modify_ldt | ❌ | |
| 155 | pivot_root | ❌ | |
| 156 | _sysctl | ❌ | |
| 157 | prctl | ✅ | [⚠️](limitations-on-system-calls/namespaces-cgroups-and-security.md#prctl) |
| 158 | arch_prctl | ✅ | [⚠️](limitations-on-system-calls/system-information-and-misc.md#arch_prctl) |
| 159 | adjtimex | ❌ | |
| 160 | setrlimit | ✅ | |
| 161 | chroot | ✅ | |
| 162 | sync | ✅ | |
| 163 | acct | ❌ | |
| 164 | settimeofday | ❌ | |
| 165 | mount | ✅ | [⚠️](limitations-on-system-calls/file-systems-and-mount-control.md#mount) |
| 166 | umount2 | ✅ | [⚠️](limitations-on-system-calls/file-systems-and-mount-control.md#umount-and-umount2) |
| 167 | swapon | ❌ | |
| 168 | swapoff | ❌ | |
| 169 | reboot | ❌ | |
| 170 | sethostname | ✅ | |
| 171 | setdomainname | ✅ | |
| 172 | iopl | ❌ | |
| 173 | ioperm | ❌ | |
| 174 | create_module | ❌ | |
| 175 | init_module | ❌ | |
| 176 | delete_module | ❌ | |
| 177 | get_kernel_syms | ❌ | |
| 178 | query_module | ❌ | |
| 179 | quotactl | ❌ | |
| 180 | nfsservctl | ❌ | |
| 181 | getpmsg | ❌ | |
| 182 | putpmsg | ❌ | |
| 183 | afs_syscall | ❌ | |
| 184 | tuxcall | ❌ | |
| 185 | security | ❌ | |
| 186 | gettid | ✅ | |
| 187 | readahead | ❌ | |
| 188 | setxattr | ✅ | |
| 189 | lsetxattr | ✅ | |
| 190 | fsetxattr | ✅ | |
| 191 | getxattr | ✅ | |
| 192 | lgetxattr | ✅ | |
| 193 | fgetxattr | ✅ | |
| 194 | listxattr | ✅ | |
| 195 | llistxattr | ✅ | |
| 196 | flistxattr | ✅ | |
| 197 | removexattr | ✅ | |
| 198 | lremovexattr | ✅ | |
| 199 | fremovexattr | ✅ | |
| 200 | tkill | ❌ | |
| 201 | time | ✅ | |
| 202 | futex | ✅ | |
| 203 | sched_setaffinity | ✅ | |
| 204 | sched_getaffinity | ✅ | |
| 205 | set_thread_area | ❌ | |
| 206 | io_setup | ❌ | |
| 207 | io_destroy | ❌ | |
| 208 | io_getevents | ❌ | |
| 209 | io_submit | ❌ | |
| 210 | io_cancel | ❌ | |
| 211 | get_thread_area | ❌ | |
| 212 | lookup_dcookie | ❌ | |
| 213 | epoll_create | ✅ | |
| 214 | epoll_ctl_old | ❌ | |
| 215 | epoll_wait_old | ❌ | |
| 216 | remap_file_pages | ❌ | |
| 217 | getdents64 | ✅ | |
| 218 | set_tid_address | ✅ | |
| 219 | restart_syscall | ❌ | |
| 220 | semtimedop | ✅ | [⚠️](limitations-on-system-calls/inter-process-communication.md#semop-and-semtimedop) |
| 221 | fadvise64 | ✅ | |
| 222 | timer_create | ✅ | [⚠️](limitations-on-system-calls/signals-and-timers.md#timer_create) |
| 223 | timer_settime | ✅ | |
| 224 | timer_gettime | ✅ | |
| 225 | timer_getoverrun | ❌ | |
| 226 | timer_delete | ✅ | |
| 227 | clock_settime | ❌ | |
| 228 | clock_gettime | ✅ | [⚠️](limitations-on-system-calls/system-information-and-misc.md#clock_gettime) |
| 229 | clock_getres | ❌ | |
| 230 | clock_nanosleep | ✅ | [⚠️](limitations-on-system-calls/system-information-and-misc.md#clock_nanosleep) |
| 231 | exit_group | ✅ | |
| 232 | epoll_wait | ✅ | |
| 233 | epoll_ctl | ✅ | |
| 234 | tgkill | ✅ | |
| 235 | utimes | ✅ | |
| 236 | vserver | ❌ | |
| 237 | mbind | ❌ | |
| 238 | set_mempolicy | ❌ | |
| 239 | get_mempolicy | ❌ | |
| 240 | mq_open | ❌ | |
| 241 | mq_unlink | ❌ | |
| 242 | mq_timedsend | ❌ | |
| 243 | mq_timedreceive | ❌ | |
| 244 | mq_notify | ❌ | |
| 245 | mq_getsetattr | ❌ | |
| 246 | kexec_load | ❌ | |
| 247 | waitid | ✅ | |
| 248 | add_key | ❌ | |
| 249 | request_key | ❌ | |
| 250 | keyctl | ❌ | |
| 251 | ioprio_set | ✅ | |
| 252 | ioprio_get | ✅ | |
| 253 | inotify_init | ❌ | |
| 254 | inotify_add_watch | ❌ | |
| 255 | inotify_rm_watch | ❌ | |
| 256 | migrate_pages | ❌ | |
| 257 | openat | ✅ | [⚠️](limitations-on-system-calls/file-and-directory-operations.md#open-and-openat) |
| 258 | mkdirat | ✅ | |
| 259 | mknodat | ✅ | |
| 260 | fchownat | ✅ | |
| 261 | futimesat | ✅ | |
| 262 | newfstatat | ✅ | |
| 263 | unlinkat | ✅ | |
| 264 | renameat | ✅ | |
| 265 | linkat | ✅ | |
| 266 | symlinkat | ✅ | |
| 267 | readlinkat | ✅ | |
| 268 | fchmodat | ✅ | |
| 269 | faccessat | ✅ | |
| 270 | pselect6 | ✅ | |
| 271 | ppoll | ✅ | |
| 272 | unshare | ✅ | |
| 273 | set_robust_list | ✅ | |
| 274 | get_robust_list | ❌ | |
| 275 | splice | ❌ | |
| 276 | tee | ❌ | |
| 277 | sync_file_range | ❌ | |
| 278 | vmsplice | ❌ | |
| 279 | move_pages | ❌ | |
| 280 | utimensat | ✅ | |
| 281 | epoll_pwait | ✅ | |
| 282 | signalfd | ✅ | |
| 283 | timerfd_create | ✅ | |
| 284 | eventfd | ✅ | |
| 285 | fallocate | ✅ | |
| 286 | timerfd_settime | ✅ | |
| 287 | timerfd_gettime | ✅ | |
| 288 | accept4 | ✅ | |
| 289 | signalfd4 | ✅ | |
| 290 | eventfd2 | ✅ | [⚠️](limitations-on-system-calls/file-descriptor-and-io-control.md#eventfd-and-eventfd2) |
| 291 | epoll_create1 | ✅ | |
| 292 | dup3 | ✅ | |
| 293 | pipe2 | ✅ | [⚠️](limitations-on-system-calls/file-descriptor-and-io-control.md#pipe-and-pipe2) |
| 294 | inotify_init1 | ❌ | |
| 295 | preadv | ✅ | |
| 296 | pwritev | ✅ | |
| 297 | rt_tgsigqueueinfo | ❌ | |
| 298 | perf_event_open | ❌ | |
| 299 | recvmmsg | ❌ | |
| 300 | fanotify_init | ❌ | |
| 301 | fanotify_mark | ❌ | |
| 302 | prlimit64 | ✅ | |
| 303 | name_to_handle_at | ❌ | |
| 304 | open_by_handle_at | ❌ | |
| 305 | clock_adjtime | ❌ | |
| 306 | syncfs | ❌ | |
| 307 | sendmmsg | ❌ | |
| 308 | setns | ✅ | |
| 309 | getcpu | ✅ | |
| 310 | process_vm_readv | ❌ | |
| 311 | process_vm_writev | ❌ | |
| 312 | kcmp | ❌ | |
| 313 | finit_module | ❌ | |
| 314 | sched_setattr | ✅ | [⚠️](limitations-on-system-calls/process-and-thread-management.md#sched_getattr-and-sched_setattr) |
| 315 | sched_getattr | ✅ | [⚠️](limitations-on-system-calls/process-and-thread-management.md#sched_getattr-and-sched_setattr) |
| 316 | renameat2 | ✅ | [⚠️](limitations-on-system-calls/file-and-directory-operations.md#renameat2) |
| 318 | getrandom | ✅ | [⚠️](limitations-on-system-calls/system-information-and-misc.md#getrandom) |
| 319 | memfd_create | ✅ | |
| 322 | execveat | ✅ | |
| 327 | preadv2 | ✅ | |
| 328 | pwritev2 | ✅ | |
| 332 | statx | ✅ | |
| 434 | pidfd_open | ✅ | |
| 435 | clone3 | ✅ | |
| 436 | close_range | ✅ | |
| 439 | faccessat2 | ✅ | |
| 441 | epoll_pwait2 | ✅ | |
Most of these system calls (or their variants) are also supported
for the RISC-V and LoongArch architectures.
## File Systems
Here is the list of supported file systems:
* Devfs
* Devpts
* Ext2
* Procfs
* Ramfs
## Sockets
Here is the list of supported socket types:
* TCP sockets over IPv4
* UDP sockets over IPv4
* Unix sockets
## vDSO
Here is the list of supported symbols in vDSO:
* `__vdso_clock_gettime`
* `__vdso_gettimeofday`
* `__vdso_time`
## Boot Protocols
Here is the list of supported boot protocols:
* [Multiboot](https://www.gnu.org/software/grub/manual/multiboot/multiboot.html)
* [Multiboot2](https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html)
* [Linux 32-bit boot protocol](https://www.kernel.org/doc/html/v5.4/x86/boot.html#bit-boot-protocol)
* [Linux EFI handover](https://www.kernel.org/doc/html/v5.4/x86/boot.html#efi-handover-protocol)

View File

@ -0,0 +1,21 @@
# Limitations on System Calls
This section documents known limitations of Asterinas's implementation of Linux system calls.
It introduce [**System Call Matching Language (SCML)**](system-call-matching-language.md),
a lightweight domainspecific language for
specifying allowed and disallowed patterns of systemcall invocations.
The rest of this section uses SCML
to accurately and concisely describe
both supported and unsupported functionality of system calls,
which are divided into the following categories:
* [Process and thread management](process-and-thread-management.md)
* [Memory management](memory-management.md)
* [File & directory operations](file-and-directory-operations.md)
* [File systems & mount control](file-systems-and-mount-control.md)
* [File descriptor & I/O control](file-descriptor-and-io-control.md)
* [Inter-process communication](inter-process-communication.md)
* [Networking & sockets](networking-and-sockets.md)
* [Signals & timers](signals-and-timers.md)
* [Namespaces, cgroups & security](namespaces-cgroups-and-security.md)
* [System information & misc](system-information-and-misc.md)

View File

@ -0,0 +1,136 @@
# File and Directory Operations
<!--
Put system calls such as
open, openat, creat, close, read, write, readv, writev, pread64,
pwrite64, lseek, stat, fstat, lstat, statx, mkdir, rmdir, link,
unlink, rename, symlink, readlink, chmod, fchmod, chown, fchown,
utime, and utimensat
under this category.
-->
## `open` and `openat`
Supported functionality of `open` in SCML:
```c
access_mode =
O_RDONLY |
O_WRONLY |
O_RDWR;
creation_flags =
O_CLOEXEC |
O_DIRECTORY |
O_EXCL |
O_NOCTTY |
O_NOFOLLOW |
O_TRUNC;
status_flags =
O_APPEND |
O_ASYNC |
O_DIRECT |
O_LARGEFILE |
O_NOATIME |
O_NONBLOCK |
O_SYNC;
// Open an existing file
open(
path,
flags = <access_mode> | <creation_flags> | <status_flags>,
);
// Create a new file
open(
path,
flags = O_CREAT | <access_mode> | <creation_flags> | <status_flags>,
mode
);
// Status flags that are meaningful with O_PATH
opath_valid_flags = O_CLOEXEC | O_DIRECTORY | O_NOFOLLOW;
// All other flags are ignored with O_PATH
opath_ignored_flags = O_CREAT | <creation_flags> | <status_flags>;
// Obtain a file descriptor to indicate a location in FS
open(
path,
flags = O_PATH | <opath_valid_flags> | <opath_ignored_flags>
);
// Create an unnamed file
// open(path, flags = O_TMPFILE | <creation_flags> | <status_flags>)
```
Silently-ignored flags:
* `O_NOCTTY`
* `O_DSYNC`
* `O_SYNC`
* `O_LARGEFILE`
* `O_NOATIME`
* `O_NOCTTY`
Partially-supported flags:
* `O_PATH`
Unsupported flags:
* `O_TMPFILE`
Supported and unsupported functionality of `openat` are the same as `open`.
The SCML rules are omitted for brevity.
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/openat.2.html).
## `renameat2`
Supported functionality in SCML:
```c
// Rename a file, moving it between directories if required.
renameat2(olddirfd, oldpath, newdirfd, newpath, 0);
```
Unsupported flags:
* `RENAME_EXCHANGE`
* `RENAME_NOREPLACE`
* `RENAME_WHITEOUT`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/rename.2.html).
## `lseek`
Supported functionality in SCML:
```c
// Set file offset
lseek(
fd, offset,
whence = SEEK_SET | SEEK_CUR | SEEK_END
);
```
Unsupported flags:
* `SEEK_DATA`
* `SEEK_HOLE`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/lseek.2.html).
## `newfstatat`
Supported functionality in SCML:
```c
// Retrieve file status by file descriptor
newfstatat(
dirfd, path, statbuf,
flags = AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW
);
```
Silently-ignored flags:
* `AT_NO_AUTOMOUNT`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/newfstatat.2.html).

View File

@ -0,0 +1,88 @@
# File Descriptor and I/O Control
<!--
Put system calls such as
dup, dup2, dup3, fcntl, ioctl, pipe, pipe2, splice, tee, vmsplice, sendfile,
eventfd, eventfd2, inotify_init, inotify_init1, inotify_add_watch, and inotify_rm_watch
under this category.
-->
## `fcntl`
Supported functionality in SCML:
```c
ignore_flags = O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC;
can_change_flags = O_APPEND | O_ASYNC | O_DIRECT | O_NOATIME | O_NONBLOCK;
// Duplicate a file descriptor
fcntl(fd, cmd = F_DUPFD | F_DUPFD_CLOEXEC, arg);
// Retrieve file descriptor flags (F_GETFD), file status flags (F_GETFL)
// or SIGIO/SIGURG owner process (F_GETOWN)
fcntl(fd, cmd = F_GETFD | F_GETFL | F_GETOWN);
// Set file descriptor flags
fcntl(fd, cmd = F_SETFD, arg = FD_CLOEXEC);
// Set file status flags
fcntl(fd, cmd = F_SETFL, arg = <ignore_flags> | <can_change_flags>);
// Manage record locks: test (F_GETLK), non-blocking set (F_SETLK), blocking set (F_SETLKW)
fcntl(fd, cmd = F_GETLK | F_SETLK | F_SETLKW, arg);
// Assign SIGIO/SIGURG owner process
fcntl(fd, cmd = F_SETOWN, arg);
```
Unsupported commands:
* `F_NOTIFY`
* `F_OFD_SETLK`, `F_OFD_SETLKW` and `F_OFD_GETLK`
* `F_GETOWN_EX` and `F_SETOWN_EX`
* `F_GETSIG` and `F_SETSIG`
* `F_SETLEASE` and `F_GETLEASE`
* `F_SETPIPE_SZ` and `F_GETPIPE_SZ`
* `F_ADD_SEALS` and `F_GET_SEALS`
* `F_GET_RW_HINT` and `F_SET_RW_HINT`
* `F_GET_FILE_RW_HINT` and `F_SET_FILE_RW_HINT`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/fcntl.2.html).
## `pipe` and `pipe2`
Supported functionality in SCML:
```c
// Create pipe
pipe(pipefd);
// Create pipe with enhanced behavior control
pipe2(pipefd, flags = O_CLOEXEC);
```
Silently-ignored flags:
* `O_DIRECT`
* `O_NONBLOCK`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/pipe.2.html).
## `eventfd` and `eventfd2`
Supported functionality in SCML:
```c
// Create event notification descriptor
eventfd(initval);
// Create event notification descriptor with enhanced behavior control
eventfd2(initval, flags = EFD_CLOEXEC);
```
Silently-ignored flags:
* `EFD_NONBLOCK`
* `EFD_SEMAPHORE`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/eventfd.2.html).

View File

@ -0,0 +1,86 @@
# File Systems & Mount Control
<!--
Put system calls such as
mount, umount2, pivot_root, statfs, fstatfs, truncate, ftruncate, fsync,
fdatasync, sync, syncfs, sync_file_range, open_tree, move_mount, fsopen,
fsconfig, fsmount, and fspick
under this category.
-->
## Mount and Unmount File Systems
### `mount`
Supported functionality in SCML:
```c
// Create a new mount
mount(
source, target, filesystemtype,
mountflags = 0,
data
);
// Move the existing mount point
mount(
source, target, filesystemtype,
mountflags = MS_MOVE,
data
);
// Create a bind mount
mount(
source, target, filesystemtype,
mountflags = MS_BIND | MS_REC | MS_MOVE,
data
);
```
Silently-ignored mount flags:
* `MS_DIRSYNC`
* `MS_LAZYTIME`
* `MS_MANDLOCK`
* `MS_NOATIME`
* `MS_NODEV`
* `MS_NODIRATIME`
* `MS_NOEXEC`
* `MS_NOSUID`
* `MS_RDONLY`
* `MS_RELATIME`
* `MS_SILENT`
* `MS_STRICTATIME`
* `MS_SYNCHRONOUS`
Partially supported mount flags:
* `MS_REC` is only effective when used in conjunction with `MS_BIND`
Unsupported mount flags:
* `MS_REMOUNT`
* `MS_SHARED`
* `MS_PRIVATE`
* `MS_SLAVE`
* `MS_UNBINDABLE`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/mount.2.html).
### `umount` and `umount2`
Supported functionality in SCML:
```c
// Unmount a mounted file system
umount(target);
// Unmount a mounted file system with enhanced behavior control
umount2(target, flags = UMOUNT_NOFOLLOW);
```
Silently-ignored flags:
* `MNT_FORCE`
* `MNT_DETACH`
* `MNT_EXPIRE`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/umount.2.html).

View File

@ -0,0 +1,166 @@
# Inter-Process Communication
<!--
Put system calls such as
msgget, msgsnd, msgrcv, msgctl, semget, semop, semctl, shmget, shmat, shmctl
futex, set_robust_list, and get_robust_list
under this category.
-->
## System V semaphore
### `semget`
Supported functionality in SCML:
```c
// Creat or open a semaphore set
semget(
key,
nsems,
semflg = IPC_CREAT | IPC_EXCL
);
```
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/semget.2.html).
### `semop` and `semtimedop`
Supported functionality in SCML:
```c
struct sembuf = {
sem_flg = IPC_NOWAIT,
..
};
// Semaphore operations without blocking
semop(
semid,
sops = [ <sembuf> ],
nsops
);
```
Unsupported semaphore flags:
* `SEM_UNDO`
Supported and unsupported functionality of `semtimedop` are the same as `semop`.
The SCML rules are omitted for brevity.
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/semop.2.html).
### `semctl`
Supported functionality in SCML:
```c
// Remove the semaphore set
semctl(
semid,
semnum,
cmd = IPC_RMID
);
// Initialize the value of the semnum-th semaphore
semctl(
semid,
semnum,
cmd = SETVAL,
arg
);
// Return the current value (GETVAL), last operating process's PID (GETPID),
// count of processes awaiting increment (GETNCNT) or count of processes awaiting
// zero (GETZCNT) of the semnum-th semaphore
semctl(
semid,
semnum,
cmd = GETVAL | GETPID | GETNCNT | GETZCNT
);
// Retrieve a copy of the `semid_ds` kernel structure for the specified semaphore set
semctl(
semid,
semnum,
cmd = IPC_STAT,
arg
);
```
Unsupported commands:
* `IPC_INFO`
* `SEM_INFO`
* `SEM_STAT`
* `SEM_STAT_ANY`
* `GETALL`
* `SETALL`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/semctl.2.html).
### `futex`
Supported functionality in SCML:
```c
opt_flags = FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME;
// Block current thread if target value at `uaddr` matches `val`, and wait up to `timeout`.
futex(
uaddr,
futex_op = FUTEX_WAIT | <opt_flags>,
val, timeout
);
// Block current thread with bitmask condition if target value at `uaddr` matches `val`,
// and wait up to `timeout`.
futex(
uaddr,
futex_op = FUTEX_WAIT_BITSET | <opt_flags>,
val, timeout, unused = NULL, bitmask
);
// Unblock up to `max_waiters` threads waiting on `uaddr`
futex(
uaddr,
futex_op = FUTEX_WAKE | <opt_flags>,
max_waiters
);
// Unblock up to `max_waiters` threads on `uaddr`, if the value on `uaddr` matches `bitmask`
futex(
uaddr,
futex_op = FUTEX_WAKE_BITSET | <opt_flags>,
max_waiters, unused0 = NULL, unused1 = NULL, bitmask
);
// Unblock up to `max_waiters` threads waiting on `uaddr`, and requeue up to
// `max_requeue_waiters` of the remaining waiters to the target futex at `uaddr2`.
futex(
uaddr,
futex_op = FUTEX_REQUEUE | <opt_flags>,
max_waiters, max_requeue_waiters, uaddr2
);
// Perform atomic operation encoded in `operation` on `uaddr2`. Unblock up to `max_waiters`
// threads waiting on `uaddr`, and conditionally unblock up to `max_waiters2` threads
// waiting on `uaddr2` based on the result of the atomic operation.
futex(
uaddr,
futex_op = FUTEX_WAKE_OP | <opt_flags>,
max_waiters, max_waiters2, uaddr2, operation
);
```
Unsupported operations:
* `FUTEX_FD`
* `FUTEX_CMP_REQUEUE`
* `FUTEX_LOCK_PI`
* `FUTEX_UNLOCK_PI`
* `FUTEX_TRYLOCK_PI`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/futex.2.html).

View File

@ -0,0 +1,182 @@
# Memory Management
<!--
Put system calls such as
brk, mmap, munmap, mprotect, mremap, msync, mincore, madvise,
shmget, shmat, shmctl, mlock, munlock, mbind, and set_mempolicy
under this part.
-->
## Memory Mappings
### `mmap` and `munmap`
Supported functionality in SCML:
```c
prot = PROT_NONE |
PROT_EXEC |
PROT_READ |
PROT_WRITE;
opt_flags =
MAP_ANONYMOUS |
MAP_FIXED |
MAP_FIXED_NOREPLACE |
MAP_GROWSDOWN |
MAP_HUGETLB |
MAP_LOCKED |
MAP_NONBLOCK |
MAP_NORESERVE |
MAP_POPULATE |
MAP_SYNC;
// Create a private memory mapping
mmap(
addr, length,
prot = <prot>,
flags = MAP_PRIVATE | <opt_flags>
fd, offset
);
// Create a shared memory mapping
mmap(
addr, length,
prot = <prot>,
flags = MAP_SHARED | MAP_SHARED_VALIDATE | <opt_flags>
fd, offset
);
// Unmap a memory mapping
munmap(addr, length);
```
Silently-ignored flags:
* `MAP_HUGETLB`
* `MAP_GROWSDOWN`
* `MAP_LOCKED`
* `MAP_NONBLOCK`
* `MAP_NORESERVE`
* `MAP_POPULATE`
* `MAP_SYNC`
Partially supported flags:
* `MAP_FIXED_NOREPLACE` is treated as `MAP_FIXED`
Unsupported flags:
* `MAP_32BIT`
* `MAP_HUGE_1GB`
* `MAP_HUGE_2MB`
* `MAP_UNINITIALIZED`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/mmap.2.html).
### `msync`
Supported functionality in SCML:
```c
// Flush memory region to disk asynchronously
msync(
addr, length,
flags = MS_ASYNC | MS_INVALIDATE
);
// Flush memory region to disk synchronously
msync(
addr, length,
flags = MS_SYNC | MS_INVALIDATE
);
```
Silently-ignored flags:
* `MS_INVALIDATE` is ignored because all processes use the same page cache
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/msync.2.html).
### `mremap`
Supported functionality in SCML:
```c
// Resize an existing memory mapping. Relocation is allowed if given `MREMAP_MAYMOVE`.
mremap(
old_address,
old_size,
new_size,
flags = MREMAP_MAYMOVE
);
// Resize an existing memory mapping and force relocation to a specified location.
mremap(
old_address,
old_size,
new_size,
flags = MREMAP_MAYMOVE | MREMAP_FIXED,
new_address
);
```
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/mremap.2.html).
### `mprotect`
Supported functionality in SCML:
```c
// Set memory access permissions
mprotect(
addr,
len,
prot = <prot>
);
```
Silently-ignored protection flags:
* `PROT_SEM`
* `PROT_SAO`
* `PROT_GROWSUP`
* `PROT_GROWSDOWN`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/mprotect.2.html).
### `madvise`
Supported functionality in SCML:
```c
// Apply the default memory access pattern with no special optimizations
madvise(addr, length, advice = MADV_NORMAL);
// Indicate sequential access to enable aggressive read-ahead and immediate page release
madvise(addr, length, advice = MADV_SEQUENTIAL);
// Prefetch pages for near-future access to reduce latency
madvise(addr, length, advice = MADV_WILLNEED);
```
Silently-ignored advice:
* `MADV_DONTNEED`
Unsupported advice:
* `MADV_RANDOM`
* `MADV_REMOVE`
* `MADV_DONTFORK`
* `MADV_DOFORK`
* `MADV_HWPOISON`
* `MADV_MERGEABLE`
* `MADV_UNMERGEABLE`
* `MADV_SOFT_OFFLINE`
* `MADV_HUGEPAGE`
* `MADV_NOHUGEPAGE`
* `MADV_DONTDUMP`
* `MADV_DODUMP`
* `MADV_FREE`
* `MADV_WIPEONFORK`
* `MADV_KEEPONFORK`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/madvise.2.html).

View File

@ -0,0 +1,97 @@
# Namespaces, Cgroups & Security
<!--
Put system calls such as
unshare, setns, clone (with namespace flags), chroot, pivot_root, prctl,
capset, seccomp, landlock_create_ruleset, landlock_add_rule,
landlock_restrict_self, and bpf
under this category.
-->
## `prctl`
Supported functionality in SCML:
```c
// Retrieve or set the parent-death signal
prctl(op = PR_GET_PDEATHSIG PR_SET_PDEATHSIG, sig);
// Get or set the name of calling thread
prctl(op = PR_GET_NAME PR_SET_NAME, name);
// Query whether process retains permitted capabilities after `UID` changes
prctl(op = PR_GET_KEEPCAPS);
// Configure permitted capabilities retention after `UID` changes
prctl(op = PR_SET_KEEPCAPS, state);
// Retrieve or set "child subreaper" attribute
prctl(op = PR_GET_CHILD_SUBREAPER | PR_SET_CHILD_SUBREAPER, isset);
```
Partially-supported operations:
* `PR_GET_DUMPABLE` and `PR_SET_DUMPABLE` because coredump is not supported
Unsupported operations:
* `PR_CAP_AMBIENT`, `PR_CAPBSET_READ` and `PR_CAPBSET_DROP`
* `PR_GET_ENDIAN` and `PR_SET_ENDIAN`
* `PR_GET_FP_MODE` and `PR_SET_FP_MODE`
* `PR_GET_FPEMU` and `PR_SET_FPEMU`
* `PR_GET_FPEXC` and `PR_SET_FPEXC`
* `PR_GET_IO_FLUSHER` and `PR_SET_IO_FLUSHER`
* `PR_MCE_KILL` and `PR_MCE_KILL_GET`
* `PR_SET_MM` and `PR_SET_VMA`
* `PR_MPX_ENABLE_MANAGEMENT` and `PR_MPX_DISABLE_MANAGEMENT`
* `PR_GET_NO_NEW_PRIVS` and `PR_SET_NO_NEW_PRIVS`
* `PR_PAC_RESET_KEYS`
* `PR_SET_PTRACER`
* `PR_GET_SECCOMP` and `PR_SET_SECCOMP`
* `PR_GET_SECUREBITS` and `PR_SET_SECUREBITS`
* `PR_GET_SPECULATION_CTRL` and `PR_SET_SPECULATION_CTRL`
* `PR_SVE_GET_VL` and `PR_SVE_SET_VL`
* `PR_SET_SYSCALL_USER_DISPATCH`
* `PR_GET_TAGGED_ADDR_CTRL` and `PR_SET_TAGGED_ADDR_CTRL`
* `PR_TASK_PERF_EVENTS_ENABLE` and `PR_TASK_PERF_EVENTS_DISABLE`
* `PR_GET_THP_DISABLE` and `PR_SET_THP_DISABLE`
* `PR_GET_TID_ADDRESS`
* `PR_GET_TIMERSLACK` and `PR_SET_TIMERSLACK`
* `PR_GET_TIMING` and `PR_SET_TIMING`
* `PR_GET_TSC` and `PR_SET_TSC`
* `PR_GET_UNALIGN` and `PR_SET_UNALIGN`
* `PR_GET_AUXV`
* `PR_GET_MDWE` and `PR_SET_MDWE`
* `PR_RISCV_SET_ICACHE_FLUSH_CTX`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/prctl.2.html).
## `capget` and `capset`
Supported functionality in SCML:
```c
// Get capabilities of thread
capget(
hdrp = {
version = _LINUX_CAPABILITY_VERSION_3,
..
},
datap
);
// Set capabilities of thread
capset(
hdrp = {
version = _LINUX_CAPABILITY_VERSION_3,
..
},
datap
);
```
Unsupported versions:
* `_LINUX_CAPABILITY_VERSION_1`
* `_LINUX_CAPABILITY_VERSION_2`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/capget.2.html).

View File

@ -0,0 +1,49 @@
# Networking & Sockets
<!--
Put system calls such as
socket, socketpair, bind, listen, accept, connect, getsockname, getpeername,
sendto, recvfrom, sendmsg, recvmsg, shutdown, setsockopt, getsockopt,
sendmmsg, recvmmsg, accept4, recvmsg, and socketcall
under this category.
-->
## `socket`
```c
// Optional flags for socket type
opt_type_flags = SOCK_NONBLOCK | SOCK_CLOEXEC;
// Create a UNIX socket
socket(
family = AF_UNIX,
type = SOCK_STREAM | SOCK_SEQPACKET | <opt_type_flags>,
protocol = 0
);
// Create an IPv4 socket (TCP or UDP)
socket(
family = AF_INET,
type = SOCK_STREAM | SOCK_DGRAM | <opt_type_flags>,
protocol = IPPROTO_IP | IPPROTO_TCP | IPPROTO_UDP
);
// Create a netlink socket
socket(
family = AF_NETLINK,
type = SOCK_RAW | SOCK_DGRAM | <opt_type_flags>,
protocol = NETLINK_ROUTE | NETLINK_KOBJECT_UEVENT
);
// Create a VSOCK socket
socket(
family = AF_VSOCK,
type = SOCK_STREAM | <opt_type_flags>,
protocol = 0
);
```
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/socket.2.html).

View File

@ -0,0 +1,66 @@
# Process & Thread Management
<!--
Put system calls such as
fork, vfork, clone, execve, exit, exit_group, wait4, waitid,
getpid, getppid, gettid, setuid, setgid, getuid, getgid, and prctl
under this category.
-->
## `sched_getattr` and `sched_setattr`
Supported functionality in SCML:
```c
// Get the scheduling policy of a "normal" thread
sched_getattr(
pid,
attr = {
sched_policy = SCHED_OTHER | SCHED_BATCH | SCHED_IDLE,
sched_flags = 0,
..
},
flags = 0,
);
// Set the scheduling policy of a "normal" thread
sched_setattr(
pid,
attr = {
sched_policy = SCHED_OTHER | SCHED_BATCH | SCHED_IDLE,
sched_flags = 0,
..
},
flags = 0,
);
// Get the scheduling policy of a real-time thread
sched_getattr(
pid,
attr = {
sched_policy = SCHED_FIFO | SCHED_RR,
sched_flags = 0,
..
},
flags = 0,
);
// Set the scheduling policy of a real-time thread
sched_setattr(
pid,
attr = {
sched_policy = SCHED_FIFO | SCHED_RR,
sched_flags = 0,
..
},
flags = 0,
);
```
Unsupported scheduling policies:
* `SCHED_DEADLINE`
Unsupported scheduling flags:
* `SCHED_FLAG_RESET_ON_FORK`
* `SCHED_FLAG_RECLAIM`
* `SCHED_FLAG_DL_OVERRUN`
* `SCHED_FLAG_UTIL_CLAMP_MIN`
* `SCHED_FLAG_UTIL_CLAMP_MAX`

View File

@ -0,0 +1,84 @@
# Signals & Timers
<!--
Put system calls such as
rt_sigaction, rt_sigprocmask, rt_sigpending, rt_sigqueueinfo, rt_tgsigqueueinfo,
rt_sigreturn, kill, tkill, tgkill, alarm, setitimer, getitimer, nanosleep,
timer_create, timer_settime, timer_gettime, and timer_delete
under this category.
-->
## Signals
### `rt_sigaction`
Supported functionality in SCML:
```c
// Change and/or retrieve a signal action
rt_sigaction(
signum,
act = {
sa_flags = SA_ONSTACK | SA_RESTART | SA_NODEFER | SA_RESTORER | SA_SIGINFO | SA_RESETHAND,
..
},
oldact, sigsetsize
);
```
Unsupported `sigaction` flags:
* `SA_NOCLDSTOP`
* `SA_NOCLDWAIT`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/sigaction.2.html).
### `rt_sigprocmask`
Supported functionality in SCML:
```c
// Change and/or retrieve blocked signals
rt_sigprocmask(
how = SIG_BLOCK | SIG_UNBLOCK | SIG_SETMASK, set, oldset, sigsetsize
);
```
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/sigprocmask.2.html).
## POSIX Interval Timers
### `timer_create`
Supported functionality in SCML:
```c
opt_notify_methods = SIGEV_NONE | SIGEV_SIGNAL | SIGEV_THREAD_ID;
// Create a timer with predefined clock source
timer_create(
clockid = CLOCK_PROCESS_CPUTIME_ID | CLOCK_THREAD_CPUTIME_ID | CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_BOOTTIME,
sevp = <opt_notify_methods>,
timerid
);
// Create a timer based on a per-process or per-thread clock
timer_create(
clockid = <INTEGER>,
sevp = <opt_notify_methods>,
timerid
);
```
Unsupported predefined clock IDs:
* `CLOCK_REALTIME_ALARM`
* `CLOCK_BOOTTIME_ALARM`
* `CLOCK_TAI`
Unsupported notification methods:
* `SIGEV_THREAD`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/timer_create.2.html).

View File

@ -0,0 +1,284 @@
# System Call Matching Language (SCML)
SCML specifies matching patterns for systemcall invocations.
Asterinas developers can easily write SCML rules to describe supported patterns.
Likewise, users and developers can intuitively read these rules
to understand which system calls and features are available.
SCML is designed to integrate seamlessly with
[strace](https://man7.org/linux/man-pages/man1/strace.1.html),
the standard Linux systemcall tracer.
Strace emits each invocation in a Cstyle syntax;
given a set of SCML rules,
a tool can automatically determine
whether a strace log entry conforms to the supported patterns.
This paves the way for an SCMLbased analyzer
that reports unsupported calls in any application's trace.
## Strace: A Quick Example
To illustrate, run strace on a simple "Hello, World!" program:
```bash
$ strace ./hello_world
```
A typical trace might look like this:
```shell
execve("./hello_world", ["./hello_world"], 0xffffffd3f710 /* 4 vars */) = 0
brk(NULL) = 0xaaaabdc1b000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff890f4000
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\360\206\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1722920, ...}) = 0
write(1, "Hello, World!\n", 14) = 14
exit_group(0) = ?
```
Key points of this output:
* System calls are rendered as `name(arg1, …, argN)`.
* Flags appear as `FLAG1|FLAG2|…|FLAGN`.
* Structs use `{field1=value1, …}`.
* Arrays are shown as `[value1, …]`.
SCML's syntax draws directly from these conventions.
## SCML by Example
SCML is intentionally simple:
most Linux systemcall semantics hinge on bitflags.
SCML rules act as templates:
you define a rule once,
and a human or an analyzer uses it to check if a syscall invocation matches it or not.
Imagine you're developing a Linux-compatible OS (like Asterinas)
that supports just a restricted subset of syscalls and their options.
We will use SCML to describe the restricted functionality.
### Matching Rules for System Calls
For example,
your OS supports the [`open`](https://man7.org/linux/man-pages/man2/openat.2.html) system call
with one or more of the four flags: `O_RDONLY`, `O_WRONLY`, `O_RDWR`, and `O_CLOEXEC`:
This constraint can be expressed in the following system call matching rule.
```c
open(path, flags = O_RDONLY | O_WRONLY | O_RDWR | O_CLOEXEC);
```
To allow file creation,
you add another matching rule that
includes the `O_CREAT` flag and requires a `mode` argument:
```c
open(path, flags = O_CREAT | O_RDONLY | O_WRONLY | O_RDWR | O_CLOEXEC, mode);
```
To support the `O_PATH` flag
(only valid with `O_CLOEXEC`, not with `O_RDONLY`, `O_WRONLY`, or `O_RDWR`),
you add a third matching rule:
```c
open(path, flags = O_PATH | O_CLOEXEC);
```
SCML rules constrain only the flagged arguments;
other parameters (like `path` and `mode`) accept any value.
### C-Style Comments
SCML also supports Cstyle comments:
```c
// All matching rules for the open syscall.
// A supported invocation of the open syscall must match at least one of the rules.
open(path, flags = O_RDONLY | O_WRONLY | O_RDWR | O_CLOEXEC);
open(path, flags = O_CREAT | O_RDONLY | O_WRONLY | O_RDWR | O_CLOEXEC, mode);
open(path, flags = O_PATH | O_CLOEXEC);
```
### Matching Rules for Bitflags
Above, we embedded flag combinations directly within individual systemcall rules,
which can lead to duplication and make maintenance harder.
SCML allows you to define named bitflag rules that
can be reused across multiple rules.
This reduces repetition and centralizes your flag definitions.
For example:
```c
// Define a reusable bitflags rule
access_mode = O_RDONLY | O_WRONLY | O_RDWR;
open(path, flags = <access_mode> | O_CLOEXEC);
open(path, flags = O_CREAT | <access_mode> | O_CLOEXEC, mode);
open(path, flags = O_PATH | O_CLOEXEC);
```
### Matching Rules for Structs
SCML can match flags inside struct fields.
Consider [`sigaction`](https://man7.org/linux/man-pages/man2/sigaction.2.html):
```c
struct sigaction = {
sa_flags: SA_NOCLDSTOP | SA_NOCLDWAIT,
..
};
```
Here, `..` is a wildcard for remaining fields that we do not care.
Then, we can write a system call rule that
refers to the struct rule using the `<struct_rule>` syntax.
```c
sigaction(signum, act = <sigaction>, oldact = <sigaction>);
```
### Matching Rules for Arrays
SCML can describe how to match flags embedded inside the struct values of an array.
This is the case of the [`poll`](https://man7.org/linux/man-pages/man2/poll.2.html) system call.
It takes an array of values of `struct pollfd`,
whose `event` and `revents` fields are bitflags.
```c
// Support all but the POLLPRI flags
events = POLLIN | POLLOUT | POLLRDHUP | POLLERR | POLLHUP | POLLNVAL;
struct pollfd = {
events = <events>,
revents = <events>,
..
};
poll(fds = [ <pollfd> ], nfds, timeout);
```
Notice how SCML denotes an array with the `[ <struct_rule> ]` syntax.
### Special Built-in Matching Rules
Bitflags-based matching rules described above are expressive enough to
capture most patterns of interesting system call arguments.
But some system call arguments cannot be characterized with bitflags.
To address such cases, SCML introduces two special built-in matching rules:
`<PATH>` and `<INTEGER>`
#### The file path matching rule
The `<PATH>` matching rule is used to
denote a system call argument of a C-string file path.
For example, the matching rules for the `open` system call
can be enhanced with `<PATH>` as follows:
```c
access_mode = O_RDONLY | O_WRONLY | O_RDWR;
open(path = <PATH>, flags = <access_mode> | O_CLOEXEC);
open(path = <PATH>, flags = O_CREAT | <access_mode> | O_CLOEXEC, mode);
open(path = <PATH>, flags = O_PATH | O_CLOEXEC);
```
File paths provide a new dimension to determine whether a system call is supported or not.
Linux has multiple pseudo file systems such as
DevTmpFS, ProcFS, SysFS, CgroupFS, and ConfigFS,
mounted at well-known locations.
A Linux-compatible OS such as Asterinas may only support a sub-tree of an pseudo FS.
Knowing which system call arguments refer to file paths,
a tool may be built to automatically issue warnings
when unsupported file paths are accessed by system calls.
#### The integer matching rule
The `<INTEGER>` matching rule can match any integer system call argument
such as `1234`, `-100`, `0xdeadbeef`, and `0o666`.
It can be used as a fallback rule
when a system call takes an argument of either bitflags or integer.
```c
timer_create(
clockid =
// Static clock IDs represented as bitflags
CLOCK_PROCESS_CPUTIME_ID | CLOCK_THREAD_CPUTIME_ID | CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_BOOTTIME |
// Dynamic clock IDs (per-process or per-thread clock IDs)
// represented as an integer value.
<INTEGER>,
sevp,
timerid
);
```
### Advanced Usage
Just like you can write multiple rules of the same system call,
you may define multiple rules for the same struct:
```c
// Rules for control message header
struct cmsghdr = {
cmsg_level = SOL_SOCKET,
cmsg_type = SO_TIMESTAMP_OLD | SCM_RIGHTS | SCM_CREDENTIALS,
..
};
struct cmsghdr = {
cmsg_level = SOL_IP,
cmsg_type = IP_TTL,
..
};
```
A `cmsghdr` value matches if it satisfies any one rule.
Struct rules may also be nested:
```c
// Rule for message header, which refers to the rules for control message header
struct msghdr = {
msg_control = [ <cmsghdr> ],
..
};
recvmsg(socket, message = <msghdr>, flags);
```
## Formal Syntax
Below is the formal syntax of SCML,
expressed in Extended BackusNaur Form (EBNF).
Nonterminals are in angle brackets, terminals in quotes.
```
<scml> ::= { <rule> }
<rule> ::= <syscall-rule> ';'
| <struct-rule> ';'
| <bitflags-rule> ';'
<syscall-rule> ::= <identifier> '(' [ <param-list> ] ')'
<param-list> ::= <param> { ',' <param> }
<param> ::= <identifier> '=' <expr>
| <identifier>
<expr> ::= <expr> '|' <expr>
| <term>
<term> ::= <identifier>
| '<' <identifier> '>'
<array> ::= '[' '<' <identifier> '>' ']'
<struct-rule> ::= 'struct' <identifier> '=' '{' <field-list> [ ',' '..' ] '}'
<field-list> ::= <field> { ',' <field> }
<field> ::= <identifier>
| <identifier> ':' <expr>
| <identifier> ':' <array>
<bitflags-rule> ::= <identifier> '=' <expr>
<identifier> ::= letter { letter | digit | '_' }
comment ::= '//' { any-char }
```

View File

@ -0,0 +1,123 @@
# System Information & Misc.
<!--
Put system calls such as
uname, getrlimit, setrlimit, sysinfo, times, gettimeofday, clock_gettime,
clock_settime, getrusage, getdents, getdents64, personality, syslog,
arch_prctl, set_tid_address, and getrandom
under this category.
-->
## POSIX Clocks
### `clock_gettime`
Supported functionality in SCML:
```c
predefined_clockid = CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_MONOTONIC_RAW |
CLOCK_REALTIME_COARSE | CLOCK_MONOTONIC_COARSE | CLOCK_BOOTTIME |
CLOCK_PROCESS_CPUTIME_ID | CLOCK_THREAD_CPUTIME_ID;
// Get the time of a clock specified by a static ID
clock_gettime(clockid = <predefined_clockid>, tp);
// Get the time of a clock specified by a dynamic ID
clock_gettime(clockid = <INTEGER>, tp);
```
Unsupported predefined clock IDs:
* `CLOCK_REALTIME_ALARM`
* `CLOCK_BOOTTIME_ALARM`
* `CLOCK_TAI`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/clock_gettime.2.html).
### `clock_nanosleep`
Supported functionality in SCML:
```c
// Sleep with a specified clock
clock_nanosleep(
clockid = CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_BOOTTIME | CLOCK_PROCESS_CPUTIME_ID,
flags =
// Optional flags:
//
// Sleep until an absolute time point
TIMER_ABSTIME,
t, remain
);
```
Unsupported clock IDs:
* `CLOCK_TAI`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html).
## `arch_prctl`
Supported functionality in SCML:
```c
// Get or set the FS register
arch_prctl(
code = ARCH_GET_FS | ARCH_SET_FS,
addr
);
```
Unsupported codes:
* `ARCH_GET_CPUID` and `ARCH_SET_CPUID`
* `ARCH_GET_GS` and `ARCH_SET_GS`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/arch_prctl.2.html).
## `getrusage`
Supported functionality in SCML:
```c
// Return resource usage statistics for the calling process
getrusage(
who = RUSAGE_SELF,
usage
);
// Return resource usage statistics for the calling thread
getrusage(
who = RUSAGE_THREAD,
usage
);
```
Unsupported `who` flags:
* `RUSAGE_CHILDREN`
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/getrusage.2.html).
## `getrandom`
Supported functionality in SCML:
```c
// Obtain random bytes
getrandom(
buf, buflen,
flags =
// Optional flags:
//
// High-entropy pool
GRND_RANDOM
);
```
Silently-ignored flags:
* `GRND_NONBLOCK` because the underlying operation never blocks
For more information,
see [the man page](https://man7.org/linux/man-pages/man2/getrandom.2.html).

View File

@ -32,7 +32,7 @@ Therefore, it is recommended to use a Docker image to deploy the environment.
Run a TDX Docker container:
```bash
docker run -it --privileged --network=host --device=/dev/kvm asterinas/osdk:0.9.4-tdx
docker run -it --privileged --network=host --device=/dev/kvm asterinas/osdk:0.16.1-20250922
```
## Edit `OSDK.toml` for Intel TDX support
@ -53,7 +53,6 @@ grub.mkrescue_path = "~/tdx-tools/grub"
grub.protocol = "linux"
qemu.args = """\
-accel kvm \
-name process=tdxvm,debug-threads=on \
-m 8G \
-vga none \
-monitor pty \

View File

@ -25,6 +25,9 @@ comma separated configuration list:
- `vscode`: generate a '.vscode/launch.json' for debugging with Visual Studio Code
(Requires [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)).
Besides, to collect coverage data, we can use option `--coverage`. This option
enables the coverage feature and collect coverage data to `coverage.profraw` when exit.
See [Debug Command](debug.md) to interact with the GDB server in terminal.
## Examples

View File

@ -0,0 +1,7 @@
# Environment Variables
The OSDK tool uses the following environment variables to customize compilation and target behavior.
## OSDK-Specific Variables
- `OSDK_TARGET_ARCH`: If set, OSDK will use the specified value as its default target architecture (e.g., x86_64, riscv64).
If not set, OSDK will default to the host architecture.

View File

@ -0,0 +1,103 @@
# RFC-0001: RFC process
* Status: Draft
* Pull request: https://github.com/asterinas/asterinas/pull/2365/
* Date submitted: 2025-08-24
* Date approved: YYYY-MM-DD
## Summary
The "RFC" (request for comments) process is intended to provide a consistent, transparent, structured path for the community to make "big" decisions. For example, the RFC process can be used to evolve the project roadmap and the system architecture.
## Motivation
As the Asterinas project grows in scale and community size, an informal decision-making process becomes insufficient. A formalized process is crucial for maintaining the quality and coherence of the project. Several highly successful open-source projects have demonstrated the value of such a process, including Rust ([RFCs](https://rust-lang.github.io/rfcs/introduction.html)), Fuchsia ([RFCs](https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs)), Python ([Python Enhancement Proposals](https://peps.python.org/) or PEPs), and Kubernetes ([Kubernetes Enhancement Proposals](https://www.kubernetes.dev/resources/keps/) or KEPs).
Adopting a formal RFC process will:
- **Enhance decision quality**: By requiring a detailed proposal and public discussion, we can ensure that decisions are well-reasoned, technically sound, and consider a wide range of perspectives.
- **Foster Consensus**: The process provides a clear framework for the community to come together, discuss differing viewpoints, and arrive at a consensus on important issues.
- **Create design records**: Approved RFCs will serve as a historical archive, documenting the design choices made and the reasoning behind them. This is invaluable for new contributors and for future reference.
By introducing this process, we aim to support the healthy and sustainable growth of the Asterinas project.
## Design
### When to follow the RFC process
The RFC process should be used for any "substantial" change to Asterinas. Examples of changes that **require** an RFC include:
- Launching new top-level sub-projects of a similar significance to OSTD and OSDK.
- Defining or significantly altering the project roadmap and goals.
- Establishing or changing project-wide norms, such as this RFC process itself or coding style guides.
- Proposing significant architectural designs, such as the framekernel architecture or safe policy injection.
- Introducing changes that affect user-space programs, such as adding a non-Linux system call or feature.
Examples of changes that **do not** require an RFC include:
- Proposing a design whose impact is confined to a single sub-project or module. If the design is significant or non-trivial, submit a design proposal on Github Issues for discussion.
- Adding well-understood features with established patterns, such as a standard Linux system call or a device driver.
- Refactoring existing code, fixing bugs, or improving performance.
When in doubt, it is best to consult with the project maintainers using the methods described in the next section.
### How the RFC process works
The RFC process consists of several distinct stages:
#### The Socialization Stage
Before investing the time to write a full RFC, it is highly recommended to socialize the core idea with the community. This helps gauge interest, gather early feedback, and refine the proposal. Good venues for this include:
- Starting a discussion on the project's [GitHub Discussions page](https://github.com/asterinas/asterinas/discussions).
- Posting a "Pre-RFC" document to solicit more detailed feedback.
- Talking to key contributors, code owners, or maintainers directly.
Having support from at least a few other community members is a strong signal that the idea is ready for a formal RFC. Additionally, having a proof-of-concept implementation or identifying individuals committed to the implementation can strengthen the proposal.
#### The Draft Stage
Once you are ready to proceed, create a formal RFC document.
1. Fork the `asterinas/asterinas` repository.
2. In [the `rfcs` directory](https://github.com/asterinas/asterinas/tree/main/book/src/rfcs), copy `rfc-template.md` and rename it to `0000-your-rfc-title.md`. The `0000` is a placeholder for the RFC number, which will be assigned later.
3. Fill out the template with your proposal. The template provides a solid structure, but feel free to adapt it to best suit your proposal.
#### The Iteration Stage
Submit your RFC draft as a pull request to the Asterinas repository. Once the PR is opened, the formal review process begins:
- A project maintainer will be assigned as the **facilitator** for the RFC. The facilitator's role is to guide the discussion, ensure it remains productive, and ultimately determine when consensus has been reached.
- All members of the community are encouraged to review the proposal and provide constructive feedback through comments on the pull request.
- The RFC author is responsible for engaging with the feedback, addressing concerns, and updating the RFC text to reflect the evolving consensus.
#### The Voting Stage
When the discussion has converged and the major points of feedback have been addressed, the author can request that the facilitator initiate a final vote.
- The vote is open to all project maintainers and code owners of top-level sub-projects. See the [`CODEOWNERS`](https://github.com/asterinas/asterinas/blob/main/CODEOWNERS) file for details.
- Voters can express either "approval" or "rejection."
- The final decision will be based on a [rough consensus](https://en.wikipedia.org/wiki/Rough_consensus) as determined by the facilitator. This means that while unanimous agreement is not required, any major objections must be addressed.
If the final decision is approval:
1. The facilitator will assign an unique RFC number.
2. The author will update the RFC's file name with the assigned RFC number. The author should also update the metadata fields of the RFC.
3. The facilitator will merge the pull request.
#### The Maintenance Stage
Once an RFC is approved, the proposed changes are ready for implementation. When the corresponding work is completed and merged, the RFC's status is updated from "approved" to "implemented."
Approved RFCs are considered immutable historical records of design decisions. As such, only minor corrective edits like fixing typos or broken links are allowed.
Significant changes or amendments to an existing RFC must be proposed through an entirely new RFC. This new proposal can also be used to formally deprecate a previous RFC, in which case the original's status will be updated to "deprecated."
## License
All RFCs submitted to the Asterinas project are licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). This license is more permissive than [the MPL license](https://www.mozilla.org/en-US/MPL/) used for the Asterinas code.
## Drawbacks
Introducing a formal RFC process can increase the overhead for making changes to the project. The process is intentionally deliberate, which may slow down the pace of development for major features. There is also a risk that the process could become overly bureaucratic if not managed carefully. For contributors, the effort required to write a high-quality RFC and see it through the review process can be significant.
## Prior Art and References
The Asterinas RFC process is heavily inspired by the well-established processes of the following two open-source projects:
- [Rust RFC Process](https://rust-lang.github.io/rfcs/0002-rfc-process.html): The overall structure and philosophy are closely modeled on Rust's RFC process.
- [Fuchsia RFC Process](https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/rfc_process): We have drawn on the Fuchsia process for its clear definition of roles and its emphasis on transparent decision-making.

5
book/src/rfcs/README.md Normal file
View File

@ -0,0 +1,5 @@
# RFC Overview
The Asterinas RFC process is intended to provide a consistent, transparent, structured path for the community to make "big" decisions. For example, the RFC process can be used to evolve the project roadmap and the system architecture.
For more details, see the [RFC-0001 RFC process](0001-rfc-process.md).

View File

@ -0,0 +1,28 @@
# RFC-0000: Your short, descriptive title
* Status: Draft
* Pull request: (link to PR)
* Date submitted: YYYY-MM-DD
* Date approved: YYYY-MM-DD
## Summary
Provide a concise, one-paragraph summary of the proposed change. This should explain the core idea at a high level, making it understandable to someone without deep context.
## Motivation
Explain the "why" behind this RFC. What problem does this solve? What is the user or developer story that justifies this change? Why is this change important for the Asterinas project *now*? This section should clearly articulate the benefits and convince readers of the proposal's necessity.
## Design
This is the heart of the RFC. Describe the proposed design in sufficient detail for a technical review. Explain how it works, how it interacts with other parts of the system, and any new APIs or concepts being introduced. Use code snippets, diagrams, and bullet points where they add clarity.
## Drawbacks, Alternatives, and Unknown
- **Drawbacks:** What are the negative consequences of this proposal? What compromises are being made?
- **Alternatives:** What other designs or solutions were considered? Why was this specific design chosen over them? What is the impact of *not* doing this?
- **Unresolved Questions:** What parts of the design are still to be determined (TBD)? What questions will need to be answered during the implementation phase?
## Prior Art and References
Include links to relevant work

View File

@ -10,8 +10,9 @@ including crates, modules, structs, traits, functions, macros, and more.
The use of the `#[warn(missing_docs)]` lint enforces this rule.
Asterinas adheres to the API style guidelines of the Rust community.
The recommended API documentation style can be found at
[How to write documentation - The rustdoc book](https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html).
The recommended API documentation style are specified by two official resources:
1. The rustdoc book: [How to write documentation](https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html);
2. The Rust RFC book: [API Documentation Conventions](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text).
## Lint Guidelines

View File

@ -1,378 +0,0 @@
# Linux Compatibility
> "We don't break user space."
>
> --- Linus Torvalds
Asterinas is dedicated to maintaining compatibility with the Linux ABI,
ensuring that applications and administrative tools
designed for Linux can seamlessly operate within Asterinas.
While we prioritize compatibility,
it is important to note that Asterinas does not,
nor will it in the future,
support the loading of Linux kernel modules.
## System Calls
At the time of writing,
Asterinas implements 214 out of the 336 system calls
provided by Linux on x86-64 architecture.
| Numbers | Names | Is Implemented |
| ------- | ---------------- | --------------- |
| 0 | read | ✅ |
| 1 | write | ✅ |
| 2 | open | ✅ |
| 3 | close | ✅ |
| 4 | stat | ✅ |
| 5 | fstat | ✅ |
| 6 | lstat | ✅ |
| 7 | poll | ✅ |
| 8 | lseek | ✅ |
| 9 | mmap | ✅ |
| 10 | mprotect | ✅ |
| 11 | munmap | ✅ |
| 12 | brk | ✅ |
| 13 | rt_sigaction | ✅ |
| 14 | rt_sigprocmask | ✅ |
| 15 | rt_sigreturn | ✅ |
| 16 | ioctl | ✅ |
| 17 | pread64 | ✅ |
| 18 | pwrite64 | ✅ |
| 19 | readv | ✅ |
| 20 | writev | ✅ |
| 21 | access | ✅ |
| 22 | pipe | ✅ |
| 23 | select | ✅ |
| 24 | sched_yield | ✅ |
| 25 | mremap | ✅ |
| 26 | msync | ✅ |
| 27 | mincore | ❌ |
| 28 | madvise | ✅ |
| 29 | shmget | ❌ |
| 30 | shmat | ❌ |
| 31 | shmctl | ❌ |
| 32 | dup | ✅ |
| 33 | dup2 | ✅ |
| 34 | pause | ✅ |
| 35 | nanosleep | ✅ |
| 36 | getitimer | ✅ |
| 37 | alarm | ✅ |
| 38 | setitimer | ✅ |
| 39 | getpid | ✅ |
| 40 | sendfile | ✅ |
| 41 | socket | ✅ |
| 42 | connect | ✅ |
| 43 | accept | ✅ |
| 44 | sendto | ✅ |
| 45 | recvfrom | ✅ |
| 46 | sendmsg | ✅ |
| 47 | recvmsg | ✅ |
| 48 | shutdown | ✅ |
| 49 | bind | ✅ |
| 50 | listen | ✅ |
| 51 | getsockname | ✅ |
| 52 | getpeername | ✅ |
| 53 | socketpair | ✅ |
| 54 | setsockopt | ✅ |
| 55 | getsockopt | ✅ |
| 56 | clone | ✅ |
| 57 | fork | ✅ |
| 58 | vfork | ❌ |
| 59 | execve | ✅ |
| 60 | exit | ✅ |
| 61 | wait4 | ✅ |
| 62 | kill | ✅ |
| 63 | uname | ✅ |
| 64 | semget | ✅ |
| 65 | semop | ✅ |
| 66 | semctl | ✅ |
| 67 | shmdt | ❌ |
| 68 | msgget | ❌ |
| 69 | msgsnd | ❌ |
| 70 | msgrcv | ❌ |
| 71 | msgctl | ❌ |
| 72 | fcntl | ✅ |
| 73 | flock | ✅ |
| 74 | fsync | ✅ |
| 75 | fdatasync | ✅ |
| 76 | truncate | ✅ |
| 77 | ftruncate | ✅ |
| 78 | getdents | ✅ |
| 79 | getcwd | ✅ |
| 80 | chdir | ✅ |
| 81 | fchdir | ✅ |
| 82 | rename | ✅ |
| 83 | mkdir | ✅ |
| 84 | rmdir | ✅ |
| 85 | creat | ✅ |
| 86 | link | ✅ |
| 87 | unlink | ✅ |
| 88 | symlink | ✅ |
| 89 | readlink | ✅ |
| 90 | chmod | ✅ |
| 91 | fchmod | ✅ |
| 92 | chown | ✅ |
| 93 | fchown | ✅ |
| 94 | lchown | ✅ |
| 95 | umask | ✅ |
| 96 | gettimeofday | ✅ |
| 97 | getrlimit | ✅ |
| 98 | getrusage | ✅ |
| 99 | sysinfo | ✅ |
| 100 | times | ❌ |
| 101 | ptrace | ❌ |
| 102 | getuid | ✅ |
| 103 | syslog | ❌ |
| 104 | getgid | ✅ |
| 105 | setuid | ✅ |
| 106 | setgid | ✅ |
| 107 | geteuid | ✅ |
| 108 | getegid | ✅ |
| 109 | setpgid | ✅ |
| 110 | getppid | ✅ |
| 111 | getpgrp | ✅ |
| 112 | setsid | ✅ |
| 113 | setreuid | ✅ |
| 114 | setregid | ✅ |
| 115 | getgroups | ✅ |
| 116 | setgroups | ✅ |
| 117 | setresuid | ✅ |
| 118 | getresuid | ✅ |
| 119 | setresgid | ✅ |
| 120 | getresgid | ✅ |
| 121 | getpgid | ✅ |
| 122 | setfsuid | ✅ |
| 123 | setfsgid | ✅ |
| 124 | getsid | ✅ |
| 125 | capget | ✅ |
| 126 | capset | ✅ |
| 127 | rt_sigpending | ✅ |
| 128 | rt_sigtimedwait | ❌ |
| 129 | rt_sigqueueinfo | ❌ |
| 130 | rt_sigsuspend | ✅ |
| 131 | sigaltstack | ✅ |
| 132 | utime | ✅ |
| 133 | mknod | ✅ |
| 134 | uselib | ❌ |
| 135 | personality | ❌ |
| 136 | ustat | ❌ |
| 137 | statfs | ✅ |
| 138 | fstatfs | ✅ |
| 139 | sysfs | ❌ |
| 140 | getpriority | ✅ |
| 141 | setpriority | ✅ |
| 142 | sched_setparam | ✅ |
| 143 | sched_getparam | ✅ |
| 144 | sched_setscheduler | ✅ |
| 145 | sched_getscheduler | ✅ |
| 146 | sched_get_priority_max | ✅ |
| 147 | sched_get_priority_min | ✅ |
| 148 | sched_rr_get_interval | ❌ |
| 149 | mlock | ❌ |
| 150 | munlock | ❌ |
| 151 | mlockall | ❌ |
| 152 | munlockall | ❌ |
| 153 | vhangup | ❌ |
| 154 | modify_ldt | ❌ |
| 155 | pivot_root | ❌ |
| 156 | _sysctl | ❌ |
| 157 | prctl | ✅ |
| 158 | arch_prctl | ✅ |
| 159 | adjtimex | ❌ |
| 160 | setrlimit | ✅ |
| 161 | chroot | ✅ |
| 162 | sync | ✅ |
| 163 | acct | ❌ |
| 164 | settimeofday | ❌ |
| 165 | mount | ✅ |
| 166 | umount2 | ✅ |
| 167 | swapon | ❌ |
| 168 | swapoff | ❌ |
| 169 | reboot | ❌ |
| 170 | sethostname | ❌ |
| 171 | setdomainname | ❌ |
| 172 | iopl | ❌ |
| 173 | ioperm | ❌ |
| 174 | create_module | ❌ |
| 175 | init_module | ❌ |
| 176 | delete_module | ❌ |
| 177 | get_kernel_syms | ❌ |
| 178 | query_module | ❌ |
| 179 | quotactl | ❌ |
| 180 | nfsservctl | ❌ |
| 181 | getpmsg | ❌ |
| 182 | putpmsg | ❌ |
| 183 | afs_syscall | ❌ |
| 184 | tuxcall | ❌ |
| 185 | security | ❌ |
| 186 | gettid | ✅ |
| 187 | readahead | ❌ |
| 188 | setxattr | ✅ |
| 189 | lsetxattr | ✅ |
| 190 | fsetxattr | ✅ |
| 191 | getxattr | ✅ |
| 192 | lgetxattr | ✅ |
| 193 | fgetxattr | ✅ |
| 194 | listxattr | ✅ |
| 195 | llistxattr | ✅ |
| 196 | flistxattr | ✅ |
| 197 | removexattr | ✅ |
| 198 | lremovexattr | ✅ |
| 199 | fremovexattr | ✅ |
| 200 | tkill | ❌ |
| 201 | time | ✅ |
| 202 | futex | ✅ |
| 203 | sched_setaffinity | ✅ |
| 204 | sched_getaffinity | ✅ |
| 205 | set_thread_area | ❌ |
| 206 | io_setup | ❌ |
| 207 | io_destroy | ❌ |
| 208 | io_getevents | ❌ |
| 209 | io_submit | ❌ |
| 210 | io_cancel | ❌ |
| 211 | get_thread_area | ❌ |
| 212 | lookup_dcookie | ❌ |
| 213 | epoll_create | ✅ |
| 214 | epoll_ctl_old | ❌ |
| 215 | epoll_wait_old | ❌ |
| 216 | remap_file_pages | ❌ |
| 217 | getdents64 | ✅ |
| 218 | set_tid_address | ✅ |
| 219 | restart_syscall | ❌ |
| 220 | semtimedop | ✅ |
| 221 | fadvise64 | ❌ |
| 222 | timer_create | ✅ |
| 223 | timer_settime | ✅ |
| 224 | timer_gettime | ✅ |
| 225 | timer_getoverrun | ❌ |
| 226 | timer_delete | ✅ |
| 227 | clock_settime | ❌ |
| 228 | clock_gettime | ✅ |
| 229 | clock_getres | ❌ |
| 230 | clock_nanosleep | ✅ |
| 231 | exit_group | ✅ |
| 232 | epoll_wait | ✅ |
| 233 | epoll_ctl | ✅ |
| 234 | tgkill | ✅ |
| 235 | utimes | ✅ |
| 236 | vserver | ❌ |
| 237 | mbind | ❌ |
| 238 | set_mempolicy | ❌ |
| 239 | get_mempolicy | ❌ |
| 240 | mq_open | ❌ |
| 241 | mq_unlink | ❌ |
| 242 | mq_timedsend | ❌ |
| 243 | mq_timedreceive | ❌ |
| 244 | mq_notify | ❌ |
| 245 | mq_getsetattr | ❌ |
| 246 | kexec_load | ❌ |
| 247 | waitid | ✅ |
| 248 | add_key | ❌ |
| 249 | request_key | ❌ |
| 250 | keyctl | ❌ |
| 251 | ioprio_set | ❌ |
| 252 | ioprio_get | ❌ |
| 253 | inotify_init | ❌ |
| 254 | inotify_add_watch | ❌ |
| 255 | inotify_rm_watch | ❌ |
| 256 | migrate_pages | ❌ |
| 257 | openat | ✅ |
| 258 | mkdirat | ✅ |
| 259 | mknodat | ✅ |
| 260 | fchownat | ✅ |
| 261 | futimesat | ✅ |
| 262 | newfstatat | ✅ |
| 263 | unlinkat | ✅ |
| 264 | renameat | ✅ |
| 265 | linkat | ✅ |
| 266 | symlinkat | ✅ |
| 267 | readlinkat | ✅ |
| 268 | fchmodat | ✅ |
| 269 | faccessat | ✅ |
| 270 | pselect6 | ✅ |
| 271 | ppoll | ✅ |
| 272 | unshare | ❌ |
| 273 | set_robust_list | ✅ |
| 274 | get_robust_list | ❌ |
| 275 | splice | ❌ |
| 276 | tee | ❌ |
| 277 | sync_file_range | ❌ |
| 278 | vmsplice | ❌ |
| 279 | move_pages | ❌ |
| 280 | utimensat | ✅ |
| 281 | epoll_pwait | ✅ |
| 282 | signalfd | ✅ |
| 283 | timerfd_create | ✅ |
| 284 | eventfd | ✅ |
| 285 | fallocate | ✅ |
| 286 | timerfd_settime | ✅ |
| 287 | timerfd_gettime | ✅ |
| 288 | accept4 | ✅ |
| 289 | signalfd4 | ✅ |
| 290 | eventfd2 | ✅ |
| 291 | epoll_create1 | ✅ |
| 292 | dup3 | ✅ |
| 293 | pipe2 | ✅ |
| 294 | inotify_init1 | ❌ |
| 295 | preadv | ✅ |
| 296 | pwritev | ✅ |
| 297 | rt_tgsigqueueinfo | ❌ |
| 298 | perf_event_open | ❌ |
| 299 | recvmmsg | ❌ |
| 300 | fanotify_init | ❌ |
| 301 | fanotify_mark | ❌ |
| 302 | prlimit64 | ✅ |
| 303 | name_to_handle_at | ❌ |
| 304 | open_by_handle_at | ❌ |
| 305 | clock_adjtime | ❌ |
| 306 | syncfs | ❌ |
| 307 | sendmmsg | ❌ |
| 308 | setns | ❌ |
| 309 | getcpu | ✅ |
| 310 | process_vm_readv | ❌ |
| 311 | process_vm_writev | ❌ |
| 312 | kcmp | ❌ |
| 313 | finit_module | ❌ |
| 314 | sched_setattr | ✅ |
| 315 | sched_getattr | ✅ |
| 318 | getrandom | ✅ |
| 322 | execveat | ✅ |
| 327 | preadv2 | ✅ |
| 328 | pwritev2 | ✅ |
| 332 | statx | ✅ |
| 435 | clone3 | ✅ |
| 436 | close_range | ✅ |
| 439 | faccessat2 | ✅ |
| 441 | epoll_pwait2 | ✅ |
## File Systems
Here is the list of supported file systems:
* Devfs
* Devpts
* Ext2
* Procfs
* Ramfs
## Sockets
Here is the list of supported socket types:
* TCP sockets over IPv4
* UDP sockets over IPv4
* Unix sockets
## vDSO
Here is the list of supported symbols in vDSO:
* `__vdso_clock_gettime`
* `__vdso_gettimeofday`
* `__vdso_time`
## Boot Protocols
Here is the list of supported boot protocols:
* [Multiboot](https://www.gnu.org/software/grub/manual/multiboot/multiboot.html)
* [Multiboot2](https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html)
* [Linux 32-bit boot protocol](https://www.kernel.org/doc/html/v5.4/x86/boot.html#bit-boot-protocol)
* [Linux EFI handover](https://www.kernel.org/doc/html/v5.4/x86/boot.html#efi-handover-protocol)

View File

@ -1 +0,0 @@
# RFC-0001: RFC Process

View File

@ -1 +0,0 @@
# RFC-0002: Operating System Development Kit (OSDK)

View File

@ -1 +0,0 @@
# RFC Process

View File

@ -19,8 +19,10 @@ aster-time = { path = "comps/time" }
aster-virtio = { path = "comps/virtio" }
aster-rights = { path = "libs/aster-rights" }
aster-systree = { path = "comps/systree" }
aster-keyboard = { path = "comps/keyboard" }
component = { path = "libs/comp-sys/component" }
controlled = { path = "libs/comp-sys/controlled" }
logo-ascii-art = { path = "libs/logo-ascii-art" }
osdk-frame-allocator = { path = "../osdk/deps/frame-allocator" }
osdk-heap-allocator = { path = "../osdk/deps/heap-allocator" }
ostd = { path = "../ostd" }
@ -32,6 +34,7 @@ aster-bigtcp = { path = "libs/aster-bigtcp" }
atomic-integer-wrapper = { path = "libs/atomic-integer-wrapper" }
id-alloc = { path = "../ostd/libs/id-alloc" }
int-to-c-enum = { path = "libs/int-to-c-enum" }
jhash = { path = "libs/jhash" }
cpio-decoder = { path = "libs/cpio-decoder" }
xarray = { path = "libs/xarray" }
intrusive-collections = "0.9.5"
@ -67,12 +70,16 @@ fixed = "1.28.0"
[target.x86_64-unknown-none.dependencies]
tdx-guest = { version = "0.2.1", optional = true }
[target.riscv64gc-unknown-none-elf.dependencies]
[target.riscv64imac-unknown-none-elf.dependencies]
riscv = { version = "0.11.1", features = ["s-mode"] }
[target.loongarch64-unknown-none-softfloat.dependencies]
loongArch64 = "0.2.5"
[features]
all = ["cvm_guest"]
cvm_guest = ["dep:tdx-guest", "ostd/cvm_guest", "aster-virtio/cvm_guest"]
coverage = ["ostd/coverage"]
[lints]
workspace = true

View File

@ -10,6 +10,7 @@ spin = "0.9.4"
ostd = { path = "../../../ostd" }
align_ext = { path = "../../../ostd/libs/align_ext" }
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
aster-util = { path = "../../libs/aster-util" }
component = { path = "../../libs/comp-sys/component" }
log = "0.4"
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }

View File

@ -1,12 +1,14 @@
// SPDX-License-Identifier: MPL-2.0
use align_ext::AlignExt;
use aster_util::mem_obj_slice::Slice;
use bitvec::array::BitArray;
use int_to_c_enum::TryFromInt;
use ostd::{
mm::{
DmaDirection, DmaStream, DmaStreamSlice, FrameAllocOptions, Infallible, USegment, VmIo,
VmReader, VmWriter,
io_util::{HasVmReaderWriter, VmReaderWriterResult},
DmaDirection, DmaStream, FrameAllocOptions, HasSize, Infallible, USegment, VmReader,
VmWriter,
},
sync::{SpinLock, WaitQueue},
Error,
@ -374,10 +376,10 @@ pub struct BioSegment {
/// The inner part of `BioSegment`.
// TODO: Decouple `BioSegmentInner` with DMA-related buffers.
#[derive(Debug, Clone)]
#[derive(Debug)]
struct BioSegmentInner {
/// Internal DMA slice.
dma_slice: DmaStreamSlice<DmaStream>,
dma_slice: Slice<Arc<DmaStream>>,
/// Whether the segment is allocated from the pool.
from_pool: bool,
}
@ -391,7 +393,7 @@ pub enum BioDirection {
ToDevice,
}
impl<'a> BioSegment {
impl BioSegment {
/// Allocates a new `BioSegment` with the wanted blocks count and
/// the bio direction.
pub fn alloc(nblocks: usize, direction: BioDirection) -> Self {
@ -415,16 +417,17 @@ impl<'a> BioSegment {
len: usize,
direction: BioDirection,
) -> Self {
let offset = offset_within_first_block;
assert!(
is_sector_aligned(offset_within_first_block)
&& offset_within_first_block < BLOCK_SIZE
is_sector_aligned(offset)
&& offset < BLOCK_SIZE
&& is_sector_aligned(len)
&& offset_within_first_block + len <= nblocks * BLOCK_SIZE
&& offset + len <= nblocks * BLOCK_SIZE
);
// The target segment is whether from the pool or newly-allocated
let bio_segment_inner = target_pool(direction)
.and_then(|pool| pool.alloc(nblocks, offset_within_first_block, len))
.and_then(|pool| pool.alloc(nblocks, offset, len))
.unwrap_or_else(|| {
let segment = FrameAllocOptions::new()
.zeroed(false)
@ -432,7 +435,7 @@ impl<'a> BioSegment {
.unwrap();
let dma_stream = DmaStream::map(segment.into(), direction.into(), false).unwrap();
BioSegmentInner {
dma_slice: DmaStreamSlice::new(dma_stream, offset_within_first_block, len),
dma_slice: Slice::new(Arc::new(dma_stream), offset..offset + len),
from_pool: false,
}
});
@ -448,7 +451,7 @@ impl<'a> BioSegment {
let dma_stream = DmaStream::map(segment, direction.into(), false).unwrap();
Self {
inner: Arc::new(BioSegmentInner {
dma_slice: DmaStreamSlice::new(dma_stream, 0, len),
dma_slice: Slice::new(Arc::new(dma_stream), 0..len),
from_pool: false,
}),
}
@ -456,7 +459,7 @@ impl<'a> BioSegment {
/// Returns the number of bytes.
pub fn nbytes(&self) -> usize {
self.inner.dma_slice.nbytes()
self.inner.dma_slice.size()
}
/// Returns the number of sectors.
@ -471,41 +474,33 @@ impl<'a> BioSegment {
/// Returns the offset (in bytes) within the first block.
pub fn offset_within_first_block(&self) -> usize {
self.inner.dma_slice.offset() % BLOCK_SIZE
self.inner.dma_slice.offset().start % BLOCK_SIZE
}
/// Returns the inner DMA slice.
pub fn inner_dma_slice(&self) -> &DmaStreamSlice<DmaStream> {
pub fn inner_dma_slice(&self) -> &Slice<Arc<DmaStream>> {
&self.inner.dma_slice
}
/// Returns the inner VM segment.
#[cfg(ktest)]
pub fn inner_segment(&self) -> &USegment {
self.inner.dma_slice.stream().segment()
self.inner.dma_slice.mem_obj().segment()
}
}
/// Returns a reader to read data from it.
pub fn reader(&'a self) -> Result<VmReader<'a, Infallible>, Error> {
impl HasVmReaderWriter for BioSegment {
type Types = VmReaderWriterResult;
fn reader(&self) -> Result<VmReader<'_, Infallible>, Error> {
self.inner.dma_slice.reader()
}
/// Returns a writer to write data into it.
pub fn writer(&'a self) -> Result<VmWriter<'a, Infallible>, Error> {
fn writer(&self) -> Result<VmWriter<'_, Infallible>, Error> {
self.inner.dma_slice.writer()
}
}
impl VmIo for BioSegment {
fn read(&self, offset: usize, writer: &mut VmWriter) -> Result<(), Error> {
self.inner.dma_slice.read(offset, writer)
}
fn write(&self, offset: usize, reader: &mut VmReader) -> Result<(), Error> {
self.inner.dma_slice.write(offset, reader)
}
}
// The timing for free the segment to the pool.
impl Drop for BioSegmentInner {
fn drop(&mut self) {
@ -521,7 +516,7 @@ impl Drop for BioSegmentInner {
impl BioSegmentInner {
/// Returns the bio direction.
fn direction(&self) -> BioDirection {
match self.dma_slice.stream().direction() {
match self.dma_slice.mem_obj().direction() {
DmaDirection::FromDevice => BioDirection::FromDevice,
DmaDirection::ToDevice => BioDirection::ToDevice,
_ => unreachable!(),
@ -536,7 +531,7 @@ impl BioSegmentInner {
/// the `DmaStream`.
// TODO: Use a more advanced allocation algorithm to replace the naive one to improve efficiency.
struct BioSegmentPool {
pool: DmaStream,
pool: Arc<DmaStream>,
total_blocks: usize,
direction: BioDirection,
manager: SpinLock<PoolSlotManager>,
@ -572,7 +567,7 @@ impl BioSegmentPool {
});
Self {
pool,
pool: Arc::new(pool),
total_blocks,
direction,
manager,
@ -634,11 +629,10 @@ impl BioSegmentPool {
.map(|pos| end + pos)
.unwrap_or(self.total_blocks);
let dma_slice = DmaStreamSlice::new(
self.pool.clone(),
start * BLOCK_SIZE + offset_within_first_block,
len,
);
let dma_slice = {
let offset = start * BLOCK_SIZE + offset_within_first_block;
Slice::new(self.pool.clone(), offset..offset + len)
};
let bio_segment = BioSegmentInner {
dma_slice,
from_pool: true,
@ -658,8 +652,8 @@ impl BioSegmentPool {
assert!(bio_segment.from_pool && bio_segment.direction() == self.direction);
let (start, end) = {
let dma_slice = &bio_segment.dma_slice;
let start = dma_slice.offset().align_down(BLOCK_SIZE) / BLOCK_SIZE;
let end = (dma_slice.offset() + dma_slice.nbytes()).align_up(BLOCK_SIZE) / BLOCK_SIZE;
let start = dma_slice.offset().start.align_down(BLOCK_SIZE) / BLOCK_SIZE;
let end = dma_slice.offset().end.align_up(BLOCK_SIZE) / BLOCK_SIZE;
if end <= start || end > self.total_blocks {
return;

View File

@ -28,7 +28,6 @@
//!
#![no_std]
#![deny(unsafe_code)]
#![feature(fn_traits)]
#![feature(step_trait)]
#![feature(trait_upcasting)]

View File

@ -6,9 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
spin = "0.9.4"
ostd = { path = "../../../ostd" }
component = { path = "../../libs/comp-sys/component" }
spin = "0.9.4"
font8x8 = { version = "0.2.5", default-features = false, features = [ "unicode" ] }
[lints]
workspace = true

Some files were not shown because too many files have changed in this diff Show More