Commit graph

9206 commits

Author SHA1 Message Date
bunnie
4e522873f0 add preemptionstate opcode to the hal api 2025-10-26 13:38:28 +08:00
bunnie
0003921eb1 disable preemption during video capture
the camirq is a perfectly good source of preemption,
and xous will run other threads when the handler is finished.

having both natural timer preemption and camera preemption running
at the sime time seems unnecessary and hurts performance.
2025-10-26 13:37:31 +08:00
bunnie
d2254e2ce4
add HAL to keystore dependencies 2025-10-26 13:37:04 +08:00
bunnie
2a2863c11a
put keystore in charge of enabling preemption
this is done after critical setup is done. it doesn't guarantee
that it has an infinite time slice, but it makes the startup sequence
more deterministic.
2025-10-26 13:35:57 +08:00
bunnie
21c9089de2 make pre-emption controllable 2025-10-26 13:35:35 +08:00
bunnie
b8613797e5
add test code for boot0 write protection
this is a test stub that can be activated in baremetal that
confirms whether or not the bits blown to protect the boot0
region work or not.

This test should be run as part of the check-off process for the golden
image sent for production.
2025-10-26 02:01:00 +08:00
bunnie
6dd2a1f554
update dependencies for keystore 2025-10-26 02:00:19 +08:00
bunnie
ba91aa5b58
Add audit code for the keystore
the snippet `attack_keystore()` is left in place along with hints
on how to attack the keystore. Nominally, the attack should fail,
but there are some critical pre-assumptions that can be violated.

I am interested in knowing how robust those assumptions are, so,
documentation and sample code is provided to would-be attackers.

Do me a solid and if you do find a vulnerability, open an issue
ASAP and let me know. Full well aware that some vulns may well
be unpatchable; it is what it is. Hardware is hard, but maybe
we can work together to make it better.
2025-10-26 01:57:06 +08:00
bunnie
1c435909a2
fix the sense of the access permission bits
I had read the docs as saying 1 is denied access, but in fact,
1 is allowed access, at least empirically.
2025-10-26 01:55:27 +08:00
bunnie
bce08a1d27 clarify comments on coreuser protection 2025-10-26 01:46:57 +08:00
bunnie
72a7ea3a56 add settings for IFR locations 0x280 and 0xc0
Setting these JTAG-only accessible locations will set
write protection on boot0. This effectively makes the public keys
used to establish the boot chain indelible.
2025-10-26 01:31:34 +08:00
bunnie
f68cc0ba83 reorder some bao-video operation for a cleaner init sequence 2025-10-25 22:55:23 +08:00
bunnie
392cd64493
cleanup options in slot management code
- feature gate some unsafe-debug
- tie akey_id to 0xff which should disable key chaining, which
is not used in our scheme because authentication is not hmac-based,
uses public keys instead
2025-10-25 22:27:50 +08:00
bunnie
87e279b4cb add api dependency to ticktimer 2025-10-25 22:24:53 +08:00
bunnie
37ff052b34 chunk data to the USB subsystem
the chunks match the size of the application buffer, eliminating
the possibility of an overrun (of the buffer at least)

there is a possibility still i think of overrunning USB itself
but i think the CPU can't produce data fast enough to actually
do that.
2025-10-25 22:23:36 +08:00
bunnie
e98ffaadfd fix missing import path 2025-10-25 22:23:08 +08:00
bunnie
e9bf366d3d update freq v voltage setting code in loader 2025-10-25 22:22:40 +08:00
bunnie
66131a59bf add speed-up setting for dabao
the boot1 loader on alpha0 release is conservative
2025-10-25 22:12:42 +08:00
bunnie
3944978ded reposition selftest to before the main loop
this allows selftest to run immediately on power-on, instead of
waiting for USB connection
2025-10-25 21:38:25 +08:00
bunnie
b4502854f1 adjust dabao default frequency to full speed
latest rev of the board seems to handle the heat load OK.

