This will simplify the implementation of reboots. We will just need
to add a loop to the vcpu threads instead of going back to the VMM
thread to recreate all vcpu threads and devices.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Rust 2018 introduced a new directory structure `foo.rs + foo/bar.rs`
to replace the old `foo/mod.rs + foo/bar.rs` for a module `foo` with
submodule `bar`. While it solved the issue of "a bunch of tabs named
mod.rs", it introduced a new problem. If a lib has multiple modules
with submodules, most file browsers list directories before files,
```
├── lib.rs
├── foo1
│ └── bar1.rs
├── foo2
│ └── bar2.rs
├── foo3
│ └── bar3.rs
├── foo1.rs
├── foo2.rs
└── foo3.rs
```
and thus visually `foo1` is far from `foo1.rs`.
This commit introduces a customized file hierarchy: for a module
`foo` and its submodule `bar`, we place the source code in
`foo/foo.rs` and `foo/bar.rs` respectively, so we can avoid `mod.rs`
and also put source files of a module in a single directory.
For sure this breaks the community convention and we have to use the
`path` attribute every time.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
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>
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>
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>
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>
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>
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>