qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] memory: check write/read_with_attrs in memory d


From: Li Qiang
Subject: Re: [Qemu-devel] [PATCH] memory: check write/read_with_attrs in memory dispatch
Date: Tue, 13 Nov 2018 18:10:20 +0800

Peter Maydell <address@hidden> 于2018年11月13日周二 下午5:49写道:

> On 13 November 2018 at 01:42, Li Qiang <address@hidden> wrote:
> > This can avoid the NULL-deref if the rm doesn't has a
> > read/write nor write/read_with_attrs callback.
> >
> > Signed-off-by: Li Qiang <address@hidden>
> > ---
> >  memory.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
>
> Alternative approach -- assert that every MemoryRegionOps has
> pointers to callbacks in it, when it is registered in
> memory_region_init_io()
>

Actually I have considered this approach, but I rember Paolo remind me that
some
of this MR without read callback's is valid because the read can never be
called, such as
'notdirty_mem_ops'. So I choose add a check here.



> and memory_region_init_rom_device_nomigrate().
>
> I don't have a strong opinion on which is better, but I guess
> I slightly favour requiring devices to be specific about what
> their read/write behaviour is.
>
> Do we have many devices that legitimately only want to implement
> one of read and write, not both ?


AFAICS, the device has just one read or write is not uncommon.
But nearly all of them implement a nop function does nothing.
So there just very little lack of the read or write function.

Thanks,
Li Qiang


>
> thanks
> -- PMM
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]