-
Notifications
You must be signed in to change notification settings - Fork 60
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
arm64/vmm: Preserve PSR_C64 when injecting an exception #2255
base: dev
Are you sure you want to change the base?
Conversation
This looks to be the bug @kwitaszczyk was running into, and the cause of the problem aligns with what @bsdjhb and I had managed to ascertain at the PI meeting. |
The handling of vbar_el1 also looks a bit dodgy. If CPACR_EL1.CEN[0] is 0 then CVBAR_EL1 is just interpreted as VBAR_EL1 by the architecture when trapping to EL1 (setting PCC's address to it), which means we need to derive a capability for tf_elr from elr_el1. |
2210edc
to
4fea6a9
Compare
This should be testable by running GDB against a plain FreeBSD VM, setting a breakpoint from GDB and triggering a breakpoint from within the VM, just as for the SPSR C64 issue except with a FreeBSD guest. I'm not sure how exactly I expect it to break, whether it'll get stuck in a trap loop or end up in bhyve. Hopefully at least it doesn't wedge the host, which should be true as long as some of this code is preemptible... otherwise there are other ways a malicious guest could trigger the same kinds of issues even with correct handling here. |
Unfortunately, it doesn't seem the host kernel enters the block of |
Can you add a trace to see if |
It doesn't seem
and I don't get anything in the serial console. |
4fea6a9
to
5788478
Compare
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.
I do think there are other things to check (CEN) that Jess noted, but this is certainly an improvement over what is there now.
I have a patch to address that comment, but had been holding off on pushing it until I could test with hybrid kernels. Now I'm looking at an apparent regression with the VHE merge after I rebased onto dev; hopefully it won't take too long to fix. |
Is this blocked on the VHE regression or can this be merged as-is? |
5788478
to
4641655
Compare
The latest PR addresses this. Without the patch, the bhyve vcpu threads end up in a loop somewhere, but the VM is killable, the bug doesn't bring down the host. |
It's not required, and causes the host to freeze when single-stepping a guest, for reasons that I don't understand. The problem appeared only after we started using VHE by default.
When the CPU is configured to trap upon execution of Morello-specific instructions or access of Morello-specific control registers, i.e., vmm is executing a vanilla aarch64 guest, we need to derive a capability from elr_el1, since upon exception entry the capability value of PCC is set to VBAR_ELx.
4641655
to
0d15d77
Compare
Re MDSCR_EL1.KDE, the relevant points are:
I think though this also means that breakpoints are enabled in this window for VHE, so were one to place a guest breakpoint at an address that is in the window where we're world switching we'd see that breakpoint be hit in the host. Single-stepping with MDSCR_EL1.KDE just makes this issue more obvious because it immediately takes effect wherever you are. Now, I agree that MDSCR_EL1.KDE is unnecessary here. ELD is always going to be EL2 already thanks to MDCR_EL2.TDE so there's no need to set it for single-stepping EL1. However, the fact that it breaks things also shows that there is this other bug with regards to PSTATE.D; MDSCR_EL1.KDE's value should be entirely irrelevant. I believe that, were one to set PSTATE.D for the VHE case like happens implicitly from the trap in the nVHE case, the single-step issue would also be fixed. |
I'm not sure if this might be simplistic, but it resolves a problem I see with breakpoint injection from bhyve's gdb stub. This arises when the debugger has installed a breakpoint, and the guest triggers a breakpoint exception some other way, e.g., a dtrace FBT probe.