@@ -20,9 +20,11 @@ use std::error::{self, Error as KernelLoaderError};
20
20
use std:: ffi:: CStr ;
21
21
use std:: fmt:: { self , Display } ;
22
22
#[ cfg( any( feature = "elf" , feature = "bzimage" ) ) ]
23
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
23
24
use std:: io:: SeekFrom ;
24
25
use std:: io:: { Read , Seek } ;
25
26
#[ cfg( feature = "elf" ) ]
27
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
26
28
use std:: mem;
27
29
28
30
use vm_memory:: { Address , Bytes , GuestAddress , GuestMemory , GuestUsize } ;
@@ -41,6 +43,7 @@ pub mod bootparam;
41
43
#[ cfg_attr( feature = "cargo-clippy" , allow( clippy:: all) ) ]
42
44
mod elf;
43
45
#[ cfg( any( feature = "elf" , feature = "bzimage" ) ) ]
46
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
44
47
mod struct_util;
45
48
46
49
#[ derive( Debug , PartialEq ) ]
@@ -164,10 +167,12 @@ pub trait KernelLoader {
164
167
}
165
168
166
169
#[ cfg( feature = "elf" ) ]
170
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
167
171
/// Raw ELF (a.k.a. vmlinux) kernel image support.
168
172
pub struct Elf ;
169
173
170
174
#[ cfg( feature = "elf" ) ]
175
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
171
176
impl KernelLoader for Elf {
172
177
/// Loads a kernel from a vmlinux elf image to a slice
173
178
///
@@ -276,10 +281,12 @@ impl KernelLoader for Elf {
276
281
}
277
282
278
283
#[ cfg( feature = "bzimage" ) ]
284
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
279
285
/// Big zImage (bzImage) kernel image support.
280
286
pub struct BzImage ;
281
287
282
288
#[ cfg( feature = "bzimage" ) ]
289
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
283
290
impl KernelLoader for BzImage {
284
291
/// Loads a bzImage
285
292
///
@@ -406,6 +413,7 @@ pub fn load_cmdline<M: GuestMemory>(
406
413
mod test {
407
414
use super :: * ;
408
415
#[ cfg( any( feature = "elf" , feature = "bzimage" ) ) ]
416
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
409
417
use std:: io:: Cursor ;
410
418
use vm_memory:: { Address , GuestAddress , GuestMemoryMmap } ;
411
419
@@ -417,6 +425,7 @@ mod test {
417
425
418
426
#[ allow( non_snake_case) ]
419
427
#[ cfg( feature = "bzimage" ) ]
428
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
420
429
fn make_bzImage ( ) -> Vec < u8 > {
421
430
let mut v = Vec :: new ( ) ;
422
431
v. extend_from_slice ( include_bytes ! ( "bzimage" ) ) ;
@@ -425,6 +434,7 @@ mod test {
425
434
426
435
// Elf64 image that prints hello world on x86_64.
427
436
#[ cfg( feature = "elf" ) ]
437
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
428
438
fn make_elf_bin ( ) -> Vec < u8 > {
429
439
let mut v = Vec :: new ( ) ;
430
440
v. extend_from_slice ( include_bytes ! ( "test_elf.bin" ) ) ;
@@ -435,6 +445,7 @@ mod test {
435
445
#[ allow( non_snake_case) ]
436
446
#[ test]
437
447
#[ cfg( feature = "bzimage" ) ]
448
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
438
449
fn load_bzImage ( ) {
439
450
let gm = create_guest_mem ( ) ;
440
451
let image = make_bzImage ( ) ;
@@ -504,6 +515,7 @@ mod test {
504
515
505
516
#[ test]
506
517
#[ cfg( feature = "elf" ) ]
518
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
507
519
fn load_elf ( ) {
508
520
let gm = create_guest_mem ( ) ;
509
521
let image = make_elf_bin ( ) ;
@@ -594,6 +606,7 @@ mod test {
594
606
}
595
607
596
608
#[ cfg( feature = "elf" ) ]
609
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
597
610
#[ test]
598
611
fn bad_magic ( ) {
599
612
let gm = create_guest_mem ( ) ;
@@ -607,6 +620,7 @@ mod test {
607
620
}
608
621
609
622
#[ cfg( feature = "elf" ) ]
623
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
610
624
#[ test]
611
625
fn bad_endian ( ) {
612
626
// Only little endian is supported
@@ -621,6 +635,7 @@ mod test {
621
635
}
622
636
623
637
#[ cfg( feature = "elf" ) ]
638
+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
624
639
#[ test]
625
640
fn bad_phoff ( ) {
626
641
// program header has to be past the end of the elf header
0 commit comments