Skip to content

Commit

Permalink
Use DUCT-TAPE to fix irq test
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Szaknis <[email protected]>
  • Loading branch information
L0czek committed Jul 5, 2024
1 parent edf99c2 commit fd2da19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/armv9a/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@ pub use regs::*;
pub const fn bits_in_reg(mask: u64, val: u64) -> u64 {
(val << (mask.trailing_zeros())) & mask
}

pub fn is_irq_pending() -> bool {
let val: u64;

unsafe {
core::arch::asm!(
"mrs {}, ISR_EL1",
out(reg) val
)
}

val != 0
}
9 changes: 9 additions & 0 deletions rmm/src/rsi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod ripas;
pub mod version;

use alloc::vec::Vec;
use armv9a::is_irq_pending;

use crate::define_interface;
use crate::event::RsiHandle;
Expand Down Expand Up @@ -214,6 +215,14 @@ pub fn set_event_handler(rsi: &mut RsiHandle) {
{
let (token_part, token_left) = get_token_part(&rd, rec, buffer_size)?;

if is_irq_pending() {
error!("IRQ is pending while fetching token");
set_reg(rec, 0, INCOMPLETE)?;
set_reg(rec, 1, 0)?;
ret[0] = rmi::SUCCESS_REC_ENTER;
return Ok(());
}

unsafe {
let pa_ptr = attest_pa as *mut u8;
core::ptr::copy(token_part.as_ptr(), pa_ptr.add(pa_offset), token_part.len());
Expand Down

0 comments on commit fd2da19

Please sign in to comment.