@@ -184,6 +184,10 @@ pub enum VcpuExit<'a> {
184
184
/// size
185
185
size : u64 ,
186
186
} ,
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 ] ) ,
187
191
/// Corresponds to an exit reason that is unknown from the current version
188
192
/// of the kvm-ioctls crate. Let the consumer decide about what to do with
189
193
/// it.
@@ -1688,6 +1692,26 @@ impl VcpuFd {
1688
1692
Ok ( VcpuExit :: IoapicEoi ( eoi. vector ) )
1689
1693
}
1690
1694
KVM_EXIT_HYPERV => Ok ( VcpuExit :: Hyperv ) ,
1695
+ #[ cfg( target_arch = "riscv64" ) ]
1696
+ KVM_EXIT_RISCV_SBI => {
1697
+ // SAFETY: Safe because the exit_reason (which comes from the kernel) told us
1698
+ // which union field to use and the type of extension_id is 'enum sbi_ext_id'.
1699
+ match unsafe { run. __bindgen_anon_1 . riscv_sbi . extension_id } as u32 {
1700
+ SBI_EXT_0_1_CONSOLE_PUTCHAR => {
1701
+ // SAFETY: Safe because the exit_reason (which comes from the kernel) told us
1702
+ // which union field to use
1703
+ let ch = unsafe { run. __bindgen_anon_1 . riscv_sbi . args [ 0 ] } ;
1704
+ Ok ( VcpuExit :: SbiExt0_1ConsolePutchar ( ch) )
1705
+ }
1706
+ SBI_EXT_0_1_CONSOLE_GETCHAR => {
1707
+ // SAFETY: Safe because the exit_reason (which comes from the kernel) told us
1708
+ // which union field to use
1709
+ let ch = unsafe { & mut run. __bindgen_anon_1 . riscv_sbi . ret [ ..1 ] } ;
1710
+ Ok ( VcpuExit :: SbiExt0_1ConsoleGetchar ( ch) )
1711
+ }
1712
+ r => Ok ( VcpuExit :: Unsupported ( r) ) ,
1713
+ }
1714
+ }
1691
1715
r => Ok ( VcpuExit :: Unsupported ( r) ) ,
1692
1716
}
1693
1717
} else {
0 commit comments