[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/42] spapr: Don't hijack current_machine->boot_order
From: |
David Gibson |
Subject: |
[PULL 05/42] spapr: Don't hijack current_machine->boot_order |
Date: |
Thu, 3 Jun 2021 18:21:54 +1000 |
From: Greg Kurz <groug@kaod.org>
QEMU 6.0 moved all the -boot variables to the machine. Especially, the
removal of the boot_order static changed the handling of '-boot once'
from:
if (boot_once) {
qemu_boot_set(boot_once, &error_fatal);
qemu_register_reset(restore_boot_order, g_strdup(boot_order));
}
to
if (current_machine->boot_once) {
qemu_boot_set(current_machine->boot_once, &error_fatal);
qemu_register_reset(restore_boot_order,
g_strdup(current_machine->boot_order));
}
This means that we now register as subsequent boot order a copy
of current_machine->boot_once that was just set with the previous
call to qemu_boot_set(), i.e. we never transition away from the
once boot order.
It is certainly fragile^Wwrong for the spapr code to hijack a
field of the base machine type object like that. The boot order
rework simply turned this software boundary violation into an
actual bug.
Have the spapr code to handle that with its own field in
SpaprMachineState. Also kfree() the initial boot device
string when "once" was used.
Fixes: 4b7acd2ac821 ("vl: clean up -boot variables")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1960119
Cc: pbonzini@redhat.com
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210521160735.1901914-1-groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 8 +++++---
include/hw/ppc/spapr.h | 3 +++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index c23bcc4490..4dd90b75cc 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1005,7 +1005,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,
void *fdt, bool reset)
_FDT(chosen = fdt_add_subnode(fdt, 0, "chosen"));
if (reset) {
- const char *boot_device = machine->boot_order;
+ const char *boot_device = spapr->boot_device;
char *stdout_path = spapr_vio_stdout_path(spapr->vio_bus);
size_t cb = 0;
char *bootlist = get_boot_devices_list(&cb);
@@ -2376,8 +2376,10 @@ static SaveVMHandlers savevm_htab_handlers = {
static void spapr_boot_set(void *opaque, const char *boot_device,
Error **errp)
{
- MachineState *machine = MACHINE(opaque);
- machine->boot_order = g_strdup(boot_device);
+ SpaprMachineState *spapr = SPAPR_MACHINE(opaque);
+
+ g_free(spapr->boot_device);
+ spapr->boot_device = g_strdup(boot_device);
}
static void spapr_create_lmb_dr_connectors(SpaprMachineState *spapr)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index bbf817af46..f05219f75e 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -223,6 +223,9 @@ struct SpaprMachineState {
int fwnmi_machine_check_interlock;
QemuCond fwnmi_machine_check_interlock_cond;
+ /* Set by -boot */
+ char *boot_device;
+
/*< public >*/
char *kvm_type;
char *host_model;
--
2.31.1
- [PULL 00/42] ppc-for-6.1 queue 20210603, David Gibson, 2021/06/03
- [PULL 02/42] target/ppc: moved ppc_store_lpcr and ppc_store_msr to cpu.c, David Gibson, 2021/06/03
- [PULL 04/42] target/ppc: removed unnecessary inclusion of helper-proto.h, David Gibson, 2021/06/03
- [PULL 01/42] target/ppc: cleaned error_report from ppc_store_sdr1, David Gibson, 2021/06/03
- [PULL 03/42] target/ppc: reduce usage of fpscr_set_rounding_mode, David Gibson, 2021/06/03
- [PULL 06/42] spapr: Fix EEH capability issue on KVM guest for PCI passthru, David Gibson, 2021/06/03
- [PULL 10/42] spapr: Remove stale comment about power-saving LPCR bits, David Gibson, 2021/06/03
- [PULL 07/42] spapr: nvdimm: Forward declare and move the definitions, David Gibson, 2021/06/03
- [PULL 11/42] spapr: Set LPCR to current AIL mode when starting a new CPU, David Gibson, 2021/06/03
- [PULL 05/42] spapr: Don't hijack current_machine->boot_order,
David Gibson <=
- [PULL 12/42] target/ppc: used ternary operator when registering MAS, David Gibson, 2021/06/03
- [PULL 14/42] target/ppc: created tcg-stub.c file, David Gibson, 2021/06/03
- [PULL 08/42] spapr: nvdimm: Fix the persistent-memory root node name in device tree, David Gibson, 2021/06/03
- [PULL 09/42] target/ppc: fold ppc_store_ptcr into it's only caller, David Gibson, 2021/06/03
- [PULL 13/42] target/ppc: added ifdefs around TCG-only code, David Gibson, 2021/06/03
- [PULL 18/42] monitor: removed cpustats command, David Gibson, 2021/06/03
- [PULL 21/42] HMP: added info cpustats to removed_features.rst, David Gibson, 2021/06/03
- [PULL 17/42] target/ppc: removed mentions to DO_PPC_STATISTICS, David Gibson, 2021/06/03
- [PULL 20/42] hw/core/cpu: removed cpu_dump_statistics function, David Gibson, 2021/06/03
- [PULL 24/42] target/ppc: overhauled and moved logic of storing fpscr, David Gibson, 2021/06/03