From 5206da52967d9e3bdc08cf2e3ed36024581116a2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 17 Apr 2023 14:28:58 +0800 Subject: [PATCH 1/9] bump release notes --- RELEASE-v0.9.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE-v0.9.md b/RELEASE-v0.9.md index 76fb24c7e..c3cf78c12 100644 --- a/RELEASE-v0.9.md +++ b/RELEASE-v0.9.md @@ -371,6 +371,10 @@ perform the Xous firmware upgrade. This requires running manual update commands, - @xobs has added the feature `--gdb-stub` to the build. When selected, the kernel is built with GDB support over serial port. This works well in Renode. To try it in hardware, one must first run `console app` inside `shellchat` to activate the GDB UART (otherwise the sole serial port is connected to the console log). - @xobs added graphical panic output to the kernel. This is different from a guru meditation in that it only happens when the kernel itself panics. - Pulled in `ebreak` fix for VexRiscv CPU +- In `vault`, deleting a password and saving the record with the blank password triggers a password generation dialog box (useful for re-doing passwords) +- Add USB serial support + - console logs can now be viewed via USB serial with the shellchat command `usb console` (`usb noconsole` to turn off). You will need a terminal client that is capable of CRLF translations. + - TRNG can be set to emit raw binary data over USB serial with `usb trng` (`usb notrng` to turn off). This should be compatible with existing methods to extract randomness from USB dongles such as the OneRNG (looking for an existing HW RNG dongle user to test and confirm compatibility with their existing system!). ## Roadmap - Lots of testing and bug fixes From 97da54437e1fda6c46a35d5bae3bca0c40cfd001 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 20 Apr 2023 13:06:02 +0800 Subject: [PATCH 2/9] kernel: allow debug of crashed processes When a process crashes, report this in the kernel console and offer to attach a debugger. Signed-off-by: Sean Cross --- kernel/src/arch/riscv/irq.rs | 2 +- kernel/src/debug/gdb.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/src/arch/riscv/irq.rs b/kernel/src/arch/riscv/irq.rs index 94b64987b..be8d107a5 100644 --- a/kernel/src/arch/riscv/irq.rs +++ b/kernel/src/arch/riscv/irq.rs @@ -411,7 +411,7 @@ pub extern "C" fn trap_handler( ex ); #[cfg(any(feature = "precursor", feature = "renode"))] - panic!( + println!( "{}: CPU Exception on PID {}: {}", if is_kernel_failure { "!!! KERNEL FAILURE !!!" diff --git a/kernel/src/debug/gdb.rs b/kernel/src/debug/gdb.rs index 55fd0e2ca..1c0bf89c7 100644 --- a/kernel/src/debug/gdb.rs +++ b/kernel/src/debug/gdb.rs @@ -295,7 +295,7 @@ pub fn report_stop(_pid: xous_kernel::PID, tid: xous_kernel::TID, _pc: usize) { }; } -pub fn report_terminated(_pid: xous_kernel::PID) { +pub fn report_terminated(pid: xous_kernel::PID) { let Some(XousDebugState { mut target, server: gdb, @@ -306,7 +306,6 @@ pub fn report_terminated(_pid: xous_kernel::PID) { let new_gdb = match gdb { GdbStubStateMachine::Running(inner) => { - println!("Reporting a STOP"); match inner.report_stop( &mut target, MultiThreadStopReason::Signal(Signal::EXC_BAD_ACCESS), @@ -326,9 +325,9 @@ pub fn report_terminated(_pid: xous_kernel::PID) { println!("GDB state was in Disconnect, which shouldn't be possible!"); return; } - GdbStubStateMachine::Idle(_inner) => { - println!("GDB state was in Idle, which shouldn't be possible!"); - return; + GdbStubStateMachine::Idle(inner) => { + println!("Please connect a debugger to debug process {}", pid); + GdbStubStateMachine::Idle(inner) } }; From ef077ed7dec5ecf1eb15907367e7036e7810f834 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 20 Apr 2023 13:06:33 +0800 Subject: [PATCH 3/9] codec: place codec object into heap The codec object contains a lot of data including a `FrameRing` buffer as well as some other services. With the latest version of Rust, this has grown large and no longer fits onto the stack. As a result, it crashes with a stack overflow immediately upon boot. Move the Codec onto the heap. This frees up stack and allows it to run under Rust 1.69.0. Signed-off-by: Sean Cross --- services/codec/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/codec/src/main.rs b/services/codec/src/main.rs index 545e845ac..818ab3be8 100644 --- a/services/codec/src/main.rs +++ b/services/codec/src/main.rs @@ -31,7 +31,7 @@ fn main() -> ! { log::trace!("registered with NS -- {:?}", codec_sid); let codec_conn = xous::connect(codec_sid).expect("couldn't make connection for the codec implementation"); - let mut codec = Codec::new(codec_conn, &xns); + let mut codec = Box::new(Codec::new(codec_conn, &xns)); let ticktimer = ticktimer_server::Ticktimer::new().unwrap(); log::trace!("ready to accept requests"); From 5e5cc9352b2b5984f5b36aa651258cd37deec0df Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 20 Apr 2023 13:14:36 +0800 Subject: [PATCH 4/9] services: aes: fix () warnings on vex Rust 1.69 adds more warnings on excess punctuation. Remove this to clear up the warning. Signed-off-by: Sean Cross --- services/aes/src/vex/aes128.rs | 10 +++++----- services/aes/src/vex/aes256.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/services/aes/src/vex/aes128.rs b/services/aes/src/vex/aes128.rs index aa9c88b81..1ef8f7c2d 100644 --- a/services/aes/src/vex/aes128.rs +++ b/services/aes/src/vex/aes128.rs @@ -21,7 +21,7 @@ fn set_encrypt_key_inner_128(user_key: &[u8], swap_final: bool) -> VexKeys128 { ^ (TE2[(temp >> 16) & 0xff] & 0xff000000) ^ (TE3[(temp >> 8) & 0xff] & 0x00ff0000) ^ (TE0[(temp) & 0xff] & 0x0000ff00) - ^ (TE1[(temp >> 24)] & 0x000000ff) + ^ (TE1[temp >> 24] & 0x000000ff) ^ rcon; rk[5 + rk_offset] = rk[1 + rk_offset] ^ rk[4 + rk_offset]; rk[6 + rk_offset] = rk[2 + rk_offset] ^ rk[5 + rk_offset]; @@ -68,19 +68,19 @@ pub fn aes128_dec_key_schedule(user_key: &[u8]) -> VexKeys128 { /* apply the inverse MixColumn transform to all round keys but the first and the last: */ let mut rk_offset = 4; for _ in 1..rounds { - rk[0 + rk_offset] = TD0[TE1[(rk[0 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[0 + rk_offset] = TD0[TE1[rk[0 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[0 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[0 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[0 + rk_offset] as usize) & 0xff] as usize & 0xff]; - rk[1 + rk_offset] = TD0[TE1[(rk[1 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[1 + rk_offset] = TD0[TE1[rk[1 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[1 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[1 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[1 + rk_offset] as usize) & 0xff] as usize & 0xff]; - rk[2 + rk_offset] = TD0[TE1[(rk[2 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[2 + rk_offset] = TD0[TE1[rk[2 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[2 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[2 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[2 + rk_offset] as usize) & 0xff] as usize & 0xff]; - rk[3 + rk_offset] = TD0[TE1[(rk[3 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[3 + rk_offset] = TD0[TE1[rk[3 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[3 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[3 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[3 + rk_offset] as usize) & 0xff] as usize & 0xff]; diff --git a/services/aes/src/vex/aes256.rs b/services/aes/src/vex/aes256.rs index 7738edf32..30ad61d0b 100644 --- a/services/aes/src/vex/aes256.rs +++ b/services/aes/src/vex/aes256.rs @@ -26,7 +26,7 @@ fn set_encrypt_key_inner_256(user_key: &[u8], swap_final: bool) -> VexKeys256 { ^ (TE2[(temp >> 16) & 0xff] & 0xff000000) ^ (TE3[(temp >> 8) & 0xff] & 0x00ff0000) ^ (TE0[(temp) & 0xff] & 0x0000ff00) - ^ (TE1[(temp >> 24)] & 0x000000ff) + ^ (TE1[temp >> 24] & 0x000000ff) ^ rcon; rk[9 + rk_offset] = rk[1 + rk_offset] ^ rk[8 + rk_offset]; rk[10 + rk_offset] = rk[2 + rk_offset] ^ rk[9 + rk_offset]; @@ -39,7 +39,7 @@ fn set_encrypt_key_inner_256(user_key: &[u8], swap_final: bool) -> VexKeys256 { let temp = rk[11 + rk_offset] as usize; rk[12 + rk_offset] = rk[4 + rk_offset] - ^ (TE2[(temp >> 24)] & 0xff000000) + ^ (TE2[temp >> 24] & 0xff000000) ^ (TE3[(temp >> 16) & 0xff] & 0x00ff0000) ^ (TE0[(temp >> 8) & 0xff] & 0x0000ff00) ^ (TE1[(temp) & 0xff] & 0x000000ff); @@ -90,19 +90,19 @@ pub fn aes256_dec_key_schedule(user_key: &[u8]) -> VexKeys256 { /* apply the inverse MixColumn transform to all round keys but the first and the last: */ let mut rk_offset = 4; for _ in 1..rounds { - rk[0 + rk_offset] = TD0[TE1[(rk[0 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[0 + rk_offset] = TD0[TE1[rk[0 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[0 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[0 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[0 + rk_offset] as usize) & 0xff] as usize & 0xff]; - rk[1 + rk_offset] = TD0[TE1[(rk[1 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[1 + rk_offset] = TD0[TE1[rk[1 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[1 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[1 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[1 + rk_offset] as usize) & 0xff] as usize & 0xff]; - rk[2 + rk_offset] = TD0[TE1[(rk[2 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[2 + rk_offset] = TD0[TE1[rk[2 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[2 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[2 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[2 + rk_offset] as usize) & 0xff] as usize & 0xff]; - rk[3 + rk_offset] = TD0[TE1[(rk[3 + rk_offset] as usize >> 24)] as usize & 0xff] + rk[3 + rk_offset] = TD0[TE1[rk[3 + rk_offset] as usize >> 24] as usize & 0xff] ^ TD1[TE1[(rk[3 + rk_offset] as usize >> 16) & 0xff] as usize & 0xff] ^ TD2[TE1[(rk[3 + rk_offset] as usize >> 8) & 0xff] as usize & 0xff] ^ TD3[TE1[(rk[3 + rk_offset] as usize) & 0xff] as usize & 0xff]; From bef83c7a1966a0446836204b2bc54cfad2dcb7f5 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Thu, 20 Apr 2023 15:39:37 +0200 Subject: [PATCH 5/9] services/usb-device-xous: fix keyboard feature warning Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/usb-device-xous/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/usb-device-xous/Cargo.toml b/services/usb-device-xous/Cargo.toml index d7314fccc..0aa0ad443 100644 --- a/services/usb-device-xous/Cargo.toml +++ b/services/usb-device-xous/Cargo.toml @@ -19,7 +19,7 @@ num-traits = {version = "0.2.14", default-features = false} rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} susres = {package = "xous-api-susres", version = "0.9.36"} modals = {path = "../modals"} -keyboard = {path = "../keyboard", feature="inject-api"} +keyboard = { path = "../keyboard", features = ["inject-api"] } bitfield = "0.13.2" vcell = "0.1.3" xous-semver = "0.1.2" From 60a5acbfcf19cfa7f2837ccaba36c39c6d57025d Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Thu, 20 Apr 2023 15:41:15 +0200 Subject: [PATCH 6/9] tools/sign_image: fix warnings Signed-off-by: Jean-Pierre De Jesus DIAZ --- tools/src/sign_image.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/sign_image.rs b/tools/src/sign_image.rs index 2065ec1b6..5216c7ceb 100644 --- a/tools/src/sign_image.rs +++ b/tools/src/sign_image.rs @@ -1,4 +1,4 @@ -use std::io::{Error, ErrorKind, Read, Write}; +use std::io::{Read, Write}; use std::path::Path; use ring::signature::Ed25519KeyPair; From 9b7dbcee2abb0e70aaa03ab204501d1396ece5ce Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 21 Apr 2023 13:43:27 +0800 Subject: [PATCH 7/9] fix manifest feature issue --- services/keyboard/Cargo.toml | 2 +- services/usb-device-xous/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/keyboard/Cargo.toml b/services/keyboard/Cargo.toml index f0d6e879f..44498fdc8 100644 --- a/services/keyboard/Cargo.toml +++ b/services/keyboard/Cargo.toml @@ -33,4 +33,4 @@ debuginject = [] # used only if you want direct key injection via serial or USB. rawserial = [] braille = [] inject-api = [] # used by the serial feature in usb -default = ["debuginject", "inject-api"] # "debugprint" +default = ["debuginject"] # "debugprint" diff --git a/services/usb-device-xous/Cargo.toml b/services/usb-device-xous/Cargo.toml index d7314fccc..daea13cea 100644 --- a/services/usb-device-xous/Cargo.toml +++ b/services/usb-device-xous/Cargo.toml @@ -19,7 +19,7 @@ num-traits = {version = "0.2.14", default-features = false} rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} susres = {package = "xous-api-susres", version = "0.9.36"} modals = {path = "../modals"} -keyboard = {path = "../keyboard", feature="inject-api"} +keyboard = {path = "../keyboard", features=["inject-api"]} bitfield = "0.13.2" vcell = "0.1.3" xous-semver = "0.1.2" From 0b9199bc253215359bcaf253ba26f4683687b578 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 21 Apr 2023 13:43:50 +0800 Subject: [PATCH 8/9] fix regression due to #366 Boxing the `Codec` object and sticking it on the heap causes audio playback to hard-lock (no kp, no other explanation given). Not sure what the issue is, but a cleaner fix is arguably to simply increase the stack size so the objects can be allocated there. I suspect the problem may have to do with how the FIFO structures are memory-mapped and somehow this does not play nice with Box (there are `unsafe` routines within it). --- services/codec/src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/codec/src/main.rs b/services/codec/src/main.rs index 818ab3be8..50f8e3e27 100644 --- a/services/codec/src/main.rs +++ b/services/codec/src/main.rs @@ -20,7 +20,17 @@ struct ScalarCallback { cb_to_client_id: u32, } -fn main() -> ! { +fn main () -> ! { + let stack_size = 256 * 1024; + std::thread::Builder::new() + .stack_size(stack_size) + .spawn(wrapped_main) + .unwrap() + .join() + .unwrap() +} + +fn wrapped_main() -> ! { log_server::init_wait().unwrap(); log::set_max_level(log::LevelFilter::Info); info!("my PID is {}", xous::process::id()); @@ -31,7 +41,7 @@ fn main() -> ! { log::trace!("registered with NS -- {:?}", codec_sid); let codec_conn = xous::connect(codec_sid).expect("couldn't make connection for the codec implementation"); - let mut codec = Box::new(Codec::new(codec_conn, &xns)); + let mut codec = Codec::new(codec_conn, &xns); let ticktimer = ticktimer_server::Ticktimer::new().unwrap(); log::trace!("ready to accept requests"); From 7d3f0cd0f81ec978eb413e0e6b4c3ea5967681a6 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 21 Apr 2023 14:16:28 +0800 Subject: [PATCH 9/9] revert #368 this somehow causes the build to break, and I just checked and I don't see warnings on our build. There must be some config differences on hosts, but I'm not sure what it is... --- tools/src/sign_image.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/sign_image.rs b/tools/src/sign_image.rs index 5216c7ceb..2065ec1b6 100644 --- a/tools/src/sign_image.rs +++ b/tools/src/sign_image.rs @@ -1,4 +1,4 @@ -use std::io::{Read, Write}; +use std::io::{Error, ErrorKind, Read, Write}; use std::path::Path; use ring::signature::Ed25519KeyPair;