@@ -108,16 +108,15 @@ impl Display for Error {
108
108
}
109
109
}
110
110
111
- /// * `kernel_load` - The actual `guest_mem` address where kernel image is loaded start.
112
- /// * `kernel_end` - The offset of `guest_mem` where kernel image load is loaded finish, return
113
- /// in case of loading initrd adjacent to kernel image.
114
- /// * `setup_header` - The setup_header belongs to linux boot protocol, only for bzImage, vmm
115
- /// will use it to setup setup_header.init_size, which is a must for bzImage
116
- /// direct boot.
117
111
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
118
112
pub struct KernelLoaderResult {
113
+ // Address in the guest memory where the kernel image starts to be loaded
119
114
pub kernel_load : GuestAddress ,
115
+ // Offset in guest memory corresponding to the end of kernel image, in case that
116
+ // device tree blob and initrd will be loaded adjacent to kernel image.
120
117
pub kernel_end : GuestUsize ,
118
+ // This field is only for bzImage following https://www.kernel.org/doc/Documentation/x86/boot.txt
119
+ // VMM should make use of it to fill zero page for bzImage direct boot.
121
120
pub setup_header : Option < bootparam:: setup_header > ,
122
121
}
123
122
@@ -142,7 +141,7 @@ impl KernelLoader for Elf {
142
141
/// # Arguments
143
142
///
144
143
/// * `guest_mem` - The guest memory region the kernel is written to.
145
- /// * `kernel_start` - The offset into 'guest _mem ' at which to load the kernel.
144
+ /// * `kernel_start` - The offset into 'guest_mem ' at which to load the kernel.
146
145
/// * `kernel_image` - Input vmlinux image.
147
146
/// * `lowest_kernel_start` - This is the start of the high memory, kernel should above it.
148
147
///
@@ -181,7 +180,6 @@ impl KernelLoader for Elf {
181
180
return Err ( Error :: InvalidProgramHeaderSize ) ;
182
181
}
183
182
if ( ehdr. e_phoff as usize ) < mem:: size_of :: < elf:: Elf64_Ehdr > ( ) {
184
- // If the program header is backwards, bail.
185
183
return Err ( Error :: InvalidProgramHeaderOffset ) ;
186
184
}
187
185
if ( lowest_kernel_start. is_some ( ) )
@@ -216,7 +214,7 @@ impl KernelLoader for Elf {
216
214
. seek ( SeekFrom :: Start ( phdr. p_offset ) )
217
215
. map_err ( |_| Error :: SeekKernelStart ) ?;
218
216
219
- // vmm does not specify where the kernel should be loaded, just
217
+ // if the vmm does not specify where the kernel should be loaded, just
220
218
// load it to the physical address p_paddr for each segment.
221
219
let mem_offset = match kernel_start {
222
220
Some ( start) => start
@@ -234,6 +232,7 @@ impl KernelLoader for Elf {
234
232
. ok_or ( Error :: MemoryOverflow ) ?;
235
233
}
236
234
235
+ // elf image has no setup_header which is defined for bzImage
237
236
loader_result. setup_header = None ;
238
237
239
238
Ok ( loader_result)
@@ -250,8 +249,8 @@ impl KernelLoader for BzImage {
250
249
///
251
250
/// # Arguments
252
251
///
253
- /// * `guest_mem` - The guest memory region the kernel is written to .
254
- /// * `kernel_start` - The offset into 'guest _mem ' at which to load the kernel.
252
+ /// * `guest_mem` - The guest memory where the kernel image is loaded .
253
+ /// * `kernel_start` - The offset into 'guest_mem ' at which to load the kernel.
255
254
/// * `kernel_image` - Input bzImage image.
256
255
/// * `lowest_kernel_start` - This is the start of the high memory, kernel should above it.
257
256
///
0 commit comments