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
Hector Martin
8104ec02c4
iodev: Add proxy ops
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Hector Martin
ce79483165
proxy: Add support for passing buffer/string values to reqs
...
This only works if the utils class has been instantiated, which is a bit
of a hack.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Hector Martin
f8c1c65cf9
Revert "proxy: add fb console console ops"
...
This reverts commit de0456b9a5
.
These ops become redundant with the new iodev control op.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Sven Peter
35007b700e
proxy: add dart ops
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 01:36:29 +09:00
Hector Martin
6d87b3b016
chainload.py: Improve chainloading
...
- Support chainload-in-place
- Do Mach-O loading host-side
- Handle copying SEPFW (WIP, ADT not updated yet)
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-14 21:13:19 +09:00
Hector Martin
b40fffea20
adt.py: Add basic ADT parser
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-14 21:12:38 +09:00
Sven Peter
de0456b9a5
proxy: add fb console console ops
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Hector Martin
0df6db324b
timer_test.py: More exhaustive tests
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-14 17:48:02 +09:00
Hector Martin
f30e91b933
asm.py: Build for ARMv8.2-A
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-14 17:48:01 +09:00
Sven Peter
1314a426e2
proxyclient: add PMGR ops
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-11 05:26:29 +09:00
Sven Peter
f17a15d19a
proxyclient/i2c: experiment with the i2c and ti usb chip
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-09 14:47:22 +09:00
Sven Peter
8aa3c69a2d
tunables: add tunables_apply_local_addr
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-08 20:32:12 +09:00
Sven Peter
a17e64f1e2
tunables: add proxy ops
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-08 20:32:12 +09:00
Sven Peter
ed72fe443c
proxyclient/asm.py: allow to override compiler prefix
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-05 23:49:25 +09:00
Hector Martin
3a42f80a73
chainload.py: Set up sane EL1 config for timers/IRQs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-28 19:31:14 +09:00
Hector Martin
70f6bc7514
linux.py: support up to 512MB kernels
...
Some people apparently have the patience to load KASAN kernels over
serial :-)
Also bump the python-managed heap to 1GB.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-08 01:33:43 +09:00
Hector Martin
3c514e826c
fptest.py: test Apple floating-point controls
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 23:22:41 +09:00
Hector Martin
db49cc92f3
hacr_trap_bits.py: figure out HACR_EL2 sysreg traps
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 23:20:50 +09:00
Hector Martin
1a880518b0
chainload.py: implement chainloading at EL1
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 22:41:06 +09:00
Hector Martin
3bf3613e7d
find_all_regs: print EL2-only registers
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 22:40:25 +09:00
Hector Martin
b8349819fe
Implement calling code as EL1
...
This works by clearing HCR_EL2.TGE, and then doing essentially the same
thunk/return dance as for EL0 calls. However, since most EL1 exceptions
are not routed to EL2, we install hypercall vectors in EL1 to forward
them to EL2, and then short circuit the exception return to whatever
triggered the original exception.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 22:10:37 +09:00
Hector Martin
acf1198fbb
timer_test.py: add test of HV/guest timers
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-01 01:47:42 +09:00
Hector Martin
0f2be2c0ee
utils.py: unbork inst()
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-01 01:45:39 +09:00
Hector Martin
2f959f758c
find_all_regs.py: show EL0-accessible registers
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-25 00:33:00 +09:00
Hector Martin
d918b066b6
utils.py: add silent and call arguments to msr/mrs
...
call allows the caller to override the function used for the function
call, e.g. to use EL0.
Use silent=True for find_all_regs.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-25 00:30:58 +09:00
Hector Martin
3872b1a7da
exception: implement el0_call to run code as EL0
...
This lets us test register access and other features from EL0.
No serious attempt at security is made, but at least EL0 runs off of a
separate stack and can return to EL2 at any time with `brk`; we can
easily implement a guard mode to break straight to EL2 on exception
later if needed.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-24 21:48:12 +09:00
Hector Martin
73a85be2b8
memory: prepare for EL0 support
...
Enable EL0 access to MMIO/etc, but not main RAM, because AArch64
architecturally enforces EL0w ^ EL2x.
Instead, create an alias of main RAM to grant EL0 full permissions,
at 0x80_0000_0000.
Grant EL0 full access to MMIO stuff, since EL2 will never execute
from there.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-24 21:48:12 +09:00
Hector Martin
a0960fca81
find_all_regs.py: test writability
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-24 21:48:12 +09:00
Hector Martin
65824016b7
utils.py add silent argument to inst()
2021-02-24 19:01:17 +09:00
Hector Martin
64306e78a0
linux.py: only mask DAIF.IF
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-21 11:55:54 +09:00
Sven Peter
54a147013f
chainload.py: compress payload to improve loading time
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-02-20 01:29:46 +09:00
Sven Peter
fa02cc9602
utils.py: add compressed writemem
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-02-20 01:29:46 +09:00
Hector Martin
b7d30250b2
utils: allow inst() to return r0 and take args
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-19 03:25:28 +09:00
Sven Peter
870fead39c
proxyclient: add ops for writeread{8,16,32,64}
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-02-18 16:12:28 +09:00
Khoa Hoang
2789b6f3e0
proxyclient: add input support for tty mode
...
Use miniterm from pyserial for tty passthrough mode
Signed-off-by: Khoa Hoang <admin@khoahoang.com>
2021-02-13 02:48:58 +09:00
Hector Martin
207767472b
Add find_all_regs.py (brute-force system regs)
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-11 00:56:19 +09:00
Hector Martin
063b9a1d27
exception: Add GUARD_SILENT feature to suppress logs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-11 00:55:59 +09:00
Hector Martin
c1b9ef89b5
utils.py: guard mrs/msr/etc
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-11 00:55:59 +09:00
Hector Martin
7d3dd54441
utils.py: replace manual reg list with a full dump
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-11 00:55:59 +09:00
Hector Martin
ec59b0d2c7
chainload: do proper Mach-O parsing
...
This is required for payloads to work properly
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
d12ac86448
utils.py: add more timer registers
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
1bb05d056f
linux.py: Fix and simplify argument count handling
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Janne Grunau
57c4ddd00d
linux.py: add support for setting boot arguments
...
Signed-off-by: Janne Grunau <j@jannau.net>
2021-02-06 12:16:04 +09:00
Janne Grunau
214173ba51
linux.py: support xz compressed payload
...
3 second faster load and uncompress time for small kernel
(5.6M uncompressed, 2.1M gz and 1.6M xz). Compression method is
autodetect by the filename suffix or can be set by the '--compression'
command line option.
Also supports uncompressed payloads (no auto detection).
Signed-off-by: Janne Grunau <j@jannau.net>
2021-02-06 12:16:04 +09:00
Janne Grunau
128368751c
linux.py: use argparse and pathlib
...
Signed-off-by: Janne Grunau <j@jannau.net>
2021-02-06 12:16:04 +09:00