All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "open list:RISC-V" <qemu-riscv@nongnu.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Bin Meng <bmeng.cn@gmail.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [PATCH v1 1/1] riscv: Pass RISCVHartArrayState by pointer
Date: Sat, 16 Jan 2021 14:38:32 -0800	[thread overview]
Message-ID: <CAKmqyKNvtuY2eaQHiM4YMKyy_bWAiHFrMan_R+7M_fw7=ioW=A@mail.gmail.com> (raw)
In-Reply-To: <a566580a-ef30-0d2f-116e-1e3666f1187d@amsat.org>

On Sat, Jan 16, 2021 at 2:32 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 1/16/21 12:00 AM, Alistair Francis wrote:
> > We were accidently passing RISCVHartArrayState by value instead of
> > pointer. The type is 824 bytes long so let's correct that and pass it by
> > pointer instead.
> >
> > Fixes: Coverity CID 1438099
> > Fixes: Coverity CID 1438100
> > Fixes: Coverity CID 1438101
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >  include/hw/riscv/boot.h |  6 +++---
> >  hw/riscv/boot.c         |  8 ++++----
> >  hw/riscv/sifive_u.c     | 10 +++++-----
> >  hw/riscv/spike.c        |  8 ++++----
> >  hw/riscv/virt.c         |  8 ++++----
> >  5 files changed, 20 insertions(+), 20 deletions(-)
> >
> > diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
> > index 20ff5fe5e5..11a21dd584 100644
> > --- a/include/hw/riscv/boot.h
> > +++ b/include/hw/riscv/boot.h
> > @@ -24,9 +24,9 @@
> >  #include "hw/loader.h"
> >  #include "hw/riscv/riscv_hart.h"
> >
> > -bool riscv_is_32bit(RISCVHartArrayState harts);
> > +bool riscv_is_32bit(RISCVHartArrayState *harts);
> >
> > -target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState harts,
> > +target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
> >                                            target_ulong firmware_end_addr);
> >  target_ulong riscv_find_and_load_firmware(MachineState *machine,
> >                                            const char *default_machine_firmware,
> > @@ -42,7 +42,7 @@ target_ulong riscv_load_kernel(const char *kernel_filename,
> >  hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
> >                           uint64_t kernel_entry, hwaddr *start);
> >  uint32_t riscv_load_fdt(hwaddr dram_start, uint64_t dram_size, void *fdt);
> > -void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState harts,
> > +void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts,
> >                                 hwaddr saddr,
> >                                 hwaddr rom_base, hwaddr rom_size,
> >                                 uint64_t kernel_entry,
> > diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
> > index 83586aef41..acf77675b2 100644
> > --- a/hw/riscv/boot.c
> > +++ b/hw/riscv/boot.c
> > @@ -33,14 +33,14 @@
> >
> >  #include <libfdt.h>
> >
> > -bool riscv_is_32bit(RISCVHartArrayState harts)
> > +bool riscv_is_32bit(RISCVHartArrayState *harts)
> >  {
> > -    RISCVCPU hart = harts.harts[0];
> > +    RISCVCPU hart = harts->harts[0];
>
> This doesn't look improved. Maybe you want:
>
>        return riscv_cpu_is_32bit(&harts->harts[0].env);

I suspect this ends up generating the same code.

Either way, good point I have just squashed this change into the patch.

Alistair

>
> >
> >      return riscv_cpu_is_32bit(&hart.env);
> >  }


WARNING: multiple messages have this Message-ID (diff)
From: Alistair Francis <alistair23@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alistair Francis <alistair.francis@wdc.com>,
	 "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"open list:RISC-V" <qemu-riscv@nongnu.org>,
	 Bin Meng <bmeng.cn@gmail.com>,
	Palmer Dabbelt <palmer@dabbelt.com>
Subject: Re: [PATCH v1 1/1] riscv: Pass RISCVHartArrayState by pointer
Date: Sat, 16 Jan 2021 14:38:32 -0800	[thread overview]
Message-ID: <CAKmqyKNvtuY2eaQHiM4YMKyy_bWAiHFrMan_R+7M_fw7=ioW=A@mail.gmail.com> (raw)
In-Reply-To: <a566580a-ef30-0d2f-116e-1e3666f1187d@amsat.org>

On Sat, Jan 16, 2021 at 2:32 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 1/16/21 12:00 AM, Alistair Francis wrote:
> > We were accidently passing RISCVHartArrayState by value instead of
> > pointer. The type is 824 bytes long so let's correct that and pass it by
> > pointer instead.
> >
> > Fixes: Coverity CID 1438099
> > Fixes: Coverity CID 1438100
> > Fixes: Coverity CID 1438101
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >  include/hw/riscv/boot.h |  6 +++---
> >  hw/riscv/boot.c         |  8 ++++----
> >  hw/riscv/sifive_u.c     | 10 +++++-----
> >  hw/riscv/spike.c        |  8 ++++----
> >  hw/riscv/virt.c         |  8 ++++----
> >  5 files changed, 20 insertions(+), 20 deletions(-)
> >
> > diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
> > index 20ff5fe5e5..11a21dd584 100644
> > --- a/include/hw/riscv/boot.h
> > +++ b/include/hw/riscv/boot.h
> > @@ -24,9 +24,9 @@
> >  #include "hw/loader.h"
> >  #include "hw/riscv/riscv_hart.h"
> >
> > -bool riscv_is_32bit(RISCVHartArrayState harts);
> > +bool riscv_is_32bit(RISCVHartArrayState *harts);
> >
> > -target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState harts,
> > +target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
> >                                            target_ulong firmware_end_addr);
> >  target_ulong riscv_find_and_load_firmware(MachineState *machine,
> >                                            const char *default_machine_firmware,
> > @@ -42,7 +42,7 @@ target_ulong riscv_load_kernel(const char *kernel_filename,
> >  hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
> >                           uint64_t kernel_entry, hwaddr *start);
> >  uint32_t riscv_load_fdt(hwaddr dram_start, uint64_t dram_size, void *fdt);
> > -void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState harts,
> > +void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts,
> >                                 hwaddr saddr,
> >                                 hwaddr rom_base, hwaddr rom_size,
> >                                 uint64_t kernel_entry,
> > diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
> > index 83586aef41..acf77675b2 100644
> > --- a/hw/riscv/boot.c
> > +++ b/hw/riscv/boot.c
> > @@ -33,14 +33,14 @@
> >
> >  #include <libfdt.h>
> >
> > -bool riscv_is_32bit(RISCVHartArrayState harts)
> > +bool riscv_is_32bit(RISCVHartArrayState *harts)
> >  {
> > -    RISCVCPU hart = harts.harts[0];
> > +    RISCVCPU hart = harts->harts[0];
>
> This doesn't look improved. Maybe you want:
>
>        return riscv_cpu_is_32bit(&harts->harts[0].env);

I suspect this ends up generating the same code.

Either way, good point I have just squashed this change into the patch.

Alistair

>
> >
> >      return riscv_cpu_is_32bit(&hart.env);
> >  }


  reply	other threads:[~2021-01-16 22:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 23:00 [PATCH v1 1/1] riscv: Pass RISCVHartArrayState by pointer Alistair Francis
2021-01-15 23:00 ` Alistair Francis
2021-01-15 23:03 ` Palmer Dabbelt
2021-01-15 23:03   ` Palmer Dabbelt
2021-01-16 16:30 ` Bin Meng
2021-01-16 16:30   ` Bin Meng
2021-01-16 17:50   ` Alistair Francis
2021-01-16 17:50     ` Alistair Francis
2021-01-16 18:55 ` Alistair Francis
2021-01-16 18:55   ` Alistair Francis
2021-01-16 22:32 ` Philippe Mathieu-Daudé
2021-01-16 22:32   ` Philippe Mathieu-Daudé
2021-01-16 22:38   ` Alistair Francis [this message]
2021-01-16 22:38     ` Alistair Francis
2021-01-17 16:52     ` Philippe Mathieu-Daudé
2021-01-17 16:52       ` Philippe Mathieu-Daudé
2021-01-19 21:50       ` Eric Blake
2021-01-19 21:50         ` Eric Blake
2021-01-18 17:14 ` Richard Henderson
2021-01-18 17:14   ` Richard Henderson

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='CAKmqyKNvtuY2eaQHiM4YMKyy_bWAiHFrMan_R+7M_fw7=ioW=A@mail.gmail.com' \
    --to=alistair23@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=bmeng.cn@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.