Commit graph

36 commits

Author SHA1 Message Date
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
f815ed85b5 fix rust 1.64.0 rkyv warning regressions on unused enum types
rkyv-derived enums throw warnings that they are unused.
Not sure how to get rid of them; I've tried surrounding them in
`#[allow(dead_code)]` directives, and also explicitly creating
each enum variant that I'm aware of through some dummy code and
some log prints of the dummy code calls to ensure the results are
used, and the warnings still persist.

Significantly, the warnings only happen for enums that take
a value. Simple rkyv enums do not throw a warning.

These warnings overwhelm the build logs, so they need to be isolated
in order for us to ensure that the build is clean of other more
important warnings.

The method chosen to isolate them is to take the enums that are
problematic, carve them into their own special file, and add
a file-wide `#![allow(dead_code)]` directive. This only happens
in 7 service crates, and this change commits all of the modifications
in a single big commit that could be undone later if this turns out
to be a compiler regression or something similar.

I also opened an issue with the rkyv maintainer to see what his
opinion is on the situation.

https://github.com/rkyv/rkyv/issues/318
2022-10-09 17:17:20 +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
9a712e643f fix hosted mode 2022-09-22 16:42:41 +08:00
bunnie
7b040f5c34 Close issue #71 (wait_event() for SHA512 block)
I was this many years old when I learned that:

- If you put a `let` inside a block and then pass it outside
the block, it definitely gets a different address. This was causing
KP's in the interrupt handler routine because I was using a block
to mark off the configuration feature and then passing the handle
to the data structure outside the block; instead of just aliasing
the handle over as I assumed it actually makes a copy in a new
address location. This made debugging really hard until I figured
that out, the solution was to put #cfg directives on every line
related to the feature instead of grouping them together into a
block and using a single #cfg directive.

- event_wait() takes longer than 2us to execute. However, the
sha512 computation is done in 2us. So, by the time we checked
if we should wait and called event_wait(), the interrupt that
would wake us up from event_wait would have already happened.
This race condition is what broke event_wait() in the first place.

We now just use a spin loop without even a yield(); as the yield
would take longer to execute than waiting for the hash function
to finalize.
2022-09-22 15:06:54 +08:00
bunnie
e288286bda reduce binary burden of backup SHA implementations
When the hardware engine is unavailable, the implementation
falls back to a software SHA. This code path is actually
rarely used, but it is the top object code consumer according
to our bloat analysis tool (40kiB for each instance of
the compress function alone).

This patch annotates the SHA functions with `#[inline(never)]`
to reduce the size of these rarely-used functions.

...it might actually be that on our small-cache system,
reducing the in-lining could improve performance as well
because it helps the whole routine fit inside L2 cache.

Anyways, it's a rarely-used path (I've never seen the code
used once tbh) so let's reduce its overhead and keep
Xous trim.
2022-06-10 18:02:52 +08:00
Sean Cross
3ae9d8abf0 apps/services: remove xous::xous_main macro usage
This macro will be removed, since it is no longer necessary. Remove this
macro across the project and replace it with a standard `main()`
function.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-31 13:33:30 +08:00
bunnie
b275b1d3c2 move some low-level hardware facing services to "Late" suspend status
So far it's been no problem to suspend these in any order, but as
more services come to rely upon them it's better if they suspend after
any client applications have been suspended.
2022-01-10 13:48:49 +08:00
bunnie
c5fe1bc99b add sequencing to suspend/resume order of operations
this is necessary because we want to make sure that the SPINOR
service does not shut down before the PDDB service finishes syncing
its disks.
2022-01-10 13:45:56 +08:00
bunnie
74531517dd move more crates to standardized formatting 2021-08-20 00:24:16 +08:00
bunnie
c0ce66ee51 fix permissions. windows is sort of stupid and makes everything +x 2021-08-19 23:34:29 +08:00
bunnie
7edc119472 clean up debug spew 2021-08-09 14:06:54 +08:00
bunnie
04dc6a4c2b refactor engine-sha512 to be named sha2
this makes patch.crates-io much easier to debug, we now
have the hardware hasher working in all the places i expect it to.
2021-08-09 04:40:33 +08:00
bunnie
ec6a3fd1a3 self-signing working, but the patch to use the SHA hash engine seems to be disregarded... 2021-08-09 03:27:43 +08:00
bunnie
40b671ffac refactor for sha256 software emulation native in the engine512 crate 2021-08-05 22:07:21 +08:00
bunnie
68ea69c2ed Merge branch 'bunnie-dev' into main 2021-08-03 17:22:10 +08:00
bunnie
d86c78eea8 partial progress on self-signing 2021-08-03 04:58:34 +08:00
Sean Cross
b86e0a65cd services: recognize xous as a hardware OS
Support `xous` as a valid OS. This allows us to build the entire kernel
under this target.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-02 18:11:48 +08:00
bunnie
a4f8346c34 reflect the latest fixes to the secure boot process
also patch up some issues with sha512 reset and loose
ends on docs and updates
2021-07-13 00:46:31 +08:00
bunnie
6c697de512 add l2 cache support (suspend/resume flushing)
also noted some performance benchmark improvements
2021-07-05 17:05:10 +08:00
bunnie
e2ada8f8fe attempt to fix up some build system warts 2021-06-28 01:31:43 +08:00
bunnie
16ec932286 refactor to sync/async apis split 2021-06-23 19:12:43 +08:00
bunnie
69a22adee9 menus basically working 2021-06-19 00:25:18 +08:00
bunnie
aa967a5a17 quiet up hosted mode build warnings 2021-06-18 22:37:08 +08:00
bunnie
eee9f4e765 refactor xous-names to permit only a fixed number of connections
this prevents less trusted processes from connecting to servers
after the kernel initializations are done.

this works so long as we don't have disconnects from the kernel
servers. In order to support disconnects we will also need a
way to re-enumerate the SID to guarantee that we don't have a re-use
problem. But for now, the kernel is not designed with any practical
disconnect mechanism; there is no code that calls the Quit mechanism
on any server.
2021-06-15 17:41:14 +08:00
bunnie
fadc9c29ab Merge remote-tracking branch 'origin/master' into bunnie-dev 2021-06-02 03:59:25 +08:00
bunnie
b9f3182bb9 mods for hosted mode to work again 2021-06-02 03:45:15 +08:00
bunnie
7c55925926 intermediate check-in on wfi 2021-05-30 23:07:16 +08:00
bunnie
1e2d46366a attempt to convert sha512 to use xous::wait_event()
doesn't work, for some reason the interrupt doesn't want to fire.
cross-check against hardware simulations...
2021-05-30 16:18:23 +08:00
bunnie
52c32cc4d1 auto-powerdown of sha block when not in use 2021-05-30 00:12:18 +08:00
bunnie
58edcc56f2 sha512 tests fully implemented, working through sus/res
note: sha512 will fail if a suspend is forced upon it!! but
it will vociferously complain if this happens.
2021-05-21 15:56:58 +08:00
bunnie
5526bc4100 add hardware support for sha512/256 2021-05-21 04:35:01 +08:00
bunnie
21a5ddb40f sha512 hardware acceleration is working, now benchmarking
also need to extend hw implementation to sha512/256
2021-05-21 03:15:13 +08:00
bunnie
d44ad58637 sha512 now compiling, at least. 2021-05-20 03:29:26 +08:00
bunnie
a8e68bcebe fix file permissions 2021-05-19 00:39:47 +08:00
bunnie
7d9e84c456 initial frameworks around sha512 acceleration integration 2021-05-19 00:39:03 +08:00