Commit graph

10340 commits

Author SHA1 Message Date
bunnie
cdbe8578ab add vault documentation 2025-07-31 17:23:32 +08:00
Sam Chin
043fc06804 now you can turn on and off the LED 2025-07-31 16:48:29 +08:00
bunnie
3427a9d09b
Merge branch 'main' into sam.artybio-LED 2025-07-29 17:37:39 +08:00
bunnie
840d74981c
Merge pull request #669 from betrusted-io/more-opt
More optimizations
2025-07-29 17:37:25 +08:00
bunnie
bd48886cc1 fix small syntax errors from refactor 2025-07-29 17:27:26 +08:00
bunnie
4ba2b476d1 Merge branch 'more-opt' of github.com:betrusted-io/xous-core into more-opt 2025-07-29 17:24:26 +08:00
bunnie
c151688822 convert enums into named struct per @xobs suggestion 2025-07-29 17:23:08 +08:00
bunnie
2119413b7d
Update kernel/src/syscall.rs
Co-authored-by: Sean Cross <sean@xobs.io>
2025-07-29 17:20:50 +08:00
bunnie
d58a0c763f
Update kernel/src/services.rs
Co-authored-by: Sean Cross <sean@xobs.io>
2025-07-29 17:20:35 +08:00
bunnie
a35f20b1c8
Update kernel/src/services.rs
Co-authored-by: Sean Cross <sean@xobs.io>
2025-07-29 17:19:26 +08:00
bunnie
f53502d9a2
Update kernel/src/services.rs
Co-authored-by: Sean Cross <sean@xobs.io>
2025-07-29 17:19:18 +08:00
Sam Chin
02fa80af01 wip 2025-07-29 14:51:24 +08:00
bunnie
126896bf54 optimize kernel message passing times
Based on this benchmark of elapsed_ms():

```rust
    pub fn elapsed_ms(&self) -> u64 {
        let response = send_message(
            self.conn,
            xous::Message::new_blocking_scalar(api::Opcode::ElapsedMs.to_usize().unwrap(), 0, 0, 0, 0),
        )
        .expect("Ticktimer: failure to send message to Ticktimer");
        if let xous::Result::Scalar2(upper, lower) = response {
            upper as u64 | ((lower as u64) << 32)
        } else {
            panic!("Ticktimer elapsed_ms(): unexpected return value.");
        }
    }
```

We find the following context switches:
    1. send_message -> kernel/src/syscall.rs @ 166 - ss.remember_server_message()
        - *context switch round trip* to enqueue the message into the target thread's space, then switch back.
        - takes 546ns just in the target context, out of 4430ns round-trip
          (measured as leave userspace of caller to enter userspace of callee) (12% of total time)
        - emplaces the message in the target queue
        - generates "sender_idx" which is the index in the message queue to find the message, which is put into Envelope
    2. send_message -> kernel/src/syscall.rs @ 222 - ss.activate_process_thread()
        - activates the thread to run
        - Total penalty is closer to 1us - 22% of total time - once pre/amble/post-amble overhead considered

This set of patches removes the context-switch round trip to emplace messages in the target's thread
space, as well as to set thread results, by passing them as arguments to `activate_process_thread`.

What then happens is that these items are emplaced after the activation privot to the target
process space occurs, saving a set of TLB-flushes and page table walks.

More testing is required, but at least on a reasonable set of cases the system seems to be stable
with these patcehs, and we get a 24% speedup on blocking scalar messages and 8% speedup on
mutable lends in the case that the target is waiting to receive messages.
2025-07-29 01:24:38 +08:00
bunnie
0e1018797e implement HW acceleration for AES128. 2025-07-27 03:17:40 +08:00
bunnie
098d326b55 note performance improvements 2025-07-27 03:17:15 +08:00
bunnie
6fd1757a04 optimize AES routines
- change ordering of aes instructions to remove pipeline bubbles
- port the aes-256 encryption routine from assembly
2025-07-27 02:15:05 +08:00
bunnie
c732dc268c
Merge branch 'main' into vault2 2025-07-26 00:48:14 +08:00
bunnie
1de1693b7f
Merge pull request #668 from betrusted-io/opt-mmu-real
remove some redundant mmu flush commands
2025-07-26 00:48:03 +08:00
bunnie
25f7bd6f52 remove some redundant mmu flush commands
The double-flush in activate() has a big impact on performance,
and I'm pretty sure it only needs to happen after the SATP update
not before, at least architecturally. Eliminating the extra
flush improves the fast message passing benchmark time by 9%.
2025-07-26 00:46:15 +08:00
bunnie
55f09493d6
Merge branch 'main' into vault2 2025-07-25 19:05:01 +08:00
bunnie
c590184096
Merge pull request #667 from betrusted-io/fix-verilator
Fix verilator
2025-07-25 19:04:15 +08:00
bunnie
bd45919944 add aes test option into the mbox1 test 2025-07-25 18:59:33 +08:00
sam chin
01d0e709cb
Merge branch 'main' into sam.artybio-LED 2025-07-24 15:54:28 +08:00
bunnie
57ce335bd7 add verilator-only tags to appropriate locations in cramium-sim target 2025-07-24 00:30:28 +08:00
bunnie
2e8e2e0364 introduce a message passing test before mbox test 2025-07-24 00:30:04 +08:00
bunnie
7db16f6cf8 cleanup dependencies in loader for vexii on cram-soc 2025-07-24 00:29:42 +08:00
bunnie
9c7ed885f9 add vexii-test entries to the cramium target 2025-07-24 00:29:21 +08:00
bunnie
89d80f6288 make the kernel irq extension generic to verilator target 2025-07-24 00:28:10 +08:00
bunnie
1f55dd8ab1 add the messaging test into the mbox environment 2025-07-23 01:23:45 +08:00
bunnie
45e1fa306e fix linker script for the simulation target
no need to include fonts in the verilator target environment
2025-07-23 01:23:22 +08:00
bunnie
80e367c519 add ticktimer to simulation set so we can do context switch benchamrking 2025-07-23 01:22:35 +08:00
bunnie
b241b84014 update soc details to add some reporting conveniences 2025-07-23 01:22:14 +08:00
bunnie
01701dbeef
Merge branch 'main' into vault2 2025-07-22 01:47:36 +08:00
bunnie
0782418440
Merge pull request #665 from betrusted-io/vexii
Merge Vexii testing changes
2025-07-22 01:46:05 +08:00
bunnie
c0735374f0 fix hosted mode 2025-07-22 01:43:58 +08:00
bunnie
ee5bf1fccf commit current baremetal state checkpoint
various tests & stuff in flux
2025-07-22 01:11:35 +08:00
bunnie
9bb7c12b0b add ramtests module to artyvexii 2025-07-22 00:48:34 +08:00
bunnie
65bbaaecd2 changes and updates to artyvexii baremetal config 2025-07-22 00:47:55 +08:00
bunnie
b76f376f77 utralib updates based on soc changes 2025-07-22 00:47:33 +08:00
bunnie
a0a2d1728c loader changes for vexii
primarily modify the loading method to mark pages with A/D flags
as needed to work around lack of A/D handling in the trap handler
of Xous.

