528 Commits

Author SHA1 Message Date
Tate, Hongliang Tian
d044be4e49 Update the license to MPLv2 2023-12-26 17:43:45 +08:00
Jianfeng Jiang
77e49d5cd5 Rename the banner 2023-12-26 11:49:24 +08:00
Jianfeng Jiang
7b7e3c4b7a Rename the path of dependent crates 2023-12-26 11:49:24 +08:00
Jianfeng Jiang
632b1937c5 Rename docker image as asterinas/asterinas 2023-12-26 11:49:24 +08:00
Jianfeng Jiang
99f6765ced Rename jinux to asterinas in documentation and code 2023-12-26 11:49:24 +08:00
Jianfeng Jiang
2b248dc326 Rename jinux-runner to aster-runner 2023-12-26 11:49:24 +08:00
Jianfeng Jiang
f3dab1f798 Raname kernel as asterinas 2023-12-26 11:49:24 +08:00
Jianfeng Jiang
93781df27b Rename crates from jinux-* to aster-* 2023-12-26 11:49:24 +08:00
Ruihan Li
6dbf5d560d Improve code readability in BoundSocket
The previous iface observer refactoring exposes some existing code
readability issues (as pointed out by @tatetian). Ideally, it is a bit
better to fix readability issues before doing new code refactoring, but
to avoid complex rebase conflicts, this commit fixes these issues only
after the code refactoring has landed.
2023-12-26 06:51:25 +08:00
Ruihan Li
9f28aae78d Split UDP logic into multiple files
The TCP logic consists of multiple files, each file representing a TCP
state. Since the UPP logic also consists of two states, `BoundDatagram`
and `UnboundDatagram`, this commit puts them into separate files, just
like TCP does.
2023-12-26 06:51:25 +08:00
Ruihan Li
bc771de494 Remove the redundant bound_socket() from ListenStream
There is no need to get the bound socket by cloning the first element
from `self.backlog_sockets`. If we want a bound socket, we can always
use `self.bound_socket` directly.
2023-12-26 06:51:25 +08:00
Ruihan Li
0cc9c5fb3a Implement iface event observers and move Pollee to them
Finally, this commit implements an iface event observer trait for the
`ConnectingStream`, `ListenStream`, and `ConnectedStream` states in
`StreamSocket`, as well as the `BoundDatagram` state in
`DatagramSocket`. It also moves the `Pollee` from `AnyBoundSocket` to
these observer implementors.

What I have tried to do is minimize the semantic changes. Ideally, this
commit should be a pure refactor commit, meaning that even if the
sematics of the previous code is wrong, the sematics after this commit
should be wrong in the same way. Fixing the wrong sematics should be
done in a separate commit afterwards.

However, keeping exactly the same sematics for `ListenStream` is hard.
We used to maintain a `Pollee` for each `BacklogSocket`, but now we can
just maintain one `Pollee` for the whole `ListenStream`. However,
implementing the correct semantics looks much easier, so we just do it.

For `ConnectingStream`, it used to share the same `Pollee` logic with
`ConnectedStream` (because the `Pollee` was maintained by
`AnyBoundSocket`, which is used by both). Now we write the `Pollee`
logic separately for `ConnectingStream`, so we can just write a correct
one or try to reuse the logic in `ConnectingStream`. This commit does
the former.

There should be no semantic changes for `ConnectedStream` in
`StreamSocket` and `BoundDatagram` in `DatagramSocket`.
2023-12-26 06:51:25 +08:00
Ruihan Li
6b903d0c10 Seperate ConnectingStream from InitStream
For TCP streams we used to have three states, e.g. `InitStream`,
`ListenStream`, `ConnectedStream`. If the socket is not bound, it is in
the `InitStream` state. If the socket is bound, it is still in that
state. Most seriously, if the socket is connecting to the remote peer,
but the connection has not been established, it is also in the
`InitStream` state.

While the socket is trying to connect to its peer, it needs to handle
iface events to update its internal state. So it is expected to
implement the trait that observes such events for this later. However,
the reality that sockets connecting to their peers are mixed in with
other unbound and bound sockets in the `InitStream` will complicate
things.

