From: Paolo Bonzini <pbonzini@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 06/22] memory: dispatch unassigned accesses based on .valid.accepts
Date: Tue, 16 Jul 2013 14:33:02 +0200 [thread overview]
Message-ID: <51E53D7E.4060002@redhat.com> (raw)
In-Reply-To: <51E53C62.3070204@siemens.com>
Il 16/07/2013 14:28, Jan Kiszka ha scritto:
> On 2013-05-30 23:03, Paolo Bonzini wrote:
>> This provides the basics for detecting accesses to unassigned memory
>> as soon as they happen, and also for a simple implementation of
>> address_space_access_valid.
>>
>> Reviewed-by: Richard Henderson <rth@twiddle.net>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> exec.c | 36 ++++++++++++------------------------
>> memory.c | 28 ++++++++++++++++++++++++++--
>> 2 files changed, 38 insertions(+), 26 deletions(-)
>>
>> diff --git a/exec.c b/exec.c
>> index 785eeeb..c5100d6 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -1383,32 +1383,14 @@ ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
>> return ram_addr;
>> }
>>
>> -static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
>> - unsigned size)
>> +static bool unassigned_mem_accepts(void *opaque, hwaddr addr,
>> + unsigned size, bool is_write)
>> {
>> -#ifdef DEBUG_UNASSIGNED
>> - printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
>> -#endif
>> -#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
>> - cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
>> -#endif
>> - return 0;
>> -}
>> -
>> -static void unassigned_mem_write(void *opaque, hwaddr addr,
>> - uint64_t val, unsigned size)
>> -{
>> -#ifdef DEBUG_UNASSIGNED
>> - printf("Unassigned mem write " TARGET_FMT_plx " = 0x%"PRIx64"\n", addr, val);
>> -#endif
>> -#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
>> - cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);
>> -#endif
>> + return false;
>> }
>>
>> -static const MemoryRegionOps unassigned_mem_ops = {
>> - .read = unassigned_mem_read,
>> - .write = unassigned_mem_write,
>> +const MemoryRegionOps unassigned_mem_ops = {
>> + .valid.accepts = unassigned_mem_accepts,
>> .endianness = DEVICE_NATIVE_ENDIAN,
>> };
>>
>> @@ -1442,9 +1424,15 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
>> tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr);
>> }
>>
>> +static bool notdirty_mem_accepts(void *opaque, hwaddr addr,
>> + unsigned size, bool is_write)
>> +{
>> + return is_write;
>> +}
>> +
>> static const MemoryRegionOps notdirty_mem_ops = {
>> - .read = unassigned_mem_read,
>> .write = notdirty_mem_write,
>> + .valid.accepts = notdirty_mem_accepts,
>> .endianness = DEVICE_NATIVE_ENDIAN,
>> };
>>
>> diff --git a/memory.c b/memory.c
>> index 99f046d..15da877 100644
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -814,6 +814,29 @@ void memory_region_init(MemoryRegion *mr,
>> mr->flush_coalesced_mmio = false;
>> }
>>
>> +static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
>> + unsigned size)
>> +{
>> +#ifdef DEBUG_UNASSIGNED
>> + printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
>> +#endif
>> +#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
>> + cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
>> +#endif
>> + return 0;
>
> This changed the value read from unassigned memory from -1 to 0. Any
> particular reason or an unintentional change?
Cut-and-paste (unassigned RAM used to return 0, invalid MMIO used to
return -1, unifying the paths dropped the difference).
I guess unassigned RAM can read as -1 just fine, so we can just change
unassigned_mem_read to return -1.
Paolo
> Jan
>
>> +}
>> +
>> +static void unassigned_mem_write(void *opaque, hwaddr addr,
>> + uint64_t val, unsigned size)
>> +{
>> +#ifdef DEBUG_UNASSIGNED
>> + printf("Unassigned mem write " TARGET_FMT_plx " = 0x%"PRIx64"\n", addr, val);
>> +#endif
>> +#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
>> + cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);
>> +#endif
>> +}
>> +
>> static bool memory_region_access_valid(MemoryRegion *mr,
>> hwaddr addr,
>> unsigned size,
>> @@ -847,7 +870,7 @@ static uint64_t memory_region_dispatch_read1(MemoryRegion *mr,
>> uint64_t data = 0;
>>
>> if (!memory_region_access_valid(mr, addr, size, false)) {
>> - return -1U; /* FIXME: better signalling */
>> + return unassigned_mem_read(mr, addr, size);
>> }
>>
>> if (!mr->ops->read) {
>> @@ -898,7 +921,8 @@ static void memory_region_dispatch_write(MemoryRegion *mr,
>> unsigned size)
>> {
>> if (!memory_region_access_valid(mr, addr, size, true)) {
>> - return; /* FIXME: better signalling */
>> + unassigned_mem_write(mr, addr, data, size);
>> + return;
>> }
>>
>> adjust_endianness(mr, &data, size);
>>
next prev parent reply other threads:[~2013-07-16 12:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 21:03 [Qemu-devel] [PULL 00/22] Memory/IOMMU patches, part 2: unassigned access detection Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 01/22] exec: eliminate io_mem_ram Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 02/22] exec: drop useless #if Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 03/22] cputlb: simplify tlb_set_page Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 04/22] exec: make io_mem_unassigned private Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 05/22] exec: do not use error_mem_read Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 06/22] memory: dispatch unassigned accesses based on .valid.accepts Paolo Bonzini
2013-06-01 15:28 ` Blue Swirl
2013-06-03 7:31 ` Paolo Bonzini
2013-06-03 10:14 ` Andreas Färber
2013-07-16 12:28 ` Jan Kiszka
2013-07-16 12:33 ` Paolo Bonzini [this message]
2013-07-16 12:38 ` Peter Maydell
2013-07-16 12:44 ` Jan Kiszka
2013-05-30 21:03 ` [Qemu-devel] [PATCH 07/22] memory: add address_space_translate Paolo Bonzini
2013-06-20 13:53 ` Peter Maydell
2013-06-20 14:19 ` Paolo Bonzini
2013-06-20 14:43 ` Peter Maydell
2013-06-20 14:53 ` Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 08/22] memory: move unassigned_mem_ops to memory.c Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 09/22] memory: assign MemoryRegionOps to all regions Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 10/22] exec: expect mr->ops to be initialized for ROM Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 11/22] exec: introduce memory_access_is_direct Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 12/22] exec: introduce memory_access_size Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 13/22] memory: export memory_region_access_valid to exec.c Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 14/22] exec: implement .valid.accepts for subpages Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 15/22] memory: add address_space_access_valid Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 16/22] memory: accept mismatching sizes in memory_region_access_valid Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 17/22] memory: add big endian support to access_with_adjusted_size Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 18/22] memory: split accesses even when the old MMIO callbacks are used Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 19/22] memory: correctly handle endian-swapped 64-bit accesses Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 20/22] exec: just use io_mem_read/io_mem_write for 8-byte I/O accesses Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 21/22] memory: propagate errors on I/O dispatch Paolo Bonzini
2013-05-30 21:03 ` [Qemu-devel] [PATCH 22/22] memory: add return value to address_space_rw/read/write Paolo Bonzini
2013-06-17 21:18 ` [Qemu-devel] [PULL 00/22] Memory/IOMMU patches, part 2: unassigned access detection Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2013-05-24 17:05 [Qemu-devel] [PATCH " Paolo Bonzini
2013-05-24 17:05 ` [Qemu-devel] [PATCH 06/22] memory: dispatch unassigned accesses based on .valid.accepts Paolo Bonzini
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=51E53D7E.4060002@redhat.com \
--to=pbonzini@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.