Skip to content

Commit 38b6133

Browse files
author
BillXiang
committed
riscv64: Handle KVM_EXIT_RISCV_SBI exit
Handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: BillXiang <[email protected]>
1 parent e590ced commit 38b6133

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

kvm-ioctls/src/ioctls/vcpu.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ pub enum VcpuExit<'a> {
184184
/// size
185185
size: u64,
186186
},
187+
/// Corresponds to SBI_EXT_0_1_CONSOLE_PUTCHAR.
188+
SbiExt0_1ConsolePutchar(u64),
189+
/// Corresponds to SBI_EXT_0_1_CONSOLE_GETCHAR.
190+
SbiExt0_1ConsoleGetchar(&'a mut [u64]),
187191
/// Corresponds to an exit reason that is unknown from the current version
188192
/// of the kvm-ioctls crate. Let the consumer decide about what to do with
189193
/// it.
@@ -1688,6 +1692,20 @@ impl VcpuFd {
16881692
Ok(VcpuExit::IoapicEoi(eoi.vector))
16891693
}
16901694
KVM_EXIT_HYPERV => Ok(VcpuExit::Hyperv),
1695+
#[cfg(target_arch = "riscv64")]
1696+
KVM_EXIT_RISCV_SBI => {
1697+
match unsafe {run.__bindgen_anon_1.riscv_sbi.extension_id} as u32 {
1698+
SBI_EXT_0_1_CONSOLE_PUTCHAR => {
1699+
let ch = unsafe { run.__bindgen_anon_1.riscv_sbi.args[0] };
1700+
Ok(VcpuExit::SbiExt0_1ConsolePutchar(ch))
1701+
}
1702+
SBI_EXT_0_1_CONSOLE_GETCHAR => {
1703+
let ch = unsafe { &mut run.__bindgen_anon_1.riscv_sbi.ret[..1] };
1704+
Ok(VcpuExit::SbiExt0_1ConsoleGetchar(ch))
1705+
}
1706+
r => Ok(VcpuExit::Unsupported(r)),
1707+
}
1708+
}
16911709
r => Ok(VcpuExit::Unsupported(r)),
16921710
}
16931711
} else {

0 commit comments

Comments
 (0)