From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH-for-5.2] memory: Add trace events to audit MemoryRegionOps fields
Date: Tue, 18 Aug 2020 08:32:54 +0200 [thread overview]
Message-ID: <d87db8e9-40b1-334d-22b0-90674ddf8177@redhat.com> (raw)
In-Reply-To: <20200806152613.18523-1-philmd@redhat.com>
On 06/08/20 17:26, Philippe Mathieu-Daudé wrote:
> Add trace events to audit MemoryRegionOps field such:
> - are all the valid/impl fields provided?
> - is the region a power of two?
>
> These cases are accepted, but it is interesting to list them.
>
> Example:
>
> $ qemu-system-i386 -S -trace memory_region_io_check\*
> memory_region_io_check_odd_size mr name:'dma-page' size:0x3
> memory_region_io_check_access_size_incomplete mr name:'acpi-tmr' min/max:[valid:1/4 impl:4/0]
> memory_region_io_check_access_size_incomplete mr name:'acpi-evt' min/max:[valid:1/2 impl:2/0]
> memory_region_io_check_access_size_incomplete mr name:'acpi-cnt' min/max:[valid:1/2 impl:2/0]
Can they be detected using Coccinelle instead?
Paolo
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Based-on: <20200805130221.24487-1-philmd@redhat.com>
> "softmmu: Add missing trace-events file"
> ---
> softmmu/memory.c | 11 +++++++++++
> softmmu/trace-events | 2 ++
> 2 files changed, 13 insertions(+)
>
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index d030eb6f7c..daa0daf2a8 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -1488,6 +1488,17 @@ void memory_region_init_io(MemoryRegion *mr,
> mr->ops = ops ? ops : &unassigned_mem_ops;
> mr->opaque = opaque;
> mr->terminates = true;
> + if (size != UINT64_MAX && !is_power_of_2(size)) {
> + trace_memory_region_io_check_odd_size(name, size);
> + }
> + if (ops && (!ops->impl.min_access_size || !ops->impl.max_access_size ||
> + !ops->valid.min_access_size || !ops->valid.max_access_size)) {
> + trace_memory_region_io_check_access_size_incomplete(name,
> + mr->ops->valid.min_access_size,
> + mr->ops->valid.max_access_size,
> + mr->ops->impl.min_access_size,
> + mr->ops->impl.max_access_size);
> + }
> }
>
> void memory_region_init_ram_nomigrate(MemoryRegion *mr,
> diff --git a/softmmu/trace-events b/softmmu/trace-events
> index b80ca042e1..00eb316aef 100644
> --- a/softmmu/trace-events
> +++ b/softmmu/trace-events
> @@ -18,6 +18,8 @@ memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uint64_t
> flatview_new(void *view, void *root) "%p (root %p)"
> flatview_destroy(void *view, void *root) "%p (root %p)"
> flatview_destroy_rcu(void *view, void *root) "%p (root %p)"
> +memory_region_io_check_odd_size(const char *name, uint64_t size) "mr name:'%s' size:0x%"PRIx64
> +memory_region_io_check_access_size_incomplete(const char *name, unsigned vmin, unsigned vmax, unsigned imin, unsigned imax) "mr name:'%s' min/max:[valid:%u/%u impl:%u/%u]"
>
> # vl.c
> vm_state_notify(int running, int reason, const char *reason_str) "running %d reason %d (%s)"
>
next prev parent reply other threads:[~2020-08-18 6:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-06 15:26 [PATCH-for-5.2] memory: Add trace events to audit MemoryRegionOps fields Philippe Mathieu-Daudé
2020-08-18 6:32 ` Paolo Bonzini [this message]
2020-08-18 7:56 ` Philippe Mathieu-Daudé
2020-08-19 9:14 ` Stefan Hajnoczi
2020-08-19 10:10 ` Philippe Mathieu-Daudé
2020-08-19 14:07 ` Stefan Hajnoczi
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=d87db8e9-40b1-334d-22b0-90674ddf8177@redhat.com \
--to=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).