Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce riscv64 ioctls #275

Merged
merged 17 commits into from
Oct 17, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
riscv64: Enable get_dirty_log doc test
Add assembly code which does dirty one page and forces MMIO exit on
RISC-V 64-bit platform to complete `get_dirty_log` doc test.

Signed-off-by: Ruoqing He <[email protected]>
  • Loading branch information
RuoqingHe committed Oct 15, 2024
commit af83785985aa609d8ca51d2cb5aa27f67b54c7ae
15 changes: 15 additions & 0 deletions src/ioctls/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,13 @@ impl VmFd {
/// 0x00, 0x00, 0x00,
/// 0x14, /* b <this address>; shouldn't get here, but if so loop forever */
/// ];
/// #[cfg(target_arch = "riscv64")]
/// let asm_code = [
/// 0x17, 0x03, 0x00, 0x00, // auipc t1, 0; <this address> -> t1
/// 0xa3, 0x23, 0x73, 0x00, // sw t2, t1 + 7; dirty current page
/// 0x23, 0x20, 0x75, 0x00, // sw t2, a0; trigger MMIO exit
/// 0x6f, 0x00, 0x00, 0x00, // j .;shouldn't get here, but if so loop forever
/// ];
///
/// // Write the code in the guest memory. This will generate a dirty page.
/// unsafe {
Expand Down Expand Up @@ -894,6 +901,14 @@ impl VmFd {
/// vcpu_fd.set_one_reg(core_reg_base + 2 * 0, &mmio_addr.to_le_bytes()); // set X0
/// }
///
/// #[cfg(target_arch = "riscv64")]
/// {
/// let core_reg_base: u64 = 0x8030_0000_0200_0000;
/// let mmio_addr: u64 = guest_addr + mem_size as u64;
/// vcpu_fd.set_one_reg(core_reg_base, &guest_addr.to_le_bytes()); // set PC
/// vcpu_fd.set_one_reg(core_reg_base + 10, &mmio_addr.to_le_bytes()); // set A0
/// }
///
/// loop {
/// match vcpu_fd.run().expect("run failed") {
/// VcpuExit::MmioWrite(addr, data) => {
Expand Down