# Strange kernel exception while volatile access (#Rust)

**URL:** <https://sel4.discourse.group/t/strange-kernel-exception-while-volatile-access-rust/882>\
**Category:** New to seL4\
**Tags:** arm\
**Created:** [September 7, 2024, 2:37pm UTC](https://sel4.discourse.group/t/strange-kernel-exception-while-volatile-access-rust/882 "2024-09-07T14:37:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BDUG](https://yyz2.discourse-cdn.com/free1/user_avatar/sel4.discourse.group/bdug/32/313_2.png) [@BDUG](https://sel4.discourse.group/u/BDUG)\
**Post date:** [September 7, 2024, 2:37pm UTC](https://sel4.discourse.group/t/strange-kernel-exception-while-volatile-access-rust/882/1 "2024-09-07T14:37:33Z")

</div>

I receive the following failure

```auto
vm fault on data at address 0x203800 with status 0x92000010
in thread 0x807ff49400 "rootserver" at address 0x253504
With stack:
0x2a29f0: 0x2a2960

```

It happens when I call

```auto
ptr::read_volatile((mapped_address + 0x000) as *const u32);

```

I would understand it, when it happens with the first call, but it happens with the 5th call.

The memory mapping happens via the following code:

```auto
    // Take a CSpace slot 
    let device_frame_slot = empty_slots
        .pop()
        .unwrap()
        .downcast::<sel4::cap_type::Granule>();

    // Retype the untyped memory and put it into the CSpace slot
    let cap_status = device_ut_cap
    .untyped_retype(
        &sel4::cap_type::Granule::object_blueprint(),
        &sel4::init_thread::slot::CNODE.cap().relative_self(),
        device_frame_slot.index(),
        1,
    );
    if cap_status.is_err() {
        return 0;
    }
    cap_status.unwrap();
    
    // Take the capability out of the slot 
    let device_frame_cap = device_frame_slot.cap();
    
    // Map the physical address to a page table entry
    let mut device_page_addr_ptr: usize = init_free_page_addr(bootinfo) as usize; // TODO
    
    let cap_status = device_frame_cap
        .frame_map(
            sel4::init_thread::slot::VSPACE.cap(),
            device_page_addr_ptr,
            sel4::CapRights::read_write(),
            sel4::VmAttributes::default(),
        );
    if cap_status.is_err() {
        return 0;
    }
    cap_status.unwrap();
    
    return device_page_addr_ptr as usize + device_addr_offset;   

```

The return value is the variable `mapped_address` the code snipped before.
