Commit graph

9995 commits

Author SHA1 Message Date
bunnie
0529a10eb8 modify audit to leak information about the erase coupons
this helps verify the erase state by implication of secret keys
2026-02-04 15:54:20 +08:00
bunnie
0ae03c6354
Merge pull request #805 from betrusted-io/antirollback-ci
Add ability to simulate third party images
2026-02-04 03:16:04 +08:00
bunnie
f17b67c16d put the test key into the devkey slot
i feel a little more comfortable with this because there are
checks that *any* key in that slot would be treated as a devkey
and would lead to key erasure. so just in case i messed up
something in the other checks, this would trigger a key erasure.

I think there is no way around signing at least a beta image
containing the third party keys if i truly want to check all
the paths, so trying to isolate what it can do is important.
2026-02-04 03:14:29 +08:00
bunnie
cf267f096c generate actual private keys instead of using random data
by doing this we make this safer by ensuring that the public
keys are valid public keys, allowing us to sign these images
with production keys and not accidentally signing a weak
public key.
2026-02-04 03:07:38 +08:00
bunnie
0caf0bb2d7 add a testing key for third party images
just some fake base64 data to make a unique key that we can
use to "sign" third party images
2026-02-04 02:50:24 +08:00
bunnie
f0fb76dca1 add ability to generate and install testing keys for third party images 2026-02-04 02:50:08 +08:00
bunnie
e1a40b2fb9
Merge pull request #804 from betrusted-io/antirollback-ci
minor fix: fix argument name
2026-02-03 23:51:25 +08:00
bunnie
0e345b8a48 fix argument name 2026-02-03 23:50:36 +08:00
bunnie
5720fb03e2
Merge pull request #803 from betrusted-io/antirollback-ci
More CI features, streamline boot1
2026-02-03 22:52:13 +08:00
bunnie
293a445944 add test command to generate collateral keys
this allows us to simulate a third party firmware's behavior
so we can test that collateral key states go through the right
set of state transitions in various test cases.

the collateral test is also made more precise and can now
report unititialized/permission denied state
2026-02-03 22:07:14 +08:00
bunnie
602cc44ff8 add the ability to create a fake public key block
This just populates a pubkey block with random data, simulating
a third party firmware. A fake pubkey block can't boot anything
else because we can't sign a firmware that matches that. But,
it's also good enough to be able to test collateral key states.
2026-02-03 22:05:55 +08:00
bunnie
a840beb98e
loosen check on key tag
The original check on public key tag was "if the tag doesn't match
one of four approved tags erase secrets".

With third party images, third parties can pick their own tags - so
as-writ this would constrain third parties to have to use the same tags
as baochip, which is too restrictive.

Change the check to explicitly trigger erasure if and only if
the tag is "dev ". Note there are plenty of other checks around as
well so this is not the sole check, thus I think loosening this
permission is good for keeping hygiene between third party firmwwares
and baochips own firmwares.
2026-02-03 18:33:33 +08:00
bunnie
33b35fb054
remove avalanche TRNG code from bootloader
Now that the sensitive keys are provisioned in Xous and not in
boot1, there is no need to have a dependency on the avalanche
generator (and in fact, in practice, it's never used because
the random data that is collected is always collected before
the board type is set to even allow usage of the avalanche generator).

To wit: The only bits that are created using the ring oscillator
are public random identifiers such as the UUID, which are not
security critical pieces of data.

Removing this unused path simplifies the bootloader code.
2026-02-03 18:16:11 +08:00
bunnie
f96c01634f
streamline acram/slot manager access
Reviewing the code, I was decomposing multi-element slots
into individual slots, but erasing them as a multi-element slot.
This results in unnecessary churn.

The barrier to doing a simple check on the full slot all at
once was a missing API for unchecked reads of the full slot:
during checking, we want to be able to retrieve the contents
even if technically the ACL access is denied (note that the
ACL is enforced in *hardware*, the software based check of
the ACL is just a "belt and suspenders" check).

