From: Peter Maydell <peter.maydell@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
"patches@linaro.org" <patches@linaro.org>
Subject: Re: [Qemu-devel] [PATCH] exec.c: Replace memory_region_is_unassigned() with memory_region_is_ram_backed()
Date: Mon, 9 Jul 2018 18:33:35 +0100 [thread overview]
Message-ID: <CAFEAcA9g3NCcodB8H3m5MsCL=JD56HO6D-utLyUKvY_Nwv-0Jg@mail.gmail.com> (raw)
In-Reply-To: <c2311584-618a-b880-d42a-637a9333702a@linaro.org>
On 9 July 2018 at 18:23, Richard Henderson <richard.henderson@linaro.org> wrote:
> On 07/09/2018 08:58 AM, Peter Maydell wrote:
>> The function memory_region_is_unassigned() is rather misnamed, because
>> what it is actually testing is whether the memory region is backed
>> by host RAM, and so whether get_page_addr_code() can find a ram_addr_t
>> corresponding to the guest address.
>>
>> Replace it with memory_region_is_ram_backed(), which has a name
>> better matching its actual semantics. (We invert the sense of the
>> return value to avoid having a _not_ in the function name.)
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> The difference between this and memory_region_is_ram() is pretty
>> subtle, to the extent I'm not completely sure exactly what it is;
>> io_mem_notdirty and io_mem_watch at least won't be considered as
>> "ram" by memory_region_is_ram(), though.
>
> Yeah, I'm not quite sure why io_mem_rom and io_mem_notdirty at least do not
> have the rom_device bit set.
>
> I suppose io_mem_watch is even more special in that it also wants to trap read
> operations. And do we really want to trap execute operations in that? Surely
> that's what actual breakpoints are for. Of course, that would probably mean
> special casing the special case.
>
>> -bool memory_region_is_unassigned(MemoryRegion *mr)
>> +bool memory_region_is_ram_backed(MemoryRegion *mr)
>
> Well... ok. We should document that this, surprisingly, does not include
> actual ram. Just things that are ram with caveats.
I think it must include actual RAM, or we would not be able to
execute from actual RAM ? The only way to get to get_page_addr_code()'s
"here's the ram_addr_t for this" exit path is if memory_region_is_unassigned()
returns false.
>> - return mr != &io_mem_rom && mr != &io_mem_notdirty && !mr->rom_device
>> - && mr != &io_mem_watch;
>> + return !(mr != &io_mem_rom && mr != &io_mem_notdirty && !mr->rom_device
>> + && mr != &io_mem_watch);
>
> This is annoyingly convoluted. I would prefer to push
> the not through the expression:
>
> return (mr->rom_device || mr == &io_mem_rom
> || mr == &io_mem_notdirty || mr == &io_mem_watch);
Yeah, I was optimizing for "easy to review as not changing behaviour
except for flipping the sense of the return value", rather than
"resulting code is most simple".
thanks
-- PMM
next prev parent reply other threads:[~2018-07-09 17:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 15:58 [Qemu-devel] [PATCH] exec.c: Replace memory_region_is_unassigned() with memory_region_is_ram_backed() Peter Maydell
2018-07-09 17:23 ` Richard Henderson
2018-07-09 17:33 ` Peter Maydell [this message]
2018-07-09 17:50 ` Richard Henderson
2018-07-10 10:56 ` Peter Maydell
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='CAFEAcA9g3NCcodB8H3m5MsCL=JD56HO6D-utLyUKvY_Nwv-0Jg@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rth@twiddle.net \
/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).