Commit graph

330 commits

Author SHA1 Message Date
Janne Grunau
3128956a8e hv.py: support device specific mmiotrace handlers
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-15 15:41:50 +09:00
Janne Grunau
670ce212d1 hv.py: style: use shorter conditional statements in handle_mmiotrace()
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-15 15:41:50 +09:00
Janne Grunau
1d6a9c5257 utils.py: prepare AddrLookup for device specific mmiotrace handlers
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-15 15:41:50 +09:00
Hector Martin
e833e3c052 run_guest.py: Fix usage without -m or -c
Closes: #75

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-11 11:59:21 +09:00
Janne Grunau
d525979fb7 proxy/tools: add reboot.py
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-11 11:41:24 +09:00
Hector Martin
edbe471804 run_guest.py: Add options to run external scripts:
-m <script>

  Run a script in hypervisor context prior to starting the guest.
  This is essentially the same as the shell context.

-c <code>
  Run a literal string of code prior to starting the guest.

-S
  Start a shell instead of directly starting the guest. Use `start` to
  actually begin guest execution.

This also adds a couple example scripts under hv/.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-10 22:37:12 +09:00
Hector Martin
d9561b7507 proxyclient: Big cleanup/move to module
All the common/importable stuff now lives in the 'm1n1' module.

General use tools are in tools/

Reverse engineering experiments are in experiments/

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-10 19:40:48 +09:00
Janne Grunau
88275b5cb5 hv: add AIC interrupt tracing
Implemented by MMIO tracing of AIC's event register. Proposed by pipcet.

Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-10 15:41:02 +09:00
Janne Grunau
012d8964f9 adt.py: improve "interrupts" parsing
Correct parsing would require a second pass to use the
interrupt-parent's "#interrupt-cells".

Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-10 15:41:02 +09:00
Vincent Duvert
1a95a9fc17 Shell: do not access properties on startup
Change the way the shell finds methods to add to the locals on startup: the
methods are queried on the object’s class, rather than the object itself. This
allows detecting if an object’s member is a property and ignore it, rather than
accessing the property.

Attributes whose name starts by ‘_’ are also now ignored, which avoids
importing private methods or Python magic methods in the shell namespace.

Fixes spurious accesses to ProxyUtils’s SIMD properties (b, h, etc) on shell
startup, which caused a ProxyCommandError if m1n1 is not recent enough.

