From patchwork Tue Mar 29 15:02:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard W.M. Jones" X-Patchwork-Id: 602966 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qZDY64pxdz9sC3 for ; Wed, 30 Mar 2016 02:03:06 +1100 (AEDT) Received: from localhost ([::1]:47602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akvAe-0002nh-P5 for incoming@patchwork.ozlabs.org; Tue, 29 Mar 2016 11:03:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akvAC-0002ED-41 for qemu-devel@nongnu.org; Tue, 29 Mar 2016 11:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akvA8-00046R-Gh for qemu-devel@nongnu.org; Tue, 29 Mar 2016 11:02:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akvA8-00045s-92 for qemu-devel@nongnu.org; Tue, 29 Mar 2016 11:02:32 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BFE0746214; Tue, 29 Mar 2016 15:02:31 +0000 (UTC) Received: from moo.home.annexia.org (ovpn-204-90.brq.redhat.com [10.40.204.90]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2TF2RnS023900; Tue, 29 Mar 2016 11:02:30 -0400 From: "Richard W.M. Jones" To: qemu-devel@nongnu.org Date: Tue, 29 Mar 2016 16:02:25 +0100 Message-Id: <1459263745-1035-2-git-send-email-rjones@redhat.com> In-Reply-To: <1459263745-1035-1-git-send-email-rjones@redhat.com> References: <1459263745-1035-1-git-send-email-rjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 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. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 #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.