Commit graph

166 commits

Author SHA1 Message Date
bunnie
bc3aac677f fix zero-length key readback error in bulk reads
zero-length keys return a data section of None, instead
of Some(<empty vec>), as the latter representation deserializes
to a null pointer panic.
2023-01-30 22:14:59 +08:00
bunnie
8350095d36 fix initialization order so that CI can run 2023-01-30 22:14:58 +08:00
bunnie
e25da3a720 add implemenation of the prune debug call
this allows us to trigger the cache prune manually, instead of
in response to memory backpressure only
2022-12-29 22:04:15 +08:00
bunnie
1e56598b10 chore: fix some typos 2022-12-29 00:53:32 +08:00
bunnie
5370c333da add callback for monitoring basis lock/unlock events 2022-12-29 00:10:42 +08:00
bunnie
b1b6d46d27 chore: more typos
probably should not have tried to spell check this, now i'm wasting
my time.
2022-12-13 22:56:37 +08:00
bunnie
52955681d5 reflect unmount status after tryunmount
this fixes a problem where backups fail when autobacklight is
enabled, because autobacklight is constantly querying the PDDB
for the length of the autobacklight timeout, even after the
PDDB is unmounted.
2022-12-02 20:10:10 +08:00
bunnie
0646ec23ba track "attempted" mounts in PDDB
this is to allow a UX process to clear the "waiting for boot"
indicator once an attempt has completed.

right now, it responds *after* the mount process is done,
so the "please waiting" text persists even doing a format.

I think that is...appropriate?
2022-11-07 00:21:52 +08:00
bunnie
fa90e74a10
Merge pull request #270 from gsora/feat/pddb-init-notification
feat: show boot process notifications for PDDB
2022-11-06 03:40:17 +08:00
bunnie
7eecf2b1ce remove the initial wait from PDDB; move the pop-up modal location
The initial wait message is now rendered by the first app
that owns the screen (currently shellchat).