In fact, the connecting socket should belong to an independent state. It
does not share too much logic with unbound and bound sockets in the
`InitStream`. So in this commit we will decouple that and create a new
`ConnectingStream` state.
2023-12-26 06:51:25 +08:00
Ruihan Li
58948d498c Remove incorrect logic about TCP's HUP/RDHUP events
Changes in this commit were suggested by @StevenJiang1110. HUP/RDHUP
events are not correctly updated for TCP sockets (#529), so we are
removing this to avoid further confusion.
2023-12-26 06:51:25 +08:00
Ruihan Li
9dc5a4d28f Box the large structure AnyUnboundSocket
So far it is quite common to put the `AnyUnboundSocket` in an enum
variant, e.g. the following code snippet.
```rust
enum Inner {
    Unbound(AlwaysSome<Box<AnyUnboundSocket>>),
    Bound(AlwaysSome<Arc<AnyBoundSocket>>),
    // ...
}
```

However, this pattern is very memory inefficient because the size
difference between two enum variants is significant. The size of
`AnyUnboundSocket` is much larger than the size of
`Arc<AnyBoundSocket>`, where the latter is simply a pointer and a
reference counter.

In fact, we're about to trigger Clippy's large_enum_variant warning.
We're just below its threshold, so the warning doesn't appear.

The solution is simple: If we put `AnyBoundSocket` in `Arc`, we should
also put `AnyUnboundSocket` in `Box`. This way the sizes of different
enum variants will be similar.
2023-12-26 06:51:25 +08:00
Ruihan Li
02e10705af Use Arc to pack bound datagram structure
For TCP streams we have packed their different states with `Arc`, e.g.
`InitStream`, `ConnectedStream`, and `ListenStream`. Later we will
implement an trait that observes iface events for some of these states.

For UDP datagrams, they can be in the unbound state and the bound state.
If we want to implement the observer trait for the bound state, we need
to wrap it with `Arc` so that it can be registered with
`AnyBoundSocket`.

Alternatively, we can implement the observer trait directly on the UDP
datagram structure (i.e. `DatagramSocket`). However, there are literally
no events to handle if the socket is not bound at all (i.e. it is in the
unbound state). So a more efficient way is to implement the observer
trait only for the bound state, which motivates changes in this commit.
2023-12-26 06:51:25 +08:00
Ruihan Li
246d8521f2 Rename the nonblocking method to is_nonblocking
We used to use `is_nonblocking()` in TCP streams, but use
`nonblocking()` in UDP datagrams.

Since `is_nonblocking()` is generally preferred, this commit renames
`nonblocking()` to `is_nonblocking()` in UDP datagrams.
2023-12-26 06:51:25 +08:00
Ruihan Li
14ee9c2dc7 Fix missing kernel/initramfs memory regions 2023-12-26 06:32:01 +08:00
Ruihan Li
7278589aa2 Prettify bootloader code 2023-12-26 06:32:01 +08:00
Ruihan Li
4e6f281956 CI should fail on triple faults 2023-12-26 06:32:01 +08:00
Ruihan Li
ff7e18b114 Clean up and enable more network tests 2023-12-25 11:39:57 +08:00
Jianfeng Jiang
9a3f95eee2 Fix wrong regression test type 2023-12-24 07:05:24 +08:00
Chen Chengjun
e6f3a6a8a4 Update docker image and add the benchmarks 2023-12-20 18:06:33 +08:00
Chen Chengjun
47d2a895af Fix a bug and support more clockids in vdso. 2023-12-20 16:20:07 +08:00
Jianfeng Jiang
d24775001f Running regression test in ci 2023-12-20 14:18:07 +08:00
Ruihan Li
af81741f23 Workaround for QEMU BUG that causes CI to hang 2023-12-14 11:28:24 +08:00
Yuke Peng
f1a7c767d2 Fix IoMem read and write bugs 2023-12-14 11:26:37 +08:00
Chen Chengjun
2ad9735eab Support VDSO in Jinux 2023-12-06 19:31:19 +08:00
Chen Chengjun
715072b9f3 Implement a high precision gettime based on tsc 2023-12-06 19:31:19 +08:00
Chen Chengjun
ba08895fc3 Fix the frequecy bug caused by IOAPIC 2023-12-06 19:31:19 +08:00
Hsy-Intel
65ef055f4e impl From<TdCallError> for Error 2023-12-06 18:50:53 +08:00
Hsy-Intel
2d0f5253e9 Add error handling 2023-12-06 18:50:53 +08:00
Hsy-Intel
55ea3dc86f Add tdx-guest device 2023-12-06 18:50:53 +08:00
Jianfeng Jiang
a91a35ebce Support alternate signal stack 2023-12-06 12:54:03 +08:00
Jianfeng Jiang
3734306398 Refactor signal code 2023-12-06 11:01:54 +08:00
Jianfeng Jiang
90be8038e0 Add credential-related syscalls 2023-12-06 11:01:54 +08:00
Jianfeng Jiang
c99e6b4ced Implememt static cap credentials 2023-12-06 11:01:54 +08:00
Jianfeng Jiang
2a0446265e Add passwd&group files and enable gvisor uidgid test 2023-12-06 11:01:54 +08:00
Chuandong Li
5aa3124e66 Make the upgrade method of read-write locks atomic 2023-12-06 10:40:11 +08:00
Chuandong Li
07dd0fbd38 Fix the misuse of spin::mutex 2023-12-06 10:22:03 +08:00
Yingdi Shan
f6b01c1da2 Allow commit author emails to be @[mail.]zgclab.edu.cn 2023-12-01 10:02:59 +08:00
Chuandong Li
0fd7a473da Support streaming dma mappings 2023-11-29 13:39:54 +08:00
Chuandong Li
ceaba95fa0 Support coherent dma mappings 2023-11-29 13:39:54 +08:00
Jianfeng Jiang
ce5730287e Refactor session & tty code 2023-11-28 12:11:54 +08:00
Jianfeng Jiang
3bde0f6bb7 Add unit test for session and group 2023-11-28 12:11:54 +08:00
Jianfeng Jiang
9d8a2b420d Refactor tty&pty code 2023-11-28 12:11:54 +08:00
Jianfeng Jiang
001326110e Add trait FileIo and refactor current devices 2023-11-28 12:11:54 +08:00
Jianfeng Jiang
43fd1a52fa Add syscall getsid, setsid and refactor other syscalls 2023-11-28 12:11:54 +08:00
Jianfeng Jiang
9040fb54ea Add basic structures for session, terminal and job control 2023-11-28 12:11:54 +08:00
LI Qing
2edbe1f725 Add as_device method for file handle 2023-11-28 12:11:54 +08:00