-
Notifications
You must be signed in to change notification settings - Fork 29
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
virt_to_phys: breaks if guest_address is not equal to 0 #713
Comments
The conclusion is that the physical address of the PML4 has to be changed accordingly, and that the control register that stores By adding the offset An open question is whether this can be fixed in Uhyve. (Edit: Identical behavior to Line 223 in efc3563
|
Related: #719 |
To summarize the issue: The page tables must reside within the physical memory space. Hermit uses recursive pagetables, so it is agnostic to the location of PML4, as long as the location is written to the last entry in PML4: Lines 176 to 184 in e6ffffa
So, I think this is quite solvable by modifying
|
uhyve/src/linux/x86_64/kvm_cpu.rs Line 244 in e6ffffa
Completely missed that part, I will take a look. Thank you! |
I tried an entirely different method other than using It still doesn't 100% work and I am not 100% pleased with it - I will have to go over this one with you. The |
First attempt (lots of dirty hacks, some hardcoded things, non-conventional variable names etc. etc., It seems like I've gotten a little bit further as the tests pass, but I am getting an error here - so something is not writing in something else properly: As I am not completely sure whether essentially ignoring the (Problem: EDIT: That was the case! Solved in 96e7939, but now I'm dealing with another error. Tree: https://github.com/n0toose/uhyve/tree/make-it-boot |
This is the result of an excruciatingly long debugging session for #711.
Say that we want to replace
arch::RAM_START
in the line 98 of vm.rs:uhyve/src/vm.rs
Line 94 in efc3563
... to
let mem = MmapMemory::new(0, memory_size, GuestPhysAddr::new(0x20000), params.thp, params.ksm);
.So,
guest_address
will be equal to0x20000
. There are many parts of the code which effectively already consider this case, by subtractingself.mem.guest_address
. This is very often the case invm.rs
.Debugging this was much more difficult because of the fact that the process "froze". With
cargo test gdb
(I could've used gdb) and LLDB running on the side. A previous indicator that something inphys_to_virt
is broken was running the following test with a similar change:uhyve/src/arch/x86_64/mod.rs
Line 372 in efc3563
This would always return a
WrongMemoryError
.virt_to_phys
invokes a function calledmem.host_address(pagetable_l0)
:uhyve/src/arch/x86_64/mod.rs
Line 208 in efc3563
That function has two conditions (function slightly modified for clarity and because it was easier for me to debug that way):
Let's take a look at
read_addrs
inuhyve/src/linux/gdb.rs
:uhyve/src/linux/gdb/mod.rs
Line 129 in efc3563
This uses a constant:
pub const BOOT_PML4: GuestPhysAddr = GuestPhysAddr::new(0x10000);
uhyve/src/consts.rs
Line 12 in efc3563
which is passed onto:
uhyve/src/linux/gdb/mod.rs
Line 134 in efc3563
... as the
pagetable_l0
variable, which is in turn passed as theaddr
variable. If we choose a guest_address equal to0x20000
, the first condition will fail.This error basically pops up everywhere, one way or another, when the guest_address is modified. This was the best and most reproducible case that I could find after spending hours of trying to crack it for #711.
The text was updated successfully, but these errors were encountered: