right now the inability to move the WDT object through the
hardware manager is causing it to be initialized fairly late
in boot which makes it less useful for recovering from boot
failures
the commited code works, but there's something weird going on
with the clock setting math that indicates i'm not understanding
exactly what's going on. Need to move on and solve other problems,
but this will be an outstanding issue.
occassionally the hardware block just goes unresponsive. the
'fix' is to reset it, and then re-initialize the interface.
I suspect this has to do with the UDMA silently dropping transactions
when there's too much contention on the bus.
- adds API for retrieving & setting the ephemeral key. This is
a key that is erased by a power-on reset, but is preserved between
deep-sleep sleep/wake cycles. It is intended for securing a lock
PIN, and can be up to 192 bits long.
- adds API for checking the warm boot flags, which are also stored
in the backup registers.
- xor-masking of jump target moved to immediately before the jump
- mscratch csr zeroed
- anti-rollback single-update distance limited to 512: let's hope we
never even get close to having 512 security revisions in a single
generation!
- sanity check untrusted signature/add length fields - constrains
hash-checks to within the right "range", preventing abuse of the
hash reads as an oracle to leak state about other things in memory.
- check valid_key != valid_key2 invariant before returning
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.
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.
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.