services: fix mutable references via as_slice_mut

The function `as_slice_mut()` takes a `MemoryRange` and returns a
mutable slice. Previously, this could be called on a memory range that
was not defined as `mut`.

This will be fixed in `xous-rs` so that `as_slice_mut()` can only be
called on a region that is defined as `mut`.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-08-05 16:55:53 +08:00
parent 759ddfedd6
commit 75fbf173a9
3 changed files with 5 additions and 5 deletions

View file

@ -552,7 +552,7 @@ impl RootKeys {
fn debug_print_key(&self, offset: usize, num_bits: usize, name: &str) {
use core::fmt::Write;
let mut debugstr = xous_ipc::String::<4096>::new();
let sensitive_slice = self.sensitive_data.as_slice_mut::<u32>();
let sensitive_slice = self.sensitive_data.as_slice::<u32>();
write!(debugstr, "{}", name).unwrap();
for word in sensitive_slice[offset .. offset as usize + num_bits/(size_of::<u32>()*8)].iter() {
for byte in word.to_be_bytes().iter() {
@ -577,7 +577,7 @@ impl RootKeys {
// now get the font plane data
self.gfx.bulk_read_restart(); // reset the bulk read pointers on the gfx side
let mut bulkread = BulkRead::default();
let bulkread = BulkRead::default();
let mut buf = xous_ipc::Buffer::into_buf(bulkread).expect("couldn't transform bulkread into aligned buffer");
// this form of loop was chosen to avoid the multiple re-initializations and copies that would be entailed
// in our usual idiom for pasing buffers around. instead, we create a single buffer, and re-use it for

View file

@ -69,7 +69,7 @@ impl<'a> ShellCmdApi<'a> for Keys {
log::debug!("top of region: {:x?}", &region[0..8]);
// a region to stash a copy of the previous data in the testing area, so we can diff to confirm things worked!
let reference_region = xous::syscall::map_memory(
let mut reference_region = xous::syscall::map_memory(
None,
None,
TEST_SIZE,

View file

@ -52,13 +52,13 @@ pub fn test_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
log::debug!("memtest got msg {:?}", msg);
match FromPrimitive::from_usize(msg.body.id()) {
Some(TestOp::StartBasic) => xous::msg_scalar_unpack!(msg, iters, _, _, _, {
let testsrc = xous::syscall::map_memory(
let mut testsrc = xous::syscall::map_memory(
None,
None,
256 * 1024, // min 128k so we are working through the L2 cache
xous::MemoryFlags::R | xous::MemoryFlags::W | xous::MemoryFlags::RESERVE,
).expect("couldn't allocate RAM for testing");
let testdst = xous::syscall::map_memory(
let mut testdst = xous::syscall::map_memory(
None,
None,
256 * 1024,