Commit graph

536 commits

Author SHA1 Message Date
Hector Martin
99e38d24d0 experiments/cpu_pstates.py: Remove p-core boost testing hack
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-19 02:28:49 +09:00
Hector Martin
c8eb9a7862 experiments: Add cpu_pstate_latencies.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-19 02:03:27 +09:00
Hector Martin
6a620ddab9 experiments: Add cpu_pstates.py
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-19 02:03:24 +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
37b2fdda7c m1n1.adt: Handle empty function props
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-18 22:27:13 +09:00
Hector Martin
2d952752db proxy: Add smp_wait() to the proxy
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 15:25:34 +09:00
Hector Martin
b16bad61b4 m1n1.utils: Fix RegAccessor assignment
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:34:56 +09:00
Hector Martin
bbf8889d87 m1n1.trace.asc: Print more registers
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:34:42 +09:00
Hector Martin
36a7f3f2e1 m1n1.hw.asc: Print raw messages in hex
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:34:22 +09:00
Hector Martin
0d13ed692e m1n1.fw.asc: Align buffer sizes in reply messages
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:33:34 +09:00
Hector Martin
966b50a753 m1n1.fw.asc: Support booting an ASC
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:33:12 +09:00
Hector Martin
b53b627cb9 m1n1.hw.dart: Support initializing a DART from scratch
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:30:41 +09:00
Hector Martin
97ed24a908 m1n1.fw.asc: Make DVA offset configurable
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-17 00:30:14 +09:00
Hector Martin
77fbb05623 m1n1.adt: Pretty-print functions
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-16 17:06:51 +09:00
Hector Martin
961f8eae4d m1n1.adt: Print a useful diag when a prop fails to parse
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-16 16:48:22 +09:00
Hector Martin
de8b490b01 m1n1.adt: Add some mcc props
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-16 16:47:45 +09:00
Hector Martin
3b6a645db6 m1n1.adt: Support master (templated) ADTs properly
They used to parse but not round-trip, now they do

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-16 16:47:22 +09:00
Hector Martin
9ecaeb9e1b m1n1.hv: Add SMP support
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:32:57 +09:00
Hector Martin
509481d5d5 hv: Add SMP support
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:32:57 +09:00
Hector Martin
d68e4e42dd m1n1.trace: Show CPU number in default MMIO PrintTracer 2021-09-15 23:32:57 +09:00
Hector Martin
e88d55005a m1n1.trace: Use hv.log() in Tracer.log() 2021-09-15 23:32:57 +09:00
Hector Martin
a4efa373f3 m1n1.trace: Make Tracer.trace() take read/write args
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:32:57 +09:00
Hector Martin
81aaa72740 m1n1.hv: Improve pmgr hack messages
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:32:57 +09:00
Hector Martin
2598b3a7ba m1n1.hv: Only patch exception handling on CPU#0
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:27:21 +09:00
Hector Martin
e06e58e864 m1n1.xnutools: Update decode_debugger_state() for 12.0
We need to find a better way of doing this...

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:26:45 +09:00
Hector Martin
290e851d98 m1n1.hv: Add read/write args to hv.trace_range()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:25:12 +09:00
Hector Martin
683161eef4 m1n1.hv: Make sysreg storage per-CPU
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:24:37 +09:00
Hector Martin
3871fa1e2f m1n1.hv: Add hv.log() that prepends CPU index, use it
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:24:37 +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
6627873267 m1n1.hv, run_guest.py: Make exception hook enable an argument
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:24:37 +09:00
Hector Martin
368b48a365 hv_wdt: Make HV WDT CPU configurable and WDT optional
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 23:24:37 +09:00
Hector Martin
aa11841808 m1n1.adt: s/gate/psidx/
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 21:59:13 +09:00
Hector Martin
496516ded0 m1n1.adt: PMGR and function call stuff
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 17:11:45 +09:00
Hector Martin
dfb10956bc m1n1.fw.dcp: Add OSSerialize parser for DCPAV properties
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 17:08:21 +09:00
Hector Martin
9b91c90f3a m1n1.utils: Move FourCC definition here
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-09-15 17:08:21 +09:00
Hector Martin
fa50bb6474 fb: Do not restore logo when using kboot
Also don't clear the whole screen, only the console section so the logo
is glitchless.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-31 14:10:52 +09:00
Hector Martin
219950235c fw.dcp.ipc: Define rt_bw_config_t properly
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-30 12:09:36 +09:00
Hector Martin
4df78129aa m1n1.shell: Fix broken signature thing for some objects
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-29 01:36:27 +09:00
Hector Martin
63547f6fc9 m1n1.fw.asc.mgmt: Print endpoints
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-29 01:36:01 +09:00
Hector Martin
0584200aaf m1n1.fw.dcp.manager: Make map_buf() work
What it needs to do is map the buffer to the disp dart stream 4,
apparently (or maybe the stream varies?)

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-29 01:35:25 +09:00
Hector Martin
43c93af949 m1n1.fw.asc: Handle DARTless ASCs
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-29 01:32:27 +09:00
Hector Martin
eec6bbdeaf m1n1.hw.dart: Fix dirty cache clobbering on iomap_at()
Fixes: #102

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-29 00:03:39 +09:00
Alyssa Rosenzweig
eb466796d8 fw.dcp: Add some stubs needed for modesetting
This isn't enough to set the video mode yet but it gets us further. I
think allocate_memory/map_buf/powerOnDART need real implementations,
otherwise setting a video mode crashes the DCP in an APIODMA interrupt
handler, whatever that is.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2021-08-24 21:09:35 +09:00
Hector Martin
e6d3b6b6c6 m1n1.adt: Handle borked reg properties
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-24 12:20:31 +09:00
Hector Martin
d0731de381 m1n1.hv: Fix pac_mask for linux
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-23 23:10:28 +09:00
Hector Martin
c39fe2fbde m1n1.fw.asc: Handle syslog/ioreporting buffer size properly
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-23 23:10:28 +09:00
Hector Martin
1666d86d43 fw.asc.mgmt: Handle version negotiation properly
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-23 23:04:23 +09:00
Hector Martin
cc39491863 m1n1.proxy: Allow overriding default timeout with M1N1TIMEOUT
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-23 17:03:20 +09:00
Hector Martin
017f050fff hv_vuart: Implement RX & enough to support Linux
This works to get to a serial shell on Linux, and to use m1n1-as-LV1
proxyclient with M1N1DEVICE=/dev/m1n1-sec

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-23 17:02:28 +09:00
Hector Martin
c2c6da3df2 fw.dcp.ipc: Remove junk prints
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:53:32 +09:00
Hector Martin
fa3b1ddcf6 experiments/dcp.py: Add DCP driver example
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:40:18 +09:00
Hector Martin
de5b5d996c m1n1.fw.dcp: Add DCP client framework, port tracer to it
This also includes an update to the macOS 12.0 beta ABI

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:39:17 +09:00
Hector Martin
b32aec3786 m1n1.trace.asc: Use shared reg/msg definitions, improve syslog
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:37:09 +09:00
Hector Martin
27a0a15eee m1n1.hw/fw.asc: Add basic ASC driver and RTKit handling
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:36:49 +09:00
Hector Martin
7b01b0525b m1n1.trace.asc: Be more clear about endpoint number in log
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:34:24 +09:00
Hector Martin
105b671fb3 m1n1.hw.dart: Add mutation functions (iomap, iowrite)
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:33:18 +09:00
Hector Martin
fc5ce75c21 m1n1.adt: Add repr()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:32:26 +09:00
Hector Martin
fe503a3802 m1n1.proxy: Handle zero-length readmem()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:32:07 +09:00
Hector Martin
a96e277b56 m1n1.utils: Add Constant support to Register
This allows setting register fields to an expected contant value, e.g.
because they are opcodes for a variable-format register (like a mailbox)

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:31:10 +09:00
Hector Martin
b00b36620a m1n1.utils: Add unhex() helper
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-08-14 16:30:38 +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
Andrew Worsley
bd5211909e Fix Exception when no Signature present
Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 23:54:23 +09:00
Pip Cet
d709b047d8 proxyclient/m1n1/utils.py: don't compact non-adjacent ranges
Signed-off-by: Pip Cet <pipcet@gmail.com>
2021-08-03 13:53:41 +09:00
Andrew Worsley
1d932888f9 Add command categories to reduce command clutter
Based on a suggestion from Ludwig Schubert it now uses the inspect class
to generate signatures of the functions for the help messages and
the qualified names which is a big improvement.

