Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/fl4-core/src/arch/aarch64/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,4 +1924,26 @@ mod tests {
assert_eq!(results[1], results[2]);
}
}

/// seL4 `Arch_setMRs_fault` (src/arch/arm/api/faults.c): a VGIC
/// maintenance fault always carries one word, `seL4_VGICMaintenance_IDX`,
/// which is the list-register index, or `-1` when no index is valid
/// (`handle_vgic_maintenance` with `eisr == 0`).
#[test]
fn vgic_maintenance_fault_message_has_one_word() {
for (idx, idx_valid, mr0) in [(0, false, u64::MAX), (3, true, 3), (0, true, 0)] {
let mut s = Mem(BTreeMap::new());
let a = DummyArch;
let sender = Tcb(0x20_0000);
let receiver = Tcb(0x22_0000);
receiver.set_reg(&mut s, msg::msg_register(0), 0xdead);
faults::set_fault(&mut s, sender, Fault::VgicMaintenance { idx, idx_valid });
crate::ipc::do_ipc_transfer(&mut s, &a, sender, 0, 0x77, false, receiver);
let info = msg::msg_info(&s, receiver);
assert_eq!(info.label, fl4_abi::consts::fault::VGICMaintenance, "idx_valid={idx_valid}");
assert_eq!(info.length, 1, "idx_valid={idx_valid}: one message word");
assert_eq!(receiver.reg(&s, msg::msg_register(0)), mr0, "idx_valid={idx_valid}: MR0");
assert_eq!(receiver.reg(&s, reg::BADGE), 0x77);
}
}
}
2 changes: 1 addition & 1 deletion crates/fl4-core/src/faults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn set_mrs_fault<S: Store, A: Arch>(s: &mut S, a: &A, sender: Tcb, receiver:
if ty == ft::VCPUFault {
return msg::set_mr(s, receiver, buf, 0, w0);
} else if ty == ft::VGICMaintenance {
return if w1 != 0 { msg::set_mr(s, receiver, buf, 0, w0) } else { 0 };
return msg::set_mr(s, receiver, buf, 0, if w1 != 0 { w0 } else { u64::MAX });
} else if ty == ft::VPPIEvent {
return msg::set_mr(s, receiver, buf, 0, w0);
}
Expand Down
4 changes: 3 additions & 1 deletion fl4test/virtualization.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,9 @@ static int test_aarch64_vcpu_vgic(env_t env)
test_eq(seL4_ARM_VCPU_WriteRegs(v.cptr, seL4_VCPUReg_VGIC_HCR, 1ul | (1ul << 3)), seL4_NoError);
info = seL4_ReplyRecv(fault_ep, seL4_MessageInfo_new(0, 0, 0, 0), NULL, reply.cptr);
test_eq(seL4_MessageInfo_get_label(info), seL4_Fault_VGICMaintenance);
test_eq(seL4_MessageInfo_get_length(info), 0ul);
/* No EOI (EISR == 0): one word, IDX == -1, as in seL4 Arch_setMRs_fault. */
test_eq(seL4_MessageInfo_get_length(info), 1ul);
test_eq(seL4_GetMR(seL4_VGICMaintenance_IDX), (seL4_Word)-1);
seL4_Word mhcr = seL4_ARM_VCPU_ReadRegs(v.cptr, seL4_VCPUReg_VGIC_HCR).value;
test_eq(mhcr & (1ul | (1ul << 3)), 1ul | (1ul << 3));
}
Expand Down
Loading