qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, "P J P" <ppandit@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Prasad J Pandit" <pjp@fedoraproject.org>,
	"Li Qiang" <liq3ea@gmail.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Lei Sun" <slei.casper@gmail.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v1] memory: assert MemoryRegionOps callbacks are defined
Date: Thu, 18 Jun 2020 15:35:14 +0200	[thread overview]
Message-ID: <51f137f0-89ee-e130-a43e-c82d0b3623fa@redhat.com> (raw)
In-Reply-To: <87r1ucv7pe.fsf@linaro.org>

On 18/06/20 15:12, Alex Bennée wrote:
>>
>> @@ -1495,6 +1495,9 @@ void memory_region_init_io(MemoryRegion *mr,
>>                             const char *name,
>>                             uint64_t size)
>>  {
>> +    assert(ops);
>> +    assert(ops->read);
>> +    assert(ops->write);
> 
> If you look at memory_region_dispatch_write you can see that
> mr->ops->write being empty is acceptable because it implies
> mr->ops->write_with_attrs is set instead. I think the same is true for
> read so I think you need something more like:
> 
>      assert(ops->read || ops->read_with_attrs);
>      assert(ops->write || ops->write_with_attrs);

Also, !ops is acceptable since you have a couple lines below:

    mr->ops = ops ? ops : &unassigned_mem_ops;


>> +    assert(ops->read);
>> +    assert(ops->write);
> 
> Do ROM devices need a ->write function?

Yes, ROMD regions are treated as I/O regions for writes.  However they
don't need a read function.

> Also doesn't this break a load of running stuff without fixes for all
> the various missing bits? How far does make check-acceptance get?

This might actually be really close with the above assertions fixed.
For example, commit 08565552f7 ("cputlb: Move NOTDIRTY handling from I/O
path to TLB path", 2019-09-25) got rid of io_mem_notdirty.

The only cases I found with "git grep" are:

- tz_ppc_dummy_ops which is broken and should just use NULL ops

- hw/nvram/nrf51_nvm.c's flash_ops which is fixed if ROMD regions are
changed not to require a read callback.

- designware_pci_host_msi_ops which is broken and should have a dummy
read callback.

Needless to say, this is something that the submitter should have done,
not the reviewer.

Paolo



  reply	other threads:[~2020-06-18 13:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 12:12 [PATCH v1] memory: assert MemoryRegionOps callbacks are defined P J P
2020-06-18 12:36 ` no-reply
2020-06-18 13:12 ` Alex Bennée
2020-06-18 13:35   ` Paolo Bonzini [this message]
2020-06-18 14:29     ` Peter Maydell
2020-06-18 14:53       ` Paolo Bonzini
2020-06-19 10:48     ` P J P
2020-06-19 11:00       ` Paolo Bonzini
2020-06-18 14:52   ` Philippe Mathieu-Daudé
2020-06-18 13:19 ` no-reply

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=51f137f0-89ee-e130-a43e-c82d0b3623fa@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=alex.williamson@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=liq3ea@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=slei.casper@gmail.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).