qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Prasad J Pandit" <pjp@fedoraproject.org>,
	"Li Qiang" <liq3ea@163.com>, "Li Qiang" <liq3ea@gmail.com>,
	qemu-devel@nongnu.org, "P J P" <ppandit@redhat.com>,
	"Lei Sun" <slei.casper@gmail.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Joel Stanley" <joel@jms.id.au>,
	"Li Qiang" <pangpei.lq@antfin.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH 0/6] Add various undefined MMIO r/w functions
Date: Wed, 17 Jun 2020 16:42:52 +0200	[thread overview]
Message-ID: <4189f993-b79b-b07f-4019-b1a1c9e192a0@redhat.com> (raw)
In-Reply-To: <87tuz9wzwq.fsf@linaro.org>

On 6/17/20 4:05 PM, Alex Bennée wrote:
> 
> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 
>> On 6/17/20 3:06 PM, Alex Williamson wrote:
>>> On Wed, 17 Jun 2020 16:39:56 +1000
>>> David Gibson <david@gibson.dropbear.id.au> wrote:
>>>
>>>> On Wed, Jun 17, 2020 at 11:09:27AM +0530, P J P wrote:
>>>>> From: Prasad J Pandit <pjp@fedoraproject.org>
>>>>>
>>>>> Hello,
>>>>>
>>>>> This series adds various undefined MMIO read/write functions
>>>>> to avoid potential guest crash via a NULL pointer dereference.  
>>>>
>>>> Hrm.  If this is such a common problem, maybe we should just add a
>>>> NULL check in the common paths.
>>>
>>> +1, clearly the behavior is already expected.  Thanks,
>>
>> 20 months ago Peter suggested:
>>
>> "assert that every MemoryRegionOps has pointers to callbacks
>>  in it, when it is registered in memory_region_init_io() and
>>  memory_region_init_rom_device_nomigrate()."
>>
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg573310.html
>>
>> Li Qiang refers to this post from Paolo:
>>
>>>  static const MemoryRegionOps notdirty_mem_ops = {
>>> +    .read = notdirty_mem_read,
>>>      .write = notdirty_mem_write,
>>>      .valid.accepts = notdirty_mem_accepts,
>>>      .endianness = DEVICE_NATIVE_ENDIAN,
>>
>> "This cannot happen, since TLB_NOTDIRTY is only added
>>  to the addr_write member (see accel/tcg/cputlb.c)."
>>
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg561345.html
> 
> What about catching it in memory_region_dispatch_write:
> 
>     if (mr->ops->write) {
>         return access_with_adjusted_size(addr, &data, size,
>                                          mr->ops->impl.min_access_size,
>                                          mr->ops->impl.max_access_size,
>                                          memory_region_write_accessor, mr,
>                                          attrs);
>     } else if (mr->ops->write_with_attrs) {
>         return
>             access_with_adjusted_size(addr, &data, size,
>                                       mr->ops->impl.min_access_size,
>                                       mr->ops->impl.max_access_size,
>                                       memory_region_write_with_attrs_accessor,
>                                       mr, attrs);
>     } else {
>         qemu_log_mask(LOG_UNIMP|LOG_GUEST_ERROR, "%s: %s un-handled write\n",
>                       __func__, mr->name);

The problem is what return value to return...
MEMTX_OK/MEMTX_ERROR/MEMTX_DECODE_ERROR? This is very
device-specific and can't be decided here for all the
cases.

Better to abort() and fix each device?

>     }
> 
> 



  reply	other threads:[~2020-06-17 14:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  5:39 [PATCH 0/6] Add various undefined MMIO r/w functions P J P
2020-06-17  5:39 ` [PATCH 1/6] hw/pci-host: add pci-intack write method P J P
2020-06-17  5:39 ` [PATCH 2/6] pci-host: add pcie-msi read method P J P
2020-06-17  5:39 ` [PATCH 3/6] vfio: add quirk device write method P J P
2020-06-17  7:33   ` Philippe Mathieu-Daudé
2020-06-17  5:39 ` [PATCH 4/6] prep: add ppc-parity " P J P
2020-06-17  7:47   ` Philippe Mathieu-Daudé
2020-06-17  5:39 ` [PATCH 5/6] nvram: add nrf51_soc flash read method P J P
2020-06-17  7:42   ` Philippe Mathieu-Daudé
2020-06-17  5:39 ` [PATCH 6/6] spapr_pci: add spapr msi " P J P
2020-06-17  7:45   ` Philippe Mathieu-Daudé
2020-06-17  6:07 ` [PATCH 0/6] Add various undefined MMIO r/w functions no-reply
2020-06-17  6:39 ` David Gibson
2020-06-17 13:06   ` Alex Williamson
2020-06-17 13:20     ` Philippe Mathieu-Daudé
2020-06-17 14:05       ` Alex Bennée
2020-06-17 14:42         ` Philippe Mathieu-Daudé [this message]
2020-06-17 15:08       ` Paolo Bonzini
2020-06-17 17:57         ` P J P

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=4189f993-b79b-b07f-4019-b1a1c9e192a0@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=alex.williamson@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=hpoussin@reactos.org \
    --cc=joel@jms.id.au \
    --cc=liq3ea@163.com \
    --cc=liq3ea@gmail.com \
    --cc=pangpei.lq@antfin.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).