Signed-off-by: Vincent Duvert <vincent@duvert.net>
2021-06-09 19:47:54 +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
Sven Peter
c47f1b2095 proxy: add dart_dump.py
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-06-09 19:45:55 +09:00
Hector Martin
7b22a72442 hv.py: Add reboot() command to reboot the system and exit
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-04 15:09:59 +09:00
Hector Martin
a175b6d159 proxy: Add reboot() call to hard reboot the system
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-04 15:09:11 +09:00
Hector Martin
89a7a3a5b1 proxy.py: Rename reboot() to reload()
reboot() is confusing (it doesn't reboot the system)

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-04 15:00:24 +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
c794ea6dc2 hv_vuart: Make compatible with xnu and enable
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-30 01:39:26 +09:00
Hector Martin
a5c7e1557f proxy.py: Make compatible with older pyserial
We don't use this right now, anyway

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-30 01:22:22 +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
469b1258c0 hv.py: Branding 2021-05-28 02:13:23 +09:00
Hector Martin
3427bc0a2e hv.py: Be more selective about MMIO tracing
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 02:13:23 +09:00
Hector Martin
64973d43a5 hv.py: Disable exception patching
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 02:13:23 +09:00
Hector Martin
f502dc7a83 hv.py: Activate logo improvements
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 02:13:23 +09:00
Hector Martin
66fc157e94 fb: Improve visuals
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 00:45:05 +09:00
Hector Martin
3a44625803 hv.py; mmiotrace: Show op width
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-28 00:00:54 +09:00
Hector Martin
77a36a7d34 utils,proxy: Add basic SIMD register fetch and mutation support
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 22:57:25 +09:00
Hector Martin
5d0f6e21f6 utils: Coerce address lookup addresses to int
If this is a wrapper class, "in range()" is not optimized and does a
linear scan through the range...

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 22:14:09 +09:00
Vincent Duvert
3d1747466b Add an option to disable checksumming if possible
* Introduce feature flags which allows the proxy and m1n1 to determine which
features they have in common.
* Add a feature flag that disables checksumming (by replacing checksums with
constant values) for the data packets exchanged by REQ_MEMREAD, REQ_MEMWRITE
and REQ_EVENT. The feature is enabled if m1n1 supports it; checksumming is kept
enabled for UART communication.
* To ensure no packet loss when checksumming is disabled, an extra sentinel
value is added after the exchanged data for memory read/write operations.

Signed-off-by: Vincent Duvert <vincent@duvert.net>
2021-05-27 21:34:37 +09:00
Janne Grunau
16f0abe6bb hv.py: resolve adresses from ADT in mmiotrace
Signed-off-by: Janne Grunau <j@jannau.net>
2021-05-27 21:32:05 +09:00
Janne Grunau
67cdf57540 adt.py: add option to retrieve the adt from m1n1
Signed-off-by: Janne Grunau <j@jannau.net>
2021-05-27 21:32:05 +09:00
Janne Grunau
07314994ed adt.py: raise AttributeError in ADTNode._getattr__()
Signed-off-by: Janne Grunau <j@jannau.net>
2021-05-27 21:32:05 +09:00
Hector Martin
2aa41192ed hv.py: Put back UART MMIO bypass
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:29:58 +09:00
Hector Martin
0f99ee834d hv.py: Put back most of the removed ADT nodes
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:29:58 +09:00
Hector Martin
dedada1f57 hv.py: Remove sync mode from main MMIO region
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:29:58 +09:00
Hector Martin
85411d1714 hv_vm: Add support for 128-bit ops, stp/ldp, fix some emu bugs
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:29:58 +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
45960036c8 find_regs.py: Fix typo
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-27 21:10:37 +09:00
Hector Martin
f44942015f hv.py: Current mmiotrace config/experiments
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
5d8b3a1ab1 hv.py: Remove more devices for testing
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
59cf1a1bcd hv.py: Map low physmem to the guest
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
c943af62b9 hv: Enable FIQ trapping
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
ba3a1b1028 hacr_trap_bits.py: Enable GXF around checks
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
e99680cb1e hv: Rename HV_HOOK proxy start type to HV
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-25 20:12:20 +09:00
Hector Martin
989625ac65 adt.py: Support /-separated node path accesses 2021-05-22 04:42:38 +09:00
Hector Martin
4cc22c73c0 hv.py: Add a novm mode without stage 2 translation
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 04:42:38 +09:00
Hector Martin
81bf0ad578 apple_regs.json: More GXF and SPRR registers
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 04:42:38 +09:00
Hector Martin
a9c189fe27 hv.py: Add more sysreg redirects
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 04:42:38 +09:00
Hector Martin
5f7aded3ce find_sprr_regs.py: Port to find_regs.py, fixes
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 04:42:38 +09:00
Hector Martin
30e14f1a0b find_regs: Modular version of find_all_regs.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 03:21:01 +09:00
Hector Martin
d82f5db064 apple_regs.json: Add CNTPCT_ALIAS_EL0
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 03:21:01 +09:00
Hector Martin
81793508ae proxyutils.py: Use sysreg_parse() for mrs/msr
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 03:21:01 +09:00
Hector Martin
91a94992ea proxyutils.py: Improve the various exec() modes
Now we can just say call="el1" etc., and it takes care of the region for
you.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 03:21:01 +09:00
Hector Martin
d0995e0653 proxyutils: Make GuardedHeap able to take a single Heap argument
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 03:21:01 +09:00
Hector Martin
7bdff8ad10 sysreg.py: Add sysreg_parse() function
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-22 03:21:01 +09:00
Mark Kettenis
e23e89849f proxy: linux.py: fix tty initialization
commit 35fddd51 broke loading a kernel without explitly specifying
a tty.  Fix this.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
2021-05-16 18:47:00 +09:00
Hector Martin
957bf40d20 proxy.py: Add debug for rx events
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-16 18:46:35 +09:00
Sven Peter
35fddd5117 proxy: linux.py: allow to load u-boot before Linux
right now u-boot can bring up the PCIe bus such that Linux only requires
a very minimal driver. this new --u-boot flag for linux.py allows to
load u-boot before the Linux kernel to make use of this.
This requires a small hack to inject the booti command into the default
u-boot boot environment.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-16 02:45:46 +09:00
Hector Martin
3283987ba9 proxy.py: Fix spurious garbage printed to TTY
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-16 00:04:33 +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
323b02ce1d hv: Implement basic MMIO tracing to Python
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 23:57:48 +09:00
Janne Grunau
a742f05532 usb/hv: add second CDC ACM interface for virtualized UART
Signed-off-by: Janne Grunau <j@jannau.net>
2021-05-15 19:47:08 +09:00
Sven Peter
4a893dc57a apple_regs: document more SPRR regs
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-15 16:38:45 +09:00
Hector Martin
87ae3a91fd hv.py: Nuke all the PCIe/TB nodes for the hypervisor Type C port
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 01:39:54 +09:00
Hector Martin
e9aa876d12 Add missing xnutools.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 22:46:07 +09:00
Hector Martin
11fb2a403b adt.py: Unbork reg parsing, fix some stuff
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 22:44:50 +09:00
Hector Martin
7358e79d74 hv.py: Support pointer auth correctly
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 21:28:52 +09:00
Hector Martin
11ef3bb461 proxyutils.py: Allow mrs/msr to pass region (for EL1 etc)
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 20:10:51 +09:00
Hector Martin
757213b7a9 apple_regs.json: Add some EL1 registers for AP
Still not sure how to enable APSTS_EL12...

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 20:10:34 +09:00
Hector Martin
98839afab0 proxyutils.py: Use keyword-only arguments for msr/msr/inst
So I stop writing mrs(sysreg, value)...

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 19:02:57 +09:00
Hector Martin
aebda5213a hv.py: Now gets pretty far into XNU boot
Next up: mmiotrace

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 19:02:35 +09:00
Hector Martin
495732ef6a proxyutils.py: Fix returning from ad-hoc code
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 18:16:13 +09:00
Hector Martin
7fb35a8533 proxyutils.py: Call ad-hoc code in RX EL1 region
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 18:15:35 +09:00
Hector Martin
4a918346a8 shell.py: Add only callables to locals, but also sysregs
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:21:39 +09:00
Hector Martin
4d75ff90ff proxyutils.py: Support Apple impdef MSR trap decoding
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:21:09 +09:00
Hector Martin
f56318abc9 hacr_trap_bits.py: Look at ARM standard-but-not regs too
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:20:51 +09:00
Hector Martin
9268f83f9f sysreg.py: Define bitfields for more Apple regs
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:20:06 +09:00
Hector Martin
5bea278509 sysreg.py: Add sysreg_name() helper
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:19:50 +09:00
Hector Martin
a519af2ca8 proxyutils.py: Add support for symbolizing addresses
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:19:19 +09:00
Hector Martin
90872f460e macho.py: Support loading and importing symbol files
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:18:12 +09:00
Hector Martin
db9acba268 utils.py: Register: Initialize to 0
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:17:38 +09:00
Hector Martin
51bafa3c3f proxyutils.py: Fix silent arg for mrs/msr
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:17:09 +09:00
Hector Martin
ec5388d6b5 chainload.py: Support SMP when loading XNU
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:16:33 +09:00
Hector Martin
4e545d0513 adt.py: Improve parsing of reg/ranges & add resolver
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-12 21:16:15 +09:00
Sven Peter
e58c264a07 gxf: add SPRR/GXF proxyclient experiments
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
34123e33d8 proxyutils: added GuardedHeap
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
1c604a77c5 gxf: add support for guarded exception levels
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
2c5b202c99 sysreg: add support for Apple's custom sysregs
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
9120cb8426 memory: allow to reinit and temporarily disable the MMU
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Hector Martin
9a7a5c86a5 hv.py: Map only from guest base to RAM top to guest
This keeps the hypervisor safe, in theory.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
a6287ae68d proxy.py: Add defaults to hv_translate flag args
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
19415bd6a5 run_guest.py: Support setting boot_args
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
3fecf181f9 proxyutils.py: Only decode abort/msr info for SYNC exceptions
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
9bfe278f52 proxyutils.py: Add disassemble_at() method
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
e3d7e569dc sysreg.py: Define an impdef EC code that Apple seems to use
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
6ad3b263a1 macho.py: Add support for loaded section hooks for patching
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +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
aadf54d86f proxy.py: Add missing FB defines
Also fix some calls

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
f58a9774d2 hv.py: Shut down fb before entering guest
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-08 03:43:59 +09:00
Hector Martin
0203aa6d3d proxy: Add framebuffer ops
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-08 03:42:21 +09:00
Hector Martin
8a8a004d48 hv.py: Correctly declare BootArgs in ADT memory map
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-08 02:40:57 +09:00
Hector Martin
530069bbfa proxyutils.py: Switch to gzip compression for writemem_compressed
lzma is too slow, not worth the gain now that we have USB.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-08 02:40:13 +09:00
Hector Martin
36a6c9de3e proxy.py: Correctly indicate USB reconnection timeout
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-08 02:39:56 +09:00
Hector Martin
adb91b4374 chainload.py: Add support for setting boot-args
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-08 02:39:32 +09:00
Hector Martin
c6965acc75 adt.py: Fix typo
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-06 23:36:29 +09:00
Hector Martin
f1cc65f6c0 chainload.py: Set up SEPFW address in ADT
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-06 03:33:35 +09:00
Hector Martin
bbbea9db34 proxyutils: Disable serial timeout for writemem_compressed
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-06 03:32:39 +09:00
Hector Martin
0ae3455d51 hv_vuart: World's stupidest virtual UART implementation
Work in progress...

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 04:03:44 +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
27af846aae hv_vm.c: Move SPTE_TYPE to bit 50
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 03:23:04 +09:00
Hector Martin
76b690e767 hv.py: Make ^D exit the hypervisor, not cont
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 00:46:53 +09:00
Hector Martin
4b3f527de9 proxyutils: Disassemble faulting code on exceptions
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 00:46:48 +09:00
Hector Martin
652c7e27a1 proxyutils.py: u.inst -> u.exec and support assembly
Also refactor mrs/msr in terms of u.exec.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 00:28:39 +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
5ad0bdf994 sysreg: Fix ESR_ISS_MSR.CRm field bounds
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 23:01:55 +09:00
Hector Martin
78895edf2c hv.py: Properly copy ADT and TrustCache into guest region
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 22:57:08 +09:00
Hector Martin
954408cc65 chainload: Support old-school call based chainloading
This is useful in the middle of the HV exception handler to reboot m1n1
entirely, since we can't do a clean exit the way we would for normal
chainloading.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 22:56:47 +09:00
Hector Martin
826bdb709c sysreg.py: Correct SPSR definition for AArch64 mode
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 20:05:54 +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
Hector Martin
b015dcf272 shell.py: Make usable as a module
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:35:19 +09:00
Hector Martin
315fcf36aa uartproxy: Add support for nested invocations
This allows the proxy to call back to Python for handling exceptions or
other events, passing reason information about why it was invoked and
returning normally when the exception has been handled.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:34:08 +09:00
Hector Martin
38b716c33c hv.py: Do not fail if ADT was already mutated
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:32:18 +09:00
Hector Martin
23c723003f sysreg.py: Move sysreg definitions here from proxyutils
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:31:41 +09:00
Hector Martin
35d564801a utils.py: Add Register class to handle register fields
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:26:41 +09:00
Hector Martin
2df4654555 hv.py: Disable secondary CPUs for now
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 01:52:58 +09:00
Hector Martin
948e507031 hv: Update ADT to fix SEPFW address and disable HV USB
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-03 21:30:30 +09:00
Hector Martin
9584e7d312 uartproxy: Add IODEV_WHOAMI feature to get current iodev
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-03 21:19:35 +09:00
Hector Martin
a3e50e8f44 proxy.py: Use the enum module for GUARD_/USAGE_/IODEV_
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-03 21:19:35 +09:00
Hector Martin
ec9221cf32 adt.py: Support serializing back to binary ADT
This should losslessly round-trip

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-03 21:19:15 +09:00
Hector Martin
7d18e8afb9 hv.py: Add missing file
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-03 21:18:57 +09:00
Hector Martin
1ae60ad715 hv: Beginnings of a hypervisor
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:21:33 +09:00
Hector Martin
4547773edf setup.py: Remove unnecessary imports
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:04:01 +09:00
Hector Martin
63366e43d2 proxy.py: Fix typo
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:03:46 +09:00
Hector Martin
5fdeb1c3e3 chainload.py: Remove useless import
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:03:21 +09:00
Hector Martin
8b1ea3f04d proxyutils: Make heap size configurable
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:02:25 +09:00
Hector Martin
2a1a04ea0d setup.py: Move baudrate auto setup to proxyutils
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:02:20 +09:00
Hector Martin
7c2dace0b0 chainload.py: Cleanup, move Mach-O loader to macho.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 15:16:02 +09:00
Hector Martin
a489a646bd Add tools for ARM sysreg database management
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 15:14:35 +09:00
Hector Martin
7bb490eb58 utils.py: New file for misc util functions (non proxy)
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 15:13:29 +09:00
Hector Martin
aaf4b2785b Rename utils.py -> proxyutils.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 15:13:06 +09:00
Hector Martin
fcd103b2a4 proxy.py: Reopen port on reboot if necessary
This is needed for USB mode, as the device re-enumerates after a reboot.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-27 19:49:59 +09:00
Hector Martin
80f73926e8 proxy.py: Move M1N1DEVICE/UART port open logic into UartInterface
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-27 19:49:59 +09:00
Jean-Francois Bortolotti
82978081f8 chainload.py: Fix el1 support
Signed-off-by: Jean-Francois Bortolotti <jeff@borto.fr>
2021-04-18 02:29:32 +09:00
Hector Martin
f6297437c0 linux.py: Allow specifying a separate TTY device
This allows e.g. opening a TTY on the UART serial device after
booting the kernel via USB.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 18:12:59 +09:00
Hector Martin
7dfe24ee2c Rework kboot/chainload flow to shut down before calling the next stage
Next stage boots now exit back to main() after replying to the proxy
command, allowing shutdown functions to be called. Introduces a new
P_VECTOR proxy op, distinct from P_CALL. The Python side is reworked
to remain compatible with older versions that do not support this.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 18:12:59 +09:00
Hector Martin
88e1612c09 uartproxy: s/CRCERR/CSUMERR/ and actually use it
It's not a CRC.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:25:48 +09:00