|
|
169b9a |
From a6a1a4a3a9890749501a2a22f6883397a8579b60 Mon Sep 17 00:00:00 2001
|
|
|
6e672b |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
6e672b |
Date: Thu, 26 Jul 2018 16:24:46 +0200
|
|
|
6e672b |
Subject: [PATCH 4/8] multiboot: fprintf(stderr...) -> error_report()
|
|
|
6e672b |
|
|
|
6e672b |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
6e672b |
Message-id: <20180726162448.22072-5-kwolf@redhat.com>
|
|
|
6e672b |
Patchwork-id: 81519
|
|
|
6e672b |
O-Subject: [RHEL-7.6/7.5.z qemu-kvm PATCH 4/6] multiboot: fprintf(stderr...) -> error_report()
|
|
|
169b9a |
Bugzilla: 1549822
|
|
|
6e672b |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
6e672b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
6e672b |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
6e672b |
|
|
|
6e672b |
From: Jack Schwartz <jack.schwartz@oracle.com>
|
|
|
6e672b |
|
|
|
6e672b |
Change all fprintf(stderr...) calls in hw/i386/multiboot.c to call
|
|
|
6e672b |
error_report() instead, including the mb_debug macro. Remove the "\n"
|
|
|
6e672b |
from strings passed to all modified calls, since error_report() appends
|
|
|
6e672b |
one.
|
|
|
6e672b |
|
|
|
6e672b |
Signed-off-by: Jack Schwartz <jack.schwartz@oracle.com>
|
|
|
6e672b |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
6e672b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
6e672b |
(cherry picked from commit 4b9006a41ea8818f2385ae5228e07f211bb4a33d)
|
|
|
6e672b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
6e672b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
6e672b |
---
|
|
|
6e672b |
hw/i386/multiboot.c | 53 ++++++++++++++++++++++++++++-------------------------
|
|
|
6e672b |
1 file changed, 28 insertions(+), 25 deletions(-)
|
|
|
6e672b |
|
|
|
6e672b |
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
|
|
|
6e672b |
index c4a361f..56889e8 100644
|
|
|
6e672b |
--- a/hw/i386/multiboot.c
|
|
|
6e672b |
+++ b/hw/i386/multiboot.c
|
|
|
6e672b |
@@ -28,12 +28,13 @@
|
|
|
6e672b |
#include "hw/loader.h"
|
|
|
6e672b |
#include "elf.h"
|
|
|
6e672b |
#include "sysemu/sysemu.h"
|
|
|
6e672b |
+#include "qemu/error-report.h"
|
|
|
6e672b |
|
|
|
6e672b |
/* Show multiboot debug output */
|
|
|
6e672b |
//#define DEBUG_MULTIBOOT
|
|
|
6e672b |
|
|
|
6e672b |
#ifdef DEBUG_MULTIBOOT
|
|
|
6e672b |
-#define mb_debug(a...) fprintf(stderr, ## a)
|
|
|
6e672b |
+#define mb_debug(a...) error_report(a)
|
|
|
6e672b |
#else
|
|
|
6e672b |
#define mb_debug(a...)
|
|
|
6e672b |
#endif
|
|
|
6e672b |
@@ -118,7 +119,7 @@ static void mb_add_mod(MultibootState *s,
|
|
|
6e672b |
stl_p(p + MB_MOD_END, end);
|
|
|
6e672b |
stl_p(p + MB_MOD_CMDLINE, cmdline_phys);
|
|
|
6e672b |
|
|
|
6e672b |
- mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n",
|
|
|
6e672b |
+ mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx,
|
|
|
6e672b |
s->mb_mods_count, start, end);
|
|
|
6e672b |
|
|
|
6e672b |
s->mb_mods_count++;
|
|
|
6e672b |
@@ -159,12 +160,12 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
if (!is_multiboot)
|
|
|
6e672b |
return 0; /* no multiboot */
|
|
|
6e672b |
|
|
|
6e672b |
- mb_debug("qemu: I believe we found a multiboot image!\n");
|
|
|
6e672b |
+ mb_debug("qemu: I believe we found a multiboot image!");
|
|
|
6e672b |
memset(bootinfo, 0, sizeof(bootinfo));
|
|
|
6e672b |
memset(&mbs, 0, sizeof(mbs));
|
|
|
6e672b |
|
|
|
6e672b |
if (flags & 0x00000004) { /* MULTIBOOT_HEADER_HAS_VBE */
|
|
|
6e672b |
- fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n");
|
|
|
6e672b |
+ error_report("qemu: multiboot knows VBE. we don't.");
|
|
|
6e672b |
}
|
|
|
6e672b |
if (!(flags & 0x00010000)) { /* MULTIBOOT_HEADER_HAS_ADDR */
|
|
|
6e672b |
uint64_t elf_entry;
|
|
|
6e672b |
@@ -173,14 +174,14 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
fclose(f);
|
|
|
6e672b |
|
|
|
6e672b |
if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) {
|
|
|
6e672b |
- fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n");
|
|
|
6e672b |
+ error_report("Cannot load x86-64 image, give a 32bit one.");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
|
|
|
6e672b |
kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
|
|
|
6e672b |
&elf_low, &elf_high, 0, ELF_MACHINE, 0);
|
|
|
6e672b |
if (kernel_size < 0) {
|
|
|
6e672b |
- fprintf(stderr, "Error while loading elf kernel\n");
|
|
|
6e672b |
+ error_report("Error while loading elf kernel");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
mh_load_addr = elf_low;
|
|
|
6e672b |
@@ -189,12 +190,13 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
|
|
|
6e672b |
mbs.mb_buf = g_malloc(mb_kernel_size);
|
|
|
6e672b |
if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) {
|
|
|
6e672b |
- fprintf(stderr, "Error while fetching elf kernel from rom\n");
|
|
|
6e672b |
+ error_report("Error while fetching elf kernel from rom");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
|
|
|
6e672b |
- mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n",
|
|
|
6e672b |
- mb_kernel_size, (size_t)mh_entry_addr);
|
|
|
6e672b |
+ mb_debug("qemu: loading multiboot-elf kernel "
|
|
|
6e672b |
+ "(%#x bytes) with entry %#zx",
|
|
|
6e672b |
+ mb_kernel_size, (size_t)mh_entry_addr);
|
|
|
6e672b |
} else {
|
|
|
6e672b |
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
|
|
|
6e672b |
uint32_t mh_header_addr = ldl_p(header+i+12);
|
|
|
6e672b |
@@ -203,7 +205,7 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
|
|
|
6e672b |
mh_load_addr = ldl_p(header+i+16);
|
|
|
6e672b |
if (mh_header_addr < mh_load_addr) {
|
|
|
6e672b |
- fprintf(stderr, "invalid load_addr address\n");
|
|
|
6e672b |
+ error_report("invalid load_addr address");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
|
|
|
6e672b |
@@ -213,20 +215,20 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
|
|
|
6e672b |
if (mh_load_end_addr) {
|
|
|
6e672b |
if (mh_load_end_addr < mh_load_addr) {
|
|
|
6e672b |
- fprintf(stderr, "invalid load_end_addr address\n");
|
|
|
6e672b |
+ error_report("invalid load_end_addr address");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
mb_load_size = mh_load_end_addr - mh_load_addr;
|
|
|
6e672b |
} else {
|
|
|
6e672b |
if (kernel_file_size < mb_kernel_text_offset) {
|
|
|
6e672b |
- fprintf(stderr, "invalid kernel_file_size\n");
|
|
|
6e672b |
+ error_report("invalid kernel_file_size");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
mb_load_size = kernel_file_size - mb_kernel_text_offset;
|
|
|
6e672b |
}
|
|
|
6e672b |
if (mh_bss_end_addr) {
|
|
|
6e672b |
if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) {
|
|
|
6e672b |
- fprintf(stderr, "invalid bss_end_addr address\n");
|
|
|
6e672b |
+ error_report("invalid bss_end_addr address");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
mb_kernel_size = mh_bss_end_addr - mh_load_addr;
|
|
|
6e672b |
@@ -234,17 +236,17 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
mb_kernel_size = mb_load_size;
|
|
|
6e672b |
}
|
|
|
6e672b |
|
|
|
6e672b |
- mb_debug("multiboot: header_addr = %#x\n", mh_header_addr);
|
|
|
6e672b |
- mb_debug("multiboot: load_addr = %#x\n", mh_load_addr);
|
|
|
6e672b |
- mb_debug("multiboot: load_end_addr = %#x\n", mh_load_end_addr);
|
|
|
6e672b |
- mb_debug("multiboot: bss_end_addr = %#x\n", mh_bss_end_addr);
|
|
|
6e672b |
- mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n",
|
|
|
6e672b |
+ mb_debug("multiboot: header_addr = %#x", mh_header_addr);
|
|
|
6e672b |
+ mb_debug("multiboot: load_addr = %#x", mh_load_addr);
|
|
|
6e672b |
+ mb_debug("multiboot: load_end_addr = %#x", mh_load_end_addr);
|
|
|
6e672b |
+ mb_debug("multiboot: bss_end_addr = %#x", mh_bss_end_addr);
|
|
|
6e672b |
+ mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x",
|
|
|
6e672b |
mb_load_size, mh_load_addr);
|
|
|
6e672b |
|
|
|
6e672b |
mbs.mb_buf = g_malloc(mb_kernel_size);
|
|
|
6e672b |
fseek(f, mb_kernel_text_offset, SEEK_SET);
|
|
|
6e672b |
if (fread(mbs.mb_buf, 1, mb_load_size, f) != mb_load_size) {
|
|
|
6e672b |
- fprintf(stderr, "fread() failed\n");
|
|
|
6e672b |
+ error_report("fread() failed");
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
memset(mbs.mb_buf + mb_load_size, 0, mb_kernel_size - mb_load_size);
|
|
|
6e672b |
@@ -297,7 +299,7 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
mb_debug("multiboot loading module: %s\n", initrd_filename);
|
|
|
6e672b |
mb_mod_length = get_image_size(initrd_filename);
|
|
|
6e672b |
if (mb_mod_length < 0) {
|
|
|
6e672b |
- fprintf(stderr, "Failed to open file '%s'\n", initrd_filename);
|
|
|
6e672b |
+ error_report("Failed to open file '%s'\n", initrd_filename);
|
|
|
6e672b |
exit(1);
|
|
|
6e672b |
}
|
|
|
6e672b |
|
|
|
6e672b |
@@ -308,7 +310,7 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
mb_add_mod(&mbs, mbs.mb_buf_phys + offs,
|
|
|
6e672b |
mbs.mb_buf_phys + offs + mb_mod_length, c);
|
|
|
6e672b |
|
|
|
6e672b |
- mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT_plx"\n",
|
|
|
6e672b |
+ mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT_plx,
|
|
|
6e672b |
(char *)mbs.mb_buf + offs,
|
|
|
6e672b |
(char *)mbs.mb_buf + offs + mb_mod_length, c);
|
|
|
6e672b |
initrd_filename = next_initrd+1;
|
|
|
6e672b |
@@ -335,10 +337,11 @@ int load_multiboot(FWCfgState *fw_cfg,
|
|
|
6e672b |
stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8000ffff); /* XXX: use the -boot switch? */
|
|
|
6e672b |
stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP);
|
|
|
6e672b |
|
|
|
6e672b |
- mb_debug("multiboot: entry_addr = %#x\n", mh_entry_addr);
|
|
|
6e672b |
- mb_debug(" mb_buf_phys = "TARGET_FMT_plx"\n", mbs.mb_buf_phys);
|
|
|
6e672b |
- mb_debug(" mod_start = "TARGET_FMT_plx"\n", mbs.mb_buf_phys + mbs.offset_mods);
|
|
|
6e672b |
- mb_debug(" mb_mods_count = %d\n", mbs.mb_mods_count);
|
|
|
6e672b |
+ mb_debug("multiboot: entry_addr = %#x", mh_entry_addr);
|
|
|
6e672b |
+ mb_debug(" mb_buf_phys = "TARGET_FMT_plx, mbs.mb_buf_phys);
|
|
|
6e672b |
+ mb_debug(" mod_start = "TARGET_FMT_plx,
|
|
|
6e672b |
+ mbs.mb_buf_phys + mbs.offset_mods);
|
|
|
6e672b |
+ mb_debug(" mb_mods_count = %d", mbs.mb_mods_count);
|
|
|
6e672b |
|
|
|
6e672b |
/* save bootinfo off the stack */
|
|
|
6e672b |
mb_bootinfo_data = g_malloc(sizeof(bootinfo));
|
|
|
6e672b |
--
|
|
|
6e672b |
1.8.3.1
|
|
|
6e672b |
|