qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Thomas Huth" <thuth@redhat.com>, "Clément Chigot" <chigot@adacore.com>
Cc: qemu-ppc@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH 3/3] meson: Enable -Wvla
Date: Wed, 21 Feb 2024 18:30:41 +0100	[thread overview]
Message-ID: <edaea1af-b42e-438e-8f82-8c1fbe95f874@linaro.org> (raw)
In-Reply-To: <e38c7fa5-8dc8-4e7a-a4a9-06a88206b325@linaro.org>

On 21/2/24 18:27, Philippe Mathieu-Daudé wrote:

> Clément, ResetData::entry isn't used, so we can simplify removing
> the whole ResetData structure, but I'm not sure this is intended:
> 
> -- >8 --
> diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
> index 4873b59b6c..1ff6b5d63d 100644
> --- a/hw/sparc/leon3.c
> +++ b/hw/sparc/leon3.c
> @@ -68,14 +68,6 @@
>   #define LEON3_APB_PNP_OFFSET (0x800FF000)
>   #define LEON3_AHB_PNP_OFFSET (0xFFFFF000)
> 
> -typedef struct ResetData {
> -    struct CPUResetData {
> -        int id;
> -        SPARCCPU *cpu;
> -    } info[MAX_CPUS];
> -    uint32_t entry;             /* save kernel entry in case of reset */
> -} ResetData;
> -
>   static uint32_t *gen_store_u32(uint32_t *code, hwaddr addr, uint32_t val)
>   {
>       stl_p(code++, 0x82100000); /* mov %g0, %g1                */
> @@ -148,17 +140,14 @@ static void write_bootloader(void *ptr, hwaddr 
> kernel_addr)
> 
>   static void leon3_cpu_reset(void *opaque)
>   {
> -    struct CPUResetData *info = (struct CPUResetData *) opaque;
> -    int id = info->id;
> -    ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info);
> -    CPUState *cpu = CPU(s->info[id].cpu);
> +    CPUState *cpu = opaque;
>       CPUSPARCState *env = cpu_env(cpu);
> 
>       cpu_reset(cpu);
> 
>       cpu->halted = cpu->cpu_index != 0;
> -    env->pc = s->entry;
> -    env->npc = s->entry + 4;
> +    env->pc = LEON3_PROM_OFFSET;
> +    env->npc = LEON3_PROM_OFFSET + 4;
>   }
> 
>   static void leon3_cache_control_int(CPUSPARCState *env)
> @@ -259,7 +248,7 @@ static void leon3_generic_hw_init(MachineState 
> *machine)
>       ram_addr_t ram_size = machine->ram_size;
>       const char *bios_name = machine->firmware ?: LEON3_PROM_FILENAME;
>       const char *kernel_filename = machine->kernel_filename;
> -    SPARCCPU *cpu;
> +    SPARCCPU *cpu[MAX_CPUS];
>       CPUSPARCState   *env;
>       MemoryRegion *address_space_mem = get_system_memory();
>       MemoryRegion *prom = g_new(MemoryRegion, 1);
> @@ -267,28 +256,22 @@ static void leon3_generic_hw_init(MachineState 
> *machine)
>       char       *filename;
>       int         bios_size;
>       int         prom_size;
> -    ResetData  *reset_info;
>       DeviceState *dev, *irqmpdev;
>       int i;
>       AHBPnp *ahb_pnp;
>       APBPnp *apb_pnp;
> 
> -    reset_info = g_malloc0(sizeof(ResetData));
> -
>       for (i = 0; i < machine->smp.cpus; i++) {
>           /* Init CPU */
> -        cpu = SPARC_CPU(object_new(machine->cpu_type));
> -        qdev_init_gpio_in_named(DEVICE(cpu), leon3_start_cpu, 
> "start_cpu", 1);
> -        qdev_init_gpio_in_named(DEVICE(cpu), leon3_set_pil_in, "pil", 1);
> -        qdev_realize(DEVICE(cpu), NULL, &error_fatal);
> -        env = &cpu->env;
> +        cpu[i] = SPARC_CPU(object_new(machine->cpu_type));
> +        qdev_init_gpio_in_named(DEVICE(cpu[i]), leon3_start_cpu, 
> "start_cpu", 1);
> +        qdev_init_gpio_in_named(DEVICE(cpu[i]), leon3_set_pil_in, 
> "pil", 1);
> +        qdev_realize(DEVICE(cpu[i]), NULL, &error_fatal);
> +        env = &cpu[i]->env;
> 
>           cpu_sparc_set_id(env, i);
> 
> -        /* Reset data */
> -        reset_info->info[i].id = i;
> -        reset_info->info[i].cpu = cpu;
> -        qemu_register_reset(leon3_cpu_reset, &reset_info->info[i]);
> +        qemu_register_reset(leon3_cpu_reset, cpu[i]);

           qemu_register_reset(leon3_cpu_reset, CPU(cpu[i]));

>       }
> 
>       ahb_pnp = GRLIB_AHB_PNP(qdev_new(TYPE_GRLIB_AHB_PNP));
> @@ -312,13 +295,12 @@ static void leon3_generic_hw_init(MachineState 
> *machine)
>       sysbus_realize_and_unref(SYS_BUS_DEVICE(irqmpdev), &error_fatal);
> 
>       for (i = 0; i < machine->smp.cpus; i++) {
> -        cpu = reset_info->info[i].cpu;
> -        env = &cpu->env;
> +        env = &cpu[i]->env;
>           qdev_connect_gpio_out_named(irqmpdev, "grlib-start-cpu", i,
> -                                    qdev_get_gpio_in_named(DEVICE(cpu),
> +                                    qdev_get_gpio_in_named(DEVICE(cpu[i]),
> 
> "start_cpu", 0));
>           qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", i,
> -                                    qdev_get_gpio_in_named(DEVICE(cpu),
> +                                    qdev_get_gpio_in_named(DEVICE(cpu[i]),
>                                                              "pil", 0));
>           env->irq_manager = irqmpdev;
>           env->qemu_irq_ack = leon3_irq_manager;
> @@ -396,11 +378,6 @@ static void leon3_generic_hw_init(MachineState 
> *machine)
>                * bootloader.
>                */
>               write_bootloader(memory_region_get_ram_ptr(prom), entry);
> -            reset_info->entry = LEON3_PROM_OFFSET;
> -            for (i = 0; i < machine->smp.cpus; i++) {
> -                reset_info->info[i].cpu->env.pc = LEON3_PROM_OFFSET;
> -                reset_info->info[i].cpu->env.npc = LEON3_PROM_OFFSET + 4;
> -            }
>           }
>       }
> ---
> 
> Regards,
> 
> Phil.



  reply	other threads:[~2024-02-21 17:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 16:26 [PATCH 0/3] Replace variable length arrays in ppc KVM code Thomas Huth
2024-02-21 16:26 ` [PATCH 1/3] target/ppc/kvm: Replace variable length array in kvmppc_save_htab() Thomas Huth
2024-02-21 16:29   ` Peter Maydell
2024-02-21 16:52     ` Thomas Huth
2024-02-21 16:26 ` [PATCH 2/3] target/ppc/kvm: Replace variable length array in kvmppc_read_hptes() Thomas Huth
2024-02-21 16:30   ` Peter Maydell
2024-02-21 16:26 ` [PATCH 3/3] meson: Enable -Wvla Thomas Huth
2024-02-21 16:59   ` Thomas Huth
2024-02-21 17:27     ` Philippe Mathieu-Daudé
2024-02-21 17:30       ` Philippe Mathieu-Daudé [this message]
2024-02-22  8:19       ` Clément Chigot
2024-02-21 17:48     ` Thomas Huth

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=edaea1af-b42e-438e-8f82-8c1fbe95f874@linaro.org \
    --to=philmd@linaro.org \
    --cc=berrange@redhat.com \
    --cc=chigot@adacore.com \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    /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).