Hector Martin
5eed8f674d
hv_vm: Fix guest SError handling
...
This was broken, but somewhat masked by another bug in hv_vm.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 22:17:52 +09:00
Hector Martin
56c3d93787
hv_exc: Enable SErrors in the hypervisor
...
This finally works properly now
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 21:18:13 +09:00
Hector Martin
78cf104b1f
hv_vm: Guard emulated read/writes to catch SErrors/aborts
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 21:18:13 +09:00
Hector Martin
25bc815821
hv: Store exception info regs on entry, and use it
...
This is the second part of allowing nested exceptions
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 21:18:13 +09:00
Hector Martin
bce239b36f
exception: Make space in the stack for full exception context
...
This is step 1 of the rework to make reentrant exceptions work
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 20:29:19 +09:00
Hector Martin
a16731e8b3
hv_exc: Avoid delivering spurious HV-triggered IPIs to the guest
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 17:13:03 +09:00
Hector Martin
0e3770ca47
hv, m1n1.hv: Add cpu() command to switch CPU contexts
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 13:18:06 +09:00
Hector Martin
977cbdf4f8
hv_exc: New time accounting around Python callbacks
...
This does an explicit hypervisor rendezvous. It's not great because it
introduces spurious guest IPIs, but xnu doesn't seem to care...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-21 13:17:00 +09:00
Hector Martin
c3ba77ce16
hv_exc: Handle SYS_IMP_APL_CYC_OVRD in the fast path
...
m1n1 now uses this for SMP, and due to wfi FIQ leakage from the HV
timer this gets spammed thousands of times per second. Handle it in
the HV directly.
Fixes : #107
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-18 22:33:28 +09:00
Hector Martin
09a44e5a92
hv_exc: Disable stolen time accounting
...
This doesn't work with SMP.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:32:57 +09:00
Hector Martin
184a516367
hv_exc: Make IPI/IRQ/timer/PMC emulation storage per-CPU
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:26:14 +09:00
Hector Martin
56b54a6641
hv_vm/hv_exc: Add cpu_id to exception & mmiotrace structs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:24:37 +09:00
Hector Martin
787c46e8c7
hv_exc: Add a Big Hypervisor Lock
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:24:37 +09:00
Hector Martin
f8110dd409
hv_exc: Handle M1RACLES mitigation here due to 12.0 spam
...
macOS 12.0 added a silly ineffective "mitigation" that clears the
register on every context switch. This doesn't actually mitigate
anything, but it does make this sysreg trap performance-critical,
so we have to move its handling into the C side.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:30:18 +09:00
Sven Peter
e0d889fac1
hv: add proper single stepping support
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-07-09 15:52:40 +09:00
Janne Grunau
4b5c016368
hv: disable PMU counters inside the hypervisor
...
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-09 19:47:20 +09:00
Janne Grunau
d61bf13cb0
hv: shadow perf monitor IRQ mode and state
...
The development Mac OS kernel panics if the PMCR0 sysreg is in an
unexpected state. To avoid that the hypervisor needs to shadow the
interrupt mode and interrupt active flag after it mask the PM FIQ.
Mac OS reads and writes frequently from PMCR0 and PMC 0/1 so handling
in m1n1 is preferred over Python.
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-09 19:47:20 +09:00
Hector Martin
393089f076
hv_exc: Also pass through (E)HID4, since it's noisy
...
This seems to be poked every time the kernel does a specific kind of
dcache flush...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-30 03:37:12 +09:00
Hector Martin
f1cfe27e31
hv: Use AFSR_GL1 when in guarded mode.
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-30 03:34:17 +09:00
Hector Martin
775902112d
hv.py: Add M1RACLES mitigation
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 02:41:17 +09:00
Hector Martin
12a7a0f1bb
hv_exc: Allow the guest to see a bit of stolen time
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 02:13:23 +09:00
Hector Martin
fe2e89573e
hv: Move break handling to hv_tick(), properly poll
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 02:13:23 +09:00
Hector Martin
db0252a1d6
hv_exc: Steal time from the guest during HV exceptions
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 00:38:42 +09:00
Hector Martin
dd443d2c2c
cpu_regs: Fix missing IMP_APL prefixes
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 00:38:11 +09:00
Hector Martin
0265edebba
hv_exc: Add ACTLR_EL1 sysreg forwarding
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 00:37:48 +09:00
Hector Martin
bfe8c94c47
hv_wdt: Add hypervisor watchdog on secondary core
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:28:43 +09:00
Hector Martin
a5a974791b
hv: Support handling GL2 exceptions
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:28:43 +09:00
Hector Martin
81808da562
hv_exc: Set the step timer to 100 cycles
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
e92e075fba
hv_exc: Add IPI and guest timer FIQ virtualization
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
75f206e65c
hv_exc, hv.py: Add support for interrupting guest with ^C
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
2e014f58fa
hv: Implement a periodic hypervisor ptimer and use vtimer for stepping
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
1b1653dfe9
hv_vm: Simplify r31 handling, move LR adjustment to hv_exc.c
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
afc088840d
hv: Add Python-side MMIO emulation hooks
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 23:57:48 +09:00
Hector Martin
ed32cf6328
hv_exc: Add a hacky STEP feature to interrupt guest after a while
...
This should eventually be a proper single step feature or something, but
for now...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
9407dba2e0
hv_vm: Initial data abort handling
...
Supports software-mapping for a subset of ldr/str instructions.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 04:03:44 +09:00
Hector Martin
8a64441bcd
hv_vm: Extend hv_translate() for stage1 and write modes
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 03:27:19 +09:00
Hector Martin
0e987f031b
utils: Add flush_and_reboot() to do the iodev flush dance
...
Use this for exceptions, asserts, etc.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 03:21:48 +09:00
Hector Martin
50f112c396
hv: Add support for address translation & abort decoding
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 00:28:39 +09:00
Hector Martin
a3440f2b48
hv: Support cleanly exiting the hypervisor from an exception
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 00:28:39 +09:00
Hector Martin
4d64c33ca6
hv: Implement basic exception handling
...
Allows Python to handle hypervisor exceptions, and implements exception
info display and basic debug commands.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:36:23 +09:00