* [PATCH v2 1/6] hw/hppa: Convert type_init() -> DEFINE_TYPES()
2025-10-10 6:18 [PATCH v2 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
@ 2025-10-10 6:18 ` Philippe Mathieu-Daudé
2025-10-10 6:18 ` [PATCH v2 2/6] hw/hppa: Factor QOM HPPA_COMMON_MACHINE out Philippe Mathieu-Daudé
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-10 6:18 UTC (permalink / raw)
To: qemu-devel
Cc: Helge Deller, Anton Johansson, Richard Henderson,
Philippe Mathieu-Daudé
Prefer DEFINE_TYPES() macro over type_init() to register
multiple QOM types.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/hppa/machine.c | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index dacedc5409c..2ab5fcb471a 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -709,16 +709,6 @@ static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data)
nc->nmi_monitor_handler = hppa_nmi;
}
-static const TypeInfo HP_B160L_machine_init_typeinfo = {
- .name = MACHINE_TYPE_NAME("B160L"),
- .parent = TYPE_MACHINE,
- .class_init = HP_B160L_machine_init_class_init,
- .interfaces = (const InterfaceInfo[]) {
- { TYPE_NMI },
- { }
- },
-};
-
static void HP_C3700_machine_init_class_init(ObjectClass *oc, const void *data)
{
static const char * const valid_cpu_types[] = {
@@ -745,20 +735,24 @@ static void HP_C3700_machine_init_class_init(ObjectClass *oc, const void *data)
nc->nmi_monitor_handler = hppa_nmi;
}
-static const TypeInfo HP_C3700_machine_init_typeinfo = {
- .name = MACHINE_TYPE_NAME("C3700"),
- .parent = TYPE_MACHINE,
- .class_init = HP_C3700_machine_init_class_init,
- .interfaces = (const InterfaceInfo[]) {
- { TYPE_NMI },
- { }
+static const TypeInfo hppa_machine_types[] = {
+ {
+ .name = MACHINE_TYPE_NAME("B160L"),
+ .parent = TYPE_MACHINE,
+ .class_init = HP_B160L_machine_init_class_init,
+ .interfaces = (const InterfaceInfo[]) {
+ { TYPE_NMI },
+ { }
+ },
+ }, {
+ .name = MACHINE_TYPE_NAME("C3700"),
+ .parent = TYPE_MACHINE,
+ .class_init = HP_C3700_machine_init_class_init,
+ .interfaces = (const InterfaceInfo[]) {
+ { TYPE_NMI },
+ { }
+ },
},
};
-static void hppa_machine_init_register_types(void)
-{
- type_register_static(&HP_B160L_machine_init_typeinfo);
- type_register_static(&HP_C3700_machine_init_typeinfo);
-}
-
-type_init(hppa_machine_init_register_types)
+DEFINE_TYPES(hppa_machine_types)
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/6] hw/hppa: Factor QOM HPPA_COMMON_MACHINE out
2025-10-10 6:18 [PATCH v2 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
2025-10-10 6:18 ` [PATCH v2 1/6] hw/hppa: Convert type_init() -> DEFINE_TYPES() Philippe Mathieu-Daudé
@ 2025-10-10 6:18 ` Philippe Mathieu-Daudé
2025-10-10 6:18 ` [PATCH v2 3/6] hw/hppa: Reduce variables scope in common_init() Philippe Mathieu-Daudé
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-10 6:18 UTC (permalink / raw)
To: qemu-devel
Cc: Helge Deller, Anton Johansson, Richard Henderson,
Philippe Mathieu-Daudé
B160L and C3700 share a lot of common code. Factor it out
as an abstract HPPA_COMMON_MACHINE QOM parent.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/hppa/machine.c | 61 +++++++++++++++++++++++++----------------------
1 file changed, 33 insertions(+), 28 deletions(-)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 2ab5fcb471a..c8da159a114 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -36,6 +36,13 @@
#include "net/net.h"
#include "qemu/log.h"
+#define TYPE_HPPA_COMMON_MACHINE MACHINE_TYPE_NAME("hppa-common")
+OBJECT_DECLARE_SIMPLE_TYPE(HppaMachineState, HPPA_COMMON_MACHINE)
+
+struct HppaMachineState {
+ MachineState parent_obj;
+};
+
#define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
#define HPA_POWER_BUTTON (FIRMWARE_END - 0x10)
@@ -683,6 +690,22 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
}
}
+static void hppa_machine_common_class_init(ObjectClass *oc, const void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ NMIClass *nc = NMI_CLASS(oc);
+
+ mc->reset = hppa_machine_reset;
+ mc->block_default_type = IF_SCSI;
+ mc->default_cpus = 1;
+ mc->max_cpus = HPPA_MAX_CPUS;
+ mc->default_boot_order = "cd";
+ mc->default_ram_id = "ram";
+ mc->default_nic = "tulip";
+
+ nc->nmi_monitor_handler = hppa_nmi;
+}
+
static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data)
{
static const char * const valid_cpu_types[] = {
@@ -690,23 +713,13 @@ static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data)
NULL
};
MachineClass *mc = MACHINE_CLASS(oc);
- NMIClass *nc = NMI_CLASS(oc);
mc->desc = "HP B160L workstation";
mc->default_cpu_type = TYPE_HPPA_CPU;
mc->valid_cpu_types = valid_cpu_types;
mc->init = machine_HP_B160L_init;
- mc->reset = hppa_machine_reset;
- mc->block_default_type = IF_SCSI;
- mc->max_cpus = HPPA_MAX_CPUS;
- mc->default_cpus = 1;
mc->is_default = true;
mc->default_ram_size = 512 * MiB;
- mc->default_boot_order = "cd";
- mc->default_ram_id = "ram";
- mc->default_nic = "tulip";
-
- nc->nmi_monitor_handler = hppa_nmi;
}
static void HP_C3700_machine_init_class_init(ObjectClass *oc, const void *data)
@@ -716,42 +729,34 @@ static void HP_C3700_machine_init_class_init(ObjectClass *oc, const void *data)
NULL
};
MachineClass *mc = MACHINE_CLASS(oc);
- NMIClass *nc = NMI_CLASS(oc);
mc->desc = "HP C3700 workstation";
mc->default_cpu_type = TYPE_HPPA64_CPU;
mc->valid_cpu_types = valid_cpu_types;
mc->init = machine_HP_C3700_init;
- mc->reset = hppa_machine_reset;
- mc->block_default_type = IF_SCSI;
mc->max_cpus = HPPA_MAX_CPUS;
- mc->default_cpus = 1;
- mc->is_default = false;
mc->default_ram_size = 1024 * MiB;
- mc->default_boot_order = "cd";
- mc->default_ram_id = "ram";
- mc->default_nic = "tulip";
-
- nc->nmi_monitor_handler = hppa_nmi;
}
static const TypeInfo hppa_machine_types[] = {
{
- .name = MACHINE_TYPE_NAME("B160L"),
- .parent = TYPE_MACHINE,
- .class_init = HP_B160L_machine_init_class_init,
+ .name = TYPE_HPPA_COMMON_MACHINE,
+ .parent = TYPE_MACHINE,
+ .instance_size = sizeof(HppaMachineState),
+ .class_init = hppa_machine_common_class_init,
+ .abstract = true,
.interfaces = (const InterfaceInfo[]) {
{ TYPE_NMI },
{ }
},
+ }, {
+ .name = MACHINE_TYPE_NAME("B160L"),
+ .parent = TYPE_HPPA_COMMON_MACHINE,
+ .class_init = HP_B160L_machine_init_class_init,
}, {
.name = MACHINE_TYPE_NAME("C3700"),
- .parent = TYPE_MACHINE,
+ .parent = TYPE_HPPA_COMMON_MACHINE,
.class_init = HP_C3700_machine_init_class_init,
- .interfaces = (const InterfaceInfo[]) {
- { TYPE_NMI },
- { }
- },
},
};
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/6] hw/hppa: Reduce variables scope in common_init()
2025-10-10 6:18 [PATCH v2 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
2025-10-10 6:18 ` [PATCH v2 1/6] hw/hppa: Convert type_init() -> DEFINE_TYPES() Philippe Mathieu-Daudé
2025-10-10 6:18 ` [PATCH v2 2/6] hw/hppa: Factor QOM HPPA_COMMON_MACHINE out Philippe Mathieu-Daudé
@ 2025-10-10 6:18 ` Philippe Mathieu-Daudé
2025-10-10 17:23 ` Richard Henderson
2025-10-10 6:18 ` [PATCH v2 4/6] hw/hppa: Move CPU::kernel_entry -> Machine::boot_info.gr25 Philippe Mathieu-Daudé
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-10 6:18 UTC (permalink / raw)
To: qemu-devel
Cc: Helge Deller, Anton Johansson, Richard Henderson,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/hppa/machine.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c8da159a114..cddca69b938 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -352,16 +352,11 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
TranslateFn *translate)
{
const char *kernel_filename = machine->kernel_filename;
- const char *kernel_cmdline = machine->kernel_cmdline;
- const char *initrd_filename = machine->initrd_filename;
- const char *firmware = machine->firmware;
MachineClass *mc = MACHINE_GET_CLASS(machine);
DeviceState *dev;
PCIDevice *pci_dev;
- char *firmware_filename;
- uint64_t firmware_low, firmware_high;
long size;
- uint64_t kernel_entry = 0, kernel_low, kernel_high;
+ uint64_t kernel_entry = 0;
MemoryRegion *addr_space = get_system_memory();
MemoryRegion *rom_region;
SysBusDevice *s;
@@ -431,6 +426,10 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
firmware on 64-bit machines by default if not specified
on command line. */
if (!qtest_enabled()) {
+ const char *firmware = machine->firmware;
+ uint64_t firmware_low, firmware_high;
+ char *firmware_filename;
+
if (!firmware) {
firmware = lasi_dev ? "hppa-firmware.img" : "hppa-firmware64.img";
}
@@ -467,6 +466,10 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
/* Load kernel */
if (kernel_filename) {
+ const char *kernel_cmdline = machine->kernel_cmdline;
+ const char *initrd_filename = machine->initrd_filename;
+ uint64_t kernel_low, kernel_high;
+
size = load_elf(kernel_filename, NULL, linux_kernel_virt_to_phys,
NULL, &kernel_entry, &kernel_low, &kernel_high, NULL,
ELFDATA2MSB, EM_PARISC, 0, 0);
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 4/6] hw/hppa: Move CPU::kernel_entry -> Machine::boot_info.gr25
2025-10-10 6:18 [PATCH v2 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-10-10 6:18 ` [PATCH v2 3/6] hw/hppa: Reduce variables scope in common_init() Philippe Mathieu-Daudé
@ 2025-10-10 6:18 ` Philippe Mathieu-Daudé
2025-10-10 17:54 ` Richard Henderson
2025-10-10 6:18 ` [PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24 Philippe Mathieu-Daudé
2025-10-10 6:18 ` [PATCH v2 6/6] hw/hppa: Move CPU::initrd_base/end -> Machine::boot_info.gr22/23 Philippe Mathieu-Daudé
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-10 6:18 UTC (permalink / raw)
To: qemu-devel
Cc: Helge Deller, Anton Johansson, Richard Henderson,
Philippe Mathieu-Daudé
Current code uses CPUHPPAState::@kernel_entry to hold either:
- kernel entry virtual address
- firmware interactive mode
and CPUHPPAState::@cmdline_or_bootorder to either:
- kernel &cmdline physical address
- firmware boot order
Besides, these variables don't belong to CPUHPPAState, they
depend on how the machine is started, and only apply to the
first CPU.
The MachineReset handler initialize some registers of the
first CPU. Hold these register reset values in the MachineState,
initializing them once in machine_HP_common_init_tail().
Start by addressing the kernel entry and firmware interactive
mode values, stored in $GP25.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/hppa/cpu.h | 1 -
hw/hppa/machine.c | 28 ++++++++++++++++------------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index e14f238827b..f54634db7f1 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -272,7 +272,6 @@ typedef struct CPUArchState {
bool is_pa20;
- target_ulong kernel_entry; /* Linux kernel was loaded here */
target_ulong cmdline_or_bootorder;
target_ulong initrd_base, initrd_end;
} CPUHPPAState;
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index cddca69b938..7066f6d575c 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -41,6 +41,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(HppaMachineState, HPPA_COMMON_MACHINE)
struct HppaMachineState {
MachineState parent_obj;
+
+ struct {
+ uint64_t gr25;
+ } boot_info;
};
#define MIN_SEABIOS_HPPA_VERSION 12 /* require at least this fw version */
@@ -353,10 +357,10 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
{
const char *kernel_filename = machine->kernel_filename;
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ HppaMachineState *hms = HPPA_COMMON_MACHINE(machine);
DeviceState *dev;
PCIDevice *pci_dev;
long size;
- uint64_t kernel_entry = 0;
MemoryRegion *addr_space = get_system_memory();
MemoryRegion *rom_region;
SysBusDevice *s;
@@ -468,7 +472,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
if (kernel_filename) {
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
- uint64_t kernel_low, kernel_high;
+ uint64_t kernel_entry, kernel_low, kernel_high;
size = load_elf(kernel_filename, NULL, linux_kernel_virt_to_phys,
NULL, &kernel_entry, &kernel_low, &kernel_high, NULL,
@@ -484,6 +488,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
"-0x%08" PRIx64 ", entry at 0x%08" PRIx64
", size %" PRIu64 " kB\n",
kernel_low, kernel_high, kernel_entry, size / KiB);
+ /* Keep initial kernel_entry for first boot */
+ hms->boot_info.gr25 = kernel_entry;
if (kernel_cmdline) {
cpu[0]->env.cmdline_or_bootorder = 0x4000;
@@ -520,19 +526,16 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
cpu[0]->env.initrd_base = initrd_base;
cpu[0]->env.initrd_end = initrd_base + initrd_size;
}
- }
-
- if (!kernel_entry) {
+ } else {
/* When booting via firmware, tell firmware if we want interactive
- * mode (kernel_entry=1), and to boot from CD (cmdline_or_bootorder='d')
+ * mode (interactive_mode=1), and to boot from CD (cmdline_or_bootorder='d')
* or hard disc (cmdline_or_bootorder='c').
*/
- kernel_entry = machine->boot_config.has_menu ? machine->boot_config.menu : 0;
+ hms->boot_info.gr25 = machine->boot_config.has_menu
+ ? machine->boot_config.menu
+ : 0;
cpu[0]->env.cmdline_or_bootorder = machine->boot_config.order[0];
}
-
- /* Keep initial kernel_entry for first boot */
- cpu[0]->env.kernel_entry = kernel_entry;
}
/*
@@ -650,6 +653,7 @@ static void machine_HP_C3700_init(MachineState *machine)
static void hppa_machine_reset(MachineState *ms, ResetType type)
{
+ HppaMachineState *hms = HPPA_COMMON_MACHINE(ms);
unsigned int smp_cpus = ms->smp.cpus;
int i;
@@ -670,7 +674,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
}
cpu[0]->env.gr[26] = ms->ram_size;
- cpu[0]->env.gr[25] = cpu[0]->env.kernel_entry;
+ cpu[0]->env.gr[25] = hms->boot_info.gr25;
cpu[0]->env.gr[24] = cpu[0]->env.cmdline_or_bootorder;
cpu[0]->env.gr[23] = cpu[0]->env.initrd_base;
cpu[0]->env.gr[22] = cpu[0]->env.initrd_end;
@@ -678,7 +682,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
/* reset static fields to avoid starting Linux kernel & initrd on reboot */
- cpu[0]->env.kernel_entry = 0;
+ memset(&hms->boot_info, 0, sizeof(hms->boot_info));
cpu[0]->env.initrd_base = 0;
cpu[0]->env.initrd_end = 0;
cpu[0]->env.cmdline_or_bootorder = 'c';
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 4/6] hw/hppa: Move CPU::kernel_entry -> Machine::boot_info.gr25
2025-10-10 6:18 ` [PATCH v2 4/6] hw/hppa: Move CPU::kernel_entry -> Machine::boot_info.gr25 Philippe Mathieu-Daudé
@ 2025-10-10 17:54 ` Richard Henderson
0 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2025-10-10 17:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Helge Deller, Anton Johansson
On 10/9/25 23:18, Philippe Mathieu-Daudé wrote:
> Current code uses CPUHPPAState::@kernel_entry to hold either:
> - kernel entry virtual address
> - firmware interactive mode
> and CPUHPPAState::@cmdline_or_bootorder to either:
> - kernel &cmdline physical address
> - firmware boot order
>
> Besides, these variables don't belong to CPUHPPAState, they
> depend on how the machine is started, and only apply to the
> first CPU.
>
> The MachineReset handler initialize some registers of the
> first CPU. Hold these register reset values in the MachineState,
> initializing them once in machine_HP_common_init_tail().
>
> Start by addressing the kernel entry and firmware interactive
> mode values, stored in $GP25.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/hppa/cpu.h | 1 -
> hw/hppa/machine.c | 28 ++++++++++++++++------------
> 2 files changed, 16 insertions(+), 13 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> - }
> -
> - if (!kernel_entry) {
> + } else {
> /* When booting via firmware, tell firmware if we want interactive
> - * mode (kernel_entry=1), and to boot from CD (cmdline_or_bootorder='d')
> + * mode (interactive_mode=1), and to boot from CD (cmdline_or_bootorder='d')
> * or hard disc (cmdline_or_bootorder='c').
> */
> - kernel_entry = machine->boot_config.has_menu ? machine->boot_config.menu : 0;
> + hms->boot_info.gr25 = machine->boot_config.has_menu
> + ? machine->boot_config.menu
> + : 0;
There is no interactive_mode variable, so the change to the comment isn't great. Perhaps
just mention gr25.
As an aside, the expression involves two booleans, so better written as
machine->boot_config.has_menu && machine->boot_config.menu
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24
2025-10-10 6:18 [PATCH v2 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-10-10 6:18 ` [PATCH v2 4/6] hw/hppa: Move CPU::kernel_entry -> Machine::boot_info.gr25 Philippe Mathieu-Daudé
@ 2025-10-10 6:18 ` Philippe Mathieu-Daudé
2025-10-10 17:57 ` Richard Henderson
2025-10-10 6:18 ` [PATCH v2 6/6] hw/hppa: Move CPU::initrd_base/end -> Machine::boot_info.gr22/23 Philippe Mathieu-Daudé
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-10 6:18 UTC (permalink / raw)
To: qemu-devel
Cc: Helge Deller, Anton Johansson, Richard Henderson,
Philippe Mathieu-Daudé
Current code uses CPUHPPAState::@cmdline_or_bootorder to hold either:
- kernel &cmdline physical address
- firmware boot order
Besides, these variables don't belong to CPUHPPAState, they
depend on how the machine is started, and only apply to the
first CPU.
Initialize the register value the reset handler needs ($GP24)
once in machine_HP_common_init_tail().
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/hppa/cpu.h | 1 -
hw/hppa/machine.c | 14 +++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index f54634db7f1..6c9bcbd9078 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -272,7 +272,6 @@ typedef struct CPUArchState {
bool is_pa20;
- target_ulong cmdline_or_bootorder;
target_ulong initrd_base, initrd_end;
} CPUHPPAState;
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 7066f6d575c..b6f15bc61a3 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -43,6 +43,7 @@ struct HppaMachineState {
MachineState parent_obj;
struct {
+ uint64_t gr24;
uint64_t gr25;
} boot_info;
};
@@ -492,8 +493,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
hms->boot_info.gr25 = kernel_entry;
if (kernel_cmdline) {
- cpu[0]->env.cmdline_or_bootorder = 0x4000;
- pstrcpy_targphys("cmdline", cpu[0]->env.cmdline_or_bootorder,
+ hms->boot_info.gr24 = 0x4000;
+ pstrcpy_targphys("cmdline", hms->boot_info.gr24,
TARGET_PAGE_SIZE, kernel_cmdline);
}
@@ -528,13 +529,13 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
}
} else {
/* When booting via firmware, tell firmware if we want interactive
- * mode (interactive_mode=1), and to boot from CD (cmdline_or_bootorder='d')
- * or hard disc (cmdline_or_bootorder='c').
+ * mode (interactive_mode=1), and to boot from CD (bootorder='d')
+ * or hard disc (bootorder='c').
*/
hms->boot_info.gr25 = machine->boot_config.has_menu
? machine->boot_config.menu
: 0;
- cpu[0]->env.cmdline_or_bootorder = machine->boot_config.order[0];
+ hms->boot_info.gr24 = machine->boot_config.order[0];
}
}
@@ -675,7 +676,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
cpu[0]->env.gr[26] = ms->ram_size;
cpu[0]->env.gr[25] = hms->boot_info.gr25;
- cpu[0]->env.gr[24] = cpu[0]->env.cmdline_or_bootorder;
+ cpu[0]->env.gr[24] = hms->boot_info.gr24;
cpu[0]->env.gr[23] = cpu[0]->env.initrd_base;
cpu[0]->env.gr[22] = cpu[0]->env.initrd_end;
cpu[0]->env.gr[21] = smp_cpus;
@@ -685,7 +686,6 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
memset(&hms->boot_info, 0, sizeof(hms->boot_info));
cpu[0]->env.initrd_base = 0;
cpu[0]->env.initrd_end = 0;
- cpu[0]->env.cmdline_or_bootorder = 'c';
}
static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24
2025-10-10 6:18 ` [PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24 Philippe Mathieu-Daudé
@ 2025-10-10 17:57 ` Richard Henderson
0 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2025-10-10 17:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Helge Deller, Anton Johansson
On 10/9/25 23:18, Philippe Mathieu-Daudé wrote:
> } else {
> /* When booting via firmware, tell firmware if we want interactive
> - * mode (interactive_mode=1), and to boot from CD (cmdline_or_bootorder='d')
> - * or hard disc (cmdline_or_bootorder='c').
> + * mode (interactive_mode=1), and to boot from CD (bootorder='d')
> + * or hard disc (bootorder='c').
> */
Again there is no bootorder variable, so gr24 might be better.
> @@ -685,7 +686,6 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
> memset(&hms->boot_info, 0, sizeof(hms->boot_info));
> cpu[0]->env.initrd_base = 0;
> cpu[0]->env.initrd_end = 0;
> - cpu[0]->env.cmdline_or_bootorder = 'c';
> }
You need to retain this store, but adjust to boot_info.gr24.
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 6/6] hw/hppa: Move CPU::initrd_base/end -> Machine::boot_info.gr22/23
2025-10-10 6:18 [PATCH v2 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-10-10 6:18 ` [PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24 Philippe Mathieu-Daudé
@ 2025-10-10 6:18 ` Philippe Mathieu-Daudé
2025-10-10 17:59 ` Richard Henderson
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-10 6:18 UTC (permalink / raw)
To: qemu-devel
Cc: Helge Deller, Anton Johansson, Richard Henderson,
Philippe Mathieu-Daudé
These variables don't belong to CPUHPPAState, they depend on how
the machine is started, and only apply to the first CPU.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/hppa/cpu.h | 2 --
hw/hppa/machine.c | 12 ++++++------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 6c9bcbd9078..49d0243f677 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -271,8 +271,6 @@ typedef struct CPUArchState {
struct {} end_reset_fields;
bool is_pa20;
-
- target_ulong initrd_base, initrd_end;
} CPUHPPAState;
/**
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index b6f15bc61a3..61e83daaadb 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -43,6 +43,8 @@ struct HppaMachineState {
MachineState parent_obj;
struct {
+ uint64_t gr22;
+ uint64_t gr23;
uint64_t gr24;
uint64_t gr25;
} boot_info;
@@ -524,8 +526,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
}
load_image_targphys(initrd_filename, initrd_base, initrd_size);
- cpu[0]->env.initrd_base = initrd_base;
- cpu[0]->env.initrd_end = initrd_base + initrd_size;
+ hms->boot_info.gr23 = initrd_base;
+ hms->boot_info.gr22 = initrd_base + initrd_size;
}
} else {
/* When booting via firmware, tell firmware if we want interactive
@@ -677,15 +679,13 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
cpu[0]->env.gr[26] = ms->ram_size;
cpu[0]->env.gr[25] = hms->boot_info.gr25;
cpu[0]->env.gr[24] = hms->boot_info.gr24;
- cpu[0]->env.gr[23] = cpu[0]->env.initrd_base;
- cpu[0]->env.gr[22] = cpu[0]->env.initrd_end;
+ cpu[0]->env.gr[23] = hms->boot_info.gr23;
+ cpu[0]->env.gr[22] = hms->boot_info.gr22;
cpu[0]->env.gr[21] = smp_cpus;
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
/* reset static fields to avoid starting Linux kernel & initrd on reboot */
memset(&hms->boot_info, 0, sizeof(hms->boot_info));
- cpu[0]->env.initrd_base = 0;
- cpu[0]->env.initrd_end = 0;
}
static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread