qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"Anton Johansson" <anjo@rev.ng>, "Helge Deller" <deller@gmx.de>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 6/6] hw/hppa: Move kernel addresses to HppaMachineState::boot_info structure
Date: Thu,  9 Oct 2025 16:31:06 +0200	[thread overview]
Message-ID: <20251009143106.22724-7-philmd@linaro.org> (raw)
In-Reply-To: <20251009143106.22724-1-philmd@linaro.org>

Restrict kernel* related variables scope, move fields that don't
belong to CPUHPPAState to HppaMachineState::boot_info::kernel.
Replace target_ulong -> vaddr type for virtual addresses.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/hppa/cpu.h |  3 ---
 hw/hppa/machine.c | 31 +++++++++++++++++--------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 0aa06f6ebec..49d0243f677 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -271,9 +271,6 @@ typedef struct CPUArchState {
     struct {} end_reset_fields;
 
     bool is_pa20;
-
-    target_ulong kernel_entry; /* Linux kernel was loaded here */
-    target_ulong initrd_base, initrd_end;
 } CPUHPPAState;
 
 /**
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c315d13ea01..a50efac375d 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -50,6 +50,8 @@ struct HppaMachineState {
                 bool interactive_mode;
             } firmware;
             struct {
+                vaddr entry; /* Linux kernel was loaded here */
+                vaddr initrd_base, initrd_end;
                 hwaddr cmdline_paddr;
             } kernel;
         };
@@ -365,8 +367,6 @@ 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);
     HppaMachineState *hms = HPPA_COMMON_MACHINE(machine);
@@ -375,7 +375,6 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     char *firmware_filename;
     uint64_t firmware_low, firmware_high;
     long size;
-    uint64_t kernel_entry = 0, kernel_low, kernel_high;
     MemoryRegion *addr_space = get_system_memory();
     MemoryRegion *rom_region;
     SysBusDevice *s;
@@ -481,6 +480,11 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
 
     /* Load kernel */
     if (kernel_filename) {
+        uint64_t kernel_entry;
+        uint64_t kernel_low, kernel_high;
+        const char *kernel_cmdline = machine->kernel_cmdline;
+        const char *initrd_filename = machine->initrd_filename;
+
         size = load_elf(kernel_filename, NULL, linux_kernel_virt_to_phys,
                         NULL, &kernel_entry, &kernel_low, &kernel_high, NULL,
                         ELFDATA2MSB, EM_PARISC, 0, 0);
@@ -496,6 +500,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
                       ", size %" PRIu64 " kB\n",
                       kernel_low, kernel_high, kernel_entry, size / KiB);
         hms->boot_info.is_kernel = true;
+        /* Keep initial kernel_entry for first boot */
+        hms->boot_info.kernel.entry = kernel_entry;
 
         if (kernel_cmdline) {
             hms->boot_info.kernel.cmdline_paddr = 0x4000;
@@ -529,8 +535,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.kernel.initrd_base = initrd_base;
+            hms->boot_info.kernel.initrd_end  = initrd_base + initrd_size;
         }
     }
 
@@ -544,9 +550,6 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
                                                   : 0;
         hms->boot_info.firmware.bootorder = machine->boot_config.order[0];
     }
-
-    /* Keep initial kernel_entry for first boot */
-    cpu[0]->env.kernel_entry = kernel_entry;
 }
 
 /*
@@ -687,20 +690,20 @@ 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.is_kernel
-                         ? cpu[0]->env.kernel_entry
+                         ? hms->boot_info.kernel.entry
                          : hms->boot_info.firmware.interactive_mode;
     cpu[0]->env.gr[24] = hms->boot_info.is_kernel
                          ? hms->boot_info.kernel.cmdline_paddr
                          : hms->boot_info.firmware.bootorder;
-    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.kernel.initrd_base;
+    cpu[0]->env.gr[22] = hms->boot_info.kernel.initrd_end;
     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 */
-    cpu[0]->env.kernel_entry = 0;
-    cpu[0]->env.initrd_base = 0;
-    cpu[0]->env.initrd_end = 0;
+    hms->boot_info.kernel.entry = 0;
+    hms->boot_info.kernel.initrd_base = 0;
+    hms->boot_info.kernel.initrd_end = 0;
     hms->boot_info.kernel.cmdline_paddr = 0;
     hms->boot_info.firmware.bootorder = mc->default_boot_order[0];
 }
-- 
2.51.0



      parent reply	other threads:[~2025-10-09 14:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 14:31 [PATCH 0/6] hw/hppa: Clarify machine variables and move them out of CPUArchState Philippe Mathieu-Daudé
2025-10-09 14:31 ` [PATCH 1/6] hw/hppa: Use the machine default boot order at reset Philippe Mathieu-Daudé
2025-10-09 17:40   ` Richard Henderson
2025-10-09 14:31 ` [PATCH 2/6] hw/hppa: Convert type_init() -> DEFINE_TYPES() Philippe Mathieu-Daudé
2025-10-09 17:07   ` Richard Henderson
2025-10-09 14:31 ` [PATCH 3/6] hw/hppa: Factor QOM HPPA_COMMON_MACHINE out Philippe Mathieu-Daudé
2025-10-09 17:09   ` Richard Henderson
2025-10-09 14:31 ` [PATCH 4/6] hw/hppa: Introduce HppaMachineState::boot_info::firmware structure Philippe Mathieu-Daudé
2025-10-09 17:20   ` Richard Henderson
2025-10-09 17:25     ` Philippe Mathieu-Daudé
2025-10-09 14:31 ` [PATCH 5/6] hw/hppa: Introduce HppaMachineState::boot_info::kernel structure Philippe Mathieu-Daudé
2025-10-09 14:31 ` Philippe Mathieu-Daudé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251009143106.22724-7-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=anjo@rev.ng \
    --cc=deller@gmx.de \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).