Skip to content

Commit fa7873d

Browse files
committed
[trace] Update the registers for the trace reporting calling convention
- Use registers r12, r13 and r14 to pass trace data information from the guest to the host - This is in use temporarily, until the virtio queues are implemented Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
1 parent 6e013f1 commit fa7873d

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/hyperlight_guest/src/exit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ pub(crate) unsafe fn out32(port: u16, val: u32) {
103103
asm!("out dx, eax",
104104
in("dx") port,
105105
in("eax") val,
106-
in("r8") OutBAction::TraceBatch as u64,
107-
in("r9") ptr,
108-
in("r10") len,
106+
in("r12") OutBAction::TraceBatch as u64,
107+
in("r13") ptr,
108+
in("r14") len,
109109
options(preserves_flags, nomem, nostack)
110110
)
111111
};

src/hyperlight_guest_tracing/src/state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ fn send_to_host(data: &[u8]) {
5454
in("dx") OutBAction::TraceBatch as u16,
5555
in("al") 0u8,
5656
// Additional magic number to identify the action
57-
in("r8") OutBAction::TraceBatch as u64,
58-
in("r9") data.as_ptr() as u64,
59-
in("r10") data.len() as u64,
57+
in("r12") OutBAction::TraceBatch as u64,
58+
in("r13") data.as_ptr() as u64,
59+
in("r14") data.len() as u64,
6060
);
6161
}
6262
}

src/hyperlight_host/src/sandbox/trace/context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ impl EventsBatch {
4141
/// Extract a batch of guest trace events from guest memory.
4242
///
4343
/// The guest passes the trace data pointer as a Guest Virtual Address (GVA)
44-
/// in register r9. With Copy-on-Write enabled, this GVA may not be
44+
/// in register r13. With Copy-on-Write enabled, this GVA may not be
4545
/// identity-mapped to its physical address, so we walk the guest page
4646
/// tables to translate GVA → GPA before reading the data.
4747
///
4848
/// # Arguments
49-
/// * `regs` - The guest registers (r8 = magic, r9 = GVA pointer, r10 = length)
49+
/// * `regs` - The guest registers (r12 = magic, r13 = GVA pointer, r14 = length)
5050
/// * `mem_mgr` - The sandbox memory manager with access to shared and scratch memory
5151
/// * `root_pt` - The root page table physical address (CR3) for GVA translation
5252
fn from_regs(
5353
regs: &CommonRegisters,
5454
mem_mgr: &mut SandboxMemoryManager<HostSharedMemory>,
5555
root_pt: u64,
5656
) -> Result<Self> {
57-
let magic_no = regs.r8;
58-
let trace_data_ptr = regs.r9 as usize;
59-
let trace_data_len = regs.r10 as usize;
57+
let magic_no = regs.r12;
58+
let trace_data_gva = regs.r13;
59+
let trace_data_len = regs.r14 as usize;
6060

6161
// Validate the magic number to ensure the guest is providing trace data
6262
if magic_no != OutBAction::TraceBatch as u64 {

0 commit comments

Comments
 (0)