Also greatly reduced the clutter by putting the class functions into seperate
categories based on their class name. Now the top level help fits on one
page making it much more readable.

Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Andrew Worsley
ddb6951abb Fix some review comments, spacing
Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Andrew Worsley
255f1bac16 Add some doc string to write/read/mrs/msr
Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Andrew Worsley
eab52cc855 Extend help to all commands
Also print 1 line summary or full output if called directly on command

Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Andrew Worsley
bf4f702077 Add some docstrings/help to shell commands
Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Andrew Worsley
012ecc07e7 Add simple help command to shell tool
Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Andrew Worsley
2ea43e6ff1 Briefly document protocol
Signed-off-by: Andrew Worsley <amworsley@gmail.com>
2021-08-03 13:52:31 +09:00
Hector Martin
63e8d0d48e m1n1.fw.dcp.ipc: Fix late_init_signal return type
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-07-18 02:28:27 +09:00
Hector Martin
9fae977161 m1n1.fw.dcp.ipc: Add SizedArray/SizedBytes to handle data/len pairs
The serialization always uses fixed-length arrays. These wrappers use a
length argument (possibly coming later in the args) to size the fields
so that the arrays are truncated or padded to the right length as
returned to the user.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-07-18 02:28:26 +09:00
Hector Martin
231aa772fd m1n1.fw.dcp: Initial DCP log tracing implementation
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-07-15 22:29:01 +09:00
Hector Martin
f635d64429 hv/trace_dcp.py: Update call list for 11.4 (partial?)
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-07-15 22:28:27 +09:00
Hector Martin
0034311ee3 m1n1.utils: Add indent argument to chexdump
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-07-15 22:27:52 +09:00
Hector Martin
4a6fa4b0e1 hv/trace_dcp.py: Redo cmd/ack handling properly, add logging & msg list
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-07-15 16:27:56 +09:00
Sven Peter
5b86c1ee8d proxyclient: sep: add initial code to boot SEPOS
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-07-09 15:58:00 +09:00
Sven Peter
93ca3fae08 hv: add hardware breakpoint support
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-07-09 15:52:40 +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
Sven Peter
620f1972ce linux.py: add missing serial import
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-07-09 15:41:04 +09:00
Janne Grunau
e74b79dc2a m1n1/hv: fix irq trace after "Rework MMIO PT handling & tracing"
Also removes unused leftover demonstration code which came obsolete by
tracer scripts. See hv/trace_gpio.py for an example.