Also inside main.rs is a todo list for polishing off the vex-ii
port and turning into something actually sustainable for Denarius
once we have more of a full SoC model available.
2025-07-22 00:46:04 +08:00
bunnie
815c082153 add breadcrumb for improving the cbo.flush instruction
whenever rust stabilizes "zicbom" in RV we can remove the ugly
.word hard-coding of the flush instruction.
2025-07-21 19:12:37 +08:00
bunnie
6eaf3501bd add cbo.flush support for vexii targets
Spinor is the one location where memory changes out "from underneath
the CPU" in a cacheable region. This happens when we update a block
of FLASH.

Vex-ii has a physically tagged d-cache, but the cbo.flush instruction
needs the *virtual* address to be passed (it then goes through a page
walk or TLB lookup to resolve the tag). The virtual address only
exists and can be correctly resolved to a physical address in the
process space of the owner of the region that maps to the SPINOR
FLASH. Thus, we introduce a flush routine in the lib.rs side that
calls the cbo.flush instruction on every line that has been potentially
modified by the flash write routine.

Note that cbo.flush is not yet natively supported by Rust stable,
so it's coded as a series of hex words fixed to a given register (a0)
to avoid introducing a nightly dependency. Once the cbo.flush
assembly instructions stabilize we can make the assembly read more
nicely, but functionally it should compile to exactly the same code.
2025-07-21 19:09:05 +08:00
bunnie
77d7094d3b reduce the pddb size for the vexii-test target 2025-07-21 19:03:24 +08:00
bunnie
75556b2321 add feature flags for vexii-test in rootkeys and shellchat 2025-07-21 19:02:21 +08:00
bunnie
4dda0da6c9 swap out curve25519 backend for vexii-test targets
we don't have a curve25519 accelerator on the vexii-test device
due to a lack of space to fit it. so for vexii-test targets
we swap in the u32 (vs u32e) backend.

This requires re-writing the config.toml file based on the
presence (or absence) of a vexii-test flag.
2025-07-21 19:01:10 +08:00
bunnie
a3d350b86f note aes performance on vex-ii; fix typo on aes256soft_test
aes256 soft test was running on hw before by accident.
2025-07-21 17:19:22 +08:00
bunnie
cb7f6d50b1 add vexii-test feature to pddb 2025-07-21 17:14:02 +08:00
bunnie
1effeab858 add legacy_int handler to the kernel, handle vexii init case
The "main" product line is affected here in that the UART
init is hosted above the trng init. This should have no impact
on security or boot time, but allows us to more easily debug
TRNG init issues. This is necessary because in the vexii test
version the XADC interface is broken by the slower clocking
and I'm not taking the time to trace down that issue as it
does nothing to further the goal of testing the vex-ii core
in a non-production config.

legacy_int handler allows vex-ii to emulate/behave like the vex-i
in terms of interrupt handling.

eventually this will be replaced with/augmeted by a PLIC.
2025-07-21 17:11:23 +08:00
bunnie
52abe83b74 handle vex-ii a/d flags and error gracefully on page re-allocates
1. Instead of panicing when a page is re-requested, return an
error message to the caller. This allows us to have the UART
pre-allocated by the loader and the kernel to request it prophylactically

2. add A/D flags for R/W pages in vexii-testing. This is a work-around
until we have proper A/D tracking in the page lifecycle mechanism.
2025-07-21 17:08:56 +08:00
bunnie
de8ddbf9c2 handle case where uart is re-allocated by the kernel
this case happens when the loader is instructed to pre-allocate
the kernel UART page based on the early-printk feature.
2025-07-21 17:07:28 +08:00