qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
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 15:05:41 +0100	[thread overview]
Message-ID: <87tuz9wzwq.fsf@linaro.org> (raw)
In-Reply-To: <8357f8a5-83e3-47a7-57c9-b88edfa3812c@redhat.com>


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);
    }


-- 
Alex Bennée


  reply	other threads:[~2020-06-17 14:06 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 [this message]
2020-06-17 14:42         ` Philippe Mathieu-Daudé
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=87tuz9wzwq.fsf@linaro.org \
    --to=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=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).