@@ -20,9 +20,11 @@ use std::error::{self, Error as KernelLoaderError};
2020use std:: ffi:: CStr ;
2121use std:: fmt:: { self , Display } ;
2222#[ cfg( any( feature = "elf" , feature = "bzimage" ) ) ]
23+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
2324use std:: io:: SeekFrom ;
2425use std:: io:: { Read , Seek } ;
2526#[ cfg( feature = "elf" ) ]
27+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
2628use std:: mem;
2729
2830use vm_memory:: { Address , Bytes , GuestAddress , GuestMemory , GuestUsize } ;
@@ -41,6 +43,7 @@ pub mod bootparam;
4143#[ cfg_attr( feature = "cargo-clippy" , allow( clippy:: all) ) ]
4244mod elf;
4345#[ cfg( any( feature = "elf" , feature = "bzimage" ) ) ]
46+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
4447mod struct_util;
4548
4649#[ derive( Debug , PartialEq ) ]
@@ -164,10 +167,12 @@ pub trait KernelLoader {
164167}
165168
166169#[ cfg( feature = "elf" ) ]
170+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
167171/// Raw ELF (a.k.a. vmlinux) kernel image support.
168172pub struct Elf ;
169173
170174#[ cfg( feature = "elf" ) ]
175+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
171176impl KernelLoader for Elf {
172177 /// Loads a kernel from a vmlinux elf image to a slice
173178 ///
@@ -276,10 +281,12 @@ impl KernelLoader for Elf {
276281}
277282
278283#[ cfg( feature = "bzimage" ) ]
284+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
279285/// Big zImage (bzImage) kernel image support.
280286pub struct BzImage ;
281287
282288#[ cfg( feature = "bzimage" ) ]
289+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
283290impl KernelLoader for BzImage {
284291 /// Loads a bzImage
285292 ///
@@ -406,6 +413,7 @@ pub fn load_cmdline<M: GuestMemory>(
406413mod test {
407414 use super :: * ;
408415 #[ cfg( any( feature = "elf" , feature = "bzimage" ) ) ]
416+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
409417 use std:: io:: Cursor ;
410418 use vm_memory:: { Address , GuestAddress , GuestMemoryMmap } ;
411419
@@ -417,6 +425,7 @@ mod test {
417425
418426 #[ allow( non_snake_case) ]
419427 #[ cfg( feature = "bzimage" ) ]
428+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
420429 fn make_bzImage ( ) -> Vec < u8 > {
421430 let mut v = Vec :: new ( ) ;
422431 v. extend_from_slice ( include_bytes ! ( "bzimage" ) ) ;
@@ -425,6 +434,7 @@ mod test {
425434
426435 // Elf64 image that prints hello world on x86_64.
427436 #[ cfg( feature = "elf" ) ]
437+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
428438 fn make_elf_bin ( ) -> Vec < u8 > {
429439 let mut v = Vec :: new ( ) ;
430440 v. extend_from_slice ( include_bytes ! ( "test_elf.bin" ) ) ;
@@ -435,6 +445,7 @@ mod test {
435445 #[ allow( non_snake_case) ]
436446 #[ test]
437447 #[ cfg( feature = "bzimage" ) ]
448+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
438449 fn load_bzImage ( ) {
439450 let gm = create_guest_mem ( ) ;
440451 let image = make_bzImage ( ) ;
@@ -504,6 +515,7 @@ mod test {
504515
505516 #[ test]
506517 #[ cfg( feature = "elf" ) ]
518+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
507519 fn load_elf ( ) {
508520 let gm = create_guest_mem ( ) ;
509521 let image = make_elf_bin ( ) ;
@@ -594,6 +606,7 @@ mod test {
594606 }
595607
596608 #[ cfg( feature = "elf" ) ]
609+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
597610 #[ test]
598611 fn bad_magic ( ) {
599612 let gm = create_guest_mem ( ) ;
@@ -607,6 +620,7 @@ mod test {
607620 }
608621
609622 #[ cfg( feature = "elf" ) ]
623+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
610624 #[ test]
611625 fn bad_endian ( ) {
612626 // Only little endian is supported
@@ -621,6 +635,7 @@ mod test {
621635 }
622636
623637 #[ cfg( feature = "elf" ) ]
638+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
624639 #[ test]
625640 fn bad_phoff ( ) {
626641 // program header has to be past the end of the elf header
0 commit comments