* [PATCH] ppc/pegasos2: Add support for -initrd command line option
@ 2023-07-04 18:19 BALATON Zoltan
2023-07-04 18:24 ` BALATON Zoltan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: BALATON Zoltan @ 2023-07-04 18:19 UTC (permalink / raw)
To: qemu-devel, qemu-ppc; +Cc: Daniel Henrique Barboza
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/ppc/pegasos2.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index af5489de26..9c9944188b 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -44,6 +44,8 @@
#define PROM_ADDR 0xfff00000
#define PROM_SIZE 0x80000
+#define INITRD_MIN_ADDR 0x600000
+
#define KVMPPC_HCALL_BASE 0xf000
#define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
#define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5)
@@ -80,6 +82,8 @@ struct Pegasos2MachineState {
uint64_t kernel_addr;
uint64_t kernel_entry;
uint64_t kernel_size;
+ uint64_t initrd_addr;
+ uint64_t initrd_size;
};
static void *build_fdt(MachineState *machine, int *fdt_size);
@@ -117,7 +121,8 @@ static void pegasos2_init(MachineState *machine)
I2CBus *i2c_bus;
const char *fwname = machine->firmware ?: PROM_FILENAME;
char *filename;
- int i, sz;
+ int i;
+ ssize_t sz;
uint8_t *spd_data;
/* init CPU */
@@ -213,6 +218,20 @@ static void pegasos2_init(MachineState *machine)
warn_report("Using Virtual OpenFirmware but no -kernel option.");
}
+ if (machine->initrd_filename) {
+ pm->initrd_addr = pm->kernel_addr + pm->kernel_size + 64 * KiB;
+ pm->initrd_addr = ROUND_UP(pm->initrd_addr, 4);
+ pm->initrd_addr = MAX(pm->initrd_addr, INITRD_MIN_ADDR);
+ sz = load_image_targphys(machine->initrd_filename, pm->initrd_addr,
+ machine->ram_size - pm->initrd_addr);
+ if (sz <= 0) {
+ error_report("Could not load initrd '%s'",
+ machine->initrd_filename);
+ exit(1);
+ }
+ pm->initrd_size = sz;
+ }
+
if (!pm->vof && machine->kernel_cmdline && machine->kernel_cmdline[0]) {
warn_report("Option -append may be ineffective with -bios.");
}
@@ -335,6 +354,11 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason)
error_report("Memory for kernel is in use");
exit(1);
}
+ if (pm->initrd_size &&
+ vof_claim(pm->vof, pm->initrd_addr, pm->initrd_size, 0) == -1) {
+ error_report("Memory for initrd is in use");
+ exit(1);
+ }
fdt = build_fdt(machine, &sz);
/* FIXME: VOF assumes entry is same as load address */
d[0] = cpu_to_be64(pm->kernel_entry);
@@ -966,6 +990,12 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory");
qemu_fdt_add_subnode(fdt, "/chosen");
+ if (pm->initrd_addr && pm->initrd_size) {
+ qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+ pm->initrd_addr + pm->initrd_size);
+ qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
+ pm->initrd_addr);
+ }
qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
machine->kernel_cmdline ?: "");
qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen");
--
2.30.9
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ppc/pegasos2: Add support for -initrd command line option
2023-07-04 18:19 [PATCH] ppc/pegasos2: Add support for -initrd command line option BALATON Zoltan
@ 2023-07-04 18:24 ` BALATON Zoltan
2023-07-05 8:34 ` Daniel Henrique Barboza
2023-07-05 9:35 ` Cédric Le Goater
2 siblings, 0 replies; 5+ messages in thread
From: BALATON Zoltan @ 2023-07-04 18:24 UTC (permalink / raw)
To: qemu-devel, qemu-ppc; +Cc: Daniel Henrique Barboza
On Tue, 4 Jul 2023, BALATON Zoltan wrote:
Forgot to add commit message here:
This also changes type of sz local variable to ssize_t because it is used
to store return value of load_elf() and load_image_targphys() that return
ssize_t.
Should I resend for this or you can ammend on commit?
Regards,
BALATON Zoltan
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> hw/ppc/pegasos2.c | 32 +++++++++++++++++++++++++++++++-
> 1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> index af5489de26..9c9944188b 100644
> --- a/hw/ppc/pegasos2.c
> +++ b/hw/ppc/pegasos2.c
> @@ -44,6 +44,8 @@
> #define PROM_ADDR 0xfff00000
> #define PROM_SIZE 0x80000
>
> +#define INITRD_MIN_ADDR 0x600000
> +
> #define KVMPPC_HCALL_BASE 0xf000
> #define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
> #define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5)
> @@ -80,6 +82,8 @@ struct Pegasos2MachineState {
> uint64_t kernel_addr;
> uint64_t kernel_entry;
> uint64_t kernel_size;
> + uint64_t initrd_addr;
> + uint64_t initrd_size;
> };
>
> static void *build_fdt(MachineState *machine, int *fdt_size);
> @@ -117,7 +121,8 @@ static void pegasos2_init(MachineState *machine)
> I2CBus *i2c_bus;
> const char *fwname = machine->firmware ?: PROM_FILENAME;
> char *filename;
> - int i, sz;
> + int i;
> + ssize_t sz;
> uint8_t *spd_data;
>
> /* init CPU */
> @@ -213,6 +218,20 @@ static void pegasos2_init(MachineState *machine)
> warn_report("Using Virtual OpenFirmware but no -kernel option.");
> }
>
> + if (machine->initrd_filename) {
> + pm->initrd_addr = pm->kernel_addr + pm->kernel_size + 64 * KiB;
> + pm->initrd_addr = ROUND_UP(pm->initrd_addr, 4);
> + pm->initrd_addr = MAX(pm->initrd_addr, INITRD_MIN_ADDR);
> + sz = load_image_targphys(machine->initrd_filename, pm->initrd_addr,
> + machine->ram_size - pm->initrd_addr);
> + if (sz <= 0) {
> + error_report("Could not load initrd '%s'",
> + machine->initrd_filename);
> + exit(1);
> + }
> + pm->initrd_size = sz;
> + }
> +
> if (!pm->vof && machine->kernel_cmdline && machine->kernel_cmdline[0]) {
> warn_report("Option -append may be ineffective with -bios.");
> }
> @@ -335,6 +354,11 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason)
> error_report("Memory for kernel is in use");
> exit(1);
> }
> + if (pm->initrd_size &&
> + vof_claim(pm->vof, pm->initrd_addr, pm->initrd_size, 0) == -1) {
> + error_report("Memory for initrd is in use");
> + exit(1);
> + }
> fdt = build_fdt(machine, &sz);
> /* FIXME: VOF assumes entry is same as load address */
> d[0] = cpu_to_be64(pm->kernel_entry);
> @@ -966,6 +990,12 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
> qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory");
>
> qemu_fdt_add_subnode(fdt, "/chosen");
> + if (pm->initrd_addr && pm->initrd_size) {
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
> + pm->initrd_addr + pm->initrd_size);
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
> + pm->initrd_addr);
> + }
> qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
> machine->kernel_cmdline ?: "");
> qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen");
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ppc/pegasos2: Add support for -initrd command line option
2023-07-04 18:19 [PATCH] ppc/pegasos2: Add support for -initrd command line option BALATON Zoltan
2023-07-04 18:24 ` BALATON Zoltan
@ 2023-07-05 8:34 ` Daniel Henrique Barboza
2023-07-05 9:35 ` Cédric Le Goater
2 siblings, 0 replies; 5+ messages in thread
From: Daniel Henrique Barboza @ 2023-07-05 8:34 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel, qemu-ppc
On 7/4/23 15:19, BALATON Zoltan wrote:
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
And pushed to ppc-next after amending the commit msg.
Daniel
> hw/ppc/pegasos2.c | 32 +++++++++++++++++++++++++++++++-
> 1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> index af5489de26..9c9944188b 100644
> --- a/hw/ppc/pegasos2.c
> +++ b/hw/ppc/pegasos2.c
> @@ -44,6 +44,8 @@
> #define PROM_ADDR 0xfff00000
> #define PROM_SIZE 0x80000
>
> +#define INITRD_MIN_ADDR 0x600000
> +
> #define KVMPPC_HCALL_BASE 0xf000
> #define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
> #define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5)
> @@ -80,6 +82,8 @@ struct Pegasos2MachineState {
> uint64_t kernel_addr;
> uint64_t kernel_entry;
> uint64_t kernel_size;
> + uint64_t initrd_addr;
> + uint64_t initrd_size;
> };
>
> static void *build_fdt(MachineState *machine, int *fdt_size);
> @@ -117,7 +121,8 @@ static void pegasos2_init(MachineState *machine)
> I2CBus *i2c_bus;
> const char *fwname = machine->firmware ?: PROM_FILENAME;
> char *filename;
> - int i, sz;
> + int i;
> + ssize_t sz;
> uint8_t *spd_data;
>
> /* init CPU */
> @@ -213,6 +218,20 @@ static void pegasos2_init(MachineState *machine)
> warn_report("Using Virtual OpenFirmware but no -kernel option.");
> }
>
> + if (machine->initrd_filename) {
> + pm->initrd_addr = pm->kernel_addr + pm->kernel_size + 64 * KiB;
> + pm->initrd_addr = ROUND_UP(pm->initrd_addr, 4);
> + pm->initrd_addr = MAX(pm->initrd_addr, INITRD_MIN_ADDR);
> + sz = load_image_targphys(machine->initrd_filename, pm->initrd_addr,
> + machine->ram_size - pm->initrd_addr);
> + if (sz <= 0) {
> + error_report("Could not load initrd '%s'",
> + machine->initrd_filename);
> + exit(1);
> + }
> + pm->initrd_size = sz;
> + }
> +
> if (!pm->vof && machine->kernel_cmdline && machine->kernel_cmdline[0]) {
> warn_report("Option -append may be ineffective with -bios.");
> }
> @@ -335,6 +354,11 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason)
> error_report("Memory for kernel is in use");
> exit(1);
> }
> + if (pm->initrd_size &&
> + vof_claim(pm->vof, pm->initrd_addr, pm->initrd_size, 0) == -1) {
> + error_report("Memory for initrd is in use");
> + exit(1);
> + }
> fdt = build_fdt(machine, &sz);
> /* FIXME: VOF assumes entry is same as load address */
> d[0] = cpu_to_be64(pm->kernel_entry);
> @@ -966,6 +990,12 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
> qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory");
>
> qemu_fdt_add_subnode(fdt, "/chosen");
> + if (pm->initrd_addr && pm->initrd_size) {
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
> + pm->initrd_addr + pm->initrd_size);
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
> + pm->initrd_addr);
> + }
> qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
> machine->kernel_cmdline ?: "");
> qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen");
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ppc/pegasos2: Add support for -initrd command line option
2023-07-04 18:19 [PATCH] ppc/pegasos2: Add support for -initrd command line option BALATON Zoltan
2023-07-04 18:24 ` BALATON Zoltan
2023-07-05 8:34 ` Daniel Henrique Barboza
@ 2023-07-05 9:35 ` Cédric Le Goater
2023-07-05 9:37 ` Cédric Le Goater
2 siblings, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2023-07-05 9:35 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel, qemu-ppc; +Cc: Daniel Henrique Barboza
Hello,
On 7/4/23 20:19, BALATON Zoltan wrote:
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
The patch is not a oneliner, it deserves a minimal commit log.
Thanks,
C.
> ---
> hw/ppc/pegasos2.c | 32 +++++++++++++++++++++++++++++++-
> 1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> index af5489de26..9c9944188b 100644
> --- a/hw/ppc/pegasos2.c
> +++ b/hw/ppc/pegasos2.c
> @@ -44,6 +44,8 @@
> #define PROM_ADDR 0xfff00000
> #define PROM_SIZE 0x80000
>
> +#define INITRD_MIN_ADDR 0x600000
> +
> #define KVMPPC_HCALL_BASE 0xf000
> #define KVMPPC_H_RTAS (KVMPPC_HCALL_BASE + 0x0)
> #define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5)
> @@ -80,6 +82,8 @@ struct Pegasos2MachineState {
> uint64_t kernel_addr;
> uint64_t kernel_entry;
> uint64_t kernel_size;
> + uint64_t initrd_addr;
> + uint64_t initrd_size;
> };
>
> static void *build_fdt(MachineState *machine, int *fdt_size);
> @@ -117,7 +121,8 @@ static void pegasos2_init(MachineState *machine)
> I2CBus *i2c_bus;
> const char *fwname = machine->firmware ?: PROM_FILENAME;
> char *filename;
> - int i, sz;
> + int i;
> + ssize_t sz;
> uint8_t *spd_data;
>
> /* init CPU */
> @@ -213,6 +218,20 @@ static void pegasos2_init(MachineState *machine)
> warn_report("Using Virtual OpenFirmware but no -kernel option.");
> }
>
> + if (machine->initrd_filename) {
> + pm->initrd_addr = pm->kernel_addr + pm->kernel_size + 64 * KiB;
> + pm->initrd_addr = ROUND_UP(pm->initrd_addr, 4);
> + pm->initrd_addr = MAX(pm->initrd_addr, INITRD_MIN_ADDR);
> + sz = load_image_targphys(machine->initrd_filename, pm->initrd_addr,
> + machine->ram_size - pm->initrd_addr);
> + if (sz <= 0) {
> + error_report("Could not load initrd '%s'",
> + machine->initrd_filename);
> + exit(1);
> + }
> + pm->initrd_size = sz;
> + }
> +
> if (!pm->vof && machine->kernel_cmdline && machine->kernel_cmdline[0]) {
> warn_report("Option -append may be ineffective with -bios.");
> }
> @@ -335,6 +354,11 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason)
> error_report("Memory for kernel is in use");
> exit(1);
> }
> + if (pm->initrd_size &&
> + vof_claim(pm->vof, pm->initrd_addr, pm->initrd_size, 0) == -1) {
> + error_report("Memory for initrd is in use");
> + exit(1);
> + }
> fdt = build_fdt(machine, &sz);
> /* FIXME: VOF assumes entry is same as load address */
> d[0] = cpu_to_be64(pm->kernel_entry);
> @@ -966,6 +990,12 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
> qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory");
>
> qemu_fdt_add_subnode(fdt, "/chosen");
> + if (pm->initrd_addr && pm->initrd_size) {
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
> + pm->initrd_addr + pm->initrd_size);
> + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
> + pm->initrd_addr);
> + }
> qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
> machine->kernel_cmdline ?: "");
> qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen");
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ppc/pegasos2: Add support for -initrd command line option
2023-07-05 9:35 ` Cédric Le Goater
@ 2023-07-05 9:37 ` Cédric Le Goater
0 siblings, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2023-07-05 9:37 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel, qemu-ppc; +Cc: Daniel Henrique Barboza
On 7/5/23 11:35, Cédric Le Goater wrote:
> Hello,
>
> On 7/4/23 20:19, BALATON Zoltan wrote:
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> The patch is not a oneliner, it deserves a minimal commit log.
It was fixed later on. Forget my comment.
Thanks,
C.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-05 9:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-04 18:19 [PATCH] ppc/pegasos2: Add support for -initrd command line option BALATON Zoltan
2023-07-04 18:24 ` BALATON Zoltan
2023-07-05 8:34 ` Daniel Henrique Barboza
2023-07-05 9:35 ` Cédric Le Goater
2023-07-05 9:37 ` Cédric Le Goater
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).