@@ -108,16 +108,15 @@ impl Display for Error {
108108 }
109109}
110110
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.
117111#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
118112pub struct KernelLoaderResult {
113+ // Address in the guest memory where the kernel image starts to be loaded
119114 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.
120117 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.
121120 pub setup_header : Option < bootparam:: setup_header > ,
122121}
123122
@@ -142,7 +141,7 @@ impl KernelLoader for Elf {
142141 /// # Arguments
143142 ///
144143 /// * `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.
146145 /// * `kernel_image` - Input vmlinux image.
147146 /// * `lowest_kernel_start` - This is the start of the high memory, kernel should above it.
148147 ///
@@ -181,7 +180,6 @@ impl KernelLoader for Elf {
181180 return Err ( Error :: InvalidProgramHeaderSize ) ;
182181 }
183182 if ( ehdr. e_phoff as usize ) < mem:: size_of :: < elf:: Elf64_Ehdr > ( ) {
184- // If the program header is backwards, bail.
185183 return Err ( Error :: InvalidProgramHeaderOffset ) ;
186184 }
187185 if ( lowest_kernel_start. is_some ( ) )
@@ -216,7 +214,7 @@ impl KernelLoader for Elf {
216214 . seek ( SeekFrom :: Start ( phdr. p_offset ) )
217215 . map_err ( |_| Error :: SeekKernelStart ) ?;
218216
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
220218 // load it to the physical address p_paddr for each segment.
221219 let mem_offset = match kernel_start {
222220 Some ( start) => start
@@ -234,6 +232,7 @@ impl KernelLoader for Elf {
234232 . ok_or ( Error :: MemoryOverflow ) ?;
235233 }
236234
235+ // elf image has no setup_header which is defined for bzImage
237236 loader_result. setup_header = None ;
238237
239238 Ok ( loader_result)
@@ -250,8 +249,8 @@ impl KernelLoader for BzImage {
250249 ///
251250 /// # Arguments
252251 ///
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.
255254 /// * `kernel_image` - Input bzImage image.
256255 /// * `lowest_kernel_start` - This is the start of the high memory, kernel should above it.
257256 ///
0 commit comments