From b377d7af44247616ccc481bfba3d3621cbbc41df Mon Sep 17 00:00:00 2001 From: Johnathan Van Why Date: Mon, 11 Nov 2024 16:28:57 -0800 Subject: [PATCH] Update the nightly toolchain. --- .cargo/{config => config.toml} | 0 .github/workflows/ci.yml | 12 ++++++------ apis/interface/console/src/lib.rs | 5 +++-- apis/net/ieee802154/src/lib.rs | 2 +- apis/peripherals/i2c_master/src/lib.rs | 6 +++--- apis/peripherals/i2c_master_slave/src/lib.rs | 13 ++++++++----- apis/peripherals/rng/src/lib.rs | 2 +- apis/peripherals/spi_controller/src/lib.rs | 11 +++++++---- apis/storage/key_value/src/lib.rs | 6 +++--- nightly/rust-toolchain.toml | 2 +- runtime/src/lib.rs | 2 +- unittest/src/fake/syscalls/mod.rs | 2 +- unittest/src/fake/syscalls/subscribe_impl_tests.rs | 8 +++++--- unittest/src/share_data.rs | 13 ++++++++----- 14 files changed, 48 insertions(+), 36 deletions(-) rename .cargo/{config => config.toml} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61247b852..edde893b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,15 +34,15 @@ jobs: # optimal for the Azure Standard_DS2_v2 VM, which is the VM type used by # GitHub Actions at the time of this writing. # - # We have to append the "-D warnings" flag to .cargo/config rather than - # using the RUSTFLAGS environment variable because if we set RUSTFLAGS - # cargo will ignore the rustflags config in .cargo/config, breaking - # relocation. + # We have to append the "-D warnings" flag to .cargo/config.toml rather + # than using the RUSTFLAGS environment variable because if we set + # RUSTFLAGS cargo will ignore the rustflags config in .cargo/config, + # breaking relocation. - name: Build and Test run: | sudo apt-get install ninja-build cd "${GITHUB_WORKSPACE}" - echo "[target.'cfg(all())']" >> .cargo/config - echo 'rustflags = ["-D", "warnings"]' >> .cargo/config + echo "[target.'cfg(all())']" >> .cargo/config.toml + echo 'rustflags = ["-D", "warnings"]' >> .cargo/config.toml make -j2 setup make -j2 test diff --git a/apis/interface/console/src/lib.rs b/apis/interface/console/src/lib.rs index 80404092d..288a6394c 100644 --- a/apis/interface/console/src/lib.rs +++ b/apis/interface/console/src/lib.rs @@ -54,7 +54,8 @@ impl Console { S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::WRITE }>(subscribe, &called)?; - S::command(DRIVER_NUM, command::WRITE, s.len() as u32, 0).to_result()?; + S::command(DRIVER_NUM, command::WRITE, s.len() as u32, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -87,7 +88,7 @@ impl Console { // When this fails, `called` is guaranteed unmodified, // because upcalls are never processed until we call `yield`. - S::command(DRIVER_NUM, command::READ, len as u32, 0).to_result()?; + S::command(DRIVER_NUM, command::READ, len as u32, 0).to_result::<(), ErrorCode>()?; loop { S::yield_wait(); diff --git a/apis/net/ieee802154/src/lib.rs b/apis/net/ieee802154/src/lib.rs index 4c57e721f..b8906b939 100644 --- a/apis/net/ieee802154/src/lib.rs +++ b/apis/net/ieee802154/src/lib.rs @@ -187,7 +187,7 @@ impl Ieee802154 { subscribe, &called, )?; - S::command(DRIVER_NUM, command::TRANSMIT, 0, 0).to_result()?; + S::command(DRIVER_NUM, command::TRANSMIT, 0, 0).to_result::<(), ErrorCode>()?; loop { S::yield_wait(); diff --git a/apis/peripherals/i2c_master/src/lib.rs b/apis/peripherals/i2c_master/src/lib.rs index 82eb81357..768ec4d13 100644 --- a/apis/peripherals/i2c_master/src/lib.rs +++ b/apis/peripherals/i2c_master/src/lib.rs @@ -61,7 +61,7 @@ impl I2CMaster { cmd_arg0, r_len.into(), ) - .to_result()?; + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -112,7 +112,7 @@ impl I2CMaster { addr.into(), len.into(), ) - .to_result()?; + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -163,7 +163,7 @@ impl I2CMaster { addr.into(), len.into(), ) - .to_result()?; + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); diff --git a/apis/peripherals/i2c_master_slave/src/lib.rs b/apis/peripherals/i2c_master_slave/src/lib.rs index 81a7ca3ff..2ee96d8be 100644 --- a/apis/peripherals/i2c_master_slave/src/lib.rs +++ b/apis/peripherals/i2c_master_slave/src/lib.rs @@ -55,7 +55,8 @@ impl I2CMasterSlave { S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::MASTER_WRITE }>(subscribe, &called)?; - S::command(DRIVER_NUM, i2c_master_slave_cmd::MASTER_WRITE, cmd_arg0, 0).to_result()?; + S::command(DRIVER_NUM, i2c_master_slave_cmd::MASTER_WRITE, cmd_arg0, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -113,7 +114,8 @@ impl I2CMasterSlave { S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::MASTER_READ }>(subscribe, &called)?; // When this fails, `called` is guaranteed unmodified, // because upcalls are never processed until we call `yield`. - S::command(DRIVER_NUM, i2c_master_slave_cmd::MASTER_READ, cmd_arg0, 0).to_result()?; + S::command(DRIVER_NUM, i2c_master_slave_cmd::MASTER_READ, cmd_arg0, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -208,7 +210,7 @@ impl I2CMasterSlave { cmd_arg0, 0, ) - .to_result()?; + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -293,7 +295,8 @@ impl I2CMasterSlave { S::allow_rw::(allow_rw, buf)?; S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::SLAVE_READ }>(subscribe, &called)?; - S::command(DRIVER_NUM, i2c_master_slave_cmd::SLAVE_START_LISTEN, 0, 0).to_result()?; + S::command(DRIVER_NUM, i2c_master_slave_cmd::SLAVE_START_LISTEN, 0, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -356,7 +359,7 @@ impl I2CMasterSlave { len as u32, 0, ) - .to_result()?; + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); diff --git a/apis/peripherals/rng/src/lib.rs b/apis/peripherals/rng/src/lib.rs index e25478f20..4ba29de5b 100644 --- a/apis/peripherals/rng/src/lib.rs +++ b/apis/peripherals/rng/src/lib.rs @@ -59,7 +59,7 @@ impl Rng { S::subscribe::<_, _, DefaultConfig, DRIVER_NUM, 0>(subscribe, &called)?; // Send the command to the kernel driver to fill the allowed_readwrite buffer - S::command(DRIVER_NUM, GET_BYTES, n, 0).to_result()?; + S::command(DRIVER_NUM, GET_BYTES, n, 0).to_result::<(), ErrorCode>()?; // Wait for a callback to happen while !called.get() { diff --git a/apis/peripherals/spi_controller/src/lib.rs b/apis/peripherals/spi_controller/src/lib.rs index 01cd2136a..fc36cd7d0 100644 --- a/apis/peripherals/spi_controller/src/lib.rs +++ b/apis/peripherals/spi_controller/src/lib.rs @@ -55,7 +55,8 @@ impl SpiController { S::allow_ro::(allow_ro, w_buf)?; S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::COMPLETE }>(subscribe, &called)?; - S::command(DRIVER_NUM, spi_controller_cmd::READ_WRITE_BYTES, len, 0).to_result()?; + S::command(DRIVER_NUM, spi_controller_cmd::READ_WRITE_BYTES, len, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -88,7 +89,8 @@ impl SpiController { S::allow_ro::(allow_ro, w_buf)?; S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::COMPLETE }>(subscribe, &called)?; - S::command(DRIVER_NUM, spi_controller_cmd::READ_WRITE_BYTES, len, 0).to_result()?; + S::command(DRIVER_NUM, spi_controller_cmd::READ_WRITE_BYTES, len, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -121,7 +123,8 @@ impl SpiController { S::allow_rw::(allow_rw, r_buf)?; S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::COMPLETE }>(subscribe, &called)?; - S::command(DRIVER_NUM, spi_controller_cmd::READ_BYTES, len, 0).to_result()?; + S::command(DRIVER_NUM, spi_controller_cmd::READ_BYTES, len, 0) + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -163,7 +166,7 @@ impl SpiController { len, 0, ) - .to_result()?; + .to_result::<(), ErrorCode>()?; loop { S::yield_wait(); diff --git a/apis/storage/key_value/src/lib.rs b/apis/storage/key_value/src/lib.rs index 8ac7e8c52..66ad37aed 100644 --- a/apis/storage/key_value/src/lib.rs +++ b/apis/storage/key_value/src/lib.rs @@ -39,7 +39,7 @@ impl KeyValue { S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::CALLBACK }>(subscribe, &called)?; - S::command(DRIVER_NUM, command::GET, 0, 0).to_result()?; + S::command(DRIVER_NUM, command::GET, 0, 0).to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -69,7 +69,7 @@ impl KeyValue { S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::CALLBACK }>(subscribe, &called)?; - S::command(DRIVER_NUM, command_num, 0, 0).to_result()?; + S::command(DRIVER_NUM, command_num, 0, 0).to_result::<(), ErrorCode>()?; loop { S::yield_wait(); @@ -112,7 +112,7 @@ impl KeyValue { S::subscribe::<_, _, C, DRIVER_NUM, { subscribe::CALLBACK }>(subscribe, &called)?; - S::command(DRIVER_NUM, command::DELETE, 0, 0).to_result()?; + S::command(DRIVER_NUM, command::DELETE, 0, 0).to_result::<(), ErrorCode>()?; loop { S::yield_wait(); diff --git a/nightly/rust-toolchain.toml b/nightly/rust-toolchain.toml index 23f78a371..f30a8bc4f 100644 --- a/nightly/rust-toolchain.toml +++ b/nightly/rust-toolchain.toml @@ -1,4 +1,4 @@ # This is the nightly Rust toolchain used by `make test`. [toolchain] -channel = "nightly-2024-04-19" +channel = "nightly-2024-11-11" components = ["miri", "rust-src"] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 1054e41af..f6f4d69f9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -6,7 +6,7 @@ //! execute. It reads the `LIBTOCK_PLATFORM` variable to determine what location //! to build for (see the `layouts/` directory to see what platforms are //! available). It expects the following cargo config options to be set (e.g. in -//! `.cargo/config`): +//! `.cargo/config.toml`): //! ``` //! [build] //! rustflags = [ diff --git a/unittest/src/fake/syscalls/mod.rs b/unittest/src/fake/syscalls/mod.rs index c55f58248..53d18b401 100644 --- a/unittest/src/fake/syscalls/mod.rs +++ b/unittest/src/fake/syscalls/mod.rs @@ -35,5 +35,5 @@ mod yield_impl_tests; // executes this. It is used by submodules of fake::syscalls. fn assert_valid(_value: T) { #[cfg(miri)] - format!("{:?}", _value); + let _ = format!("{:?}", _value); } diff --git a/unittest/src/fake/syscalls/subscribe_impl_tests.rs b/unittest/src/fake/syscalls/subscribe_impl_tests.rs index d6fbacdbc..8bf62141f 100644 --- a/unittest/src/fake/syscalls/subscribe_impl_tests.rs +++ b/unittest/src/fake/syscalls/subscribe_impl_tests.rs @@ -95,15 +95,17 @@ fn skip_with_error() { skip_with_error: Some(ErrorCode::NoAck), }); unsafe extern "C" fn upcall_fn(_: u32, _: u32, _: u32, _: Register) {} + // Convert to a raw pointer to get a stable address. + let upcall_fn_ptr = upcall_fn as *const (); let [r0, r1, r2, r3] = unsafe { subscribe( 1u32.into(), 2u32.into(), - (upcall_fn as usize).into(), + upcall_fn_ptr.into(), 1234usize.into(), ) }; - let (r0, r1, r2, r3): (u32, u32, usize, usize) = ( + let (r0, r1, r2, r3): (u32, u32, *const (), usize) = ( r0.try_into().expect("too large r0"), r1.try_into().expect("too large r1"), r2.into(), @@ -111,7 +113,7 @@ fn skip_with_error() { ); assert_eq!(r0, return_variant::FAILURE_2_U32.into()); assert_eq!(r1, ErrorCode::NoAck as u32); - assert_eq!(r2, upcall_fn as usize); + assert_eq!(r2, upcall_fn_ptr); assert_eq!(r3, 1234); } diff --git a/unittest/src/share_data.rs b/unittest/src/share_data.rs index 4687280f7..a66ae47fb 100644 --- a/unittest/src/share_data.rs +++ b/unittest/src/share_data.rs @@ -80,6 +80,7 @@ mod tests { use super::*; use crate::upcall::Upcall; use crate::DriverInfo; + use libtock_platform::Register; use std::rc::Rc; #[derive(Default)] @@ -140,6 +141,8 @@ mod tests { // is a null upcall. assert_eq!(mock_driver.share_ref.schedule_upcall(2, (3, 4, 5)), Ok(())); unsafe extern "C" fn upcall(_: u32, _: u32, _: u32, _: libtock_platform::Register) {} + // Cast to a pointer to get a stable address. + let upcall_ptr = upcall as unsafe extern "C" fn(u32, u32, u32, Register); with_kernel_data(|kernel_data| { let kernel_data = kernel_data.unwrap(); @@ -150,7 +153,7 @@ mod tests { kernel_data.drivers.get_mut(&1).unwrap().upcalls.insert( 2, Upcall { - fn_pointer: Some(upcall), + fn_pointer: Some(upcall_ptr), data: 1111usize.into(), }, ); @@ -171,7 +174,7 @@ mod tests { subscribe_num: 2 } ); - assert!(upcall_queue_entry.upcall.fn_pointer == Some(upcall)); + assert!(upcall_queue_entry.upcall.fn_pointer == Some(upcall_ptr)); let data: usize = upcall_queue_entry.upcall.data.into(); assert_eq!(data, 1111); @@ -179,7 +182,7 @@ mod tests { kernel_data.drivers.get_mut(&1).unwrap().upcalls.insert( 2, Upcall { - fn_pointer: Some(upcall), + fn_pointer: Some(upcall_ptr), data: 2222u32.into(), }, ); @@ -204,7 +207,7 @@ mod tests { subscribe_num: 2 } ); - assert!(front_queue_entry.upcall.fn_pointer == Some(upcall)); + assert!(front_queue_entry.upcall.fn_pointer == Some(upcall_ptr)); let front_data: usize = front_queue_entry.upcall.data.into(); assert_eq!(front_data, 1111); let back_queue_entry = kernel_data.upcall_queue.back().expect("Upcall not queued"); @@ -216,7 +219,7 @@ mod tests { subscribe_num: 2 } ); - assert!(back_queue_entry.upcall.fn_pointer == Some(upcall)); + assert!(back_queue_entry.upcall.fn_pointer == Some(upcall_ptr)); let back_data: usize = back_queue_entry.upcall.data.into(); assert_eq!(back_data, 2222); });