qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, crosthwaite.peter@gmail.com,
	stefanha@redhat.com, rth@twiddle.net
Subject: [Qemu-devel] [PATCH] exec: Rename and fix trace events for tracing I/O port access.
Date: Tue, 29 Mar 2016 16:02:25 +0100	[thread overview]
Message-ID: <1459263745-1035-2-git-send-email-rjones@redhat.com> (raw)
In-Reply-To: <1459263745-1035-1-git-send-email-rjones@redhat.com>

cpu_in and cpu_out replaced the old DEBUG_IOPORT mechanism.  However
they weren't very useful - for most guests neither tracepoint would
ever fire (even when using TCG).

This commit moves the tracepoints down the stack into exec.c, and
renames them as ioport_in/ioport_out so it's more obvious what they
do.

Also:
 - they now work for 64 bit accesses
 - print the read/written value in hexadecimal

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
 exec.c       | 10 +++++++++-
 ioport.c     |  7 -------
 trace-events |  6 +++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/exec.c b/exec.c
index f398d21..7477eea 100644
--- a/exec.c
+++ b/exec.c
@@ -42,8 +42,8 @@
 #include <qemu.h>
 #else /* !CONFIG_USER_ONLY */
 #include "sysemu/xen-mapcache.h"
+#endif
 #include "trace.h"
-#endif
 #include "exec/cpu-all.h"
 #include "qemu/rcu_queue.h"
 #include "qemu/main-loop.h"
@@ -2592,24 +2592,28 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr,
             case 8:
                 /* 64 bit write access */
                 val = ldq_p(buf);
+                trace_ioport_out(addr, 'q', val);
                 result |= memory_region_dispatch_write(mr, addr1, val, 8,
                                                        attrs);
                 break;
             case 4:
                 /* 32 bit write access */
                 val = ldl_p(buf);
+                trace_ioport_out(addr, 'l', val & 0xffffffff);
                 result |= memory_region_dispatch_write(mr, addr1, val, 4,
                                                        attrs);
                 break;
             case 2:
                 /* 16 bit write access */
                 val = lduw_p(buf);
+                trace_ioport_out(addr, 'w', val & 0xffff);
                 result |= memory_region_dispatch_write(mr, addr1, val, 2,
                                                        attrs);
                 break;
             case 1:
                 /* 8 bit write access */
                 val = ldub_p(buf);
+                trace_ioport_out(addr, 'b', val & 0xff);
                 result |= memory_region_dispatch_write(mr, addr1, val, 1,
                                                        attrs);
                 break;
@@ -2685,24 +2689,28 @@ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,
                 /* 64 bit read access */
                 result |= memory_region_dispatch_read(mr, addr1, &val, 8,
                                                       attrs);
+                trace_ioport_in(addr, 'q', val);
                 stq_p(buf, val);
                 break;
             case 4:
                 /* 32 bit read access */
                 result |= memory_region_dispatch_read(mr, addr1, &val, 4,
                                                       attrs);
+                trace_ioport_in(addr, 'l', val & 0xffffffff);
                 stl_p(buf, val);
                 break;
             case 2:
                 /* 16 bit read access */
                 result |= memory_region_dispatch_read(mr, addr1, &val, 2,
                                                       attrs);
+                trace_ioport_in(addr, 'w', val & 0xffff);
                 stw_p(buf, val);
                 break;
             case 1:
                 /* 8 bit read access */
                 result |= memory_region_dispatch_read(mr, addr1, &val, 1,
                                                       attrs);
+                trace_ioport_in(addr, 'b', val & 0xff);
                 stb_p(buf, val);
                 break;
             default:
diff --git a/ioport.c b/ioport.c
index 7a84d54..2f8ee9d 100644
--- a/ioport.c
+++ b/ioport.c
@@ -27,7 +27,6 @@
 
 #include "qemu/osdep.h"
 #include "exec/ioport.h"
-#include "trace.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
 
@@ -55,7 +54,6 @@ const MemoryRegionOps unassigned_io_ops = {
 
 void cpu_outb(pio_addr_t addr, uint8_t val)
 {
-    trace_cpu_out(addr, 'b', val);
     address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
                         &val, 1);
 }
@@ -64,7 +62,6 @@ void cpu_outw(pio_addr_t addr, uint16_t val)
 {
     uint8_t buf[2];
 
-    trace_cpu_out(addr, 'w', val);
     stw_p(buf, val);
     address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
                         buf, 2);
@@ -74,7 +71,6 @@ void cpu_outl(pio_addr_t addr, uint32_t val)
 {
     uint8_t buf[4];
 
-    trace_cpu_out(addr, 'l', val);
     stl_p(buf, val);
     address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
                         buf, 4);
@@ -86,7 +82,6 @@ uint8_t cpu_inb(pio_addr_t addr)
 
     address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
                        &val, 1);
-    trace_cpu_in(addr, 'b', val);
     return val;
 }
 
@@ -97,7 +92,6 @@ uint16_t cpu_inw(pio_addr_t addr)
 
     address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED, buf, 2);
     val = lduw_p(buf);
-    trace_cpu_in(addr, 'w', val);
     return val;
 }
 
@@ -108,7 +102,6 @@ uint32_t cpu_inl(pio_addr_t addr)
 
     address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED, buf, 4);
     val = ldl_p(buf);
-    trace_cpu_in(addr, 'l', val);
     return val;
 }
 
diff --git a/trace-events b/trace-events
index d494de1..2759412 100644
--- a/trace-events
+++ b/trace-events
@@ -136,9 +136,9 @@ thread_pool_cancel(void *req, void *opaque) "req %p opaque %p"
 paio_submit_co(int64_t sector_num, int nb_sectors, int type) "sector_num %"PRId64" nb_sectors %d type %d"
 paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int type) "acb %p opaque %p sector_num %"PRId64" nb_sectors %d type %d"
 
-# ioport.c
-cpu_in(unsigned int addr, char size, unsigned int val) "addr %#x(%c) value %u"
-cpu_out(unsigned int addr, char size, unsigned int val) "addr %#x(%c) value %u"
+# exec.c
+ioport_in(uint64_t addr, char size, uint64_t val) "addr %#"PRIx64"(%c) value %#"PRIx64
+ioport_out(uint64_t addr, char size, uint64_t val) "addr %#"PRIx64"(%c) value %#"PRIx64
 
 # balloon.c
 # Since requests are raised via monitor, not many tracepoints are needed.
-- 
2.7.4

  reply	other threads:[~2016-03-29 15:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-29 15:02 [Qemu-devel] [PATCH] exec: Rename and fix trace events for tracing I/O port access Richard W.M. Jones
2016-03-29 15:02 ` Richard W.M. Jones [this message]
2016-03-29 15:09 ` Daniel P. Berrange
2016-03-30 13:30 ` Paolo Bonzini
2016-03-31 10:08 ` 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=1459263745-1035-2-git-send-email-rjones@redhat.com \
    --to=rjones@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --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 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).