Skip to content

Commit b5afd8c

Browse files
committed
Merge tag 'hppa-system-for-v10-pull-request' of https://github.com/hdeller/qemu-hppa into staging
hppa updates * Fixes booting a Linux kernel which is provided on the command line. * Allow more than 4GB RAM on 64-bit boxes # -----BEGIN PGP SIGNATURE----- # # iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCZ5PvvgAKCRD3ErUQojoP # X7JQAQCn2MR4k4lfClDZHNmAFUNw51j56SB5HC/FCUKfOx4dCQD/Tf2OV/gstMOz # nfpvIH6ouXZ2/p5npzTyOt+A8fwUpw0= # =qrs7 # -----END PGP SIGNATURE----- # gpg: Signature made Fri 24 Jan 2025 14:53:34 EST # gpg: using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F # gpg: Good signature from "Helge Deller <deller@gmx.de>" [unknown] # gpg: aka "Helge Deller <deller@kernel.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 4544 8228 2CD9 10DB EF3D 25F8 3E5F 3D04 A7A2 4603 # Subkey fingerprint: BCE9 123E 1AD2 9F07 C049 BBDE F712 B510 A23A 0F5F * tag 'hppa-system-for-v10-pull-request' of https://github.com/hdeller/qemu-hppa: hw/hppa: Fix booting Linux kernel with initrd hw/hppa: Support up to 256 GiB RAM on 64-bit machines Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 parents ed73437 + c656f29 commit b5afd8c

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

hw/hppa/hppa_hardware.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@
4949
#define CPU_HPA_CR_REG 7 /* store CPU HPA in cr7 (SeaBIOS internal) */
5050
#define PIM_STORAGE_SIZE 600 /* storage size of pdc_pim_toc_struct (64bit) */
5151

52+
#define RAM_MAP_HIGH 0x0100000000 /* memory above 3.75 GB is mapped here */
53+
5254
#endif

hw/hppa/machine.c

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,13 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
283283
cpu[i] = HPPA_CPU(cpu_create(machine->cpu_type));
284284
}
285285

286-
/*
287-
* For now, treat address layout as if PSW_W is clear.
288-
* TODO: create a proper hppa64 board model and load elf64 firmware.
289-
*/
286+
/* Initialize memory */
290287
if (hppa_is_pa20(&cpu[0]->env)) {
291288
translate = translate_pa20;
292-
ram_max = 0xf0000000; /* 3.75 GB (limited by 32-bit firmware) */
289+
ram_max = 256 * GiB; /* like HP rp8440 */
293290
} else {
294291
translate = translate_pa10;
295-
ram_max = 0xf0000000; /* 3.75 GB (32-bit CPU) */
292+
ram_max = FIRMWARE_START; /* 3.75 GB (32-bit CPU) */
296293
}
297294

298295
soft_power_reg = translate(NULL, HPA_POWER_BUTTON);
@@ -320,7 +317,22 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
320317
info_report("Max RAM size limited to %" PRIu64 " MB", ram_max / MiB);
321318
machine->ram_size = ram_max;
322319
}
323-
memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1);
320+
if (machine->ram_size <= FIRMWARE_START) {
321+
/* contiguous memory up to 3.75 GB RAM */
322+
memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1);
323+
} else {
324+
/* non-contiguous: Memory above 3.75 GB is mapped at RAM_MAP_HIGH */
325+
MemoryRegion *mem_region;
326+
mem_region = g_new(MemoryRegion, 2);
327+
memory_region_init_alias(&mem_region[0], &addr_space->parent_obj,
328+
"LowMem", machine->ram, 0, FIRMWARE_START);
329+
memory_region_init_alias(&mem_region[1], &addr_space->parent_obj,
330+
"HighMem", machine->ram, FIRMWARE_START,
331+
machine->ram_size - FIRMWARE_START);
332+
memory_region_add_subregion_overlap(addr_space, 0, &mem_region[0], -1);
333+
memory_region_add_subregion_overlap(addr_space, RAM_MAP_HIGH,
334+
&mem_region[1], -1);
335+
}
324336

325337
return translate;
326338
}
@@ -344,7 +356,6 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
344356
uint64_t kernel_entry = 0, kernel_low, kernel_high;
345357
MemoryRegion *addr_space = get_system_memory();
346358
MemoryRegion *rom_region;
347-
unsigned int smp_cpus = machine->smp.cpus;
348359
SysBusDevice *s;
349360