The location where the pop-up modal is rendered is also now bracketed
directly around the mount call to avoid interference with other
edge cases that may pop up modals.
2022-11-06 03:07:35 +08:00
Gianguido Sorà
d277ae9551 feat: show boot process notifications for PDDB
This commit shows two notifications:
 1. as soon as the device boots, a notification greets the user and
 tells them everything is fine, the device is booting
 2. as soon as the user enters (or doesn't) enter the password, a
 notification tell the user Xous is loading and mounting PDDB

I spent too much time on this but I believe it's a nice UX improvement.
2022-11-04 17:31:27 +01:00
bunnie
0d9a39a349 print debug information when a key goes missing in bulk read
this helps debug problems down the road
2022-11-04 17:05:32 +08:00
bunnie
d74673ab29 allow main menu to be used if there are no root keys 2022-11-04 03:55:57 +08:00
bunnie
80a1bd3654 resolve issue #267 2022-11-03 23:18:13 +08:00
bunnie
719020b08b don't allow polls to the unmount to turn true until other callbacks have been allowed 2022-11-03 17:23:11 +08:00
bunnie
d63c452fb6 catch serialization buffer edge case
if the buffer fills up to the point where there isn't enough
space for the 8-bytes of header, a split_at() call will fail before
the routine even gets to decide if the record can fit.

abort the loop if the buffer is that full.
2022-10-27 23:00:10 +08:00
bunnie
c82a79dab9 add performance monitoring in for bulk reads 2022-10-27 16:45:04 +08:00
bunnie
bef734553e clarify some comments and clean up debug messages 2022-10-27 02:53:38 +08:00
bunnie
6992b31104 fix the bufserializer approach
this is much more efficient than the alloc serializer
2022-10-27 02:41:46 +08:00
bunnie
6272a94604 intermediate attempt to extract a length parameter 2022-10-27 01:57:42 +08:00
bunnie
ac01088ec7 Merge branch 'pddb-bulk' into pddb-bulk-bufserializer 2022-10-27 01:30:27 +08:00
bunnie
3d1885e165 add test code
results are slightly better on the first run (3700ms instead of 4900ms)
but there seems to be really excessive allocations using the heap
allocated serializer by rkyv. We really need to use the bufserializer
I think for this to work.
2022-10-27 01:10:17 +08:00
bunnie
721dbc82d7 add an attempt to use bufserializer that didn't work 2022-10-26 23:29:43 +08:00
bunnie
d9bffb3556 add some notes about making this more efficient 2022-10-26 22:06:00 +08:00
bunnie
665e7dce51 fix minor bugs, now passing basic test 2022-10-26 15:16:40 +08:00
bunnie
bffe92cab9 add first draft of bulk serialize/deserialize functions 2022-10-26 05:29:44 +08:00
bunnie
2e768dd19e Merge branch 'main' of github.com:betrusted-io/xous-core into pddb-bulk 2022-10-25 23:15:51 +08:00
bunnie
30ea893c74
Merge branch 'main' into xous-rs-os-selection 2022-10-25 17:28:33 +08:00
bunnie
67fc21fbdd harmonize hosted mode selection, but retain an explicit hosted flag
In general, hosted mode is assumed "by default" if the target
is not Xous. This allows packages to be built cleanly on command
lines that don't know to pass a --feature flag to specify a target.

However, an explicit "hosted" flag is still retained so that we
can confirm the build system intent. This saves us from the failure
mode that we thought we were building for target A, but accidentally
ommitted the flag, and instead we've been silently building for
"hosted" mode without any warning. The main consumer of the "hosted"
flag is now just the build.rs script inside of the utralib.
2022-10-25 17:21:02 +08:00
bunnie
97f0d34daa more analytics on PDDB debugging 2022-10-24 02:35:55 +08:00
bunnie
e515092636 add performance profiling options to PDDB 2022-10-23 23:14:57 +08:00
bunnie
d7392d3704 improve comments and add count to the user-failed mount case 2022-10-17 03:51:36 +08:00
bunnie
de41e5ecff rework password login to have a count and reboot/suspend after N retries
The implementation is a bit clumsy because the original
premise of the login loop is that it should be infalliable, and
because of the isolation of the password mechanism there isn't
a great way to pass number of failures back and forth across
that firewall (and I don't think there should be).

The application calling the password routine tracks failures
but the mounting routine has to kick that up to the main loop.
However, the PDDB main loop can't get stuck on the mount attempt
if you want to suspend, because it has to respond to the suspend
request.

So the failure message has to get kicked all the way back to the
status thread, which is what kicks off the mount, and then handled
there.
2022-10-17 02:40:51 +08:00
bunnie
ec1d1b4444 don't try to unmount anything if nothing was mounted 2022-10-17 00:32:06 +08:00
bunnie
2ff9163789 add checksums to PDDB backup
every 1MiB block is checksummed with a sha512/256 truncated to
128 bits. This is used to confirm the media and transport integrity
only. It is not intended to be a cryptographic check, it just confirms
that the backup data was transferred correctly assuming no intentionally
malicious actors in the middle.
2022-10-09 01:10:42 +08:00
bunnie
62af36560b checks for cache coherence issues
Most of the changes introduced in this commit were rolled back,
but, there is now a test facility that's hanging out for the PDDB
to help with future debug efforts.

The patch was motivated by a problem observed in FSCB consistency
when it's updated. Ultimately the root cause was traced to a
cache coherence problem and it's fixed by a patch in the spinor
crate.

However, this patch still retains a check that the data is coherent,
in case the flushing routine isn't complete or some other factor
was missed. It also includes a large amount of commented-out code
that keeps a bit of history used to debug the problem -- eventually,
we can just cull that but it's kept around in case we got the
root cause wrong (or there were multiple causes and coherence is
just one of them).
2022-10-07 18:52:57 +08:00
bunnie
4e40ae6c5d move from target selectors to feature selectors for back-ends
This will allow for e.g. xous on riscv32-imac but not a precursor
target, for example: by using feature selectors we get to have
a bigger range of targets that we support, such as for implementations
that haven't been upstreamed or have official target-triples.

The downsides are:

- patch override libraries don't absorb feature flags. so, for
example, the AES crate that is used to patch other crates won't
be aware of the target features without modifying the referencing
crates.

- features are normally meant to be additive, but target features
are mutually exclusive. The mutex is enforced by a check in
utralib that throws a panic on build if two targets are accidentally
selected at the same time.
2022-10-02 02:56:44 +08:00
bunnie
9225cbaba3 resolve issue #206 by adding check for existing basis 2022-09-20 23:06:22 +08:00
bunnie
4ae3308fbe add PIN change to the PDDB 2022-08-12 23:10:18 +08:00
bunnie
2b4ce52a10 fix some regressions on empty key listings 2022-08-02 02:52:04 +08:00
bunnie
0d61cbb838 improve debug output 2022-08-02 01:37:45 +08:00
bunnie
13b366345c clean up/optimize the key listing routine
provides some marginal improvement on the vault UX
2022-08-01 23:12:26 +08:00
bunnie
7d62ca85b8 some preliminary schwags at making flamegraphs
turns out, they're pretty useless. I mean, for debugging actual
running code. it tells us basically what we know already which is
99.99% of the time is spent waiting on inter-thread messaging
in hosted mode.
2022-08-01 01:32:19 +08:00
bunnie
e469736278 stagger the flush timing a little bit
noticed it's hitting exactly when NTP updates because it also
happens on a 24-hour schedule, staggering a bit to try and keep
everything from hitting exactly at the same time once a day.
2022-07-29 15:00:44 +08:00
bunnie
46c53d9612 add telemetry for better PDDB CI 2022-07-28 18:46:56 +08:00
bunnie
ac1f746566 add fscb/spaceupdate journal flushing & periodic flush
- fix journal number bug in basis root record
- fix conflict PTE resolution to also consider basis root record,
which has a different encryption form.
2022-07-28 04:54:35 +08:00
bunnie
6f10061653 reset "don't ask again" flag for password creation during factory test
this facility is necessary in case a worker accidentally picks
the wrong setting, disabling the feature for the device. When
the factory test completes, a call is made to reset the parameter.

This was a slightly complicated affair because the the don't ask
flag is contained within the rootkeys enclave itself, and we can't
just give access to rootkeys willy-nilly. So the flag is passed
through the PDDB and then to the rootkeys enclave. It's not harmful
to have it reset by an unauthorized actor; the pop-up will not
happen if passwords are, in fact, already set.
2022-07-19 23:57:25 +08:00
bunnie
e8188309cf add rekey operation for PDDB migrations to new devices 2022-07-19 03:16:37 +08:00
bunnie
a89ae13463 move pddb mounter to status thread 2022-07-11 04:12:44 +08:00
Sean Cross
086c014de2 pddb: close all related filehandles when a file is deleted
Signed-off-by: Sean Cross <sean@xobs.io>
2022-07-05 23:56:31 +08:00