board gets a little warm to touch when the system is clocked
at max frequency, but not unpleasantly so.
2025-10-25 21:37:38 +08:00
bunnie
0a1813b28c fix off by one in assert statement 2025-10-25 21:37:19 +08:00
bunnie
8a3e9ea3f5 fix crlf issue in logging crate 2025-10-25 21:36:46 +08:00
bunnie
63b848df28 fix timing interval to match the CPU clock frequency 2025-10-25 21:36:21 +08:00
bunnie
51ad124180 fix various dabao-console issues
- \r\n formatting is now consistent with the rest of the OS
- fixed buffer size assert failure when sending large strings
- removed 'cute' command - i love it but the UTF-8 doesn't render
on all terminals and will lead to more criticism than delight
- made usb serial a default option
2025-10-25 21:33:09 +08:00
bunnie
2be1b48653 fix import path 2025-10-25 01:38:55 +08:00
bunnie
d11d2f8cd5 modify default voltages; normalize the setting location 2025-10-25 01:37:21 +08:00
bunnie
e1f685f70d fix missing path 2025-10-25 01:32:22 +08:00
bunnie
569e9526eb fix comment 2025-10-25 01:31:48 +08:00
bunnie
4a12668751 only check the flash ID after going to QPI mode
handles more cases of flash mode switching
2025-10-25 01:31:20 +08:00
bunnie
c92af3c25a fix up pin mappings for v2 board release 2025-10-25 01:30:58 +08:00
bunnie
d44f489a83 map out PID 0's access in going to secure mode 2025-10-24 21:16:00 +08:00
bunnie
0d369f8a9f add feature for printing the ifr in boot 2025-10-24 21:15:12 +08:00
bunnie
d6d06c9eae adjust location of system timer constant 2025-10-24 21:14:49 +08:00
bunnie
1aaa8dd9ac fix typo in pinmask & adjust timings according to factory's preferences 2025-10-24 21:14:19 +08:00
bunnie
857c5875fe move the keystore to the appointed slot for access to secure regions 2025-10-24 21:13:18 +08:00
bunnie
dab13d5b70 turn on the AV generator in loader
the kernel should rely on the AV generator for random numbers,
and so it should be on and operational by the time the kernel
boots
2025-10-24 21:12:31 +08:00
bunnie
04d46b9549 update location of system timer interval definition 2025-10-24 21:12:00 +08:00
bunnie
5fb7743d3b add preemption timer to the kernel
we can use the TIMER0 mechanism now that this is available in NTO!
2025-10-24 21:10:19 +08:00
bunnie
41f09420cd
clean out some old debug, and activate erase_secrets on dev boot
this has only been lightly tested - much, much more testing
is needed.
2025-10-21 23:47:51 +08:00
bunnie
68b910ecc8
minor cleanup 2025-10-21 23:47:00 +08:00
bunnie
caf6fc3a61
Implement erase_secrets() on entry into developer mode 2025-10-21 23:46:06 +08:00
bunnie
1e9d97db44
fix default example to something more commonly used 2025-10-21 19:25:03 +08:00
bunnie
391af0313f
fix typo 2025-10-21 19:15:22 +08:00
bunnie
917154ae74
fixup coreuser settings
the more i test things the less confidence i have.

this fixes up a missing table entry in the table definition,
and then also adds a bypass routine - this is not actually
a hidden vulnerability, it's an explicit vulnerability until
the protect() routine is called. But it looks like we may have
to exploit it in order to transform our userstate in
the bootloader to one that has write-access to keys in order
to erase them in case of a developer boot.
2025-10-21 19:12:30 +08:00
bunnie
be038e56aa
cleanup comments
figured out why the data region acl wouldn't write - had
to be in boot0 declared mode
2025-10-21 19:11:52 +08:00
bunnie
e3140609e4
designate the eraseable keys
only some keys are marked as writeable to harden against
potential oracle attacks, i.e., if we made all keys
erasable and an oracle attack was found, then the entire
key region can be exposed by the oracle attack.

Instead, some key material always persists, but a sufficiently
large amount of seed material is erased such that the key is not
recoverable by guessing the key.
2025-10-21 19:08:35 +08:00
bunnie
11c23c3b1c
refactor coreuser setting and boot flow
this accommodates the notion of erasing secret keys when
a developer key is detected. Some hackery in the API is
required, because I'm trying to use the same signature
routine for both boot0 and boot1, but coreuser settings
should not be set until boot1.

Boot0 has *no* coreuser settings, whereas boot1 starts
to lay them in - this interferes with key erasure, and
so the nice clean "boot or die" abstraction disappears
because we have to now just check if a key matches a criteria
and then return because we have to handle the environment
dependent case of coreuser settings.
2025-10-21 19:06:12 +08:00
bunnie
e1c07cbf0b cleanup some debug output & fix ref link 2025-10-21 04:16:45 +08:00
bunnie
602ef2d8a4
update signing procedure notes 2025-10-21 03:16:21 +08:00
bunnie
3e4b0b6571
Add bao2 signing keys 2025-10-21 02:39:11 +08:00