@@ -8,15 +8,16 @@ use thread_local::ThreadLocal;
8
8
9
9
#[ cfg( any( cpu_target = "arm" , cpu_target = "i386" , cpu_target = "mips" ) ) ]
10
10
use crate :: SYS_fstatat64 ;
11
- #[ cfg( not( cpu_target = "arm" ) ) ]
11
+ #[ cfg( not( any ( cpu_target = "arm" , cpu_target = "riscv32" ) ) ) ]
12
12
use crate :: SYS_mmap ;
13
- #[ cfg( any( cpu_target = "arm" , cpu_target = "mips" ) ) ]
13
+ #[ cfg( any( cpu_target = "arm" , cpu_target = "mips" , cpu_target = "riscv32" ) ) ]
14
14
use crate :: SYS_mmap2 ;
15
15
#[ cfg( not( any(
16
16
cpu_target = "arm" ,
17
17
cpu_target = "mips" ,
18
18
cpu_target = "i386" ,
19
- cpu_target = "ppc"
19
+ cpu_target = "ppc" ,
20
+ cpu_target = "riscv32" ,
20
21
) ) ) ]
21
22
use crate :: SYS_newfstatat ;
22
23
use crate :: {
@@ -26,9 +27,10 @@ use crate::{
26
27
NOP_ADDRESS_FILTER ,
27
28
} ,
28
29
qemu:: { Hook , SyscallHookResult } ,
29
- Qemu , SYS_brk , SYS_fstat , SYS_fstatfs , SYS_futex , SYS_getrandom , SYS_mprotect , SYS_mremap ,
30
- SYS_munmap , SYS_pread64 , SYS_read , SYS_readlinkat , SYS_statfs ,
30
+ Qemu , SYS_brk , SYS_mprotect , SYS_mremap , SYS_munmap , SYS_pread64 , SYS_read , SYS_readlinkat ,
31
31
} ;
32
+ #[ cfg( not( cpu_target = "riscv32" ) ) ]
33
+ use crate :: { SYS_fstat , SYS_fstatfs , SYS_futex , SYS_getrandom , SYS_statfs } ;
32
34
33
35
// TODO use the functions provided by Qemu
34
36
pub const SNAPSHOT_PAGE_SIZE : usize = 4096 ;
@@ -804,6 +806,7 @@ where
804
806
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
805
807
h. access ( a2, a3 as usize ) ;
806
808
}
809
+ #[ cfg( not( cpu_target = "riscv32" ) ) ]
807
810
SYS_futex => {
808
811
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
809
812
h. access ( a0, a3 as usize ) ;
@@ -812,7 +815,8 @@ where
812
815
cpu_target = "arm" ,
813
816
cpu_target = "i386" ,
814
817
cpu_target = "mips" ,
815
- cpu_target = "ppc"
818
+ cpu_target = "ppc" ,
819
+ cpu_target = "riscv32"
816
820
) ) ) ]
817
821
SYS_newfstatat => {
818
822
if a2 != 0 {
@@ -827,10 +831,12 @@ where
827
831
h. access ( a2, 4096 ) ; // stat is not greater than a page
828
832
}
829
833
}
830
- SYS_statfs | SYS_fstatfs | SYS_fstat => {
834
+ #[ cfg( not( cpu_target = "riscv32" ) ) ]
835
+ SYS_statfs | SYS_fstat | SYS_fstatfs => {
831
836
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
832
837
h. access ( a1, 4096 ) ; // stat is not greater than a page
833
838
}
839
+ #[ cfg( not( cpu_target = "riscv32" ) ) ]
834
840
SYS_getrandom => {
835
841
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
836
842
h. access ( a0, a1 as usize ) ;
@@ -855,15 +861,15 @@ where
855
861
856
862
// TODO handle huge pages
857
863
858
- #[ cfg( any( cpu_target = "arm" , cpu_target = "mips" ) ) ]
864
+ #[ cfg( any( cpu_target = "arm" , cpu_target = "mips" , cpu_target = "riscv32" ) ) ]
859
865
if sys_const == SYS_mmap2 {
860
866
if let Ok ( prot) = MmapPerms :: try_from ( a2 as i32 ) {
861
867
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
862
868
h. add_mapped ( result, a1 as usize , Some ( prot) ) ;
863
869
}
864
870
}
865
871
866
- #[ cfg( not( cpu_target = "arm" ) ) ]
872
+ #[ cfg( not( any ( cpu_target = "arm" , cpu_target = "riscv32" ) ) ) ]
867
873
if sys_const == SYS_mmap {
868
874
if let Ok ( prot) = MmapPerms :: try_from ( a2 as i32 ) {
869
875
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
0 commit comments