Signed-off-by: Janne Grunau <j@jannau.net>
2021-07-09 15:31:08 +09:00
Hector Martin
e00e8f178d hv/trace_dcp.py: Fix stuff
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-24 02:12:07 +09:00
Hector Martin
819d2cf6bc hv/trace_dcp.py: Parsing a bunch of stuff now
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-24 01:15:32 +09:00
Hector Martin
3cfe943ec3 m1n1.trace.asc.Syslog: Fix message termination
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-24 01:15:15 +09:00
Hector Martin
7687d00f5f m1n1.trace.asc: Add EP.start() to initialize endpoints
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-24 01:14:57 +09:00
Hector Martin
c490f74872 m1n1.trace.asc: Move EP handlers to per-EP objects
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-23 20:19:30 +09:00
Hector Martin
b4c2272855 m1n1.hw.dart: Don't cache invalid mappings
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-23 20:19:30 +09:00
Hector Martin
b4fef18e12 m1n1.trace.dart: Log invalidates
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-23 17:04:30 +09:00
Hector Martin
92c3ad223c m1n1.proxyutils.RegMonitor: Add ASCII mode, overridable readmem, abbrev
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-23 17:02:14 +09:00
Hector Martin
faa37342f9 m1n1.utils.chexdump: Add abbreviation
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-23 17:01:17 +09:00
Hector Martin
cf00bedade m1n1.hv.HV: Upload ADT late to allow user overrides
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 02:02:06 +09:00
Hector Martin
94f5c29c9f hv/trace_dcp.py: More things
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
9a480c656b m1n1.shell.HistoryConsole: Guard against mon.poll() exceptions
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
912776372a m1n1.trace.asc: Support more messages, syslog decoding, associated DART
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
42b7adad06 m1n1.trace.dart: Add DART tracer/handler
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
b7147a130a m1n1.trace.ADTDevTracer: Fix _reloadcls() binding issue
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
c76489e6dd m1n1.hw.dart: Move DART support code here, add IOVA resolver
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
d025574e1d m1n1.hv.HV: Run passive tracers *before* issuing the MMIO write
E.g. this means tracers run *before* an ASC command gets sent, which
might be relevant if the same memory is used for commands and responses.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
d255a74271 m1n1.hv: Add HV.run_shell() convenience function, fix messages
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
83b05e7743 m1n1.utils.RegAccessor: Pass through None when register is unavailable
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
d942984b72 m1n1.utils.Reloadable: Be verbose about what gets reloaded
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
026c16c7c2 m1n1.utils.chexdump(): Fix justification
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
32d03f3ae2 m1n1.utils.RegMap: Fix register access widths
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-22 01:39:38 +09:00
Hector Martin
f7063e6f06 m1n1.trace.Tracer: Multiple bugfixes
- Set ident properly before looking up cache
- Off-by-one error in regmap lookups
- Reload regmap classes on reload

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 16:24:04 +09:00
Hector Martin
035aa486d6 m1n1.hv: Properly update current shell globals after run_script()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 16:19:43 +09:00
Hector Martin
a714c74e1a m1n1.utils.Reloadable: Only reload each module once
This avoids confusion with types changing ID when the same module is
repeatedly reloaded. Now we use the file mtime and only reload things
which have changed since last time, and dependent modules.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 16:00:00 +09:00
Alyssa Rosenzweig
ba478f2de5 mini.hv.dcp: Decode common messages
This accounts for most of the DCP traffic once macOS is booted. I used
a sophisticated side-channel hypervisor timing attack to determine the
message functions [ adding time.sleep(1) ]

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2021-06-21 14:02:25 +09:00
Alyssa Rosenzweig
6adf0c692c mini.trace.asc: Don't log handled messages
ASC handlers now return a boolean to indicate whether they successfully
handled the message (True if so). In that case, printing the underlying
mailbox traffic is redundant, so let's hide it.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2021-06-21 14:02:25 +09:00
Hector Martin
86e233931e m1n1.trace.asc: Add core endpoint numbers
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:51:46 +09:00
Hector Martin
e4a591d81a m1n1.trace.asc: Fix MSG_EP_MAP.LAST
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:49:55 +09:00
Hector Martin
71cdcb9bef ASCTracer: Fix subclassing
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:43:01 +09:00
Hector Martin
dbeb174ac9 m1n1.hv: Don't die on ^C in the shell 2021-06-21 02:34:07 +09:00
Hector Martin
03ceed3a97 m1n1.hv: Fix map_hook_idx read/write options
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:06:22 +09:00
Hector Martin
7632a57ff3 m1n1.trace.asc: Implement basic message handling/dispatch
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:05:36 +09:00
Hector Martin
8a0125ac17 m1n1.trce.gpio: Use new register arrays
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:05:08 +09:00
Hector Martin
86154a8194 dart_dump.py: Use new 2D register arrays
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:04:35 +09:00
Hector Martin
2e250df645 run_guest.py: Don't die if -m or -c fails, bring up a shell instead.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:04:09 +09:00
Hector Martin
0a3bd5c91b m1n1.utils: Add support for multidimensional reg arrays in RegMap
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:03:18 +09:00
Hector Martin
9e42f4fc0f m1n1.trace: Add a state stash to Tracer that persists
This allows Tracers to keep internal state around even across complete
re-instantiations.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:02:05 +09:00
Hector Martin
7090138779 m1n1.utils: Make Register sub-subclasses work, optimize
Now figures out the fields/etc in a metaclass, not at object
instantiation time.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 02:01:07 +09:00
Hector Martin
8d61a81bed m1n1.hv: Wrap tracer calls in a shell to handle exceptions
This allows you to fix a tracer and retry ('cont' or ^D) or skip
('skip') its execution.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-21 01:58:47 +09:00
Hector Martin
7c19dcc33f m1n1.hv: Handle symbol addresses properly for Linux
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-19 21:51:36 +09:00
Hector Martin
8197538078 m1n1.hv: Add System.map support and make pac_mask configurable
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-19 15:53:14 +09:00
Janne Grunau
36dcc1b8f3 hv.py: remove only the used USB-C port from the ADT
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-18 14:26:54 +09:00
Janne Grunau
bbd2cf8710 hv.py: hook USB-C port specific pmgr addresses
Allows running HV over each USB-C port of a Mac Mini with Mac OS as
guest.

Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-18 14:26:54 +09:00
Janne Grunau
d88e255c56 hv.py: remove secondary CPU cores unconditionally from the ADT
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-18 14:26:54 +09:00
Janne Grunau
98076ef693 usb: disable tps6598x interrupts
Restore the interrupt masks on chainload or HV guest start. The
interrupt mask is not restored on the USB-C port used by the hypervisor.
This prevents an interrupt storm in the guest when the other USB-C port
is exposed to the guest. Both tps6598x share unfortunately an interrupt
line.

Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-18 14:26:54 +09:00
Janne Grunau
de82209079 m1n1.trace.gpio: convert GPIOTracer to new framework
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-18 14:23:23 +09:00
Janne Grunau
ccd765464d m1n1.utils: fix RegMap range lookup
Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-18 14:23:23 +09:00
Hector Martin
cb6d1f58a2 m1n1.trace.asc: Initial ASCTracer implementation
A tracer for the ASC coprocessor mailbox interface.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:24:55 +09:00
Hector Martin
b3526bd667 m1n1.trace: Implement RegMap-based tracing & ADTDevTracer
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:23:56 +09:00
Hector Martin
2784f48a24 m1n1.hv: Fix MMIO handling bugs
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:23:08 +09:00
Hector Martin
1213ec4173 m1n1.utils: Improve RegMap lookup functions
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:22:27 +09:00
Hector Martin
94db82f8a0 m1n1.hv: Reload shell globals when reloading class
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:22:06 +09:00
Hector Martin
332e7e22e7 m1n1.utils: Improve Reloadable, add cls._reloadcls()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:21:09 +09:00
Hector Martin
0ee96c7ffd m1n1.proxutils: Add ProxyUtils.{read,write}
These implement generic-size read/write. Use them for hypervisor MMIO
handling and for regmaps.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-18 02:19:39 +09:00
Hector Martin
990f5b3995 m1n1.hv: Complete TraceMode.SYNC/HOOK support
Also fix a nasty bug in legacy/bare map_hook() support

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 20:35:57 +09:00
Hector Martin
cdbc07e74c m1n1.utils: Add Register.copy()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 20:35:26 +09:00
Hector Martin
e218129931 m1n1.utils: Introduce Reloadable class for magic live-reloading
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 20:34:54 +09:00
Hector Martin
2f68012d6c m1n1.hv: Show ident for RESERVED page table mappings
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 02:32:46 +09:00
Hector Martin
49dad3b9ff m1n1.hv: Rework MMIO PT handling & tracing
Now keeps track of the requested MMIO maps in a DictRangeMap, which is
then flattened to HV page table updates.