So, this patch adds a routine that allows for an `unsafe`
retrieval of the slot data regardless of the ACL, where the
safety condition is that the caller has to be aware that
junk data could be passed to it if the ACL isn't correct.
2026-02-03 18:12:18 +08:00
bunnie
876f6621da
Merge pull request #802 from betrusted-io/antirollback-ci
Antirollback ci
2026-02-03 04:05:01 +08:00
bunnie
7a55d6a669 add command line arguments to override antirollback settings
this argument is primarily intended for use in CI testing to create
a synthetic image that has an advanced antirollback code.
2026-02-03 03:24:06 +08:00
bunnie
56c1230b2e add error printing on boot0 signature failure
this will at least give us a hint as to why a boot1 failed to
boot. It does hand an attacker some information, but we also
need information to debug e.g. RMA and field failures.
2026-02-03 03:23:07 +08:00
bunnie
02c9226c1b
Merge pull request #801 from betrusted-io/clock-tweaks
automatically adjust BIO clock dividers on sleep
2026-02-02 23:46:32 +08:00
bunnie
e349703fd5 automatically adjust BIO clock dividers on sleep
this allows the BIO to continue to function even though
the CPU core is in WFI. It isn't running at full speed, but
for some applications (such as WS2812 LED driving) the lower
speed is perfectly adequate and you save a lot of power
by turning off the CPU core.
2026-02-02 23:37:48 +08:00
bunnie
9a70462416
Merge pull request #800 from betrusted-io/fix-disconnect
Fix HAL disconnect bug; improve correctness in connection handling; improve performance in SPIM waits
2026-02-02 02:01:35 +08:00
bunnie
7d7ddae73e pin the irq handler object for the iox banks 2026-02-02 01:29:19 +08:00
bunnie
0f19750831 remove autodrop on other hal service items 2026-02-02 01:28:32 +08:00
bunnie
2005293e11 remove autodrop on trng service 2026-02-02 01:28:15 +08:00
bunnie
70639470bf cleanup an unecessary static mut and make it an Atomic 2026-02-02 01:26:42 +08:00
bunnie
54c070b433 remove old comment that is no longer valid 2026-02-02 01:26:25 +08:00
bunnie
7f6b045681 optimize timeout handling in spim interface
while debugging the disconnect issue, discovered that the timeout
routine in `std` was extremely wastefully blasting the name server
to connect to the ticktimer every time it was called. yowch!

this patch does the following:

- cache the ticktimer connection in an AtomicU32
- check if the transaction is done on the "Fast path" before
doing any waiting
- check again after fetching time - at this point, most transacitons
are actually likely done
- only then, do the wait loop

this greatly speeds up screen drawing, it seems.
2026-02-02 01:22:26 +08:00
bunnie
be5e817c7c expose register manipulation as public functions
the library is a bit too specific to a given application
without the generic API being exposed. i.e. the way it was
originally generated would imply that every scenario for
the driver would need to be implemented in the library-side
HAL, when in reality, I think it makes much more sense for
the customization of registers (especially when debugging)
to live near the device side.
2026-02-02 01:20:41 +08:00
bunnie
d466abd456 strip out disconnect idiom in the HAL crate 2026-02-02 01:20:14 +08:00
bunnie
8bc480994c remove disconnect idiom from HAL API
the implementation is flawed - because multiple APIs hit
a single server, the reference count can reach zeoro for
a given interface, and trigger a disconnect, while another
API is still using it.

the long-term fix for this, if we wanted auto-disconnect,
would be to wrap the connection query into a helper that
uses an Arc to ensure the count is maintained across all
possible interfaces.

However, for the HAL, it's likely that pretty much every
server is going to want this connection, and want it to
stay around so - we'll just remove the auto-disconnect
idiom for now and figure something out if we end up
hitting a connection resource limit on a service that
truly only needs the HAL connection early on in its
lifecycle and never needs it again.
2026-02-02 01:17:24 +08:00
bunnie
867d9cf2a8 fix connection allocation
the kernel is supposed to first search for an existing
connection before allocating a new one. this patch fixes the
order of search so that it meets this spec.

previously it was preferring to allocate a new connection
before re-using an old one. I think we got away with this
because we just didn't have that many connections.

it'll be interesting to see if this causes any regressions
on Precursor.
2026-02-02 01:15:55 +08:00
bunnie
a0f4856f97
Merge pull request #799 from betrusted-io/out-of-tree
fix regression in app location in dabao build script
2026-01-31 15:44:03 +08:00
bunnie
791068e073 fix regression in app location in dabao build script
apps were accidentally getting stuck in the kernel

very confusing

much strange

