All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Alistair Francis <alistair.francis@wdc.com>
Cc: alistair23@gmail.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v1 1/1] core/register: Specify instance_size in the TypeInfo
Date: Mon, 24 Aug 2020 16:35:40 -0400	[thread overview]
Message-ID: <20200824203540.GR642093@habkost.net> (raw)
In-Reply-To: <87a2da602785bce972a6a6b4502769f4fee58a2d.1598074333.git.alistair.francis@wdc.com>

On Fri, Aug 21, 2020 at 10:33:06PM -0700, Alistair Francis wrote:
> Reported-by: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
>  hw/core/register.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/core/register.c b/hw/core/register.c
> index ddf91eb445..5e8e8199d0 100644
> --- a/hw/core/register.c
> +++ b/hw/core/register.c
> @@ -180,11 +180,7 @@ void register_init(RegisterInfo *reg)
>  {
>      assert(reg);
>  
> -    if (!reg->data || !reg->access) {
> -        return;
> -    }
>  
> -    object_initialize((void *)reg, sizeof(*reg), TYPE_REGISTER);
>  }
>  
>  void register_write_memory(void *opaque, hwaddr addr,
> @@ -269,13 +265,20 @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
>          int index = rae[i].addr / data_size;
>          RegisterInfo *r = &ri[index];
>  
> +        if (data + data_size * index == 0 || !&rae[i]) {
> +            continue;
> +        }
> +
> +        /* Init the register, this will zero it. */
> +        object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
> +
> +        /* Set the properties of the register */
>          *r = (RegisterInfo) {
>              .data = data + data_size * index,
>              .data_size = data_size,
>              .access = &rae[i],
>              .opaque = owner,
>          };

This doesn't look right.  Won't this wipe out all DeviceState
data in r->parent_obj?

> -        register_init(r);
>  
>          r_array->r[i] = r;
>      }
> @@ -329,6 +332,7 @@ static const TypeInfo register_info = {
>      .name  = TYPE_REGISTER,
>      .parent = TYPE_DEVICE,
>      .class_init = register_class_init,
> +    .instance_size = sizeof(RegisterInfo),
>  };
>  
>  static void register_register_types(void)
> -- 
> 2.28.0
> 
> 

-- 
Eduardo



  parent reply	other threads:[~2020-08-24 22:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-22  5:33 [PATCH v1 1/1] core/register: Specify instance_size in the TypeInfo Alistair Francis
2020-08-22 10:25 ` Philippe Mathieu-Daudé
2020-08-25 17:29   ` Alistair Francis
2020-08-24 20:35 ` Eduardo Habkost [this message]
2020-08-25 17:29   ` Alistair Francis

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=20200824203540.GR642093@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=qemu-devel@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.