Add the first two chapters about Asterinas Kernel

This commit is contained in:
Tate, Hongliang Tian 2024-01-23 15:56:00 +08:00
parent 38022ff7f1
commit 2e83322b34
4 changed files with 112 additions and 2 deletions

View File

@ -5,6 +5,7 @@
# Asterinas Kernel # Asterinas Kernel
* [Getting Started](kernel/README.md) * [Getting Started](kernel/README.md)
* [Advanced Build and Test Instructions](kernel/advanced-instructions.md)
* [A Zero-Cost, Least-Privilege Approach](kernel/the-approach/README.md) * [A Zero-Cost, Least-Privilege Approach](kernel/the-approach/README.md)
* [Framekernel OS Architecture](kernel/the-approach/framekernel.md) * [Framekernel OS Architecture](kernel/the-approach/framekernel.md)
* [Component-Level Access Control](kernel/the-approach/components.md) * [Component-Level Access Control](kernel/the-approach/components.md)

View File

@ -1 +1,36 @@
# Getting Started # Asterinas Kernel
## Overview
Asterinas is a _safe_, _fast_, and _general-purpose_ OS kernel that provides _Linux-compatible_ ABI. It can serve as a seamless replacement for Linux while enhancing _memory safety_ and _developer friendliness_.
* Asterinas prioritizes memory safety by employing Rust as its sole programming language and limiting the use of _unsafe Rust_ to a clearly defined and minimal Trusted Computing Base (TCB). This innovative framework, known as [the framekernel architecture](), establishes Asterinas as a more secure and dependable kernel option.
* Asterinas surpasses Linux in terms of developer friendliness. It empowers kernel developers to (1) utilize the more productive Rust programming language, (2) leverage a purpose-built toolkit called [OSDK]() to streamline their workflows, and (3) choose between releasing their kernel modules as open source or keeping them proprietary, thanks to the flexibility offered by [MPL]().
While the journey towards a production-grade OS kernel can be challenging, we are steadfastly progressing towards our goal. Currently, Asterinas only supports x86-64 VMs. However, [our aim for 2024]() is to make Asterinas production-ready on x86-64 for both bare-metal and VM environments.
## Getting Started
Get yourself an x86-64 machine with Docker installed. Follow the three simple steps below to get Asterinas up and running.
1. Download the latest source code.
```bash
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 asterinas:/root/asterinas asterinas/asterinas:0.3.0
```
3. Inside the container, go to the project folder to build and run Asterinas.
```bash
make build
make run
```
If everything goes well, Asterinas is now up and running inside a VM.

View File

@ -0,0 +1,75 @@
# Advanced Build and Test Instructions
## User-Mode Unit Tests
Asterinas consists of many crates, some of which do not require a VM environment and can be tested with the standard `cargo test`. They are listed in the root `Makefile` and can be tested together through the following Make command.
```bash
make test
```
To test an individual crate, enter the directory of the crate and invoke `cargo test`.
### Kernel-Mode Unit Tests
Many crates in Asterinas do require a VM environment to be tested. The unit tests for these crates are empowered by our [ktest](framework/libs/ktest) framework.
```bash
make run KTEST=1
```
It is also possible to specify a subset of tests to run.
```bash
make run KTEST=1 KTEST_WHITELIST=failing_assertion,aster_frame::test::expect_panic KTEST_CRATES=aster-frame
```
## Integration Test
### Regression Test
The following command builds and runs the test binaries in `regression/apps` directory on Asterinas.
```bash
make run AUTO_TEST=regression
```
### Syscall Test
The following command builds and runs the syscall test binaries on Asterinas.
```bash
make run AUTO_TEST=syscall
```
To run system call tests interactively, start an instance of Asterinas with the system call tests built and installed.
```bash
make run BUILD_SYSCALL_TEST=1
```
Then, in the interactive shell, run the following script to start the syscall tests.
```bash
/opt/syscall_test/run_syscall_test.sh
```
## Debug
### Using GDB to Debug
To debug Asterinas using [QEMU GDB remote debugging](https://qemu-project.gitlab.io/qemu/system/gdb.html), one could compile Asterinas in the debug profile, start an Asterinas instance and run the GDB interactive shell in another terminal.
First, start a GDB-enabled VM of Asterinas and wait for debugging connection:
```bash
make run GDB_SERVER=1 ENABLE_KVM=0
```
Next, start a GDB client in another terminal.
```bash
make run GDB_CLIENT=1
```
Currently, the Asterinas runner's debugging interface is exposed via UNIX sockets. Thus there shouldn't be multiple debugging instances in the same container. To add debug symbols for the underlying infrastructures such as UEFI firmware or bootloader, please check the runner's source code for details.

View File

@ -1 +0,0 @@
# Getting Started