Commit graph

30 commits

Author SHA1 Message Date
Changyuan Lyu
d7e2955ace refactor: move Payload into module loader
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-29 09:38:55 -07:00
Changyuan Lyu
5267efa766 refactor: move Board to a seperate mod
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-29 09:38:55 -07:00
Changyuan Lyu
1f3f298dc6 feat(mem)!: rename module ram to mapped
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
f3c2ba6bd9 feat(mem)!: rename module mmio to emulated
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
8ff458c112 test(mem): add/remove memory regions
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
37747eee6e feat(mem)!: rewrite the memory module
Before this commit, a continuous memory region can only be backed by
either a single ArcMemPages or a single MmioRange.
If a guest memory region contains both mmap()-ed pages and emulated
MMIO regions, we then need to split it into sub-regions. However,
once these sub-regions are added to the memory bus as slots, we can
no longer tell if a slot is a sub-region or a not.

It becomes difficult to handle when a guest tries to relocate
a region to a different physical address. For example, a PCI device
can re-program its BARs. We do not know if a few slots need to be
moved as a whole or not.

This commit re-designs the module `mem` by introducing `MemRegion`.
* From guest's point of view, it can have multiple sub-regions of
  different e820 types.
* From host's point of view, it is a collection of mmap()-ed host
  memories, emulated MMIO regions, and maybe some holes in between.
  Backends are grouped so they can be moved easily.

It also enables us to allocate the address for a group of slots.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
61e468bdfa feat!: move Action into module mem
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
47ab9355aa refactor(ram): move slot_id out of MemPages
The magic `UNASSIGNED_SLOT_ID` is then not needed any more.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
31d201865b refactor(mem): remove the MmapCallback trait
Similar to b82af2a ("refactor(mmio): simplify MmioBus
implementation"), a future commit will provide a general solution
for both mmap()-ed pages and emulated MMIO regions.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
a816105366 feat(mem)!: rename UserMem to ArcMemPages
The name `UserMem` was from KVM. `MemPages` sounds more
straightforward, indicating it is just a few pages requested directly
from the OS.

The name `ArcMemPages` indicates that it is cheap to call clone().

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
e09b6d27e6 refactor(mmio): simplify MmioBus implementation
Remove the mapped(), ummapped() method from the Mmio trait, since
generally mmap()-ed pages should also have these callbacks. A future
commit will provide a general solution.

Remove the unnecessary intermediate struct MmioRange.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
b44bb87b87 feat!: use RwLock and Mutex from parking_lot
`RwLock` is used a lot and the feature `hardware-lock-elision` looks
very promising.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
0580084834 refactor(io): use MmioBus as the x86 IO bus
There is no need to introduce a new module to model the IO bus.
MMIO and IO are basically the same thing except the address width.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-27 12:54:06 -07:00
Changyuan Lyu
ee37fa2af9 feat(mem): add add_within() method for Addressable
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
Changyuan Lyu
06434c414c test(mem): add more test cases in test_addressable
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
Changyuan Lyu
3972c33660 fix(mem): avoid overflows in address calculation
test_addressable() now can pass.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
Changyuan Lyu
4d496924c1 test(mem): catch numeric overflows in addr_end()
If the last 0x2000 bytes of the address range have been occupied,
adding another backend for the last 0x1000 bytes is supposed to
fail, but does not with the current implementation, due to the
numeric overflow in addr_end().

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
Changyuan Lyu
53dd02480e chore(git): ignore vsocde configs
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
Changyuan Lyu
5dd03efbd7 fix(mem): return runtime error for zero-sized slot
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
Changyuan Lyu
af08d15a96 feat(mem): return impl DoubleEndedIterator
This avoids introducing a new struct.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-26 00:06:54 -07:00
dependabot[bot]
7a320ca4a7 ci: Bump actions/checkout from 4.1.3 to 4.1.4
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.3 to 4.1.4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1d96c772d1...0ad4b8fada)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 23:32:29 -07:00
Changyuan Lyu
9744d9ad0a ci: add github actions
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 23:28:57 -07:00
Changyuan Lyu
d3fb3af2bf ci: add Cirrus CI
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
ae0aae04f8 build: use stable rust as default
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
489df47eaa chore: ignore log files
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
b21388426e feat!: remove backtrace from Error enums
It is an inevitable regression if we want to build
with stable rust :(

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
18e6566afa build: remove feature pointer_is_aligned
This feature will be stable in rust 1.79.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
0fa9d8ca61 tests: use crate assert_matches for stable rust
The assert_matches in std still requres nightly rust.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
22b4c65b3e build: update dependencies
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 22:06:25 -07:00
Changyuan Lyu
7f2e3bf287 Initial release
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2024-04-24 19:34:14 -07:00