TODO: HOOK/SYNC codepaths

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 02:00:32 +09:00
Hector Martin
228033f9ce m1n1.hv: Make map_hw() fall back to map_sw() for unaligned cases
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 01:59:35 +09:00
Hector Martin
db928acd61 m1n1.utils: RangeMap fixes & improvements, add BoolRangeMap
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 01:57:57 +09:00
Hector Martin
69745c3310 m1n1.utils: Add align_up() and align_down()
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-17 01:57:35 +09:00
Hector Martin
526cd8a55e m1n1.utils: Register: Keep fields sorted in __str__/__repr__
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-16 02:53:02 +09:00
Hector Martin
bb6ef8caa1 experiments/dart_dump.py: Port to RegMap
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-16 02:52:51 +09:00
Hector Martin
234051df1c m1n1.utils: Add RegMap base class
This metaclass voodoo allows us to define register maps like this:

class SomeDevice(RegMap):
    FOO = 0x0000, Register32
    BAR = 0x0004, Register32
    # Register array
    BAZ = range(0x100, 0x200, 4), Register32

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-16 02:29:46 +09:00
Hector Martin
53dcba6f25 m1n1.utils: RangeMap improvements, add {Scalar,Dict,Set}RangeMap
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-16 02:29:30 +09:00
Hector Martin
3d0bb889ab m1n1.utils: Move Register.value -> _value and wrap
Also pre-compute _fields

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-16 02:28:00 +09:00
Hector Martin
15381b8d74 m1n1.adt: Dump out address lookup table in script mode
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-15 19:45:58 +09:00
Hector Martin
48b4466abf m1n1.utils: Rewrite AddrLookup to improve performance & fix bugs
* Fix correctness issues (ranges could end up overlapping)
* Split ranges instead of merging them on overlap (previously a single
  range overlapping everything would reduce the lookup to a linear
  search over all ranges)
* Support removal and generic mutations by splitting out a generic
  RangeMap class that can be used with arbitrary values/collections

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-15 19:42:30 +09:00
Hector Martin
7e5054548a hv_vm: Rename SPTE_SYNC_TRACE to SPTE_TRACE_UNBUF
It's not really synchronous, it just flushes USB buffering.

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-15 16:10:06 +09:00
Hector Martin
96ecd52b65 tools/chainload.py: Remove 1-second delay
I don't think we need this any more, ever since the new reconnection
code

Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-15 15:59:55 +09:00
Hector Martin
05db5dba6f trace_agx.py: Disable tracing the PMP bits
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-15 15:46:08 +09:00
Hector Martin
baa46bf4f1 find_regs.py: Fix script mode invocation
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-06-15 15:45:51 +09:00
Janne Grunau
dc57e586bc hv/trace_gpio.py: mmiotrace handler for "/arm-io/gpio"
The hanlder omits noise/useless of the mmio access and annotates
known offsets, pins, interrupts and config values.

Signed-off-by: Janne Grunau <j@jannau.net>
2021-06-15 15:41:50 +09:00
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