Hector Martin
28ab4e1611
hv_vm: Handle load/store instructions with update
...
These don't get instruction syndromes, so we need to stop relying on
that to determine the access size.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 23:57:48 +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
Hector Martin
a1f6b2502a
usb_dwc3: Send a ZLP after multiple-of-512 transfers
...
This fixes the stalling issue with readmem() of a multiple of 512 bytes.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 21:47:22 +09:00
Hector Martin
57708b529f
usb_dwc3: Change xfer_in_progress to a bool
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 21:47:22 +09:00
Hector Martin
58489bf72c
iodev, usb: Add flush() call to flush buffers to the host
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 21:47:22 +09:00
Hector Martin
67c7043b9a
utils: In EL1, instead of rebooting, break into HV
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 20:42:50 +09:00
Hector Martin
03b70eed94
hv_vm: Move dprintf macro to utils.h, add more debugging
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 20:38:32 +09:00
Hector Martin
3de3b54b7e
hv_asm: Restore all registers on return to guest
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 20:36:39 +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
5d3f154d0f
hv_vm: Correctly split software mapped L2 blocks
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 01:28:44 +09:00
Hector Martin
bf34611bf4
hv_vm: Add out-of-bounds IPA check
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 01:15:17 +09:00
Hector Martin
e919b63a02
hv_vm: Add register-offset LDR/STR emulation, fix bugs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-15 00:43:39 +09:00
Hector Martin
1a5ba2c67e
hv_vm: Fix bad asserts
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-14 21:49:11 +09:00
Hector Martin
920ff59483
exception: Unbork EL1 stack
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 21:14:58 +09:00
Hector Martin
9efa91bf87
gxf: Do not disable the MMU around GXF calls
...
We are now SPRR compatible.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 18:31:27 +09:00
Hector Martin
b9ed00c6f3
memory: Initialize SPRR permissions
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 18:16:56 +09:00
Hector Martin
8af8dadee1
memory: Support L3 mappings, map m1n1 code as RX.
...
This replaces the old pagetable code with an adapted version of what
hv_vm.c does, which can handle block and page mappings more
intelligently.
Then, map the m1n1 code section as RX. This allows us to work in modes
where W^X is enforced.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 18:14:31 +09:00
Hector Martin
3e1ea2d503
memory: Add separate mappings for EL0 data access
...
This unborks stack and constant pool accesses from el0_call.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 17:36:02 +09:00
Hector Martin
7685800b45
heapblock: Assert if not initialized
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 17:33:57 +09:00
Hector Martin
9ffab4ac98
hv_vm.c: Remove stray ;
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-13 17:33:48 +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
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
Sven Peter
b00c5e6522
utils.h: add msr_sync convenience macros
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
36efdd2ac3
allow cpu_regs.h to be included in .S files
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
813e40f4ca
exception_asm.S: skip msr hcr_el2 if not required
...
When guarded exception levels are enabled hcr_el2 can no longer be written to from EL2.
A future commit will however use el1_call to jump to GL1. It will setup hcr_el2 before
enabling GXF such that the write doesn't have to happen in el1_call anymore
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +09:00
Sven Peter
148fe31122
exception_asm.S: correctly setup sp for EL1
...
The previous code switched SPSel to EL0 but then used eret to
jump to EL1h which uses SP_EL1 instead
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-05-11 15:48:40 +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
bcdafe8d00
hv_vm: Short-circuit hv_translate when MMU is off
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
8d5596a1a1
hv_vm: Fix bug when making L2 mappings
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
52823eaab6
hv_asm: Turn off PAN on exception entry
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +09:00
Hector Martin
4c043a0f97
memory: Move SCTLR/TCR defines to arm_cpu_regs.h
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-09 03:25:51 +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
aad892d461
fb: Implement fb_shutdown() & friends
...
Clean up after ourselves before chainload
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-07 12:19:20 +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
c0c7c57dd0
hv_vm: Fix bug inhv_pt_map_l4()
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 03:24:37 +09:00
Hector Martin
ce3a673413
uart: Move registers to uart_regs.h
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-05 03:23:25 +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
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
d35fa5e0fc
iodev: Add iodev_console_kick()
...
This is used prior to rebooting in exception handlers, to make sure all
the exception dump data gets sent to USB if we are connected via that.
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
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
4cc0f45c9d
arm_cpu_regs.h: Add SYS_ESR_EL2
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:25:46 +09:00
Hector Martin
785dba33ad
exception_asm: Fix missing register restores
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:24:52 +09:00
Hector Martin
a326aca956
hv: Enable physical timer for EL1 properly
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 19:23:35 +09:00
Hector Martin
23304719cd
hv: Move VM code to hv_vm.c
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 15:38:17 +09:00
Hector Martin
95542a4619
kboot: Handle missing CPUs properly
...
This is necessary to boot Linux in UP mode if we're in EL1 and the HV
does not support SMP yet.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-04 01:52:58 +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
1ae60ad715
hv: Beginnings of a hypervisor
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:21:33 +09:00
Hector Martin
1ff5b82aab
iodev/usb: Do not crash if USB was not initialized
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:04:38 +09:00
Hector Martin
68156fd806
utils.h: Add alignment and field macros
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 19:02:49 +09:00
Hector Martin
26c4ab3888
formatting: Sort main include first
...
clang-format is supposed to do this, but for some reason it's "sticky"
and doesn't...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 18:31:58 +09:00
Hector Martin
45a0054f63
Add build-time printf() argument checking and fix warnings
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-05-01 18:23:44 +09:00
Hector Martin
882610b50e
cpu_regs.h: s/SYS_APL/SYS_IMP_APL/ to match Linux
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-29 15:45:44 +09:00
Hector Martin
c2e2094b95
usb_dwc3: Add missing space to product name string
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 19:10:41 +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
bcece01769
usb: Hook up to iodev and bring up after payload boot attempt
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:47:43 +09:00
Hector Martin
4f7ae843fa
usb_dwc3: Fix read/write transfer pumping, add missing funcs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
df9218582e
usb_dwc3: Use new VID/PID
...
Not official yet, PR:
https://github.com/pidcodes/pidcodes.github.com/pull/635/files
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
108f104e96
usb_dwc3: USB compliance improvements
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
fcdf2aede9
smp: Print success message on CPU#0
...
SMP secondary prints only go to UART, so we need something on the main
CPU for other iodev consoles.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
34c1dc50ae
iodev: Add iodev_handle_events() and iodev_console_flush()
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
d3957cc89d
iodev: Fix error returns for iodev_read/write
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
565753980a
iodev: Move primary core check into iodev, always use in_iodev logic
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:45:19 +09:00
Hector Martin
303118fd93
uartproxy: Convert to iodev
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-17 16:26:41 +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
c8f59566eb
fb: Remove unused enable/disable code
...
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
Hector Martin
cc4a5d312d
iodev: Add new framework for I/O and console devices
...
This replaces the earlier earlycon with a single shared console buffer
for all output devices.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Hector Martin
1c518ded09
types.h: Include stdbool.h, define ssize_t
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Hector Martin
d63e84d2f7
fb: add fb_console_reserve_lines()
...
This is like fb_console_scroll(), but only scrolls if necessary to
ensure that enough free space is available at the end of the console.
This avoids spuriously scrolling during shutdown if we still have space.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Hector Martin
151c601b2a
Revert "fb: add earlycon to capture messages before fb_init"
...
This is being replaced with a global buffer in iodev.
This reverts commit 5d4067642e
.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-15 23:18:57 +09:00
Sven Peter
add04246e7
usb: add clock/power/phy bringup
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +09:00
Sven Peter
59ba266b11
usb: add DWC3 CDC ACM code
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +09:00
Sven Peter
ea362ea8f9
ringbuffer: add a simple ringbuffer data structure
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +09:00
Sven Peter
00e862238c
usb: add usb_types.h
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +09:00
Sven Peter
50afcd1ffe
usb: add more registers and removed linux-specific code from usb_dwc3_regs.h
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +09:00
Sven Peter
ac13c3b17f
usb: add drivers/usb/dwc3/core.h from linux
...
This file is taken from commit 7bc5a6ba369217e0137833f5955cf0b0f08b0712 before
the license was changed to GPLv2-only.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/dwc3/core.h?id=7bc5a6ba369217e0137833f5955cf0b0f08b0712
core.h is copyright:
Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
Authors: Felipe Balbi <balbi@ti.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
and dual-licensed under the GPLv2 and BSD3.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +09:00
Sven Peter
17fdc79c13
utils.h: add mdelay
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-15 18:39:33 +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
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
Sven Peter
5d4067642e
fb: add earlycon to capture messages before fb_init
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Sven Peter
2873aed75a
memory: speed hack: scroll fb console before shutting down the MMU
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Sven Peter
fd2deed39b
fb: add framebuffer console
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Sven Peter
819b16fbe4
fb.c: minor cleanup
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Sven Peter
05e7306bf9
fb console: add Source Code Pro font
...
This font is licensed under the OFL-1.1 License and copyright:
Copyright 2010-2019 Adobe (http://www.adobe.com/ ), with Reserved Font Name 'Source'.
All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Sven Peter
f80933a7d3
utils.h: add is_primary_core
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Sven Peter
1a04590ed3
utils.h: add min and max
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 18:11:37 +09:00
Hector Martin
9fc3f0c230
exception: Print exception context for FIQ
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-04-14 17:48:02 +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
Sven Peter
8efff1b0ab
dart: add code to setup the DART iommu
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 17:40:07 +09:00
Sven Peter
1e247107aa
types: add SZ_2K/SZ_16K/SZ_1M
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-14 17:40:07 +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
b31e1265ff
pmgr: add functions to enable/disable clocks
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-11 05:26:29 +09:00
Sven Peter
95b1cb39fc
utils.h: add poll32
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-11 05:26:29 +09:00
Sven Peter
bf3830ee6d
utils.h: add dma_mb,dma_rmb,dma_wmb
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-11 05:26:29 +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
d73276b0bc
tunables: add initial version.
...
There are at least two types in the ADT related to USB,
but there's a decent chance that there are even more
required for other devices:
* A simple tunable that applies to a whole device node
and all its MMIO ranges specified in the "reg" property.
This one seems to just be mask32.
* A slightly more complex tunable that applies to a single
MMIO range specified in the "reg" property. So far I've
only seen 32 bit masks but the format looks like it should
also support 8,16 and 64 bit masks.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-04-08 20:32:12 +09:00
Hector Martin
35f2b2435e
kboot: reserve m1n1 in memory
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-15 02:26:13 +09:00
Hector Martin
efa4452a47
Fix libc header dependencies
...
Turns out we had a bunch of silly dependencies on libc headers that are
not included with freestanding compilers. Fix all this and change the
CFLAGS to exclude libc headers and only include the built-in compiler
path.
Add our own versions of assert.h, errno.h, limits.h, and move malloc.h
and string.h together into a new path used as -isystem, so these headers
can be included using #include <>.
Remove a bunch of other dependencies in third-party code.
Add a strnlen function.
Disable building the libfdt overlay code for now, as it needs a strtoul
implementation. We can throw that in if/when we decide to use overlays.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-08 01:31:14 +09:00
Hector Martin
ce2038c59c
memory: use tlbi vmalle1is
...
This works at both EL1 and EL2(with VHE) and seems to do the right
thing.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 22:39:26 +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
f669237c2a
start.S: clean up some junk
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 21:27:25 +09:00
Hector Martin
16cff51bd4
exception,memory: s/EL2/EL1/
...
Since we're in VHE mode, we can pretend to be in EL1 - but this will
allow us to really run in EL1 if we want to in the future.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 20:31:36 +09:00
Hector Martin
4282cd0578
exception: size tables properly, work around overeager clang-format
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 19:52:53 +09:00
Hector Martin
d5acb000f2
kboot: add support for KASLR and bootloader randomness
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 19:47:39 +09:00
Hector Martin
8e4b99d75a
memory: reformat and shorten MAIR_INDEX to MAIR_IDX
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-03-04 19:47:37 +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
b5cbf7360e
exception: handle PMC FIQs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-18 17:55:55 +09:00
Hector Martin
cf640de6db
utils.h: add BIT() macro
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-18 17:55:55 +09:00
Hector Martin
17aca31498
utils.h: move reg_{clr,set,mask} here from chickens.c
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-18 17:55:55 +09:00
Hector Martin
86a7d9c0f3
cpu_regs.h: s/SYS_/SYS_APL_/
...
This synchronizes the register naming convention with Linux
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-18 17:55:55 +09:00
Sven Peter
f3eed1c7d7
MMU: correctly map MMIO/PCIe ranges
...
Previously all MMIO was mapped twice with different attributes
which may or may not lead to strange behaviour when the same
physical range is accessed from both mappings.
We now have a better idea which ranges require nGnRE and nGnRnE
and can just do it correctly instead.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-02-18 16:16:55 +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
Sven Peter
1ccf2e2af5
utils.h: add writeread{8,16,32,64}
...
These functions all perform a store direcly followed by a load.
This is useful to e.g. useful to find busy bits which might
already be cleared a few cycles after a write.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-02-18 16:12:28 +09:00
Sven Peter
24938db17a
MMU: use alle2 instead of vmalls12e1is to invalidate TLBs
...
I can't remember why I used vmalls12e1is but this leads to
the following bug:
1. Load m1n1 with normal MMU setup
2. Disable all mappings, recompile and chainload to that m1n1
3. Everything will work fine for a while even though it should explode
when enabling the MMU.
This happens becuse there are still stale TLB entries in some cache.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-02-15 01:37:39 +09:00
Hector Martin
d46d51d7ed
exception: fix vtimer FIQ masking
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-11 01:35:23 +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
eab71ee92b
fb, kboot: handle Retina flag correctly
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 22:27:45 +09:00
Hector Martin
5dbc82a9ee
payload: add support for booting in-line payloads
...
Usage:
$ cat m1n1.macho Image.gz apple-j274.dtb initramfs.gz \
> m1n1-payload.macho
That's it.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
93bad96311
minilzlib: fix support for non-CRC32 checksum types
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
61e2c36ef5
tinf, minzllib: support unknown input sizes
...
This can be used when the input file size is unknown: the decompression
functions will keep track of it and return it to the caller instead.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
0cd328214c
exception: handle all 4 available timer FIQs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
5aff13c404
proxy: add missing SPDX header
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Hector Martin
5e5627cd0b
clang-format: Add include block configs, reformat
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-06 16:44:10 +09:00
Ariel Machado
476182e1f8
utils.h: Fix 'asm-operand-widths' warnings with clang
...
Signed-off-by: Ariel Machado <ariel@fe.up.pt>
2021-02-06 12:13:29 +09:00
Hector Martin
8691fcee8a
kboot: fix fb debug print
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-05 03:49:20 +09:00
Hector Martin
234a511e35
kboot: add spin-table and SMP support
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-05 02:58:08 +09:00
Hector Martin
aaab2c6ca1
chickens: set WFI mode to clockgate only
...
This preserves CPU registers.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-05 02:58:08 +09:00
Hector Martin
e35ef6eb8c
smp: fix IRQs on secondary CPUs
...
Seems one of the registers is some kind of system-level CPU spinup flag,
without which the CPU runs but the rest of the system thinks it's still
dead.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-05 02:58:08 +09:00
Hector Martin
cb7e7f7918
exception.c: print MPIDR with IRQs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-02-05 02:58:08 +09:00
Hector Martin
96d133e854
mmu: map device memory as non-executable
...
This fixes the random SErrors after returning from a page fault. Turns
out the M1 was randomly deciding to speculate an instruction fetch from
address 0, triggering a fabric error.
Quoting the ARM ARM:
"Hardware does not prevent speculative instruction fetches from a memory
location with any of the Device memory attributes unless the memory
location is also marked as Execute-never for all Exception levels.
This means that to prevent speculative instruction fetches from memory
locations with Device memory attributes, any location that is assigned
any Device memory type must also be marked as execute-never for all
Exception levels. Failure to mark a memory location with any Device
memory attribute as execute-never for all Exception levels is a
programming error."
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-31 13:42:48 +09:00
Hector Martin
b65e2ca0e4
mmu: also set up high-VA translation
...
Just an alias
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
b2ef461114
get rid of another warning pragma
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
919e3fb64a
exception: use 64bit print types
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
65c0632ae7
exception: do not reboot on SError
...
This may or may not go well depending on the problem... but let's see
what happens.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
201d7d9a1e
exception: also print FAR_EL2
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
040cb9d6fd
exception: enable SError
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
bbe47b2f75
Move Apple ARM register definitions to cpu_regs.h
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
7807dad7bc
exception: add barriers around stuff
...
This CPU really likes to speculate...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
1f99c17fef
exception: clear L2C error status after exception
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
5dd63e41a1
exception: decode exception type on dumps
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
6dde40b05c
exception: introduce recovery from synchronous exceptions
...
Use this to recover from address faults in the proxy. Also print out L2
subsystem fault info.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
d31eab5f87
chickens: do not disable L2 subsystem errors
...
These mean real problems, let's actually fix them instead of shoving
them under the carpet.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
4167a18a64
utils: move sys_reg and is_ecore() to utils.h
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 22:00:00 +09:00
Hector Martin
2df212bf5c
adt: use ADT_FOREACH macros internally
...
This fixes some bugs too.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 03:15:00 +09:00
Hector Martin
dc2b7b3bb4
startup: clear bss section
...
iBoot does this for us, but this is for the benefit of chainload.py and
other dump loaders that may not.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 03:03:03 +09:00
Hector Martin
b673db78c3
minilzlib/xzstream.h: get rid of warning pragma
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 03:03:03 +09:00
Hector Martin
74307af0df
kboot: add proper kernel boot & DT manipulation code
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
ad93d14ee5
chickens: clear SYS_L2C_ERR_STS
...
It's unclear why this is necessary, but it fixes some strange crashes
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
c057775ab9
adt: add ADT_FOREACH_PROPERTY
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
891bc5592e
utils.h: fix msr/mrs macro expansion
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
46a46da111
string: add memmove, strrchr, strncmp
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
b82c0072e7
utils.h: mark reboot() noreturn
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
d280157289
libfdt: actually add libfdt
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-30 01:37:09 +09:00
Hector Martin
986c6730e9
Add heapblock and dlmalloc for managing memory
...
heapblock is a simple `sbrk` style implementation, also useful as an
"endless" decompression buffer. dlmalloc is used on top as a malloc
implementation.
This also changes how the Python side manages its heap. We still use a
python-side malloc implementation (since this is faster), and we put the
Python heap at the m1n1 heap + 128MB, without allocating it.
Hopefully this should never step on anything m1n1 neads, and avoids
having to manage freeing across Python script calls.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-29 16:25:15 +09:00
Hector Martin
f3d0a58f42
proxy: add mmu_shutdown call, use it for linux.py
...
I saw at least one SError crash on Linux after doing this, but can't
repro; unclear if related to the MMU changes or not...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-29 00:36:46 +09:00
Hector Martin
c3c6e4e8f9
smp: add scaffolding and proxy funcs for cross-CPU calls
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-29 00:36:46 +09:00
Hector Martin
e97b104125
main: do not spin up SMP
...
This breaks reloads, we shouldn't do this until we need to.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
eae3d06e85
smp: fix totally broken stack setup
...
This worked by accident before...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
11753f9983
start.S: probe the stack after init
...
This makes it obvious when the stack is broken.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
cffc423024
smp: use ADT data instead of hardcoded info
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
b4822eb02c
adt: improve APIs for iterating through child nodes
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
db902ce01f
wdt: move WDT disable code to wdt.c & use ADT regs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
3733ea153f
smp: fix broken spin-table routine
...
Only read target_cpu once, then keep a pointer our spin table.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Hector Martin
ba1162e322
adt: add an API for resolving reg properties
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 23:48:35 +09:00
Sven Peter
9242c820ae
MMU: clean and invalidate all caches after shutdown
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-01-28 23:20:15 +09:00
Sven Peter
2f84b33ba8
MMU: add cache operations by set/way
...
this embeds a slightly modified file taken from
arm-trusted-firmware.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-01-28 23:20:15 +09:00
Sven Peter
f244919c98
MMU: add initial support
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-01-28 23:20:15 +09:00
Sven Peter
63fad7e3e2
utils.h: add panic() macro
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-01-28 23:20:15 +09:00
Hector Martin
d762391a68
Add code to spin up secondary CPUs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 16:06:12 +09:00
Hector Martin
65276fdd3f
utils.h: add memory clobbers
...
We mostly use read32/write32 and friends to poke hardware registers,
which might have side effects on RAM, so just make everything a memory
clobber to avoid potential issues.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 16:06:12 +09:00
Hector Martin
0145830772
chickens: add firestorm chicken bits
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 16:06:12 +09:00
Hector Martin
344c84da17
clang-format everything
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-28 16:06:12 +09:00
Ariel Machado
51bf5c870a
adt: replaces int to u32 and size_t for unsigned values.
...
Makefile: increases compiler warnings
Signed-off-by: Ariel Machado <ariel@fe.up.pt>
2021-01-25 19:18:30 +09:00
Hector Martin
cc34ace39a
startup: Implement setting CPU chicken bits for Icestorm
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-25 19:11:54 +09:00
Hector Martin
58b643df77
clang-format a few missed things
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-25 17:25:49 +09:00
Hector Martin
a637b77816
Move minlzma.h -> src/minilzlib
...
This stops clang-format from running on this header.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-25 17:25:44 +09:00
Hector Martin
14db0224af
Add config.h for build-time config options
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-25 17:24:29 +09:00
Hector Martin
674a82a2bb
aic_test: UART IRQ testing stuff
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-23 22:42:59 +09:00
Hector Martin
63319ed348
utils: implement udelay()
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-23 22:42:25 +09:00
Hector Martin
009f04775e
utils: add __assert_fail function to make assert() work
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-23 22:42:25 +09:00
Hector Martin
ee12d053a9
proxy: add XZ and GZ decompression functions and code
...
This embeds tinf and minlzma.
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-23 22:42:23 +09:00
Ferdinand Bachmann
afc5813635
exceptions: fix clang warning for msr arg
...
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:09:22 +09:00
Ferdinand Bachmann
8511d9ff74
start.S: clang compat, don't use '\r' in asm files
...
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:09:22 +09:00
Ferdinand Bachmann
75c3cd39d4
start.S: don't use caller-saved registers accross calls
...
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:09:22 +09:00
Ferdinand Bachmann
6ecf5d9fb5
types.h: remove redundant definition of NULL (defined in stddef.h)
...
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:05:37 +09:00
Ferdinand Bachmann
274ea2baf2
exceptions: remove unused push_hi_regs symbol, make _exc_entry a function
...
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-23 22:05:24 +09:00
Hector Martin
31b6af14b2
exception.c: fix sp calculation in print_regs
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-18 01:57:27 +09:00
Hector Martin
81aaf2ed35
Basic exceptions, irq, cache mgmt support
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-17 00:49:22 +09:00
Ferdinand Bachmann
d49d0b781b
adt: fix ignored qualifiers in adt_getprop_copy function prototype
...
Signed-off-by: Ferdinand Bachmann <theferdi265@gmail.com>
2021-01-16 05:12:48 +09:00
Sven Peter
3268aabb91
add missing const to src/adt.h
...
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-01-16 02:48:22 +09:00
Sven Peter
4c4850935f
change #include <string.h> to #include "string.h"
...
this is required to fix the following error when compiling with clang:
CC build/string.o
src/string.c:3:10: error: 'string.h' file not found with <angled> include; use "quotes" instead
^~~~~~~~~~
"string.h"
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2021-01-16 02:48:08 +09:00
Clay Freeman
b0b3548f1d
Error codes should be returned as negative values
...
Signed-off-by: Clay Freeman <git@clayfreeman.com>
2021-01-15 12:52:34 +09:00
Hector Martin
5175c7a31b
Chainloading, ADT support, misc fixes
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-15 04:04:12 +09:00
Hector Martin
b8fd8363cd
Make UART proxy work
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-15 04:04:12 +09:00
Hector Martin
152c96a34a
Import UART proxy
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-15 04:04:12 +09:00
Hector Martin
8af9f1eb95
Initial commit
...
Signed-off-by: Hector Martin <marcan@marcan.st>
2021-01-15 04:03:35 +09:00