350361
/* SCSI disk setup. */
@@ -470,8 +481,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
470481
kernel_low, kernel_high, kernel_entry, size / KiB);
471482

472483
if (kernel_cmdline) {
473-
cpu[0]->env.gr[24] = 0x4000;
474-
pstrcpy_targphys("cmdline", cpu[0]->env.gr[24],
484+
cpu[0]->env.cmdline_or_bootorder = 0x4000;
485+
pstrcpy_targphys("cmdline", cpu[0]->env.cmdline_or_bootorder,
475486
TARGET_PAGE_SIZE, kernel_cmdline);
476487
}
477488

@@ -501,32 +512,22 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
501512
}
502513

503514
load_image_targphys(initrd_filename, initrd_base, initrd_size);
504-
cpu[0]->env.gr[23] = initrd_base;
505-
cpu[0]->env.gr[22] = initrd_base + initrd_size;
515+
cpu[0]->env.initrd_base = initrd_base;
516+
cpu[0]->env.initrd_end = initrd_base + initrd_size;
506517
}
507518
}
508519

509520
if (!kernel_entry) {
510521
/* When booting via firmware, tell firmware if we want interactive
511-
* mode (kernel_entry=1), and to boot from CD (gr[24]='d')
512-
* or hard disc * (gr[24]='c').
522+
* mode (kernel_entry=1), and to boot from CD (cmdline_or_bootorder='d')
523+
* or hard disc (cmdline_or_bootorder='c').
513524
*/
514525
kernel_entry = machine->boot_config.has_menu ? machine->boot_config.menu : 0;
515-
cpu[0]->env.gr[24] = machine->boot_config.order[0];
526+
cpu[0]->env.cmdline_or_bootorder = machine->boot_config.order[0];
516527
}
517528

518-
/* We jump to the firmware entry routine and pass the
519-
* various parameters in registers. After firmware initialization,
520-
* firmware will start the Linux kernel with ramdisk and cmdline.
521-
*/
522-
cpu[0]->env.gr[26] = machine->ram_size;
523-
cpu[0]->env.gr[25] = kernel_entry;
524-
525-
/* tell firmware how many SMP CPUs to present in inventory table */
526-
cpu[0]->env.gr[21] = smp_cpus;
527-
528-
/* tell firmware fw_cfg port */
529-
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
529+
/* Keep initial kernel_entry for first boot */
530+
cpu[0]->env.kernel_entry = kernel_entry;
530531
}
531532

532533
/*
@@ -663,18 +664,19 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
663664
cpu[i]->env.gr[5] = CPU_HPA + i * 0x1000;
664665
}
665666

666-
/* already initialized by machine_hppa_init()? */
667-
if (cpu[0]->env.gr[26] == ms->ram_size) {
668-
return;
669-
}
670-
671667
cpu[0]->env.gr[26] = ms->ram_size;
672-
cpu[0]->env.gr[25] = 0; /* no firmware boot menu */
673-
cpu[0]->env.gr[24] = 'c';
674-
/* gr22/gr23 unused, no initrd while reboot. */
668+
cpu[0]->env.gr[25] = cpu[0]->env.kernel_entry;
669+
cpu[0]->env.gr[24] = cpu[0]->env.cmdline_or_bootorder;
670+
cpu[0]->env.gr[23] = cpu[0]->env.initrd_base;
671+
cpu[0]->env.gr[22] = cpu[0]->env.initrd_end;
675672
cpu[0]->env.gr[21] = smp_cpus;
676-
/* tell firmware fw_cfg port */
677673
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
674+
675+
/* reset static fields to avoid starting Linux kernel & initrd on reboot */
676+
cpu[0]->env.kernel_entry = 0;
677+
cpu[0]->env.initrd_base = 0;
678+
cpu[0]->env.initrd_end = 0;
679+
cpu[0]->env.cmdline_or_bootorder = 'c';
678680
}
679681

680682
static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)

target/hppa/cpu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ typedef struct CPUArchState {
268268
struct {} end_reset_fields;
269269

270270
bool is_pa20;
271+
272+
target_ulong kernel_entry; /* Linux kernel was loaded here */
273+
target_ulong cmdline_or_bootorder;
274+
target_ulong initrd_base, initrd_end;
271275
} CPUHPPAState;
272276

273277
/**

0 commit comments

Comments
 (0)