wow
2026-01-31 15:36:22 +08:00
bunnie
ea8c68c654
Merge pull request #798 from betrusted-io/out-of-tree
add the ability to specify regions for apps; eliminate default apps
2026-01-31 03:08:17 +08:00
bunnie
9a008730f6 add the ability to specify regions for apps; eliminate default apps
Default apps for base xous configs are now eliminated - this
allows third party builds to add their apps without having to
delete the default apps used for initial testing (the upshot is
that the CI scripts elsewhere are now all modified to include the
apps I'm using to test the system; which is fine).

So now, `dabao` and `baosec` build what is a baseline set of
services that I think are expected in either platform. In the case
of dabao, apps get stuck in the detached-app area; in the case of baosec,
apps are stick in swap.

So:

`cargo xtask baosec bao-console vault2`

by default sticks the app `bao-console` and `vault2` into swap.
If you want one of these programs to go into RRAM instead, you would
specify the build like this:

`cargo xtask baosec bao-console~flash vault2`

The `~<region>` syntax indicates that the thing to the left of `~`
is the name of the app; and to the right is a region spec, one of:
[swap, flash, ram].

No checking is done that these regions are valid or even good
for placing these things, the image just tries its best to whack 'em
in there. If you blow out the size of the kernel, at least, a
warning will be emitted.

This change enables more flexible out-of-tree options for
developers who don't want to build the whole Xous kernel, but
at the moment, caveat hacker - things are still in flux and under
heavy development. I think in about 2-3 months things will settle
down enough that we'll cut a release and then the APIs should be
cleaner/more stable, but for now anyone developing with a pre-release
dabao board is recommended to either build kernel from scratch or
at least fetch the latest CI image off of the CI server if things
seem squirrelly.
2026-01-31 02:08:45 +08:00
bunnie
a44cdcab44
Merge pull request #797 from betrusted-io/out-of-tree
Out of tree build fixes
2026-01-30 21:54:17 +08:00
bunnie
b6b37f601e note out of tree build feature in the README docs 2026-01-30 21:02:31 +08:00
bunnie
f08a04308d bump version for xous-tools
publishing the antirollback feature
2026-01-30 20:28:26 +08:00
bunnie
d01615ff6e add handling for anti-rollback code in signed images
for out of tree builds, we'll just stick with the default code
of '1': if you're doing a build out of tree, it's assumed that
you don't care about security (not tying your application to
a given OS version opens up an attack surface; presumably if
you're doing something security-critical, the extra hundred
megabytes to clone the xous-core repo isn't a big deal? but
if you're just trying to blink some LEDs you really don't care
about the anti-rollback feature).
2026-01-30 20:25:51 +08:00
bunnie
6d6f41f426 bump minor rev on xous-tools
this forces the semver to nil so that we don't get errors in
a signing routine that lacks access to versioning.

The upshot is that out of tree apps have no version assigned
to them, and they can't be checked for version compatibility.
2026-01-30 19:42:24 +08:00
bunnie
47e0899f1b prune the previous feature added to resolve versions via web interface
The problem is that this feature, while neat, pulls in a huge
amount of code into the SBOM, a lot of which looks pretty scary,
and we're also including the ability to hit the network in the
build system which is also scary and potentially full of software
supply chain exploits.

So, while it would be "neat" to have the system be "smart enough"
to guess a semver based on a git rev of xous-core without having
to pull down tags or clone the full repo, the cost is a huge amount
of tooling and code and trusting a very large attack surface to
also not use the same mechanism to exfiltrate your keys, hack
your computer, or otherwise cause abuse.

For such a minor feature, I think this risk is not worth it.
2026-01-30 19:40:05 +08:00
bunnie
e41195e349 attempt to resolve version from URL automatically
this might be a bit too heavy-weight for a lightweight tool but
let's give it a try
2026-01-30 19:30:28 +08:00
bunnie
829a793d21
Merge pull request #796 from betrusted-io/out-of-tree
Out of tree build support
2026-01-30 05:03:48 +08:00
bunnie
87413806bf xous-make-renode-boot deprecated
cargo xtask renode-image can create teh renode images

I think make-renode-boot is actually a really old experiment
that was then pulled into the xtask image generator, but never
pruned. This *has* to be pruned now in order for cargo publish
to work so that the xous bin utils can be installable.
2026-01-30 04:33:36 +08:00
bunnie
de881ff70f commit deprecation of xous-make-renode-boot 2026-01-30 04:32:57 +08:00
bunnie
8ca4199960 remove deprecated program
this is complicating the publication process
2026-01-30 04:32:34 +08:00
bunnie
a09075f08e deprecate xous-make-renode-boot
this is no longer used and its reliance on blobs breaks publication
2026-01-30 04:30:57 +08:00
bunnie
de7c1c0f49 fix tools toml file for publication 2026-01-30 04:26:32 +08:00
bunnie
4a7ed1315e add maintenance notes 2026-01-30 04:26:15 +08:00
bunnie
d44caab9ec update api for publishing 2026-01-30 04:22:33 +08:00
bunnie
b1121daef6 security-relevant: modify collateral test to not panic on failure
The panic on failure causes incompatibility with older boot0's
that don't set up the collateral area correctly.

Make the failure more graceful, but we also promise ourselves
to add CI tests to check for this explicitly, because we can't
just rely on panics to enforce behavior.
2026-01-30 04:01:09 +08:00