[PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24

Philippe Mathieu-Daudé posted 6 patches 1 month ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>
[PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24
Posted by Philippe Mathieu-Daudé 1 month ago
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


Re: [PATCH v2 5/6] hw/hppa: Move CPU::cmdline_or_bootorder -> Machine::boot_info.gr24
Posted by Richard Henderson 1 month ago
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~