Message ID | 20210302090315.3031492-3-david.edmondson@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | improve loading of 32 bit PVH kernels | expand |
On Tue, Mar 02, 2021 at 09:03:15AM +0000, David Edmondson wrote: >When loading the PVH start address from a 32 bit ELF note, extract >only the appropriate number of bytes. > >Fixes: ab969087da65 ("pvh: Boot uncompressed kernel using direct boot ABI") >Signed-off-by: David Edmondson <david.edmondson@oracle.com> >--- > hw/i386/x86.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/hw/i386/x86.c b/hw/i386/x86.c >index 6329f90ef9..7865660e2c 100644 >--- a/hw/i386/x86.c >+++ b/hw/i386/x86.c >@@ -690,6 +690,8 @@ static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64) > elf_note_data_addr = > ((void *)nhdr64) + nhdr_size64 + > QEMU_ALIGN_UP(nhdr_namesz, phdr_align); >+ >+ pvh_start_addr = *elf_note_data_addr; > } else { > struct elf32_note *nhdr32 = (struct elf32_note *)arg1; > uint32_t nhdr_size32 = sizeof(struct elf32_note); >@@ -699,9 +701,9 @@ static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64) > elf_note_data_addr = > ((void *)nhdr32) + nhdr_size32 + > QEMU_ALIGN_UP(nhdr_namesz, phdr_align); >- } > >- pvh_start_addr = *elf_note_data_addr; >+ pvh_start_addr = *(uint32_t *)elf_note_data_addr; >+ } > > return pvh_start_addr; > } >-- >2.30.0 > > Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 6329f90ef9..7865660e2c 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -690,6 +690,8 @@ static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64) elf_note_data_addr = ((void *)nhdr64) + nhdr_size64 + QEMU_ALIGN_UP(nhdr_namesz, phdr_align); + + pvh_start_addr = *elf_note_data_addr; } else { struct elf32_note *nhdr32 = (struct elf32_note *)arg1; uint32_t nhdr_size32 = sizeof(struct elf32_note); @@ -699,9 +701,9 @@ static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64) elf_note_data_addr = ((void *)nhdr32) + nhdr_size32 + QEMU_ALIGN_UP(nhdr_namesz, phdr_align); - } - pvh_start_addr = *elf_note_data_addr; + pvh_start_addr = *(uint32_t *)elf_note_data_addr; + } return pvh_start_addr; }
When loading the PVH start address from a 32 bit ELF note, extract only the appropriate number of bytes. Fixes: ab969087da65 ("pvh: Boot uncompressed kernel using direct boot ABI") Signed-off-by: David Edmondson <david.edmondson@oracle.com> --- hw/i386/x86.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)