-
Notifications
You must be signed in to change notification settings - Fork 121
TMK documentation #1188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
romank-msft
wants to merge
1
commit into
microsoft:main
Choose a base branch
from
romank-msft:tmk_doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
TMK documentation #1188
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Test microkernels | ||
|
||
## What TMKs are | ||
|
||
During the lifetime of a VM, the guest operating system might request services that | ||
require assitance from the VMM or the hypervisor. In turn, that rests on the correct | ||
implementation of several concepts like interrupt processing, memory mappings, | ||
maintaining caches of the (virtual) hardware, etc that are both critical for the normal | ||
work of the guest OS, and hard to test. That is the case due to the guest OSes not | ||
allowing or even breaking down should any unexpected interaction happen with these | ||
low-level building blocks. Let alone it is not very prudent to incorporate a | ||
test for a VMM or a hypervisor into a guest kernel and release the kernel that way! | ||
|
||
OpenVMM includes a test harness that allows running TMKs (test microkernels) - the tests | ||
which are built and work just like guest kernels: no standard library is available and | ||
they have access to all (virtual) hardware. The code runs in an environment that normally | ||
predates running a full-fledged modern kernel so the tests can work with the hardware | ||
directly without the imposion of any specific kernel architecture. | ||
|
||
The TMKs use a specific protocol geared towards testing with a VMM. Nonetheless, you | ||
can use TMKs as a starting point in learning how the hadrware works and (with some | ||
effort) can run some bare-metal. | ||
|
||
## What TMKs solve | ||
|
||
TMKs allow testing the primitives the guest kernels rely on in a minimal, unencumbered | ||
setting. The value of adding a TMK is to make sure that the most fundamental building blocks | ||
on which rests the entirety of other code are implemented correctly, and the guest kernel | ||
will run correctly. | ||
|
||
## How to run a TMK | ||
|
||
```admonish note | ||
The command lines and other specifics may change as the TMKs are under heavy development. | ||
``` | ||
|
||
1. Build it: | ||
|
||
```sh | ||
cargo build -p simple_tmk --config openhcl/minimal_rt/x86_64-config.toml --release | ||
``` | ||
|
||
2. See the list of tests: | ||
|
||
```sh | ||
cargo run -p tmk_vmm -- --tmk target/x86_64-unknown-none/release/simple_tmk --list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arm64: cargo run -p tmk_vmm -- --tmk target/aarch64-minimal_rt-none/release/simple_tmk --list |
||
``` | ||
|
||
```console | ||
common::boot | ||
x86_64::apic::enable_x2apic | ||
x86_64::apic::self_ipi | ||
x86_64::ud2 | ||
``` | ||
|
||
3. Choose a specific test, or run all (the default): | ||
|
||
```sh | ||
cargo run -p tmk_vmm -- --tmk target/x86_64-unknown-none/release/simple_tmk --hv kvm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arm64 cargo run -p tmk_vmm -- --tmk target/aarch64-minimal_rt-none/release/simple_tmk --hv hvf can use whp or kvm, too |
||
``` | ||
|
||
```console | ||
2025-04-15T17:09:58.227718Z INFO test: test started, name: "common::boot" | ||
2025-04-15T17:09:58.237776Z INFO tmk: hello world | ||
2025-04-15T17:09:58.238365Z INFO test: test passed, name: "common::boot" | ||
2025-04-15T17:09:58.238413Z INFO test: test started, name: "x86_64::apic::enable_x2apic" | ||
2025-04-15T17:09:58.241427Z INFO tmk: apic base: 0xfee00900 ApicBase { | ||
bsp: true, | ||
x2apic: false, | ||
enable: true, | ||
base_page: 0xfee00, | ||
} | ||
``` | ||
|
||
```console | ||
2025-04-15T17:09:58.241531Z ERROR tmk: location: "tmk/simple_tmk/src/x86_64/apic.rs:27", panic: "called `Result::unwrap_err()` on an `Ok` value: ()" | ||
2025-04-15T17:09:58.241835Z INFO test: test failed, name: "x86_64::apic::enable_x2apic", reason: "explicit failure" | ||
2025-04-15T17:09:58.241883Z INFO test: test started, name: "x86_64::apic::self_ipi" | ||
2025-04-15T17:09:58.244164Z ERROR tmk: location: "tmk/simple_tmk/src/x86_64/apic.rs:79", panic: "assertion failed: got_interrupt.load(Relaxed)" | ||
2025-04-15T17:09:58.244461Z INFO test: test failed, name: "x86_64::apic::self_ipi", reason: "explicit failure" | ||
2025-04-15T17:09:58.244520Z INFO test: test started, name: "x86_64::ud2" | ||
2025-04-15T17:09:58.246944Z ERROR tmk: location: "tmk/simple_tmk/src/x86_64/mod.rs:28", panic: "assertion failed: recovered.load(Relaxed)" | ||
2025-04-15T17:09:58.247228Z INFO test: test failed, name: "x86_64::ud2", reason: "explicit failure" | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for arm64:
as the
aarch64-unknown-none
doesn't support static PIEs.