[Qemu-devel] [PULL 05/42] trace: split out trace events for crypto/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the crypto/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-4-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |  1 +
 crypto/trace-events | 19 +++
 trace-events| 18 --
 3 files changed, 20 insertions(+), 18 deletions(-)
 create mode 100644 crypto/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index cd675fd..c6e915e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -120,3 +120,4 @@ ivshmem-server-obj-y = contrib/ivshmem-server/
 ##
 trace-events-y = trace-events
 trace-events-y += util/trace-events
+trace-events-y += crypto/trace-events
diff --git a/crypto/trace-events b/crypto/trace-events
new file mode 100644
index 000..71f1d99
--- /dev/null
+++ b/crypto/trace-events
@@ -0,0 +1,19 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# crypto/tlscreds.c
+qcrypto_tls_creds_load_dh(void *creds, const char *filename) "TLS creds load 
DH creds=%p filename=%s"
+qcrypto_tls_creds_get_path(void *creds, const char *filename, const char 
*path) "TLS creds path creds=%p filename=%s path=%s"
+
+# crypto/tlscredsanon.c
+qcrypto_tls_creds_anon_load(void *creds, const char *dir) "TLS creds anon load 
creds=%p dir=%s"
+
+# crypto/tlscredsx509.c
+qcrypto_tls_creds_x509_load(void *creds, const char *dir) "TLS creds x509 load 
creds=%p dir=%s"
+qcrypto_tls_creds_x509_check_basic_constraints(void *creds, const char *file, 
int status) "TLS creds x509 check basic constraints creds=%p file=%s status=%d"
+qcrypto_tls_creds_x509_check_key_usage(void *creds, const char *file, int 
status, int usage, int critical) "TLS creds x509 check key usage creds=%p 
file=%s status=%d usage=%d critical=%d"
+qcrypto_tls_creds_x509_check_key_purpose(void *creds, const char *file, int 
status, const char *usage, int critical) "TLS creds x509 check key usage 
creds=%p file=%s status=%d usage=%s critical=%d"
+qcrypto_tls_creds_x509_load_cert(void *creds, int isServer, const char *file) 
"TLS creds x509 load cert creds=%p isServer=%d file=%s"
+qcrypto_tls_creds_x509_load_cert_list(void *creds, const char *file) "TLS 
creds x509 load cert list creds=%p file=%s"
+
+# crypto/tlssession.c
+qcrypto_tls_session_new(void *session, void *creds, const char *hostname, 
const char *aclname, int endpoint) "TLS session new session=%p creds=%p 
hostname=%s aclname=%s endpoint=%d"
diff --git a/trace-events b/trace-events
index f9eb38d..d6b3491 100644
--- a/trace-events
+++ b/trace-events
@@ -1828,24 +1828,6 @@ alsa_no_frames(int state) "No frames available and ALSA 
state is %d"
 oss_version(int version) "OSS version = %#x"
 oss_invalid_available_size(int size, int bufsize) "Invalid available size, 
size=%d bufsize=%d"
 
-# crypto/tlscreds.c
-qcrypto_tls_creds_load_dh(void *creds, const char *filename) "TLS creds load 
DH creds=%p filename=%s"
-qcrypto_tls_creds_get_path(void *creds, const char *filename, const char 
*path) "TLS creds path creds=%p filename=%s path=%s"
-
-# crypto/tlscredsanon.c
-qcrypto_tls_creds_anon_load(void *creds, const char *dir) "TLS creds anon load 
creds=%p dir=%s"
-
-# crypto/tlscredsx509.c
-qcrypto_tls_creds_x509_load(void *creds, const char *dir) "TLS creds x509 load 
creds=%p dir=%s"
-qcrypto_tls_creds_x509_check_basic_constraints(void *creds, const char *file, 
int status) "TLS creds x509 check basic constraints creds=%p file=%s status=%d"
-qcrypto_tls_creds_x509_check_key_usage(void *creds, const char *file, int 
status, int usage, int critical) "TLS creds x509 check key usage creds=%p 
file=%s status=%d usage=%d critical=%d"
-qcrypto_tls_creds_x509_check_key_purpose(void *creds, const char *file, int 
status, const char *usage, int critical) "TLS creds x509 check key usage 
creds=%p file=%s status=%d usage=%s critical=%d"
-qcrypto_tls_creds_x509_load_cert(void *creds, int isServer, const char *file) 
"TLS creds x509 load cert creds=%p isServer=%d file=%s"
-qcrypto_tls_creds_x509_load_cert_list(void *creds, const char *file) "TLS 
creds x509 load cert list creds=%p file=%s"
-
-# crypto/tlssession.c
-qcrypto_tls_session_new(void *session, void *creds, const char *hostname, 
const char *aclname, int endpoint) "TLS session new session=%p creds=%p 
hostname=%s aclname=%s endpoint=%d"
-
 # net/vhost-user.c
 vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
 
-- 
2.5.5




[Qemu-devel] [PULL 00/42] Tracing patches

2016-06-20 Thread Stefan Hajnoczi
The following changes since commit 5edbd4e30426d3a0d712510b2509a521e35192b1:

  Merge remote-tracking branch 'remotes/otubo/tags/pull-seccomp-20160620' into 
staging (2016-06-20 12:53:35 +0100)

are available in the git repository at:

  git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to f52347d5b023dd2ab5518a4faaf2e0cee55c1915:

  trace: split out trace events for linux-user/ directory (2016-06-20 17:22:17 
+0100)





Daniel P. Berrange (40):
  trace: add build framework for merging trace-events files
  trace: split out trace events for util/ directory
  trace: split out trace events for crypto/ directory
  trace: split out trace events for io/ directory
  trace: split out trace events for migration/ directory
  trace: split out trace events for block/ directory
  trace: split out trace events for hw/block/ directory
  trace: split out trace events for hw/char/ directory
  trace: split out trace events for hw/intc/ directory
  trace: split out trace events for hw/net/ directory
  trace: split out trace events for hw/virtio/ directory
  trace: split out trace events for hw/audio/ directory
  trace: split out trace events for hw/misc/ directory
  trace: split out trace events for hw/usb/ directory
  trace: split out trace events for hw/scsi/ directory
  trace: split out trace events for hw/nvram/ directory
  trace: split out trace events for hw/display/ directory
  trace: split out trace events for hw/input/ directory
  trace: split out trace events for hw/timer/ directory
  trace: split out trace events for hw/dma/ directory
  trace: split out trace events for hw/sparc/ directory
  trace: split out trace events for hw/sd/ directory
  trace: split out trace events for hw/isa/ directory
  trace: split out trace events for hw/i386/ directory
  trace: split out trace events for hw/9pfs/ directory
  trace: split out trace events for hw/ppc/ directory
  trace: split out trace events for hw/pci/ directory
  trace: split out trace events for hw/s390x/ directory
  trace: split out trace events for hw/vfio/ directory
  trace: split out trace events for hw/acpi/ directory
  trace: split out trace events for hw/arm/ directory
  trace: split out trace events for hw/alpha/ directory
  trace: split out trace events for ui/ directory
  trace: split out trace events for audio/ directory
  trace: split out trace events for net/ directory
  trace: split out trace events for target-sparc/ directory
  trace: split out trace events for target-s390x/ directory
  trace: split out trace events for target-ppc/ directory
  trace: split out trace events for qom/ directory
  trace: split out trace events for linux-user/ directory

Lluís Vilanova (2):
  exec: [tcg] Track which vCPU is performing translation and execution
  trace: [all] Add "guest_mem_before" event

 .gitignore|1 +
 Makefile  |2 +-
 Makefile.objs |   43 +
 Makefile.target   |6 +-
 audio/trace-events|   17 +
 block/trace-events|  116 ++
 crypto/trace-events   |   19 +
 docs/tracing.txt  |   32 +-
 hw/9pfs/trace-events  |   47 +
 hw/acpi/trace-events  |   18 +
 hw/alpha/trace-events |4 +
 hw/arm/trace-events   |4 +
 hw/audio/trace-events |   19 +
 hw/block/trace-events |   17 +
 hw/char/trace-events  |   49 +
 hw/display/trace-events   |  122 ++
 hw/dma/trace-events   |   32 +
 hw/i386/trace-events  |   12 +
 hw/input/trace-events |   25 +
 hw/intc/trace-events  |  123 ++
 hw/isa/trace-events   |9 +
 hw/misc/trace-events  |   52 +
 hw/net/trace-events   |  272 
 hw/nvram/trace-events |   10 +
 hw/pci/trace-events   |9 +
 hw/ppc/trace-events   |   39 +
 hw/s390x/trace-events |   15 +
 hw/scsi/trace-events  |  204 +++
 hw/sd/trace-events|5 +
 hw/sparc/trace-events |   11 +
 hw/timer/trace-events |   51 +
 hw/usb/trace-events   |  268 
 hw/vfio/trace-events  |  116 ++
 hw/virtio/trace-events|   16 +
 include/exec/cpu_ldst_template.h  |   25 +
 include/exec/cpu_ldst_useronly_template.h |   22 +
 io/trace-events   |   63 +
 linux-user/trace-events   |   12 +
 migration/trace-events  

[Qemu-devel] [PULL 07/42] trace: split out trace events for migration/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the migration/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-6-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs  |   1 +
 migration/trace-events | 209 +
 trace-events   | 208 
 3 files changed, 210 insertions(+), 208 deletions(-)
 create mode 100644 migration/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 7577dca..76d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -122,3 +122,4 @@ trace-events-y = trace-events
 trace-events-y += util/trace-events
 trace-events-y += crypto/trace-events
 trace-events-y += io/trace-events
+trace-events-y += migration/trace-events
diff --git a/migration/trace-events b/migration/trace-events
new file mode 100644
index 000..8568dab
--- /dev/null
+++ b/migration/trace-events
@@ -0,0 +1,209 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# migration/savevm.c
+qemu_loadvm_state_section(unsigned int section_type) "%d"
+qemu_loadvm_state_section_command(int ret) "%d"
+qemu_loadvm_state_section_partend(uint32_t section_id) "%u"
+qemu_loadvm_state_main(void) ""
+qemu_loadvm_state_main_quit_parent(void) ""
+qemu_loadvm_state_post_main(int ret) "%d"
+qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, 
uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u"
+qemu_savevm_send_packaged(void) ""
+loadvm_handle_cmd_packaged(unsigned int length) "%u"
+loadvm_handle_cmd_packaged_main(int ret) "%d"
+loadvm_handle_cmd_packaged_received(int ret) "%d"
+loadvm_postcopy_handle_advise(void) ""
+loadvm_postcopy_handle_listen(void) ""
+loadvm_postcopy_handle_run(void) ""
+loadvm_postcopy_handle_run_cpu_sync(void) ""
+loadvm_postcopy_handle_run_vmstart(void) ""
+loadvm_postcopy_ram_handle_discard(void) ""
+loadvm_postcopy_ram_handle_discard_end(void) ""
+loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) 
"%s: %ud"
+loadvm_process_command(uint16_t com, uint16_t len) "com=0x%x len=%d"
+loadvm_process_command_ping(uint32_t val) "%x"
+postcopy_ram_listen_thread_exit(void) ""
+postcopy_ram_listen_thread_start(void) ""
+qemu_savevm_send_postcopy_advise(void) ""
+qemu_savevm_send_postcopy_ram_discard(const char *id, uint16_t len) "%s: %ud"
+savevm_command_send(uint16_t command, uint16_t len) "com=0x%x len=%d"
+savevm_section_start(const char *id, unsigned int section_id) "%s, section_id 
%u"
+savevm_section_end(const char *id, unsigned int section_id, int ret) "%s, 
section_id %u -> %d"
+savevm_section_skip(const char *id, unsigned int section_id) "%s, section_id 
%u"
+savevm_send_open_return_path(void) ""
+savevm_send_ping(uint32_t val) "%x"
+savevm_send_postcopy_listen(void) ""
+savevm_send_postcopy_run(void) ""
+savevm_state_begin(void) ""
+savevm_state_header(void) ""
+savevm_state_iterate(void) ""
+savevm_state_cleanup(void) ""
+savevm_state_complete_precopy(void) ""
+vmstate_save(const char *idstr, const char *vmsd_name) "%s, %s"
+vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s"
+qemu_announce_self_iter(const char *mac) "%s"
+
+# migration/vmstate.c
+vmstate_load_field_error(const char *field, int ret) "field \"%s\" load 
failed, ret = %d"
+vmstate_load_state(const char *name, int version_id) "%s v%d"
+vmstate_load_state_end(const char *name, const char *reason, int val) "%s 
%s/%d"
+vmstate_load_state_field(const char *name, const char *field) "%s:%s"
+vmstate_n_elems(const char *name, int n_elems) "%s: %d"
+vmstate_subsection_load(const char *parent) "%s"
+vmstate_subsection_load_bad(const char *parent,  const char *sub, const char 
*sub2) "%s: %s/%s"
+vmstate_subsection_load_good(const char *parent) "%s"
+
+# migration/qemu-file.c
+qemu_file_fclose(void) ""
+
+# migration/ram.c
+get_queued_page(const char *block_name, uint64_t tmp_offset, uint64_t 
ram_addr) "%s/%" PRIx64 " ram_addr=%" PRIx64
+get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, 
uint64_t ram_addr, int sent) "%s/%" PRIx64 " ram_addr=%" PRIx64 " (sent=%d)"
+migration_bitmap_sync_start(void) ""
+migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64
+migration_throttle(void) ""
+ram_load_postcopy_loop(uint64_t addr, int flags) "@%" PRIx64 " %x"
+ram_postcopy_send_discard_bitmap(void) ""
+ram_save_queue_pages(const char *rbname, size_t start, size_t len) "%s: start: 
%zx len: %zx"
+
+# migration/migration.c
+await_return_path_close_on_source_close(void) ""
+await_return_path_close_on_source_joining(void) ""
+migrate_set_state(int new_state) "new state %d"
+migrate_fd_cleanup(void) ""
+migrate_fd_error(const char *error_desc) "error=%s"
+migrate_fd_cancel(void) ""
+migrate_handle_rp_req_pages(const char *rbname, size_t start, size_t len) "in 
%s at %zx len %zx"
+migrate_pending(uint64_t size, uint64_t max, uint64_t post, uint64_t nonpost) 
"pend

[Qemu-devel] [PULL 04/42] trace: split out trace events for util/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the util/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-3-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 trace-events  | 12 
 util/trace-events | 13 +
 3 files changed, 14 insertions(+), 12 deletions(-)
 create mode 100644 util/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 697fc66..cd675fd 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -119,3 +119,4 @@ ivshmem-server-obj-y = contrib/ivshmem-server/
 
 ##
 trace-events-y = trace-events
+trace-events-y += util/trace-events
diff --git a/trace-events b/trace-events
index 90edb98..f9eb38d 100644
--- a/trace-events
+++ b/trace-events
@@ -25,13 +25,6 @@
 #
 # The  should be a sprintf()-compatible format string.
 
-# util/oslib-win32.c
-# util/oslib-posix.c
-qemu_memalign(size_t alignment, size_t size, void *ptr) "alignment %zu size 
%zu ptr %p"
-qemu_anon_ram_alloc(size_t size, void *ptr) "size %zu ptr %p"
-qemu_vfree(void *ptr) "ptr %p"
-qemu_anon_ram_free(void *ptr, size_t size) "ptr %p size %zu"
-
 # hw/virtio/virtio.c
 virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) 
"vq %p elem %p len %u idx %u"
 virtqueue_flush(void *vq, unsigned int count) "vq %p count %u"
@@ -1449,11 +1442,6 @@ buffer_move_empty(const char *buf, size_t len, const 
char *from) "%s: %zd bytes
 buffer_move(const char *buf, size_t len, const char *from) "%s: %zd bytes from 
%s"
 buffer_free(const char *buf, size_t len) "%s: capacity %zd"
 
-# util/hbitmap.c
-hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long 
cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
-hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, 
uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
-hbitmap_set(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t 
ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
-
 # target-s390x/mmu_helper.c
 get_skeys_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d"
 set_skeys_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"
diff --git a/util/trace-events b/util/trace-events
new file mode 100644
index 000..3ce5f1e
--- /dev/null
+++ b/util/trace-events
@@ -0,0 +1,13 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# util/oslib-win32.c
+# util/oslib-posix.c
+qemu_memalign(size_t alignment, size_t size, void *ptr) "alignment %zu size 
%zu ptr %p"
+qemu_anon_ram_alloc(size_t size, void *ptr) "size %zu ptr %p"
+qemu_vfree(void *ptr) "ptr %p"
+qemu_anon_ram_free(void *ptr, size_t size) "ptr %p size %zu"
+
+# util/hbitmap.c
+hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long 
cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
+hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, 
uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
+hbitmap_set(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t 
ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
-- 
2.5.5




[Qemu-devel] [PULL 02/42] trace: [all] Add "guest_mem_before" event

2016-06-20 Thread Stefan Hajnoczi
From: Lluís Vilanova 

The event is described in "trace-events". Note that the "MO_AMASK" flag
is not traced, since it does not seem to affect the visible semantics of
instructions.

[s/inline inline/inline/ to fix clang build.
--Stefan]

Signed-off-by: Lluís Vilanova 
Reviewed-by: Richard Henderson 
Reviewed-by: Peter Maydell 
Message-id: 146549350711.18437.726780393247474362.st...@fimbulvetr.bsc.es
Signed-off-by: Stefan Hajnoczi 
---
 include/exec/cpu_ldst_template.h  | 25 +
 include/exec/cpu_ldst_useronly_template.h | 22 +++
 tcg/tcg-op.c  | 10 +++
 trace-events  | 21 ++
 trace/mem-internal.h  | 46 +++
 trace/mem.h   | 34 +++
 6 files changed, 158 insertions(+)
 create mode 100644 trace/mem-internal.h
 create mode 100644 trace/mem.h

diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h
index 3091c00..eaf69a1 100644
--- a/include/exec/cpu_ldst_template.h
+++ b/include/exec/cpu_ldst_template.h
@@ -23,6 +23,13 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see .
  */
+
+#if !defined(SOFTMMU_CODE_ACCESS)
+#include "trace.h"
+#endif
+
+#include "trace/mem.h"
+
 #if DATA_SIZE == 8
 #define SUFFIX q
 #define USUFFIX q
@@ -80,6 +87,12 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), 
_ra)(CPUArchState *env,
 int mmu_idx;
 TCGMemOpIdx oi;
 
+#if !defined(SOFTMMU_CODE_ACCESS)
+trace_guest_mem_before_exec(
+ENV_GET_CPU(env), ptr,
+trace_mem_build_info(SHIFT, false, MO_TE, false));
+#endif
+
 addr = ptr;
 page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
 mmu_idx = CPU_MMU_INDEX;
@@ -112,6 +125,12 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), 
_ra)(CPUArchState *env,
 int mmu_idx;
 TCGMemOpIdx oi;
 
+#if !defined(SOFTMMU_CODE_ACCESS)
+trace_guest_mem_before_exec(
+ENV_GET_CPU(env), ptr,
+trace_mem_build_info(SHIFT, true, MO_TE, false));
+#endif
+
 addr = ptr;
 page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
 mmu_idx = CPU_MMU_INDEX;
@@ -148,6 +167,12 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), 
_ra)(CPUArchState *env,
 int mmu_idx;
 TCGMemOpIdx oi;
 
+#if !defined(SOFTMMU_CODE_ACCESS)
+trace_guest_mem_before_exec(
+ENV_GET_CPU(env), ptr,
+trace_mem_build_info(SHIFT, false, MO_TE, true));
+#endif
+
 addr = ptr;
 page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
 mmu_idx = CPU_MMU_INDEX;
diff --git a/include/exec/cpu_ldst_useronly_template.h 
b/include/exec/cpu_ldst_useronly_template.h
index 040b147..b1378bf 100644
--- a/include/exec/cpu_ldst_useronly_template.h
+++ b/include/exec/cpu_ldst_useronly_template.h
@@ -22,6 +22,13 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see .
  */
+
+#if !defined(CODE_ACCESS)
+#include "trace.h"
+#endif
+
+#include "trace/mem.h"
+
 #if DATA_SIZE == 8
 #define SUFFIX q
 #define USUFFIX q
@@ -53,6 +60,11 @@
 static inline RES_TYPE
 glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
 {
+#if !defined(CODE_ACCESS)
+trace_guest_mem_before_exec(
+ENV_GET_CPU(env), ptr,
+trace_mem_build_info(DATA_SIZE, false, MO_TE, false));
+#endif
 return glue(glue(ld, USUFFIX), _p)(g2h(ptr));
 }
 
@@ -68,6 +80,11 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), 
_ra)(CPUArchState *env,
 static inline int
 glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
 {
+#if !defined(CODE_ACCESS)
+trace_guest_mem_before_exec(
+ENV_GET_CPU(env), ptr,
+trace_mem_build_info(DATA_SIZE, true, MO_TE, false));
+#endif
 return glue(glue(lds, SUFFIX), _p)(g2h(ptr));
 }
 
@@ -85,6 +102,11 @@ static inline void
 glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
   RES_TYPE v)
 {
+#if !defined(CODE_ACCESS)
+trace_guest_mem_before_exec(
+ENV_GET_CPU(env), ptr,
+trace_mem_build_info(DATA_SIZE, false, MO_TE, true));
+#endif
 glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
 }
 
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 54c0277..569cdc6 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -28,6 +28,8 @@
 #include "exec/exec-all.h"
 #include "tcg.h"
 #include "tcg-op.h"
+#include "trace-tcg.h"
+#include "trace/mem.h"
 
 /* Reduce the number of ifdefs below.  This assumes that all uses of
TCGV_HIGH and TCGV_LOW are properly protected by a conditional that
@@ -1910,12 +1912,16 @@ static void gen_ldst_i64(TCGOpcode opc, TCGv_i64 val, 
TCGv addr,
 void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop)
 {
 memop = tcg_canonicalize_memop(memop, 0, 0);
+  

[Qemu-devel] [PULL 13/42] trace: split out trace events for hw/virtio/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/virtio/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-12-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs  |  1 +
 hw/virtio/trace-events | 16 
 trace-events   | 14 --
 3 files changed, 17 insertions(+), 14 deletions(-)
 create mode 100644 hw/virtio/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 867c135..165475c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -128,3 +128,4 @@ trace-events-y += hw/block/trace-events
 trace-events-y += hw/char/trace-events
 trace-events-y += hw/intc/trace-events
 trace-events-y += hw/net/trace-events
+trace-events-y += hw/virtio/trace-events
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
new file mode 100644
index 000..2853053
--- /dev/null
+++ b/hw/virtio/trace-events
@@ -0,0 +1,16 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/virtio/virtio.c
+virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) 
"vq %p elem %p len %u idx %u"
+virtqueue_flush(void *vq, unsigned int count) "vq %p count %u"
+virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) 
"vq %p elem %p in_num %u out_num %u"
+virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p"
+virtio_irq(void *vq) "vq %p"
+virtio_notify(void *vdev, void *vq) "vdev %p vq %p"
+virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u"
+
+# hw/virtio/virtio-rng.c
+virtio_rng_guest_not_ready(void *rng) "rng %p: guest not ready"
+virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
+virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes 
requested, %u bytes quota left"
+
diff --git a/trace-events b/trace-events
index 37cac33..d2ac199 100644
--- a/trace-events
+++ b/trace-events
@@ -25,20 +25,6 @@
 #
 # The  should be a sprintf()-compatible format string.
 
-# hw/virtio/virtio.c
-virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) 
"vq %p elem %p len %u idx %u"
-virtqueue_flush(void *vq, unsigned int count) "vq %p count %u"
-virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) 
"vq %p elem %p in_num %u out_num %u"
-virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p"
-virtio_irq(void *vq) "vq %p"
-virtio_notify(void *vdev, void *vq) "vdev %p vq %p"
-virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u"
-
-# hw/virtio/virtio-rng.c
-virtio_rng_guest_not_ready(void *rng) "rng %p: guest not ready"
-virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
-virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes 
requested, %u bytes quota left"
-
 # thread-pool.c
 thread_pool_submit(void *pool, void *req, void *opaque) "pool %p req %p opaque 
%p"
 thread_pool_complete(void *pool, void *req, void *opaque, int ret) "pool %p 
req %p opaque %p ret %d"
-- 
2.5.5




[Qemu-devel] [PULL 06/42] trace: split out trace events for io/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the io/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-5-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |  1 +
 io/trace-events | 63 +
 trace-events| 62 
 3 files changed, 64 insertions(+), 62 deletions(-)
 create mode 100644 io/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index c6e915e..7577dca 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -121,3 +121,4 @@ ivshmem-server-obj-y = contrib/ivshmem-server/
 trace-events-y = trace-events
 trace-events-y += util/trace-events
 trace-events-y += crypto/trace-events
+trace-events-y += io/trace-events
diff --git a/io/trace-events b/io/trace-events
new file mode 100644
index 000..1108c16
--- /dev/null
+++ b/io/trace-events
@@ -0,0 +1,63 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# io/buffer.c
+buffer_resize(const char *buf, size_t olen, size_t len) "%s: old %zd, new %zd"
+buffer_move_empty(const char *buf, size_t len, const char *from) "%s: %zd 
bytes from %s"
+buffer_move(const char *buf, size_t len, const char *from) "%s: %zd bytes from 
%s"
+buffer_free(const char *buf, size_t len) "%s: capacity %zd"
+
+# io/task.c
+qio_task_new(void *task, void *source, void *func, void *opaque) "Task new 
task=%p source=%p func=%p opaque=%p"
+qio_task_complete(void *task) "Task complete task=%p"
+qio_task_abort(void *task) "Task abort task=%p"
+qio_task_thread_start(void *task, void *worker, void *opaque) "Task thread 
start task=%p worker=%p opaque=%p"
+qio_task_thread_run(void *task) "Task thread run task=%p"
+qio_task_thread_exit(void *task) "Task thread exit task=%p"
+qio_task_thread_result(void *task) "Task thread result task=%p"
+
+# io/channel-socket.c
+qio_channel_socket_new(void *ioc) "Socket new ioc=%p"
+qio_channel_socket_new_fd(void *ioc, int fd) "Socket new ioc=%p fd=%d"
+qio_channel_socket_connect_sync(void *ioc, void *addr) "Socket connect sync 
ioc=%p addr=%p"
+qio_channel_socket_connect_async(void *ioc, void *addr) "Socket connect async 
ioc=%p addr=%p"
+qio_channel_socket_connect_fail(void *ioc) "Socket connect fail ioc=%p"
+qio_channel_socket_connect_complete(void *ioc, int fd) "Socket connect 
complete ioc=%p fd=%d"
+qio_channel_socket_listen_sync(void *ioc, void *addr) "Socket listen sync 
ioc=%p addr=%p"
+qio_channel_socket_listen_async(void *ioc, void *addr) "Socket listen async 
ioc=%p addr=%p"
+qio_channel_socket_listen_fail(void *ioc) "Socket listen fail ioc=%p"
+qio_channel_socket_listen_complete(void *ioc, int fd) "Socket listen complete 
ioc=%p fd=%d"
+qio_channel_socket_dgram_sync(void *ioc, void *localAddr, void *remoteAddr) 
"Socket dgram sync ioc=%p localAddr=%p remoteAddr=%p"
+qio_channel_socket_dgram_async(void *ioc, void *localAddr, void *remoteAddr) 
"Socket dgram async ioc=%p localAddr=%p remoteAddr=%p"
+qio_channel_socket_dgram_fail(void *ioc) "Socket dgram fail ioc=%p"
+qio_channel_socket_dgram_complete(void *ioc, int fd) "Socket dgram complete 
ioc=%p fd=%d"
+qio_channel_socket_accept(void *ioc) "Socket accept start ioc=%p"
+qio_channel_socket_accept_fail(void *ioc) "Socket accept fail ioc=%p"
+qio_channel_socket_accept_complete(void *ioc, void *cioc, int fd) "Socket 
accept complete ioc=%p cioc=%p fd=%d"
+
+# io/channel-file.c
+qio_channel_file_new_fd(void *ioc, int fd) "File new fd ioc=%p fd=%d"
+qio_channel_file_new_path(void *ioc, const char *path, int flags, int mode, 
int fd) "File new fd ioc=%p path=%s flags=%d mode=%d fd=%d"
+
+# io/channel-tls.c
+qio_channel_tls_new_client(void *ioc, void *master, void *creds, const char 
*hostname) "TLS new client ioc=%p master=%p creds=%p hostname=%s"
+qio_channel_tls_new_server(void *ioc, void *master, void *creds, const char 
*aclname) "TLS new client ioc=%p master=%p creds=%p acltname=%s"
+qio_channel_tls_handshake_start(void *ioc) "TLS handshake start ioc=%p"
+qio_channel_tls_handshake_pending(void *ioc, int status) "TLS handshake 
pending ioc=%p status=%d"
+qio_channel_tls_handshake_fail(void *ioc) "TLS handshake fail ioc=%p"
+qio_channel_tls_handshake_complete(void *ioc) "TLS handshake complete ioc=%p"
+qio_channel_tls_credentials_allow(void *ioc) "TLS credentials allow ioc=%p"
+qio_channel_tls_credentials_deny(void *ioc) "TLS credentials deny ioc=%p"
+
+# io/channel-websock.c
+qio_channel_websock_new_server(void *ioc, void *master) "Websock new client 
ioc=%p master=%p"
+qio_channel_websock_handshake_start(void *ioc) "Websock handshake start ioc=%p"
+qio_channel_websock_handshake_pending(void *ioc, int status) "Websock 
handshake pending ioc=%p status=%d"
+qio_channel_websock_handshake_reply(void *ioc) "Websock handshake reply ioc=%p"
+qio_channel_websock_handshake_fail(void *ioc) "Websock handshake fail ioc=%p"
+qio_channel_websock_handshake_complete(void *ioc) "Websock handshake compl

[Qemu-devel] [PULL 11/42] trace: split out trace events for hw/intc/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/intc/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-10-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|   1 +
 hw/intc/trace-events | 123 +++
 trace-events |  81 -
 3 files changed, 124 insertions(+), 81 deletions(-)
 create mode 100644 hw/intc/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 8c7d8a9..8560df4 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -126,3 +126,4 @@ trace-events-y += migration/trace-events
 trace-events-y += block/trace-events
 trace-events-y += hw/block/trace-events
 trace-events-y += hw/char/trace-events
+trace-events-y += hw/intc/trace-events
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
new file mode 100644
index 000..376dd18
--- /dev/null
+++ b/hw/intc/trace-events
@@ -0,0 +1,123 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/intc/apic_common.c
+cpu_set_apic_base(uint64_t val) "%016"PRIx64
+cpu_get_apic_base(uint64_t val) "%016"PRIx64
+# coalescing
+apic_report_irq_delivered(int apic_irq_delivered) "coalescing %d"
+apic_reset_irq_delivered(int apic_irq_delivered) "old coalescing %d"
+apic_get_irq_delivered(int apic_irq_delivered) "returning coalescing %d"
+
+# hw/intc/apic.c
+apic_local_deliver(int vector, uint32_t lvt) "vector %d delivery mode %d"
+apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, 
uint8_t vector_num, uint8_t trigger_mode) "dest %d dest_mode %d delivery_mode 
%d vector %d trigger_mode %d"
+apic_mem_readl(uint64_t addr, uint32_t val)  "%"PRIx64" = %08x"
+apic_mem_writel(uint64_t addr, uint32_t val) "%"PRIx64" = %08x"
+
+# hw/intc/slavio_intctl.c
+slavio_intctl_mem_readl(uint32_t cpu, uint64_t addr, uint32_t ret) "read cpu 
%d reg 0x%"PRIx64" = %x"
+slavio_intctl_mem_writel(uint32_t cpu, uint64_t addr, uint32_t val) "write cpu 
%d reg 0x%"PRIx64" = %x"
+slavio_intctl_mem_writel_clear(uint32_t cpu, uint32_t val, uint32_t 
intreg_pending) "Cleared cpu %d irq mask %x, curmask %x"
+slavio_intctl_mem_writel_set(uint32_t cpu, uint32_t val, uint32_t 
intreg_pending) "Set cpu %d irq mask %x, curmask %x"
+slavio_intctlm_mem_readl(uint64_t addr, uint32_t ret) "read system reg 
0x%"PRIx64" = %x"
+slavio_intctlm_mem_writel(uint64_t addr, uint32_t val) "write system reg 
0x%"PRIx64" = %x"
+slavio_intctlm_mem_writel_enable(uint32_t val, uint32_t intregm_disabled) 
"Enabled master irq mask %x, curmask %x"
+slavio_intctlm_mem_writel_disable(uint32_t val, uint32_t intregm_disabled) 
"Disabled master irq mask %x, curmask %x"
+slavio_intctlm_mem_writel_target(uint32_t cpu) "Set master irq cpu %d"
+slavio_check_interrupts(uint32_t pending, uint32_t intregm_disabled) "pending 
%x disabled %x"
+slavio_set_irq(uint32_t target_cpu, int irq, uint32_t pil, int level) "Set cpu 
%d irq %d -> pil %d level %d"
+slavio_set_timer_irq_cpu(int cpu, int level) "Set cpu %d local timer level %d"
+
+# hw/intc/grlib_irqmp.c
+grlib_irqmp_check_irqs(uint32_t pend, uint32_t force, uint32_t mask, uint32_t 
lvl1, uint32_t lvl2) "pend:0x%04x force:0x%04x mask:0x%04x lvl1:0x%04x 
lvl0:0x%04x"
+grlib_irqmp_ack(int intno) "interrupt:%d"
+grlib_irqmp_set_irq(int irq) "Raise CPU IRQ %d"
+grlib_irqmp_readl_unknown(uint64_t addr) "addr 0x%"PRIx64
+grlib_irqmp_writel_unknown(uint64_t addr, uint32_t value) "addr 0x%"PRIx64" 
value 0x%x"
+
+# hw/intc/lm32_pic.c
+lm32_pic_raise_irq(void) "Raise CPU interrupt"
+lm32_pic_lower_irq(void) "Lower CPU interrupt"
+lm32_pic_interrupt(int irq, int level) "Set IRQ%d %d"
+lm32_pic_set_im(uint32_t im) "im 0x%08x"
+lm32_pic_set_ip(uint32_t ip) "ip 0x%08x"
+lm32_pic_get_im(uint32_t im) "im 0x%08x"
+lm32_pic_get_ip(uint32_t ip) "ip 0x%08x"
+
+# hw/intc/xics.c
+xics_icp_check_ipi(int server, uint8_t mfrr) "CPU %d can take IPI mfrr=%#x"
+xics_icp_accept(uint32_t old_xirr, uint32_t new_xirr) "icp_accept: XIRR 
%#"PRIx32"->%#"PRIx32
+xics_icp_eoi(int server, uint32_t xirr, uint32_t new_xirr) "icp_eoi: server %d 
given XIRR %#"PRIx32" new XIRR %#"PRIx32
+xics_icp_irq(int server, int nr, uint8_t priority) "cpu %d trying to deliver 
irq %#"PRIx32" priority %#x"
+xics_icp_raise(uint32_t xirr, uint8_t pending_priority) "raising IRQ new 
XIRR=%#x new pending priority=%#x"
+xics_set_irq_msi(int srcno, int nr) "set_irq_msi: srcno %d [irq %#x]"
+xics_masked_pending(void) "set_irq_msi: masked pending"
+xics_set_irq_lsi(int srcno, int nr) "set_irq_lsi: srcno %d [irq %#x]"
+xics_ics_write_xive(int nr, int srcno, int server, uint8_t priority) 
"ics_write_xive: irq %#x [src %d] server %#x prio %#x"
+xics_ics_reject(int nr, int srcno) "reject irq %#x [src %d]"
+xics_ics_eoi(int nr) "ics_eoi: irq %#x"
+xics_alloc(int src, int irq) "source#%d, irq %d"
+xics_alloc_block(int src, int first, int num, bool lsi, int align) "source#%d, 
first irq %d, %d irqs, lsi=%d, alignnum %d"
+xics_ic

[Qemu-devel] [PULL 09/42] trace: split out trace events for hw/block/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/block/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-8-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/block/trace-events | 17 +
 trace-events  | 16 
 3 files changed, 18 insertions(+), 16 deletions(-)
 create mode 100644 hw/block/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 998f356..7c1da65 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -124,3 +124,4 @@ trace-events-y += crypto/trace-events
 trace-events-y += io/trace-events
 trace-events-y += migration/trace-events
 trace-events-y += block/trace-events
+trace-events-y += hw/block/trace-events
diff --git a/hw/block/trace-events b/hw/block/trace-events
new file mode 100644
index 000..31df44b
--- /dev/null
+++ b/hw/block/trace-events
@@ -0,0 +1,17 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/block/virtio-blk.c
+virtio_blk_req_complete(void *req, int status) "req %p status %d"
+virtio_blk_rw_complete(void *req, int ret) "req %p ret %d"
+virtio_blk_handle_write(void *req, uint64_t sector, size_t nsectors) "req %p 
sector %"PRIu64" nsectors %zu"
+virtio_blk_handle_read(void *req, uint64_t sector, size_t nsectors) "req %p 
sector %"PRIu64" nsectors %zu"
+virtio_blk_submit_multireq(void *mrb, int start, int num_reqs, uint64_t 
offset, size_t size, bool is_write) "mrb %p start %d num_reqs %d offset 
%"PRIu64" size %zu is_write %d"
+
+# hw/block/dataplane/virtio-blk.c
+virtio_blk_data_plane_start(void *s) "dataplane %p"
+virtio_blk_data_plane_stop(void *s) "dataplane %p"
+virtio_blk_data_plane_process_request(void *s, unsigned int out_num, unsigned 
int in_num, unsigned int head) "dataplane %p out_num %u in_num %u head %u"
+
+# hw/block/hd-geometry.c
+hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS 
%d %d %d"
+hd_geometry_guess(void *blk, uint32_t cyls, uint32_t heads, uint32_t secs, int 
trans) "blk %p CHS %u %u %u trans %d"
diff --git a/trace-events b/trace-events
index fe3b9f5..ee73165 100644
--- a/trace-events
+++ b/trace-events
@@ -50,18 +50,6 @@ virtio_console_flush_buf(unsigned int port, size_t len, 
ssize_t ret) "port %u, i
 virtio_console_chr_read(unsigned int port, int size) "port %u, size %d"
 virtio_console_chr_event(unsigned int port, int event) "port %u, event %d"
 
-# hw/block/virtio-blk.c
-virtio_blk_req_complete(void *req, int status) "req %p status %d"
-virtio_blk_rw_complete(void *req, int ret) "req %p ret %d"
-virtio_blk_handle_write(void *req, uint64_t sector, size_t nsectors) "req %p 
sector %"PRIu64" nsectors %zu"
-virtio_blk_handle_read(void *req, uint64_t sector, size_t nsectors) "req %p 
sector %"PRIu64" nsectors %zu"
-virtio_blk_submit_multireq(void *mrb, int start, int num_reqs, uint64_t 
offset, size_t size, bool is_write) "mrb %p start %d num_reqs %d offset 
%"PRIu64" size %zu is_write %d"
-
-# hw/block/dataplane/virtio-blk.c
-virtio_blk_data_plane_start(void *s) "dataplane %p"
-virtio_blk_data_plane_stop(void *s) "dataplane %p"
-virtio_blk_data_plane_process_request(void *s, unsigned int out_num, unsigned 
int in_num, unsigned int head) "dataplane %p out_num %u in_num %u head %u"
-
 # thread-pool.c
 thread_pool_submit(void *pool, void *req, void *opaque) "pool %p req %p opaque 
%p"
 thread_pool_complete(void *pool, void *req, void *opaque, int ret) "pool %p 
req %p opaque %p ret %d"
@@ -128,10 +116,6 @@ fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = 
%d"
 fw_cfg_read(void *s, uint64_t ret) "%p = %"PRIx64
 fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd 
bytes)"
 
-# hw/block/hd-geometry.c
-hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS 
%d %d %d"
-hd_geometry_guess(void *blk, uint32_t cyls, uint32_t heads, uint32_t secs, int 
trans) "blk %p CHS %u %u %u trans %d"
-
 # hw/display/jazz_led.c
 jazz_led_read(uint64_t addr, uint8_t val) "read addr=0x%"PRIx64": 0x%x"
 jazz_led_write(uint64_t addr, uint8_t new) "write addr=0x%"PRIx64": 0x%x"
-- 
2.5.5




[Qemu-devel] [PULL 12/42] trace: split out trace events for hw/net/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/net/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-11-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |   1 +
 hw/net/trace-events | 272 +
 trace-events| 312 
 3 files changed, 273 insertions(+), 312 deletions(-)
 create mode 100644 hw/net/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 8560df4..867c135 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -127,3 +127,4 @@ trace-events-y += block/trace-events
 trace-events-y += hw/block/trace-events
 trace-events-y += hw/char/trace-events
 trace-events-y += hw/intc/trace-events
+trace-events-y += hw/net/trace-events
diff --git a/hw/net/trace-events b/hw/net/trace-events
new file mode 100644
index 000..aaa905f
--- /dev/null
+++ b/hw/net/trace-events
@@ -0,0 +1,272 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/net/lance.c
+lance_mem_readw(uint64_t addr, uint32_t ret) "addr=%"PRIx64"val=0x%04x"
+lance_mem_writew(uint64_t addr, uint32_t val) "addr=%"PRIx64"val=0x%04x"
+
+# hw/net/milkymist-minimac2.c
+milkymist_minimac2_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_minimac2_memory_write(uint32_t addr, uint32_t value) "addr %08x 
value %08x"
+milkymist_minimac2_mdio_write(uint8_t phy_addr, uint8_t addr, uint16_t value) 
"phy_addr %02x addr %02x value %04x"
+milkymist_minimac2_mdio_read(uint8_t phy_addr, uint8_t addr, uint16_t value) 
"phy_addr %02x addr %02x value %04x"
+milkymist_minimac2_tx_frame(uint32_t length) "length %u"
+milkymist_minimac2_rx_frame(const void *buf, uint32_t length) "buf %p length 
%u"
+milkymist_minimac2_rx_transfer(const void *buf, uint32_t length) "buf %p 
length %d"
+milkymist_minimac2_raise_irq_rx(void) "Raise IRQ RX"
+milkymist_minimac2_lower_irq_rx(void) "Lower IRQ RX"
+milkymist_minimac2_pulse_irq_tx(void) "Pulse IRQ TX"
+
+# hw/net/mipsnet.c
+mipsnet_send(uint32_t size) "sending len=%u"
+mipsnet_receive(uint32_t size) "receiving len=%u"
+mipsnet_read(uint64_t addr, uint32_t val) "read addr=0x%" PRIx64 " val=0x%x"
+mipsnet_write(uint64_t addr, uint64_t val) "write addr=0x%" PRIx64 " val=0x%" 
PRIx64
+mipsnet_irq(uint32_t isr, uint32_t intctl) "set irq to %d (%02x)"
+
+# hw/net/opencores_eth.c
+open_eth_mii_write(unsigned idx, uint16_t v) "MII[%02x] <- %04x"
+open_eth_mii_read(unsigned idx, uint16_t v) "MII[%02x] -> %04x"
+open_eth_update_irq(uint32_t v) "IRQ <- %x"
+open_eth_receive(unsigned len) "RX: len: %u"
+open_eth_receive_mcast(unsigned idx, uint32_t h0, uint32_t h1) "MCAST: idx = 
%u, hash: %08x:%08x"
+open_eth_receive_reject(void) "RX: rejected"
+open_eth_receive_desc(uint32_t addr, uint32_t len_flags) "RX: %08x, len_flags: 
%08x"
+open_eth_start_xmit(uint32_t addr, unsigned len, unsigned tx_len) "TX: %08x, 
len: %u, tx_len: %u"
+open_eth_reg_read(uint32_t addr, uint32_t v) "MAC[%02x] -> %08x"
+open_eth_reg_write(uint32_t addr, uint32_t v) "MAC[%02x] <- %08x"
+open_eth_desc_read(uint32_t addr, uint32_t v) "DESC[%04x] -> %08x"
+open_eth_desc_write(uint32_t addr, uint32_t v) "DESC[%04x] <- %08x"
+
+# hw/net/pcnet.c
+pcnet_s_reset(void *s) "s=%p"
+pcnet_user_int(void *s) "s=%p"
+pcnet_isr_change(void *s, uint32_t isr, uint32_t isr_old) "s=%p INTA=%d<=%d"
+pcnet_init(void *s, uint64_t init_addr) "s=%p init_addr=%#"PRIx64
+pcnet_rlen_tlen(void *s, uint32_t rlen, uint32_t tlen) "s=%p rlen=%d tlen=%d"
+pcnet_ss32_rdra_tdra(void *s, uint32_t ss32, uint32_t rdra, uint32_t rcvrl, 
uint32_t tdra, uint32_t xmtrl) "s=%p ss32=%d rdra=0x%08x[%d] tdra=0x%08x[%d]"
+
+# hw/net/pcnet-pci.c
+pcnet_aprom_writeb(void *opaque, uint32_t addr, uint32_t val) "opaque=%p 
addr=0x%08x val=0x%02x"
+pcnet_aprom_readb(void *opaque, uint32_t addr, uint32_t val) "opaque=%p 
addr=0x%08x val=0x%02x"
+pcnet_ioport_read(void *opaque, uint64_t addr, unsigned size) "opaque=%p 
addr=%#"PRIx64" size=%d"
+pcnet_ioport_write(void *opaque, uint64_t addr, uint64_t data, unsigned size) 
"opaque=%p addr=%#"PRIx64" data=%#"PRIx64" size=%d"
+pcnet_mmio_writeb(void *opaque, uint64_t addr, uint32_t val) "opaque=%p 
addr=%#"PRIx64" val=0x%x"
+pcnet_mmio_writew(void *opaque, uint64_t addr, uint32_t val) "opaque=%p 
addr=%#"PRIx64" val=0x%x"
+pcnet_mmio_writel(void *opaque, uint64_t addr, uint32_t val) "opaque=%p 
addr=%#"PRIx64" val=0x%x"
+pcnet_mmio_readb(void *opaque, uint64_t addr, uint32_t val) "opaque=%p 
addr=%#"PRIx64" val=0x%x"
+pcnet_mmio_readw(void *opaque, uint64_t addr, uint32_t val) "opaque=%p 
addr=%#"PRIx64" val=0x%x"
+pcnet_mmio_readl(void *opaque, uint64_t addr, uint32_t val) "opaque=%p 
addr=%#"PRIx64" val=0x%x"
+
+# hw/net/net_rx_pkt.c
+net_rx_pkt_parsed(bool ip4, bool ip6, bool udp, bool tcp, size_t l3o, size_t 
l4o, size_t l5o) "RX packet parsed: ip4: %d, ip6: %d, udp: %d, tcp: %d, l3 
offset: %zu, l4 offset: %zu, l5 offset: %z

[Qemu-devel] [PULL 17/42] trace: split out trace events for hw/scsi/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/scsi/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-16-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|   1 +
 hw/scsi/trace-events | 204 +++
 trace-events | 203 --
 3 files changed, 205 insertions(+), 203 deletions(-)
 create mode 100644 hw/scsi/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index e0e6084..06fb4af 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -132,3 +132,4 @@ trace-events-y += hw/virtio/trace-events
 trace-events-y += hw/audio/trace-events
 trace-events-y += hw/misc/trace-events
 trace-events-y += hw/usb/trace-events
+trace-events-y += hw/scsi/trace-events
diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events
new file mode 100644
index 000..5f19e32
--- /dev/null
+++ b/hw/scsi/trace-events
@@ -0,0 +1,204 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/scsi/scsi-bus.c
+scsi_req_alloc(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_req_cancel(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_req_data(int target, int lun, int tag, int len) "target %d lun %d tag %d 
len %d"
+scsi_req_data_canceled(int target, int lun, int tag, int len) "target %d lun 
%d tag %d len %d"
+scsi_req_dequeue(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_req_continue(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_req_continue_canceled(int target, int lun, int tag) "target %d lun %d tag 
%d"
+scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfer) 
"target %d lun %d tag %d command %d dir %d length %d"
+scsi_req_parsed_lba(int target, int lun, int tag, int cmd, uint64_t lba) 
"target %d lun %d tag %d command %d lba %"PRIu64
+scsi_req_parse_bad(int target, int lun, int tag, int cmd) "target %d lun %d 
tag %d command %d"
+scsi_req_build_sense(int target, int lun, int tag, int key, int asc, int ascq) 
"target %d lun %d tag %d key %#02x asc %#02x ascq %#02x"
+scsi_device_set_ua(int target, int lun, int key, int asc, int ascq) "target %d 
lun %d key %#02x asc %#02x ascq %#02x"
+scsi_report_luns(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_inquiry(int target, int lun, int tag, int cdb1, int cdb2) "target %d lun 
%d tag %d page %#02x/%#02x"
+scsi_test_unit_ready(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_request_sense(int target, int lun, int tag) "target %d lun %d tag %d"
+
+# hw/scsi/mptsas.c
+mptsas_command_complete(void *dev, uint32_t ctx, uint32_t status, uint32_t 
resid) "dev %p context 0x%08x status %x resid %d"
+mptsas_diag_read(void *dev, uint32_t addr, uint32_t val) "dev %p addr 0x%08x 
value 0x%08x"
+mptsas_diag_write(void *dev, uint32_t addr, uint32_t val) "dev %p addr 0x%08x 
value 0x%08x"
+mptsas_irq_intx(void *dev, int level) "dev %p level %d"
+mptsas_irq_msi(void *dev) "dev %p "
+mptsas_mmio_read(void *dev, uint32_t addr, uint32_t val) "dev %p addr 0x%08x 
value 0x%x"
+mptsas_mmio_unhandled_read(void *dev, uint32_t addr) "dev %p addr 0x%08x"
+mptsas_mmio_unhandled_write(void *dev, uint32_t addr, uint32_t val) "dev %p 
addr 0x%08x value 0x%x"
+mptsas_mmio_write(void *dev, uint32_t addr, uint32_t val) "dev %p addr 0x%08x 
value 0x%x"
+mptsas_process_message(void *dev, int msg, uint32_t ctx) "dev %p cmd %d 
context 0x%08x\n"
+mptsas_process_scsi_io_request(void *dev, int bus, int target, int lun, 
uint64_t len) "dev %p dev %d:%d:%d length %"PRIu64""
+mptsas_reset(void *dev) "dev %p "
+mptsas_scsi_overflow(void *dev, uint32_t ctx, uint64_t req, uint64_t found) 
"dev %p context 0x%08x: %"PRIu64"/%"PRIu64""
+mptsas_sgl_overflow(void *dev, uint32_t ctx, uint64_t req, uint64_t found) 
"dev %p context 0x%08x: %"PRIu64"/%"PRIu64""
+mptsas_unhandled_cmd(void *dev, uint32_t ctx, uint8_t msg_cmd) "dev %p context 
0x%08x: Unhandled cmd %x"
+mptsas_unhandled_doorbell_cmd(void *dev, int cmd) "dev %p value 0x%08x"
+
+# hw/scsi/mptconfig.c
+mptsas_config_sas_device(void *dev, int address, int port, int phy_handle, int 
dev_handle, int page) "dev %p address %d (port %d, handles: phy %d dev %d) page 
%d"
+mptsas_config_sas_phy(void *dev, int address, int port, int phy_handle, int 
dev_handle, int page) "dev %p address %d (port %d, handles: phy %d dev %d) page 
%d"
+
+# hw/scsi/megasas.c
+megasas_init_firmware(uint64_t pa) "pa %" PRIx64 " "
+megasas_init_queue(uint64_t queue_pa, int queue_len, uint64_t head, uint64_t 
tail, uint32_t flags) "queue at %" PRIx64 " len %d head %" PRIx64 " tail %" 
PRIx64 " flags %x"
+megasas_initq_map_failed(int frame) "scmd %d: failed to map queue"
+megasas_initq_mapped(uint64_t pa) "queue already mapped at %" PRIx64
+megasas_initq_mismatch(int queue_len, int fw_cmds) "queue size %d max fw cmds 
%d"
+megasas_qf_mapped(unsigned int index) "skip mapped frame %x"
+megasas_qf_new(unsigned in

[Qemu-devel] [PULL 10/42] trace: split out trace events for hw/char/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/char/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-9-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|  1 +
 hw/char/trace-events | 49 +
 trace-events | 48 
 3 files changed, 50 insertions(+), 48 deletions(-)
 create mode 100644 hw/char/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 7c1da65..8c7d8a9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -125,3 +125,4 @@ trace-events-y += io/trace-events
 trace-events-y += migration/trace-events
 trace-events-y += block/trace-events
 trace-events-y += hw/block/trace-events
+trace-events-y += hw/char/trace-events
diff --git a/hw/char/trace-events b/hw/char/trace-events
new file mode 100644
index 000..005fcd8
--- /dev/null
+++ b/hw/char/trace-events
@@ -0,0 +1,49 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/char/virtio-serial-bus.c
+virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t 
value) "port %u, event %u, value %u"
+virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, 
throttle %d"
+virtio_serial_handle_control_message(uint16_t event, uint16_t value) "event 
%u, value %u"
+virtio_serial_handle_control_message_port(unsigned int port) "port %u"
+
+# hw/char/virtio-console.c
+virtio_console_flush_buf(unsigned int port, size_t len, ssize_t ret) "port %u, 
in_len %zu, out_len %zd"
+virtio_console_chr_read(unsigned int port, int size) "port %u, size %d"
+virtio_console_chr_event(unsigned int port, int event) "port %u, event %d"
+
+# hw/char/grlib_apbuart.c
+grlib_apbuart_event(int event) "event:%d"
+grlib_apbuart_writel_unknown(uint64_t addr, uint32_t value) "addr 0x%"PRIx64" 
value 0x%x"
+grlib_apbuart_readl_unknown(uint64_t addr) "addr 0x%"PRIx64
+
+# hw/char/lm32_juart.c
+lm32_juart_get_jtx(uint32_t value) "jtx 0x%08x"
+lm32_juart_set_jtx(uint32_t value) "jtx 0x%08x"
+lm32_juart_get_jrx(uint32_t value) "jrx 0x%08x"
+lm32_juart_set_jrx(uint32_t value) "jrx 0x%08x"
+
+# hw/char/lm32_uart.c
+lm32_uart_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 
0x%08x"
+lm32_uart_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
+lm32_uart_irq_state(int level) "irq state %d"
+
+# hw/char/milkymist-uart.c
+milkymist_uart_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_uart_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_uart_raise_irq(void) "Raise IRQ"
+milkymist_uart_lower_irq(void) "Lower IRQ"
+
+# hw/char/escc.c
+escc_put_queue(char channel, int b) "channel %c put: 0x%02x"
+escc_get_queue(char channel, int val) "channel %c get 0x%02x"
+escc_update_irq(int irq) "IRQ = %d"
+escc_update_parameters(char channel, int speed, int parity, int data_bits, int 
stop_bits) "channel %c: speed=%d parity=%c data=%d stop=%d"
+escc_mem_writeb_ctrl(char channel, uint32_t reg, uint32_t val) "Write channel 
%c, reg[%d] = %2.2x"
+escc_mem_writeb_data(char channel, uint32_t val) "Write channel %c, ch %d"
+escc_mem_readb_ctrl(char channel, uint32_t reg, uint8_t val) "Read channel %c, 
reg[%d] = %2.2x"
+escc_mem_readb_data(char channel, uint32_t ret) "Read channel %c, ch %d"
+escc_serial_receive_byte(char channel, int ch) "channel %c put ch %d"
+escc_sunkbd_event_in(int ch, const char *name, int down) "QKeyCode 0x%2.2x 
[%s], down %d"
+escc_sunkbd_event_out(int ch) "Translated keycode 0x%2.2x"
+escc_kbd_command(int val) "Command %d"
+escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d 
buttons=%01x"
diff --git a/trace-events b/trace-events
index ee73165..25fb18d 100644
--- a/trace-events
+++ b/trace-events
@@ -39,17 +39,6 @@ virtio_rng_guest_not_ready(void *rng) "rng %p: guest not 
ready"
 virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
 virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes 
requested, %u bytes quota left"
 
-# hw/char/virtio-serial-bus.c
-virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t 
value) "port %u, event %u, value %u"
-virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, 
throttle %d"
-virtio_serial_handle_control_message(uint16_t event, uint16_t value) "event 
%u, value %u"
-virtio_serial_handle_control_message_port(unsigned int port) "port %u"
-
-# hw/char/virtio-console.c
-virtio_console_flush_buf(unsigned int port, size_t len, ssize_t ret) "port %u, 
in_len %zu, out_len %zd"
-virtio_console_chr_read(unsigned int port, int size) "port %u, size %d"
-virtio_console_chr_event(unsigned int port, int event) "port %u, event %d"
-
 # thread-pool.c
 thread_pool_submit(void *pool, void *req, void *opaque) "pool %p req %p opaque 
%p"
 thread_pool_complete(void *pool, void *req, void *opaque, int ret) "pool %p 
req %p opaque %p ret %d"

[Qemu-devel] [PULL 08/42] trace: split out trace events for block/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the block/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-7-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs  |   1 +
 block/trace-events | 116 +
 trace-events   | 115 
 3 files changed, 117 insertions(+), 115 deletions(-)
 create mode 100644 block/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 76d..998f356 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -123,3 +123,4 @@ trace-events-y += util/trace-events
 trace-events-y += crypto/trace-events
 trace-events-y += io/trace-events
 trace-events-y += migration/trace-events
+trace-events-y += block/trace-events
diff --git a/block/trace-events b/block/trace-events
new file mode 100644
index 000..354967e
--- /dev/null
+++ b/block/trace-events
@@ -0,0 +1,116 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# block.c
+bdrv_open_common(void *bs, const char *filename, int flags, const char 
*format_name) "bs %p filename \"%s\" flags %#x format_name \"%s\""
+bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d"
+
+# block/block-backend.c
+blk_co_preadv(void *blk, void *bs, int64_t offset, unsigned int bytes, int 
flags) "blk %p bs %p offset %"PRId64" bytes %u flags %x"
+blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int 
flags) "blk %p bs %p offset %"PRId64" bytes %u flags %x"
+
+# block/io.c
+bdrv_aio_discard(void *bs, int64_t sector_num, int nb_sectors, void *opaque) 
"bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p"
+bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs 
%p sector_num %"PRId64" nb_sectors %d opaque %p"
+bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void *opaque) 
"bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num 
%"PRId64" nb_sectors %d"
+bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num 
%"PRId64" nb_sectors %d"
+bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs %p 
offset %"PRId64" count %d flags %#x"
+bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t 
cluster_offset, unsigned int cluster_bytes) "bs %p offset %"PRId64" bytes %u 
cluster_offset %"PRId64" cluster_bytes %u"
+
+# block/stream.c
+stream_one_iteration(void *s, int64_t sector_num, int nb_sectors, int 
is_allocated) "s %p sector_num %"PRId64" nb_sectors %d is_allocated %d"
+stream_start(void *bs, void *base, void *s, void *co, void *opaque) "bs %p 
base %p s %p co %p opaque %p"
+
+# block/commit.c
+commit_one_iteration(void *s, int64_t sector_num, int nb_sectors, int 
is_allocated) "s %p sector_num %"PRId64" nb_sectors %d is_allocated %d"
+commit_start(void *bs, void *base, void *top, void *s, void *co, void *opaque) 
"bs %p base %p top %p s %p co %p opaque %p"
+
+# block/mirror.c
+mirror_start(void *bs, void *s, void *co, void *opaque) "bs %p s %p co %p 
opaque %p"
+mirror_restart_iter(void *s, int64_t cnt) "s %p dirty count %"PRId64
+mirror_before_flush(void *s) "s %p"
+mirror_before_drain(void *s, int64_t cnt) "s %p dirty count %"PRId64
+mirror_before_sleep(void *s, int64_t cnt, int synced, uint64_t delay_ns) "s %p 
dirty count %"PRId64" synced %d delay %"PRIu64"ns"
+mirror_one_iteration(void *s, int64_t sector_num, int nb_sectors) "s %p 
sector_num %"PRId64" nb_sectors %d"
+mirror_iteration_done(void *s, int64_t sector_num, int nb_sectors, int ret) "s 
%p sector_num %"PRId64" nb_sectors %d ret %d"
+mirror_yield(void *s, int64_t cnt, int buf_free_count, int in_flight) "s %p 
dirty count %"PRId64" free buffers %d in_flight %d"
+mirror_yield_in_flight(void *s, int64_t sector_num, int in_flight) "s %p 
sector_num %"PRId64" in_flight %d"
+mirror_yield_buf_busy(void *s, int nb_chunks, int in_flight) "s %p requested 
chunks %d in_flight %d"
+mirror_break_buf_busy(void *s, int nb_chunks, int in_flight) "s %p requested 
chunks %d in_flight %d"
+
+# block/backup.c
+backup_do_cow_enter(void *job, int64_t start, int64_t sector_num, int 
nb_sectors) "job %p start %"PRId64" sector_num %"PRId64" nb_sectors %d"
+backup_do_cow_return(void *job, int64_t sector_num, int nb_sectors, int ret) 
"job %p sector_num %"PRId64" nb_sectors %d ret %d"
+backup_do_cow_skip(void *job, int64_t start) "job %p start %"PRId64
+backup_do_cow_process(void *job, int64_t start) "job %p start %"PRId64
+backup_do_cow_read_fail(void *job, int64_t start, int ret) "job %p start 
%"PRId64" ret %d"
+backup_do_cow_write_fail(void *job, int64_t start, int ret) "job %p start 
%"PRId64" ret %d"
+
+# blockdev.c
+qmp_block_job_cancel(void *job) "job %p"
+qmp_block_job_pause(void *job) "job %p"
+qmp_block_job_resume(void *job) "job %p"
+qmp_block_job_compl

[Qemu-devel] [PULL 14/42] trace: split out trace events for hw/audio/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/audio/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-13-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/audio/trace-events | 19 +++
 trace-events  | 18 --
 3 files changed, 20 insertions(+), 18 deletions(-)
 create mode 100644 hw/audio/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 165475c..9d5f64d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -129,3 +129,4 @@ trace-events-y += hw/char/trace-events
 trace-events-y += hw/intc/trace-events
 trace-events-y += hw/net/trace-events
 trace-events-y += hw/virtio/trace-events
+trace-events-y += hw/audio/trace-events
diff --git a/hw/audio/trace-events b/hw/audio/trace-events
new file mode 100644
index 000..796f4a1
--- /dev/null
+++ b/hw/audio/trace-events
@@ -0,0 +1,19 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/audio/cs4231.c
+cs4231_mem_readl_dreg(uint32_t reg, uint32_t ret) "read dreg %d: 0x%02x"
+cs4231_mem_readl_reg(uint32_t reg, uint32_t ret) "read reg %d: 0x%08x"
+cs4231_mem_writel_reg(uint32_t reg, uint32_t old, uint32_t val) "write reg %d: 
0x%08x -> 0x%08x"
+cs4231_mem_writel_dreg(uint32_t reg, uint32_t old, uint32_t val) "write dreg 
%d: 0x%02x -> 0x%02x"
+
+# hw/audio/milkymist-ac97.c
+milkymist_ac97_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_ac97_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_ac97_pulse_irq_crrequest(void) "Pulse IRQ CR request"
+milkymist_ac97_pulse_irq_crreply(void) "Pulse IRQ CR reply"
+milkymist_ac97_pulse_irq_dmaw(void) "Pulse IRQ DMA write"
+milkymist_ac97_pulse_irq_dmar(void) "Pulse IRQ DMA read"
+milkymist_ac97_in_cb(int avail, uint32_t remaining) "avail %d remaining %u"
+milkymist_ac97_in_cb_transferred(int transferred) "transferred %d"
+milkymist_ac97_out_cb(int free, uint32_t remaining) "free %d remaining %u"
+milkymist_ac97_out_cb_transferred(int transferred) "transferred %d"
diff --git a/trace-events b/trace-events
index d2ac199..784da57 100644
--- a/trace-events
+++ b/trace-events
@@ -42,12 +42,6 @@ virtio_balloon_get_config(uint32_t num_pages, uint32_t 
actual) "num_pages: %d ac
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
%"PRIx64" num_pages: %d"
 
-# hw/audio/cs4231.c
-cs4231_mem_readl_dreg(uint32_t reg, uint32_t ret) "read dreg %d: 0x%02x"
-cs4231_mem_readl_reg(uint32_t reg, uint32_t ret) "read reg %d: 0x%08x"
-cs4231_mem_writel_reg(uint32_t reg, uint32_t old, uint32_t val) "write reg %d: 
0x%08x -> 0x%08x"
-cs4231_mem_writel_dreg(uint32_t reg, uint32_t old, uint32_t val) "write dreg 
%d: 0x%02x -> 0x%02x"
-
 # hw/nvram/ds1225y.c
 nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x"
 nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x 
-> 0x%02x"
@@ -595,18 +589,6 @@ megasas_mmio_invalid_readl(unsigned long addr) "addr 0x%lx"
 megasas_mmio_writel(const char *reg, uint32_t val) "reg %s: 0x%x"
 megasas_mmio_invalid_writel(uint32_t addr, uint32_t val) "addr 0x%x: 0x%x"
 
-# hw/audio/milkymist-ac97.c
-milkymist_ac97_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-milkymist_ac97_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-milkymist_ac97_pulse_irq_crrequest(void) "Pulse IRQ CR request"
-milkymist_ac97_pulse_irq_crreply(void) "Pulse IRQ CR reply"
-milkymist_ac97_pulse_irq_dmaw(void) "Pulse IRQ DMA write"
-milkymist_ac97_pulse_irq_dmar(void) "Pulse IRQ DMA read"
-milkymist_ac97_in_cb(int avail, uint32_t remaining) "avail %d remaining %u"
-milkymist_ac97_in_cb_transferred(int transferred) "transferred %d"
-milkymist_ac97_out_cb(int free, uint32_t remaining) "free %d remaining %u"
-milkymist_ac97_out_cb_transferred(int transferred) "transferred %d"
-
 # hw/misc/milkymist-hpdmc.c
 milkymist_hpdmc_memory_read(uint32_t addr, uint32_t value) "addr=%08x 
value=%08x"
 milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) "addr=%08x 
value=%08x"
-- 
2.5.5




[Qemu-devel] [PULL 19/42] trace: split out trace events for hw/display/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/display/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-18-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |   1 +
 hw/display/trace-events | 122 
 trace-events| 121 ---
 3 files changed, 123 insertions(+), 121 deletions(-)
 create mode 100644 hw/display/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index f299ecf..d9c98d9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -134,3 +134,4 @@ trace-events-y += hw/misc/trace-events
 trace-events-y += hw/usb/trace-events
 trace-events-y += hw/scsi/trace-events
 trace-events-y += hw/nvram/trace-events
+trace-events-y += hw/display/trace-events
diff --git a/hw/display/trace-events b/hw/display/trace-events
new file mode 100644
index 000..30bebff
--- /dev/null
+++ b/hw/display/trace-events
@@ -0,0 +1,122 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/display/jazz_led.c
+jazz_led_read(uint64_t addr, uint8_t val) "read addr=0x%"PRIx64": 0x%x"
+jazz_led_write(uint64_t addr, uint8_t new) "write addr=0x%"PRIx64": 0x%x"
+
+# hw/display/xenfb.c
+xenfb_mouse_event(void *opaque, int dx, int dy, int dz, int button_state, int 
abs_pointer_wanted) "%p x %d y %d z %d bs %#x abs %d"
+xenfb_input_connected(void *xendev, int abs_pointer_wanted) "%p abs %d"
+
+# hw/display/g364fb.c
+g364fb_read(uint64_t addr, uint32_t val) "read addr=0x%"PRIx64": 0x%x"
+g364fb_write(uint64_t addr, uint32_t new) "write addr=0x%"PRIx64": 0x%x"
+
+# hw/display/milkymist-tmu2.c
+milkymist_tmu2_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_tmu2_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_tmu2_start(void) "Start TMU"
+milkymist_tmu2_pulse_irq(void) "Pulse IRQ"
+
+# hw/display/milkymist-vgafb.c
+milkymist_vgafb_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_vgafb_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+
+# hw/display/vmware_vga.c
+vmware_value_read(uint32_t index, uint32_t value) "index %d, value 0x%x"
+vmware_value_write(uint32_t index, uint32_t value) "index %d, value 0x%x"
+vmware_palette_read(uint32_t index, uint32_t value) "index %d, value 0x%x"
+vmware_palette_write(uint32_t index, uint32_t value) "index %d, value 0x%x"
+vmware_scratch_read(uint32_t index, uint32_t value) "index %d, value 0x%x"
+vmware_scratch_write(uint32_t index, uint32_t value) "index %d, value 0x%x"
+vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) "%dx%d @ %d bpp"
+
+# hw/display/virtio-gpu.c
+virtio_gpu_features(bool virgl) "virgl %d"
+virtio_gpu_cmd_get_display_info(void) ""
+virtio_gpu_cmd_get_caps(void) ""
+virtio_gpu_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, 
uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t 
h) "res 0x%x, fmt 0x%x, w %d, h %d"
+virtio_gpu_cmd_res_create_3d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t 
h, uint32_t d) "res 0x%x, fmt 0x%x, w %d, h %d, d %d"
+virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, 
uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_cmd_ctx_create(uint32_t ctx, const char *name) "ctx 0x%x, name %s"
+virtio_gpu_cmd_ctx_destroy(uint32_t ctx) "ctx 0x%x"
+virtio_gpu_cmd_ctx_res_attach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
+virtio_gpu_cmd_ctx_res_detach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
+virtio_gpu_cmd_ctx_submit(uint32_t ctx, uint32_t size) "ctx 0x%x, size %d"
+virtio_gpu_update_cursor(uint32_t scanout, uint32_t x, uint32_t y, const char 
*type, uint32_t res) "scanout %d, x %d, y %d, %s, res 0x%x"
+virtio_gpu_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", 
type 0x%x"
+virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64
+
+# hw/display/qxl.c
+disable qxl_interface_set_mm_time(int qid, uint32_t mm_time) "%d %d"
+disable qxl_io_write_vga(int qid, const char *mode, uint32_t addr, uint32_t 
val) "%d %s addr=%u val=%u"
+qxl_create_guest_primary(int qid, uint32_t width, uint32_t height, uint64_t 
mem, uint32_t format, uint32_t position) "%d %ux%u mem=%" PRIx64 " %u,%u"
+qxl_create_guest_primary_rest(int qid, int32_t stride, uint32_t type, uint32_t 
flags) "%d %d,%d,%d"
+qxl_destroy_primary(int qid) "%d"
+qxl_enter_vga_mode(int qid) "%d"
+qxl_exit_vga_mode(int qid) "%d"
+qxl_hard_reset(int qid, int64_t loadvm) "%d loadvm=%"PRId64
+qxl_i

[Qemu-devel] [PULL 15/42] trace: split out trace events for hw/misc/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/misc/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-14-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|  1 +
 hw/misc/trace-events | 52 
 trace-events | 51 ---
 3 files changed, 53 insertions(+), 51 deletions(-)
 create mode 100644 hw/misc/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 9d5f64d..4f0ccbe 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -130,3 +130,4 @@ trace-events-y += hw/intc/trace-events
 trace-events-y += hw/net/trace-events
 trace-events-y += hw/virtio/trace-events
 trace-events-y += hw/audio/trace-events
+trace-events-y += hw/misc/trace-events
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
new file mode 100644
index 000..16b6701
--- /dev/null
+++ b/hw/misc/trace-events
@@ -0,0 +1,52 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/misc/eccmemctl.c
+ecc_mem_writel_mer(uint32_t val) "Write memory enable %08x"
+ecc_mem_writel_mdr(uint32_t val) "Write memory delay %08x"
+ecc_mem_writel_mfsr(uint32_t val) "Write memory fault status %08x"
+ecc_mem_writel_vcr(uint32_t val) "Write slot configuration %08x"
+ecc_mem_writel_dr(uint32_t val) "Write diagnostic %08x"
+ecc_mem_writel_ecr0(uint32_t val) "Write event count 1 %08x"
+ecc_mem_writel_ecr1(uint32_t val) "Write event count 2 %08x"
+ecc_mem_readl_mer(uint32_t ret) "Read memory enable %08x"
+ecc_mem_readl_mdr(uint32_t ret) "Read memory delay %08x"
+ecc_mem_readl_mfsr(uint32_t ret) "Read memory fault status %08x"
+ecc_mem_readl_vcr(uint32_t ret) "Read slot configuration %08x"
+ecc_mem_readl_mfar0(uint32_t ret) "Read memory fault address 0 %08x"
+ecc_mem_readl_mfar1(uint32_t ret) "Read memory fault address 1 %08x"
+ecc_mem_readl_dr(uint32_t ret) "Read diagnostic %08x"
+ecc_mem_readl_ecr0(uint32_t ret) "Read event count 1 %08x"
+ecc_mem_readl_ecr1(uint32_t ret) "Read event count 2 %08x"
+ecc_diag_mem_writeb(uint64_t addr, uint32_t val) "Write diagnostic %"PRId64" = 
%02x"
+ecc_diag_mem_readb(uint64_t addr, uint32_t ret) "Read diagnostic %"PRId64"= 
%02x"
+
+# hw/misc/slavio_misc.c
+slavio_misc_update_irq_raise(void) "Raise IRQ"
+slavio_misc_update_irq_lower(void) "Lower IRQ"
+slavio_set_power_fail(int power_failing, uint8_t config) "Power fail: %d, 
config: %d"
+slavio_cfg_mem_writeb(uint32_t val) "Write config %02x"
+slavio_cfg_mem_readb(uint32_t ret) "Read config %02x"
+slavio_diag_mem_writeb(uint32_t val) "Write diag %02x"
+slavio_diag_mem_readb(uint32_t ret) "Read diag %02x"
+slavio_mdm_mem_writeb(uint32_t val) "Write modem control %02x"
+slavio_mdm_mem_readb(uint32_t ret) "Read modem control %02x"
+slavio_aux1_mem_writeb(uint32_t val) "Write aux1 %02x"
+slavio_aux1_mem_readb(uint32_t ret) "Read aux1 %02x"
+slavio_aux2_mem_writeb(uint32_t val) "Write aux2 %02x"
+slavio_aux2_mem_readb(uint32_t ret) "Read aux2 %02x"
+apc_mem_writeb(uint32_t val) "Write power management %02x"
+apc_mem_readb(uint32_t ret) "Read power management %02x"
+slavio_sysctrl_mem_writel(uint32_t val) "Write system control %08x"
+slavio_sysctrl_mem_readl(uint32_t ret) "Read system control %08x"
+slavio_led_mem_writew(uint32_t val) "Write diagnostic LED %04x"
+slavio_led_mem_readw(uint32_t ret) "Read diagnostic LED %04x"
+
+# hw/misc/milkymist-hpdmc.c
+milkymist_hpdmc_memory_read(uint32_t addr, uint32_t value) "addr=%08x 
value=%08x"
+milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) "addr=%08x 
value=%08x"
+
+# hw/misc/milkymist-pfpu.c
+milkymist_pfpu_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_pfpu_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_pfpu_vectout(uint32_t a, uint32_t b, uint32_t dma_ptr) "a %08x b 
%08x dma_ptr %08x"
+milkymist_pfpu_pulse_irq(void) "Pulse IRQ"
diff --git a/trace-events b/trace-events
index 784da57..c32c9ba 100644
--- a/trace-events
+++ b/trace-events
@@ -46,26 +46,6 @@ virtio_balloon_to_target(uint64_t target, uint32_t 
num_pages) "balloon target: %
 nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x"
 nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x 
-> 0x%02x"
 
-# hw/misc/eccmemctl.c
-ecc_mem_writel_mer(uint32_t val) "Write memory enable %08x"
-ecc_mem_writel_mdr(uint32_t val) "Write memory delay %08x"
-ecc_mem_writel_mfsr(uint32_t val) "Write memory fault status %08x"
-ecc_mem_writel_vcr(uint32_t val) "Write slot configuration %08x"
-ecc_mem_writel_dr(uint32_t val) "Write diagnostic %08x"
-ecc_mem_writel_ecr0(uint32_t val) "Write event count 1 %08x"
-ecc_mem_writel_ecr1(uint32_t val) "Write event count 2 %08x"
-ecc_mem_readl_mer(uint32_t ret) "Read memory enable %08x"
-ecc_mem_readl_mdr(uint32_t ret) "Read memory delay %08x"
-ecc_mem_readl_mfsr(uint32_t ret) "Read memory fault status %08x"
-ecc_mem_readl_vcr(uint

[Qemu-devel] [PULL 18/42] trace: split out trace events for hw/nvram/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/nvram/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-17-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/nvram/trace-events | 10 ++
 trace-events  |  9 -
 3 files changed, 11 insertions(+), 9 deletions(-)
 create mode 100644 hw/nvram/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 06fb4af..f299ecf 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -133,3 +133,4 @@ trace-events-y += hw/audio/trace-events
 trace-events-y += hw/misc/trace-events
 trace-events-y += hw/usb/trace-events
 trace-events-y += hw/scsi/trace-events
+trace-events-y += hw/nvram/trace-events
diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events
new file mode 100644
index 000..325447d
--- /dev/null
+++ b/hw/nvram/trace-events
@@ -0,0 +1,10 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/nvram/ds1225y.c
+nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x"
+nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x 
-> 0x%02x"
+
+# hw/nvram/fw_cfg.c
+fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
+fw_cfg_read(void *s, uint64_t ret) "%p = %"PRIx64
+fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd 
bytes)"
diff --git a/trace-events b/trace-events
index 6bcb529..f91b641 100644
--- a/trace-events
+++ b/trace-events
@@ -42,15 +42,6 @@ virtio_balloon_get_config(uint32_t num_pages, uint32_t 
actual) "num_pages: %d ac
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
%"PRIx64" num_pages: %d"
 
-# hw/nvram/ds1225y.c
-nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x"
-nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x 
-> 0x%02x"
-
-# hw/nvram/fw_cfg.c
-fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
-fw_cfg_read(void *s, uint64_t ret) "%p = %"PRIx64
-fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd 
bytes)"
-
 # hw/display/jazz_led.c
 jazz_led_read(uint64_t addr, uint8_t val) "read addr=0x%"PRIx64": 0x%x"
 jazz_led_write(uint64_t addr, uint8_t new) "write addr=0x%"PRIx64": 0x%x"
-- 
2.5.5




[Qemu-devel] [PULL 27/42] trace: split out trace events for hw/9pfs/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/9pfs/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-26-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|  1 +
 hw/9pfs/trace-events | 47 +++
 trace-events | 46 --
 3 files changed, 48 insertions(+), 46 deletions(-)
 create mode 100644 hw/9pfs/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index e1f5cc6..82bef4d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -142,3 +142,4 @@ trace-events-y += hw/sparc/trace-events
 trace-events-y += hw/sd/trace-events
 trace-events-y += hw/isa/trace-events
 trace-events-y += hw/i386/trace-events
+trace-events-y += hw/9pfs/trace-events
diff --git a/hw/9pfs/trace-events b/hw/9pfs/trace-events
new file mode 100644
index 000..63efa27
--- /dev/null
+++ b/hw/9pfs/trace-events
@@ -0,0 +1,47 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/9pfs/virtio-9p.c
+v9fs_rerror(uint16_t tag, uint8_t id, int err) "tag %d id %d err %d"
+v9fs_version(uint16_t tag, uint8_t id, int32_t msize, char* version) "tag %d 
id %d msize %d version %s"
+v9fs_version_return(uint16_t tag, uint8_t id, int32_t msize, char* version) 
"tag %d id %d msize %d version %s"
+v9fs_attach(uint16_t tag, uint8_t id, int32_t fid, int32_t afid, char* uname, 
char* aname) "tag %u id %u fid %d afid %d uname %s aname %s"
+v9fs_attach_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, 
int64_t path) "tag %d id %d type %d version %d path %"PRId64
+v9fs_stat(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d"
+v9fs_stat_return(uint16_t tag, uint8_t id, int32_t mode, int32_t atime, 
int32_t mtime, int64_t length) "tag %d id %d stat={mode %d atime %d mtime %d 
length %"PRId64"}"
+v9fs_getattr(uint16_t tag, uint8_t id, int32_t fid, uint64_t request_mask) 
"tag %d id %d fid %d request_mask %"PRIu64
+v9fs_getattr_return(uint16_t tag, uint8_t id, uint64_t result_mask, uint32_t 
mode, uint32_t uid, uint32_t gid) "tag %d id %d getattr={result_mask %"PRId64" 
mode %u uid %u gid %u}"
+v9fs_walk(uint16_t tag, uint8_t id, int32_t fid, int32_t newfid, uint16_t 
nwnames) "tag %d id %d fid %d newfid %d nwnames %d"
+v9fs_walk_return(uint16_t tag, uint8_t id, uint16_t nwnames, void* qids) "tag 
%d id %d nwnames %d qids %p"
+v9fs_open(uint16_t tag, uint8_t id, int32_t fid, int32_t mode) "tag %d id %d 
fid %d mode %d"
+v9fs_open_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, 
int64_t path, int iounit) "tag %d id %d qid={type %d version %d path %"PRId64"} 
iounit %d"
+v9fs_lcreate(uint16_t tag, uint8_t id, int32_t dfid, int32_t flags, int32_t 
mode, uint32_t gid) "tag %d id %d dfid %d flags %d mode %d gid %u"
+v9fs_lcreate_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, 
int64_t path, int32_t iounit) "tag %d id %d qid={type %d version %d path 
%"PRId64"} iounit %d"
+v9fs_fsync(uint16_t tag, uint8_t id, int32_t fid, int datasync) "tag %d id %d 
fid %d datasync %d"
+v9fs_clunk(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d"
+v9fs_read(uint16_t tag, uint8_t id, int32_t fid, uint64_t off, uint32_t 
max_count) "tag %d id %d fid %d off %"PRIu64" max_count %u"
+v9fs_read_return(uint16_t tag, uint8_t id, int32_t count, ssize_t err) "tag %d 
id %d count %d err %zd"
+v9fs_readdir(uint16_t tag, uint8_t id, int32_t fid, uint64_t offset, uint32_t 
max_count) "tag %d id %d fid %d offset %"PRIu64" max_count %u"
+v9fs_readdir_return(uint16_t tag, uint8_t id, uint32_t count, ssize_t retval) 
"tag %d id %d count %u retval %zd"
+v9fs_write(uint16_t tag, uint8_t id, int32_t fid, uint64_t off, uint32_t 
count, int cnt) "tag %d id %d fid %d off %"PRIu64" count %u cnt %d"
+v9fs_write_return(uint16_t tag, uint8_t id, int32_t total, ssize_t err) "tag 
%d id %d total %d err %zd"
+v9fs_create(uint16_t tag, uint8_t id, int32_t fid, char* name, int32_t perm, 
int8_t mode) "tag %d id %d fid %d name %s perm %d mode %d"
+v9fs_create_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, 
int64_t path, int iounit) "tag %d id %d qid={type %d version %d path %"PRId64"} 
iounit %d"
+v9fs_symlink(uint16_t tag, uint8_t id, int32_t fid,  char* name, char* 
symname, uint32_t gid) "tag %d id %d fid %d name %s symname %s gid %u"
+v9fs_symlink_return(uint16_t tag, uint8_t id, int8_t type, int32_t version, 
int64_t path) "tag %d id %d qid={type %d version %d path %"PRId64"}"
+v9fs_flush(uint16_t tag, uint8_t id, int16_t flush_tag) "tag %d id %d 
flush_tag %d"
+v9fs_link(uint16_t tag, uint8_t id, int32_t dfid, int32_t oldfid, char* name) 
"tag %d id %d dfid %d oldfid %d name %s"
+v9fs_remove(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d"
+v9fs_wstat(uint16_t tag, uint8_t id, int32_t fid, int32_t mode, int32_t atime, 
int32_t mtime) "tag %u id %u fid %d stat={mode %d atime %d mtime %d}"
+v9fs_mknod(uint16_t tag, uint8_

[Qemu-devel] [PULL 16/42] trace: split out trace events for hw/usb/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/usb/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-15-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |   1 +
 hw/usb/trace-events | 268 
 trace-events| 267 ---
 3 files changed, 269 insertions(+), 267 deletions(-)
 create mode 100644 hw/usb/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 4f0ccbe..e0e6084 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -131,3 +131,4 @@ trace-events-y += hw/net/trace-events
 trace-events-y += hw/virtio/trace-events
 trace-events-y += hw/audio/trace-events
 trace-events-y += hw/misc/trace-events
+trace-events-y += hw/usb/trace-events
diff --git a/hw/usb/trace-events b/hw/usb/trace-events
new file mode 100644
index 000..ac2d951
--- /dev/null
+++ b/hw/usb/trace-events
@@ -0,0 +1,268 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/usb/core.c
+usb_packet_state_change(int bus, const char *port, int ep, void *p, const char 
*o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s -> %s"
+usb_packet_state_fault(int bus, const char *port, int ep, void *p, const char 
*o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s, expected %s"
+
+# hw/usb/bus.c
+usb_port_claim(int bus, const char *port) "bus %d, port %s"
+usb_port_attach(int bus, const char *port, const char *devspeed, const char 
*portspeed) "bus %d, port %s, devspeed %s, portspeed %s"
+usb_port_detach(int bus, const char *port) "bus %d, port %s"
+usb_port_release(int bus, const char *port) "bus %d, port %s"
+
+# hw/usb/hcd-ohci.c
+usb_ohci_iso_td_read_failed(uint32_t addr) "ISO_TD read error at %x"
+usb_ohci_iso_td_head(uint32_t head, uint32_t tail, uint32_t flags, uint32_t 
bp, uint32_t next, uint32_t be, uint32_t framenum, uint32_t startframe, 
uint32_t framecount, int rel_frame_num) "ISO_TD ED head 0x%.8x tailp 
0x%.8x\n0x%.8x 0x%.8x 0x%.8x 0x%.8x\nframe_number 0x%.8x starting_frame 
0x%.8x\nframe_count  0x%.8x relative %d"
+usb_ohci_iso_td_head_offset(uint32_t o0, uint32_t o1, uint32_t o2, uint32_t 
o3, uint32_t o4, uint32_t o5, uint32_t o6, uint32_t o7) "0x%.8x 0x%.8x 0x%.8x 
0x%.8x 0x%.8x 0x%.8x 0x%.8x 0x%.8x"
+usb_ohci_iso_td_relative_frame_number_neg(int rel) "ISO_TD R=%d < 0"
+usb_ohci_iso_td_relative_frame_number_big(int rel, int count) "ISO_TD R=%d > 
FC=%d"
+usb_ohci_iso_td_bad_direction(int dir) "Bad direction %d"
+usb_ohci_iso_td_bad_bp_be(uint32_t bp, uint32_t be) "ISO_TD bp 0x%.8x be 
0x%.8x"
+usb_ohci_iso_td_bad_cc_not_accessed(uint32_t start, uint32_t next) "ISO_TD cc 
!= not accessed 0x%.8x 0x%.8x"
+usb_ohci_iso_td_bad_cc_overrun(uint32_t start, uint32_t next) "ISO_TD 
start_offset=0x%.8x > next_offset=0x%.8x"
+usb_ohci_iso_td_so(uint32_t so, uint32_t eo, uint32_t s, uint32_t e, const 
char *str, ssize_t len, int ret) "0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s 
len %zu ret %d"
+usb_ohci_iso_td_data_overrun(int ret, ssize_t len) "DataOverrun %d > %zu"
+usb_ohci_iso_td_data_underrun(int ret) "DataUnderrun %d"
+usb_ohci_iso_td_nak(int ret) "got NAK/STALL %d"
+usb_ohci_iso_td_bad_response(int ret) "Bad device response %d"
+usb_ohci_port_attach(int index) "port #%d"
+usb_ohci_port_detach(int index) "port #%d"
+usb_ohci_port_wakeup(int index) "port #%d"
+usb_ohci_port_suspend(int index) "port #%d"
+usb_ohci_port_reset(int index) "port #%d"
+usb_ohci_remote_wakeup(const char *s) "%s: SUSPEND->RESUME"
+usb_ohci_reset(const char *s) "%s"
+usb_ohci_start(const char *s) "%s: USB Operational"
+usb_ohci_resume(const char *s) "%s: USB Resume"
+usb_ohci_stop(const char *s) "%s: USB Suspended"
+usb_ohci_exit(const char *s) "%s"
+usb_ohci_set_ctl(const char *s, uint32_t new_state) "%s: new state 0x%x"
+usb_ohci_td_underrun(void) ""
+usb_ohci_td_dev_error(void) ""
+usb_ohci_td_nak(void) ""
+usb_ohci_td_stall(void) ""
+usb_ohci_td_babble(void) ""
+usb_ohci_td_bad_device_response(int rc) "%d"
+usb_ohci_td_read_error(uint32_t addr) "TD read error at %x"
+usb_ohci_td_bad_direction(int dir) "Bad direction %d"
+usb_ohci_td_skip_async(void) ""
+usb_ohci_td_pkt_hdr(uint32_t addr, int64_t pktlen, int64_t len, const char *s, 
int flag_r, uint32_t cbp, uint32_t be) " TD @ 0x%.8x %" PRId64 " of %" PRId64 " 
bytes %s r=%d cbp=0x%.8x be=0x%.8x"
+usb_ohci_td_pkt_short(const char *dir, const char *buf) "%s data: %s"
+usb_ohci_td_pkt_full(const char *dir, const char *buf) "%s data: %s"
+usb_ohci_td_too_many_pending(void) ""
+usb_ohci_td_packet_status(int status) "status=%d"
+usb_ohci_ed_read_error(uint32_t addr) "ED read error at %x"
+usb_ohci_ed_pkt(uint32_t cur, int h, int c, uint32_t head, uint32_t tail, 
uint32_t next) "ED @ 0x%.8x h=%u c=%u\n  head=0x%.8x tailp=0x%.8x next=0x%.8x"
+usb_ohci_ed_pkt_flags(uint32_t fa, uint32_t en, uint32_t d, int s, int k, int 
f, uint32_t mps) "fa=%u en=%u d=%u s=%u k=%u f=%u m

[Qemu-devel] [PULL 24/42] trace: split out trace events for hw/sd/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/sd/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-23-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs  | 1 +
 hw/sd/trace-events | 5 +
 trace-events   | 4 
 3 files changed, 6 insertions(+), 4 deletions(-)
 create mode 100644 hw/sd/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index e435e84..175af1c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -139,3 +139,4 @@ trace-events-y += hw/input/trace-events
 trace-events-y += hw/timer/trace-events
 trace-events-y += hw/dma/trace-events
 trace-events-y += hw/sparc/trace-events
+trace-events-y += hw/sd/trace-events
diff --git a/hw/sd/trace-events b/hw/sd/trace-events
new file mode 100644
index 000..b580a0f
--- /dev/null
+++ b/hw/sd/trace-events
@@ -0,0 +1,5 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/sd/milkymist-memcard.c
+milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
diff --git a/trace-events b/trace-events
index 7c927b9..5fa6d54 100644
--- a/trace-events
+++ b/trace-events
@@ -57,10 +57,6 @@ spice_vmc_register_interface(void *scd) "spice vmc 
registered interface %p"
 spice_vmc_unregister_interface(void *scd) "spice vmc unregistered interface %p"
 spice_vmc_event(int event) "spice vmc event %d"
 
-# hw/sd/milkymist-memcard.c
-milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-
 # hw/isa/pc87312.c
 pc87312_io_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
 pc87312_io_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
-- 
2.5.5




[Qemu-devel] [PULL 20/42] trace: split out trace events for hw/input/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/input/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-19-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/input/trace-events | 25 +
 trace-events  | 24 
 3 files changed, 26 insertions(+), 24 deletions(-)
 create mode 100644 hw/input/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index d9c98d9..5025512 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -135,3 +135,4 @@ trace-events-y += hw/usb/trace-events
 trace-events-y += hw/scsi/trace-events
 trace-events-y += hw/nvram/trace-events
 trace-events-y += hw/display/trace-events
+trace-events-y += hw/input/trace-events
diff --git a/hw/input/trace-events b/hw/input/trace-events
new file mode 100644
index 000..00fcec1
--- /dev/null
+++ b/hw/input/trace-events
@@ -0,0 +1,25 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/input/ps2.c
+ps2_put_keycode(void *opaque, int keycode) "%p keycode %d"
+ps2_read_data(void *opaque) "%p"
+ps2_set_ledstate(void *s, int ledstate) "%p ledstate %d"
+ps2_reset_keyboard(void *s) "%p"
+ps2_write_keyboard(void *opaque, int val) "%p val %d"
+ps2_keyboard_set_translation(void *opaque, int mode) "%p mode %d"
+ps2_mouse_send_packet(void *s, int dx1, int dy1, int dz1, int b) "%p x %d y %d 
z %d bs %#x"
+ps2_mouse_event_disabled(void *opaque, int dx, int dy, int dz, int 
buttons_state, int mouse_dx, int mouse_dy, int mouse_dz) "%p x %d y %d z %d bs 
%#x mx %d my %d mz %d "
+ps2_mouse_event(void *opaque, int dx, int dy, int dz, int buttons_state, int 
mouse_dx, int mouse_dy, int mouse_dz) "%p x %d y %d z %d bs %#x mx %d my %d mz 
%d "
+ps2_mouse_fake_event(void *opaque) "%p"
+ps2_write_mouse(void *opaque, int val) "%p val %d"
+ps2_kbd_reset(void *opaque) "%p"
+ps2_mouse_reset(void *opaque) "%p"
+ps2_kbd_init(void *s) "%p"
+ps2_mouse_init(void *s) "%p"
+
+# hw/input/milkymist-softusb.c
+milkymist_softusb_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_softusb_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_softusb_mevt(uint8_t m) "m %d"
+milkymist_softusb_kevt(uint8_t m) "m %d"
+milkymist_softusb_pulse_irq(void) "Pulse IRQ"
diff --git a/trace-events b/trace-events
index c4a1c68..7f63d5b 100644
--- a/trace-events
+++ b/trace-events
@@ -42,23 +42,6 @@ virtio_balloon_get_config(uint32_t num_pages, uint32_t 
actual) "num_pages: %d ac
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
%"PRIx64" num_pages: %d"
 
-# hw/input/ps2.c
-ps2_put_keycode(void *opaque, int keycode) "%p keycode %d"
-ps2_read_data(void *opaque) "%p"
-ps2_set_ledstate(void *s, int ledstate) "%p ledstate %d"
-ps2_reset_keyboard(void *s) "%p"
-ps2_write_keyboard(void *opaque, int val) "%p val %d"
-ps2_keyboard_set_translation(void *opaque, int mode) "%p mode %d"
-ps2_mouse_send_packet(void *s, int dx1, int dy1, int dz1, int b) "%p x %d y %d 
z %d bs %#x"
-ps2_mouse_event_disabled(void *opaque, int dx, int dy, int dz, int 
buttons_state, int mouse_dx, int mouse_dy, int mouse_dz) "%p x %d y %d z %d bs 
%#x mx %d my %d mz %d "
-ps2_mouse_event(void *opaque, int dx, int dy, int dz, int buttons_state, int 
mouse_dx, int mouse_dy, int mouse_dz) "%p x %d y %d z %d bs %#x mx %d my %d mz 
%d "
-ps2_mouse_fake_event(void *opaque) "%p"
-ps2_write_mouse(void *opaque, int val) "%p val %d"
-ps2_kbd_reset(void *opaque) "%p"
-ps2_mouse_reset(void *opaque) "%p"
-ps2_kbd_init(void *s) "%p"
-ps2_mouse_init(void *s) "%p"
-
 # hw/timer/slavio_timer.c
 slavio_timer_get_out(uint64_t limit, uint32_t counthigh, uint32_t count) 
"limit %"PRIx64" count %x%08x"
 slavio_timer_irq(uint32_t counthigh, uint32_t count) "callback: count %x%08x"
@@ -146,13 +129,6 @@ lm32_timer_irq_state(int level) "irq state %d"
 milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
 milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
 
-# hw/input/milkymist-softusb.c
-milkymist_softusb_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-milkymist_softusb_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-milkymist_softusb_mevt(uint8_t m) "m %d"
-milkymist_softusb_kevt(uint8_t m) "m %d"
-milkymist_softusb_pulse_irq(void) "Pulse IRQ"
-
 # hw/timer/milkymist-sysctl.c
 milkymist_sysctl_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
 milkymist_sysctl_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
-- 
2.5.5




[Qemu-devel] [PULL 21/42] trace: split out trace events for hw/timer/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/timer/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-20-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/timer/trace-events | 51 +++
 trace-events  | 50 --
 3 files changed, 52 insertions(+), 50 deletions(-)
 create mode 100644 hw/timer/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 5025512..fbd8454 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -136,3 +136,4 @@ trace-events-y += hw/scsi/trace-events
 trace-events-y += hw/nvram/trace-events
 trace-events-y += hw/display/trace-events
 trace-events-y += hw/input/trace-events
+trace-events-y += hw/timer/trace-events
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
new file mode 100644
index 000..19db4bf
--- /dev/null
+++ b/hw/timer/trace-events
@@ -0,0 +1,51 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/timer/slavio_timer.c
+slavio_timer_get_out(uint64_t limit, uint32_t counthigh, uint32_t count) 
"limit %"PRIx64" count %x%08x"
+slavio_timer_irq(uint32_t counthigh, uint32_t count) "callback: count %x%08x"
+slavio_timer_mem_readl_invalid(uint64_t addr) "invalid read address %"PRIx64
+slavio_timer_mem_readl(uint64_t addr, uint32_t ret) "read %"PRIx64" = %08x"
+slavio_timer_mem_writel(uint64_t addr, uint32_t val) "write %"PRIx64" = %08x"
+slavio_timer_mem_writel_limit(unsigned int timer_index, uint64_t count) 
"processor %d user timer set to %016"PRIx64
+slavio_timer_mem_writel_counter_invalid(void) "not user timer"
+slavio_timer_mem_writel_status_start(unsigned int timer_index) "processor %d 
user timer started"
+slavio_timer_mem_writel_status_stop(unsigned int timer_index) "processor %d 
user timer stopped"
+slavio_timer_mem_writel_mode_user(unsigned int timer_index) "processor %d 
changed from counter to user timer"
+slavio_timer_mem_writel_mode_counter(unsigned int timer_index) "processor %d 
changed from user timer to counter"
+slavio_timer_mem_writel_mode_invalid(void) "not system timer"
+slavio_timer_mem_writel_invalid(uint64_t addr) "invalid write address %"PRIx64
+
+# hw/timer/grlib_gptimer.c
+grlib_gptimer_enable(int id, uint32_t count) "timer:%d set count 0x%x and run"
+grlib_gptimer_disabled(int id, uint32_t config) "timer:%d Timer disable config 
0x%x"
+grlib_gptimer_restart(int id, uint32_t reload) "timer:%d reload val: 0x%x"
+grlib_gptimer_set_scaler(uint32_t scaler, uint32_t freq) "scaler:0x%x freq: 
0x%x"
+grlib_gptimer_hit(int id) "timer:%d HIT"
+grlib_gptimer_readl(int id, uint64_t addr, uint32_t val) "timer:%d addr 
0x%"PRIx64" 0x%x"
+grlib_gptimer_writel(int id, uint64_t addr, uint32_t val) "timer:%d addr 
0x%"PRIx64" 0x%x"
+
+# hw/timer/lm32_timer.c
+lm32_timer_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 
0x%08x"
+lm32_timer_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 
0x%08x"
+lm32_timer_hit(void) "timer hit"
+lm32_timer_irq_state(int level) "irq state %d"
+
+# hw/timer/milkymist-sysctl.c
+milkymist_sysctl_memory_read(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_sysctl_memory_write(uint32_t addr, uint32_t value) "addr %08x value 
%08x"
+milkymist_sysctl_icap_write(uint32_t value) "value %08x"
+milkymist_sysctl_start_timer0(void) "Start timer0"
+milkymist_sysctl_stop_timer0(void) "Stop timer0"
+milkymist_sysctl_start_timer1(void) "Start timer1"
+milkymist_sysctl_stop_timer1(void) "Stop timer1"
+milkymist_sysctl_pulse_irq_timer0(void) "Pulse IRQ Timer0"
+milkymist_sysctl_pulse_irq_timer1(void) "Pulse IRQ Timer1"
+
+# hw/timer/aspeed_timer.c
+aspeed_timer_ctrl_enable(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_ctrl_external_clock(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_ctrl_overflow_interrupt(uint8_t i, bool enable) "Timer %" PRIu8 
": %d"
+aspeed_timer_ctrl_pulse_enable(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
+aspeed_timer_set_ctrl2(uint32_t value) "Value: 0x%" PRIx32
+aspeed_timer_set_value(int timer, int reg, uint32_t value) "Timer %d register 
%d: 0x%" PRIx32
+aspeed_timer_read(uint64_t offset, unsigned size, uint64_t value) "From 0x%" 
PRIx64 ": of size %u: 0x%" PRIx64
diff --git a/trace-events b/trace-events
index 7f63d5b..cdfd7ee 100644
--- a/trace-events
+++ b/trace-events
@@ -42,21 +42,6 @@ virtio_balloon_get_config(uint32_t num_pages, uint32_t 
actual) "num_pages: %d ac
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
%"PRIx64" num_pages: %d"
 
-# hw/timer/slavio_timer.c
-slavio_timer_get_out(uint64_t limit, uint32_t counthigh, uint32_t count) 
"limit %"PRIx64" count %x%08x"
-slavio_timer_irq(uint32_t counthigh, uint32_t count) "callback: count %x%08x"
-slavio_timer_mem_readl_invalid(

[Qemu-devel] [PULL 34/42] trace: split out trace events for hw/alpha/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/alpha/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-33-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs | 1 +
 hw/alpha/trace-events | 4 
 trace-events  | 3 ---
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 hw/alpha/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index cc0e1cc..c5e03bc 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -149,3 +149,4 @@ trace-events-y += hw/s390x/trace-events
 trace-events-y += hw/vfio/trace-events
 trace-events-y += hw/acpi/trace-events
 trace-events-y += hw/arm/trace-events
+trace-events-y += hw/alpha/trace-events
diff --git a/hw/alpha/trace-events b/hw/alpha/trace-events
new file mode 100644
index 000..7d52b5d
--- /dev/null
+++ b/hw/alpha/trace-events
@@ -0,0 +1,4 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/alpha/pci.c
+alpha_pci_iack_write(void) ""
diff --git a/trace-events b/trace-events
index 6972f28..e610e4a 100644
--- a/trace-events
+++ b/trace-events
@@ -239,9 +239,6 @@ cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d 
state to %" PRIu8
 cpu_halt(int cpu_index) "halting cpu %d"
 cpu_unhalt(int cpu_index) "unhalting cpu %d"
 
-# hw/alpha/pci.c
-alpha_pci_iack_write(void) ""
-
 # audio/alsaaudio.c
 alsa_revents(int revents) "revents = %d"
 alsa_pollout(int i, int fd) "i = %d fd = %d"
-- 
2.5.5




[Qemu-devel] [PULL 22/42] trace: split out trace events for hw/dma/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/dma/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-21-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |  1 +
 hw/dma/trace-events | 32 
 trace-events| 31 ---
 3 files changed, 33 insertions(+), 31 deletions(-)
 create mode 100644 hw/dma/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index fbd8454..b05f290 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -137,3 +137,4 @@ trace-events-y += hw/nvram/trace-events
 trace-events-y += hw/display/trace-events
 trace-events-y += hw/input/trace-events
 trace-events-y += hw/timer/trace-events
+trace-events-y += hw/dma/trace-events
diff --git a/hw/dma/trace-events b/hw/dma/trace-events
new file mode 100644
index 000..d8a5674
--- /dev/null
+++ b/hw/dma/trace-events
@@ -0,0 +1,32 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/dma/rc4030.c
+jazzio_read(uint64_t addr, uint32_t ret) "read reg[0x%"PRIx64"] = 0x%x"
+jazzio_write(uint64_t addr, uint32_t val) "write reg[0x%"PRIx64"] = 0x%x"
+rc4030_read(uint64_t addr, uint32_t ret) "read reg[0x%"PRIx64"] = 0x%x"
+rc4030_write(uint64_t addr, uint32_t val) "write reg[0x%"PRIx64"] = 0x%x"
+
+# hw/dma/sparc32_dma.c
+ledma_memory_read(uint64_t addr) "DMA read addr 0x%"PRIx64
+ledma_memory_write(uint64_t addr) "DMA write addr 0x%"PRIx64
+sparc32_dma_set_irq_raise(void) "Raise IRQ"
+sparc32_dma_set_irq_lower(void) "Lower IRQ"
+espdma_memory_read(uint32_t addr) "DMA read addr 0x%08x"
+espdma_memory_write(uint32_t addr) "DMA write addr 0x%08x"
+sparc32_dma_mem_readl(uint64_t addr, uint32_t ret) "read dmareg %"PRIx64": 
0x%08x"
+sparc32_dma_mem_writel(uint64_t addr, uint32_t old, uint32_t val) "write 
dmareg %"PRIx64": 0x%08x -> 0x%08x"
+sparc32_dma_enable_raise(void) "Raise DMA enable"
+sparc32_dma_enable_lower(void) "Lower DMA enable"
+
+# hw/dma/sun4m_iommu.c
+sun4m_iommu_mem_readl(uint64_t addr, uint32_t ret) "read reg[%"PRIx64"] = %x"
+sun4m_iommu_mem_writel(uint64_t addr, uint32_t val) "write reg[%"PRIx64"] = %x"
+sun4m_iommu_mem_writel_ctrl(uint64_t iostart) "iostart = %"PRIx64
+sun4m_iommu_mem_writel_tlbflush(uint32_t val) "tlb flush %x"
+sun4m_iommu_mem_writel_pgflush(uint32_t val) "page flush %x"
+sun4m_iommu_page_get_flags(uint64_t pa, uint64_t iopte, uint32_t ret) "get 
flags addr %"PRIx64" => pte %"PRIx64", *pte = %x"
+sun4m_iommu_translate_pa(uint64_t addr, uint64_t pa, uint32_t iopte) "xlate 
dva %"PRIx64" => pa %"PRIx64" iopte = %x"
+sun4m_iommu_bad_addr(uint64_t addr) "bad addr %"PRIx64
+
+# hw/dma/i8257.c
+i8257_unregistered_dma(int nchan, int dma_pos, int dma_len) "unregistered DMA 
channel used nchan=%d dma_pos=%d dma_len=%d"
diff --git a/trace-events b/trace-events
index cdfd7ee..b87ccb3 100644
--- a/trace-events
+++ b/trace-events
@@ -42,40 +42,12 @@ virtio_balloon_get_config(uint32_t num_pages, uint32_t 
actual) "num_pages: %d ac
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
%"PRIx64" num_pages: %d"
 
-# hw/dma/rc4030.c
-jazzio_read(uint64_t addr, uint32_t ret) "read reg[0x%"PRIx64"] = 0x%x"
-jazzio_write(uint64_t addr, uint32_t val) "write reg[0x%"PRIx64"] = 0x%x"
-rc4030_read(uint64_t addr, uint32_t ret) "read reg[0x%"PRIx64"] = 0x%x"
-rc4030_write(uint64_t addr, uint32_t val) "write reg[0x%"PRIx64"] = 0x%x"
-
-# hw/dma/sparc32_dma.c
-ledma_memory_read(uint64_t addr) "DMA read addr 0x%"PRIx64
-ledma_memory_write(uint64_t addr) "DMA write addr 0x%"PRIx64
-sparc32_dma_set_irq_raise(void) "Raise IRQ"
-sparc32_dma_set_irq_lower(void) "Lower IRQ"
-espdma_memory_read(uint32_t addr) "DMA read addr 0x%08x"
-espdma_memory_write(uint32_t addr) "DMA write addr 0x%08x"
-sparc32_dma_mem_readl(uint64_t addr, uint32_t ret) "read dmareg %"PRIx64": 
0x%08x"
-sparc32_dma_mem_writel(uint64_t addr, uint32_t old, uint32_t val) "write 
dmareg %"PRIx64": 0x%08x -> 0x%08x"
-sparc32_dma_enable_raise(void) "Raise DMA enable"
-sparc32_dma_enable_lower(void) "Lower DMA enable"
-
 # hw/sparc/sun4m.c
 sun4m_cpu_interrupt(unsigned int level) "Set CPU IRQ %d"
 sun4m_cpu_reset_interrupt(unsigned int level) "Reset CPU IRQ %d"
 sun4m_cpu_set_irq_raise(int level) "Raise CPU IRQ %d"
 sun4m_cpu_set_irq_lower(int level) "Lower CPU IRQ %d"
 
-# hw/dma/sun4m_iommu.c
-sun4m_iommu_mem_readl(uint64_t addr, uint32_t ret) "read reg[%"PRIx64"] = %x"
-sun4m_iommu_mem_writel(uint64_t addr, uint32_t val) "write reg[%"PRIx64"] = %x"
-sun4m_iommu_mem_writel_ctrl(uint64_t iostart) "iostart = %"PRIx64
-sun4m_iommu_mem_writel_tlbflush(uint32_t val) "tlb flush %x"
-sun4m_iommu_mem_writel_pgflush(uint32_t val) "page flush %x"
-sun4m_iommu_page_get_flags(uint64_t pa, uint64_t iopte, uint32_t ret) "get 
flags addr %"PRIx64" => pte %"PRIx64", *pte = %x"
-sun4m_iommu_translate_pa(uint64_

[Qemu-devel] [PULL 28/42] trace: split out trace events for hw/ppc/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/ppc/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Reviewed-by: Thomas Huth 
Message-id: 1466066426-16657-27-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |  1 +
 hw/ppc/trace-events | 39 +++
 trace-events| 38 --
 3 files changed, 40 insertions(+), 38 deletions(-)
 create mode 100644 hw/ppc/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 82bef4d..388e2e9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -143,3 +143,4 @@ trace-events-y += hw/sd/trace-events
 trace-events-y += hw/isa/trace-events
 trace-events-y += hw/i386/trace-events
 trace-events-y += hw/9pfs/trace-events
+trace-events-y += hw/ppc/trace-events
diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events
new file mode 100644
index 000..6da7135
--- /dev/null
+++ b/hw/ppc/trace-events
@@ -0,0 +1,39 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/ppc/spapr_pci.c
+spapr_pci_msi(const char *msg, uint32_t ca) "%s (cfg=%x)"
+spapr_pci_msi_setup(const char *name, unsigned vector, uint64_t addr) 
"dev\"%s\" vector %u, addr=%"PRIx64
+spapr_pci_rtas_ibm_change_msi(unsigned cfg, unsigned func, unsigned req, 
unsigned first) "cfgaddr %x func %u, requested %u, first irq %u"
+spapr_pci_rtas_ibm_query_interrupt_source_number(unsigned ioa, unsigned intr) 
"queries for #%u, IRQ%u"
+spapr_pci_msi_write(uint64_t addr, uint64_t data, uint32_t dt_irq) 
"@%"PRIx64"<=%"PRIx64" IRQ %u"
+spapr_pci_lsi_set(const char *busname, int pin, uint32_t irq) "%s PIN%d IRQ %u"
+spapr_pci_msi_retry(unsigned config_addr, unsigned req_num, unsigned max_irqs) 
"Guest device at %x asked %u, have only %u"
+
+# hw/ppc/spapr.c
+spapr_cas_failed(unsigned long n) "DT diff buffer is too small: %ld bytes"
+spapr_cas_continue(unsigned long n) "Copy changes to the guest: %ld bytes"
+
+# hw/ppc/spapr_hcall.c
+spapr_cas_pvr_try(uint32_t pvr) "%x"
+spapr_cas_pvr(uint32_t cur_pvr, bool cpu_match, uint32_t new_pvr, uint64_t 
pcr) "current=%x, cpu_match=%u, new=%x, compat flags=%"PRIx64
+
+# hw/ppc/spapr_iommu.c
+spapr_iommu_put(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t ret) 
"liobn=%"PRIx64" ioba=0x%"PRIx64" tce=0x%"PRIx64" ret=%"PRId64
+spapr_iommu_get(uint64_t liobn, uint64_t ioba, uint64_t ret, uint64_t tce) 
"liobn=%"PRIx64" ioba=0x%"PRIx64" ret=%"PRId64" tce=0x%"PRIx64
+spapr_iommu_indirect(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t 
iobaN, uint64_t tceN, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" 
tcelist=0x%"PRIx64" iobaN=0x%"PRIx64" tceN=0x%"PRIx64" ret=%"PRId64
+spapr_iommu_stuff(uint64_t liobn, uint64_t ioba, uint64_t tce_value, uint64_t 
npages, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tcevalue=0x%"PRIx64" 
npages=%"PRId64" ret=%"PRId64
+spapr_iommu_pci_put(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t ret) 
"liobn=%"PRIx64" ioba=0x%"PRIx64" tce=0x%"PRIx64" ret=%"PRId64
+spapr_iommu_pci_get(uint64_t liobn, uint64_t ioba, uint64_t ret, uint64_t tce) 
"liobn=%"PRIx64" ioba=0x%"PRIx64" ret=%"PRId64" tce=0x%"PRIx64
+spapr_iommu_pci_indirect(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t 
iobaN, uint64_t tceN, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" 
tcelist=0x%"PRIx64" iobaN=0x%"PRIx64" tceN=0x%"PRIx64" ret=%"PRId64
+spapr_iommu_pci_stuff(uint64_t liobn, uint64_t ioba, uint64_t tce_value, 
uint64_t npages, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" 
tcevalue=0x%"PRIx64" npages=%"PRId64" ret=%"PRId64
+spapr_iommu_xlate(uint64_t liobn, uint64_t ioba, uint64_t tce, unsigned perm, 
unsigned pgsize) "liobn=%"PRIx64" 0x%"PRIx64" -> 0x%"PRIx64" perm=%u mask=%x"
+spapr_iommu_new_table(uint64_t liobn, void *table, int fd) "liobn=%"PRIx64" 
table=%p fd=%d"
+spapr_iommu_pre_save(uint64_t liobn, uint32_t nb, uint64_t offs, uint32_t ps) 
"liobn=%"PRIx64" %"PRIx32" bus_offset=%"PRIx64" ps=%"PRIu32
+spapr_iommu_post_load(uint64_t liobn, uint32_t pre_nb, uint32_t post_nb, 
uint64_t offs, uint32_t ps) "liobn=%"PRIx64" %"PRIx32" => %"PRIx32" 
bus_offset=%"PRIx64" ps=%"PRIu32
+
+# hw/ppc/ppc.c
+ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) 
"adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
+
+# hw/ppc/prep.c
+prep_io_800_writeb(uint32_t addr, uint32_t val) "0x%08" PRIx32 " => 0x%02" 
PRIx32
+prep_io_800_readb(uint32_t addr, uint32_t retval) "0x%08" PRIx32 " <= 0x%02" 
PRIx32
diff --git a/trace-events b/trace-events
index daa4f33..607c9a7 100644
--- a/trace-events
+++ b/trace-events
@@ -184,48 +184,10 @@ qemu_spice_destroy_primary_surface(int qid, uint32_t sid, 
int async) "%d sid=%u
 qemu_spice_wakeup(uint32_t qid) "%d"
 qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint32_t 
bottom) "lr %d -> %d,  tb -> %d -> %d"
 
-# hw/ppc/spapr_pci.c
-spapr_pci_msi(const char *msg, uint32_t ca) "%s (cfg=%x)"
-spapr_pci_msi_setup(const char

[Qemu-devel] [PULL 31/42] trace: split out trace events for hw/vfio/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/vfio/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-30-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|   1 +
 hw/vfio/trace-events | 116 +++
 trace-events | 116 ---
 3 files changed, 117 insertions(+), 116 deletions(-)
 create mode 100644 hw/vfio/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 551e73e..f2753bf 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -146,3 +146,4 @@ trace-events-y += hw/9pfs/trace-events
 trace-events-y += hw/ppc/trace-events
 trace-events-y += hw/pci/trace-events
 trace-events-y += hw/s390x/trace-events
+trace-events-y += hw/vfio/trace-events
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
new file mode 100644
index 000..9da0ff9
--- /dev/null
+++ b/hw/vfio/trace-events
@@ -0,0 +1,116 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/vfio/pci.c
+vfio_intx_interrupt(const char *name, char line) " (%s) Pin %c"
+vfio_intx_eoi(const char *name) " (%s) EOI"
+vfio_intx_enable_kvm(const char *name) " (%s) KVM INTx accel enabled"
+vfio_intx_disable_kvm(const char *name) " (%s) KVM INTx accel disabled"
+vfio_intx_update(const char *name, int new_irq, int target_irq) " (%s) IRQ 
moved %d -> %d"
+vfio_intx_enable(const char *name) " (%s)"
+vfio_intx_disable(const char *name) " (%s)"
+vfio_msi_interrupt(const char *name, int index, uint64_t addr, int data) " 
(%s) vector %d 0x%"PRIx64"/0x%x"
+vfio_msix_vector_do_use(const char *name, int index) " (%s) vector %d used"
+vfio_msix_vector_release(const char *name, int index) " (%s) vector %d 
released"
+vfio_msix_enable(const char *name) " (%s)"
+vfio_msix_pba_disable(const char *name) " (%s)"
+vfio_msix_pba_enable(const char *name) " (%s)"
+vfio_msix_disable(const char *name) " (%s)"
+vfio_msix_fixup(const char *name, int bar, uint64_t start, uint64_t end) " 
(%s) MSI-X region %d mmap fixup [0x%"PRIx64" - 0x%"PRIx64"]"
+vfio_msi_enable(const char *name, int nr_vectors) " (%s) Enabled %d MSI 
vectors"
+vfio_msi_disable(const char *name) " (%s)"
+vfio_pci_load_rom(const char *name, unsigned long size, unsigned long offset, 
unsigned long flags) "Device %s ROM:\n  size: 0x%lx, offset: 0x%lx, flags: 
0x%lx"
+vfio_rom_read(const char *name, uint64_t addr, int size, uint64_t data) " (%s, 
0x%"PRIx64", 0x%x) = 0x%"PRIx64
+vfio_pci_size_rom(const char *name, int size) "%s ROM size 0x%x"
+vfio_vga_write(uint64_t addr, uint64_t data, int size) " (0x%"PRIx64", 
0x%"PRIx64", %d)"
+vfio_vga_read(uint64_t addr, int size, uint64_t data) " (0x%"PRIx64", %d) = 
0x%"PRIx64
+vfio_pci_read_config(const char *name, int addr, int len, int val) " (%s, 
@0x%x, len=0x%x) %x"
+vfio_pci_write_config(const char *name, int addr, int val, int len) " (%s, 
@0x%x, 0x%x, len=0x%x)"
+vfio_msi_setup(const char *name, int pos) "%s PCI MSI CAP @0x%x"
+vfio_msix_early_setup(const char *name, int pos, int table_bar, int offset, 
int entries) "%s PCI MSI-X CAP @0x%x, BAR %d, offset 0x%x, entries %d"
+vfio_check_pcie_flr(const char *name) "%s Supports FLR via PCIe cap"
+vfio_check_pm_reset(const char *name) "%s Supports PM reset"
+vfio_check_af_flr(const char *name) "%s Supports FLR via AF cap"
+vfio_pci_hot_reset(const char *name, const char *type) " (%s) %s"
+vfio_pci_hot_reset_has_dep_devices(const char *name) "%s: hot reset dependent 
devices:"
+vfio_pci_hot_reset_dep_devices(int domain, int bus, int slot, int function, 
int group_id) "\t%04x:%02x:%02x.%x group %d"
+vfio_pci_hot_reset_result(const char *name, const char *result) "%s hot reset: 
%s"
+vfio_populate_device_config(const char *name, unsigned long size, unsigned 
long offset, unsigned long flags) "Device %s config:\n  size: 0x%lx, offset: 
0x%lx, flags: 0x%lx"
+vfio_populate_device_get_irq_info_failure(void) "VFIO_DEVICE_GET_IRQ_INFO 
failure: %m"
+vfio_initfn(const char *name, int group_id) " (%s) group %d"
+vfio_pci_reset(const char *name) " (%s)"
+vfio_pci_reset_flr(const char *name) "%s FLR/VFIO_DEVICE_RESET"
+vfio_pci_reset_pm(const char *name) "%s PCI PM Reset"
+vfio_pci_emulated_vendor_id(const char *name, uint16_t val) "%s %04x"
+vfio_pci_emulated_device_id(const char *name, uint16_t val) "%s %04x"
+vfio_pci_emulated_sub_vendor_id(const char *name, uint16_t val) "%s %04x"
+vfio_pci_emulated_sub_device_id(const char *name, uint16_t val) "%s %04x"
+
+# hw/vfio/pci-quirks.
+vfio_quirk_rom_blacklisted(const char *name, uint16_t vid, uint16_t did) "%s 
%04x:%04x"
+vfio_quirk_generic_window_address_write(const char *name, const char * 
region_name, uint64_t data) "%s %s 0x%"PRIx64
+vfio_quirk_generic_window_data_read(const char *name, const char * 
region_name, uint64_t data) "%s %s 0x%"PRIx64
+vfio_quirk_generic_window_data_write(const char *name, const char * 
region_name, uint64_t data) "%s %s 0x%"PRIx64
+v

[Qemu-devel] [PULL 32/42] trace: split out trace events for hw/acpi/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/acpi/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-31-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|  1 +
 hw/acpi/trace-events | 18 ++
 trace-events | 17 -
 3 files changed, 19 insertions(+), 17 deletions(-)
 create mode 100644 hw/acpi/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index f2753bf..767ffa3 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -147,3 +147,4 @@ trace-events-y += hw/ppc/trace-events
 trace-events-y += hw/pci/trace-events
 trace-events-y += hw/s390x/trace-events
 trace-events-y += hw/vfio/trace-events
+trace-events-y += hw/acpi/trace-events
diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events
new file mode 100644
index 000..e95b218
--- /dev/null
+++ b/hw/acpi/trace-events
@@ -0,0 +1,18 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/acpi/memory_hotplug.c
+mhp_acpi_invalid_slot_selected(uint32_t slot) "0x%"PRIx32
+mhp_acpi_ejecting_invalid_slot(uint32_t slot) "0x%"PRIx32
+mhp_acpi_read_addr_lo(uint32_t slot, uint32_t addr) "slot[0x%"PRIx32"] addr 
lo: 0x%"PRIx32
+mhp_acpi_read_addr_hi(uint32_t slot, uint32_t addr) "slot[0x%"PRIx32"] addr 
hi: 0x%"PRIx32
+mhp_acpi_read_size_lo(uint32_t slot, uint32_t size) "slot[0x%"PRIx32"] size 
lo: 0x%"PRIx32
+mhp_acpi_read_size_hi(uint32_t slot, uint32_t size) "slot[0x%"PRIx32"] size 
hi: 0x%"PRIx32
+mhp_acpi_read_pxm(uint32_t slot, uint32_t pxm) "slot[0x%"PRIx32"] proximity: 
0x%"PRIx32
+mhp_acpi_read_flags(uint32_t slot, uint32_t flags) "slot[0x%"PRIx32"] flags: 
0x%"PRIx32
+mhp_acpi_write_slot(uint32_t slot) "set active slot: 0x%"PRIx32
+mhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "slot[0x%"PRIx32"] OST 
EVENT: 0x%"PRIx32
+mhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "slot[0x%"PRIx32"] OST 
STATUS: 0x%"PRIx32
+mhp_acpi_clear_insert_evt(uint32_t slot) "slot[0x%"PRIx32"] clear insert event"
+mhp_acpi_clear_remove_evt(uint32_t slot) "slot[0x%"PRIx32"] clear remove event"
+mhp_acpi_pc_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm deleted"
+mhp_acpi_pc_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm 
delete failed"
diff --git a/trace-events b/trace-events
index a9bff8a..8b7ffa7 100644
--- a/trace-events
+++ b/trace-events
@@ -228,23 +228,6 @@ memory_region_tb_write(int cpu_index, uint64_t addr, 
uint64_t value, unsigned si
 object_dynamic_cast_assert(const char *type, const char *target, const char 
*file, int line, const char *func) "%s->%s (%s:%d:%s)"
 object_class_dynamic_cast_assert(const char *type, const char *target, const 
char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
 
-#hw/acpi/memory_hotplug.c
-mhp_acpi_invalid_slot_selected(uint32_t slot) "0x%"PRIx32
-mhp_acpi_ejecting_invalid_slot(uint32_t slot) "0x%"PRIx32
-mhp_acpi_read_addr_lo(uint32_t slot, uint32_t addr) "slot[0x%"PRIx32"] addr 
lo: 0x%"PRIx32
-mhp_acpi_read_addr_hi(uint32_t slot, uint32_t addr) "slot[0x%"PRIx32"] addr 
hi: 0x%"PRIx32
-mhp_acpi_read_size_lo(uint32_t slot, uint32_t size) "slot[0x%"PRIx32"] size 
lo: 0x%"PRIx32
-mhp_acpi_read_size_hi(uint32_t slot, uint32_t size) "slot[0x%"PRIx32"] size 
hi: 0x%"PRIx32
-mhp_acpi_read_pxm(uint32_t slot, uint32_t pxm) "slot[0x%"PRIx32"] proximity: 
0x%"PRIx32
-mhp_acpi_read_flags(uint32_t slot, uint32_t flags) "slot[0x%"PRIx32"] flags: 
0x%"PRIx32
-mhp_acpi_write_slot(uint32_t slot) "set active slot: 0x%"PRIx32
-mhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "slot[0x%"PRIx32"] OST 
EVENT: 0x%"PRIx32
-mhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "slot[0x%"PRIx32"] OST 
STATUS: 0x%"PRIx32
-mhp_acpi_clear_insert_evt(uint32_t slot) "slot[0x%"PRIx32"] clear insert event"
-mhp_acpi_clear_remove_evt(uint32_t slot) "slot[0x%"PRIx32"] clear remove event"
-mhp_acpi_pc_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm deleted"
-mhp_acpi_pc_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm 
delete failed"
-
 # target-s390x/kvm.c
 kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
 kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
-- 
2.5.5




[Qemu-devel] [PULL 26/42] trace: split out trace events for hw/i386/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/i386/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-25-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs|  1 +
 hw/i386/trace-events | 12 
 trace-events | 11 ---
 3 files changed, 13 insertions(+), 11 deletions(-)
 create mode 100644 hw/i386/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 764e6fd..e1f5cc6 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -141,3 +141,4 @@ trace-events-y += hw/dma/trace-events
 trace-events-y += hw/sparc/trace-events
 trace-events-y += hw/sd/trace-events
 trace-events-y += hw/isa/trace-events
+trace-events-y += hw/i386/trace-events
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
new file mode 100644
index 000..ea77bc2
--- /dev/null
+++ b/hw/i386/trace-events
@@ -0,0 +1,12 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/i386/xen/xen_platform.c
+xen_platform_log(char *s) "xen platform: %s"
+
+# hw/i386/xen/xen_pvdevice.c
+xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO space 
(address %"PRIx64")"
+xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO space 
(address %"PRIx64")"
+
+# hw/i386/pc.c
+mhp_pc_dimm_assigned_slot(int slot) "0x%d"
+mhp_pc_dimm_assigned_address(uint64_t addr) "0x%"PRIx64
diff --git a/trace-events b/trace-events
index 5cefe28..12be226 100644
--- a/trace-events
+++ b/trace-events
@@ -82,9 +82,6 @@ xen_map_cache(uint64_t phys_addr) "want %#"PRIx64
 xen_remap_bucket(uint64_t index) "index %#"PRIx64
 xen_map_cache_return(void* ptr) "%p"
 
-# hw/i386/xen/xen_platform.c
-xen_platform_log(char *s) "xen platform: %s"
-
 # qemu-coroutine.c
 qemu_coroutine_enter(void *from, void *to, void *opaque) "from %p to %p opaque 
%p"
 qemu_coroutine_yield(void *from, void *to) "from %p to %p"
@@ -333,10 +330,6 @@ memory_region_tb_write(int cpu_index, uint64_t addr, 
uint64_t value, unsigned si
 object_dynamic_cast_assert(const char *type, const char *target, const char 
*file, int line, const char *func) "%s->%s (%s:%d:%s)"
 object_class_dynamic_cast_assert(const char *type, const char *target, const 
char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
 
-# hw/i386/xen/xen_pvdevice.c
-xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO space 
(address %"PRIx64")"
-xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO space 
(address %"PRIx64")"
-
 # hw/pci/pci_host.c
 pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x -> 0x%x"
 pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x <- 0x%x"
@@ -474,10 +467,6 @@ mhp_acpi_clear_remove_evt(uint32_t slot) 
"slot[0x%"PRIx32"] clear remove event"
 mhp_acpi_pc_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm deleted"
 mhp_acpi_pc_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm 
delete failed"
 
-# hw/i386/pc.c
-mhp_pc_dimm_assigned_slot(int slot) "0x%d"
-mhp_pc_dimm_assigned_address(uint64_t addr) "0x%"PRIx64
-
 # target-s390x/kvm.c
 kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
 kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
-- 
2.5.5




[Qemu-devel] [PULL 23/42] trace: split out trace events for hw/sparc/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/sparc/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-22-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/sparc/trace-events | 11 +++
 trace-events  | 10 --
 3 files changed, 12 insertions(+), 10 deletions(-)
 create mode 100644 hw/sparc/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index b05f290..e435e84 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -138,3 +138,4 @@ trace-events-y += hw/display/trace-events
 trace-events-y += hw/input/trace-events
 trace-events-y += hw/timer/trace-events
 trace-events-y += hw/dma/trace-events
+trace-events-y += hw/sparc/trace-events
diff --git a/hw/sparc/trace-events b/hw/sparc/trace-events
new file mode 100644
index 000..ab677a3
--- /dev/null
+++ b/hw/sparc/trace-events
@@ -0,0 +1,11 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/sparc/sun4m.c
+sun4m_cpu_interrupt(unsigned int level) "Set CPU IRQ %d"
+sun4m_cpu_reset_interrupt(unsigned int level) "Reset CPU IRQ %d"
+sun4m_cpu_set_irq_raise(int level) "Raise CPU IRQ %d"
+sun4m_cpu_set_irq_lower(int level) "Lower CPU IRQ %d"
+
+# hw/sparc/leon3.c
+leon3_set_irq(int intno) "Set CPU IRQ %d"
+leon3_reset_irq(int intno) "Reset CPU IRQ %d"
diff --git a/trace-events b/trace-events
index b87ccb3..7c927b9 100644
--- a/trace-events
+++ b/trace-events
@@ -42,12 +42,6 @@ virtio_balloon_get_config(uint32_t num_pages, uint32_t 
actual) "num_pages: %d ac
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
%"PRIx64" num_pages: %d"
 
-# hw/sparc/sun4m.c
-sun4m_cpu_interrupt(unsigned int level) "Set CPU IRQ %d"
-sun4m_cpu_reset_interrupt(unsigned int level) "Reset CPU IRQ %d"
-sun4m_cpu_set_irq_raise(int level) "Raise CPU IRQ %d"
-sun4m_cpu_set_irq_lower(int level) "Lower CPU IRQ %d"
-
 # vl.c
 vm_state_notify(int running, int reason) "running %d reason %d"
 load_file(const char *name, const char *path) "name %s location %s"
@@ -56,10 +50,6 @@ system_wakeup_request(int reason) "reason=%d"
 qemu_system_shutdown_request(void) ""
 qemu_system_powerdown_request(void) ""
 
-# hw/sparc/leon3.c
-leon3_set_irq(int intno) "Set CPU IRQ %d"
-leon3_reset_irq(int intno) "Reset CPU IRQ %d"
-
 # spice-qemu-char.c
 spice_vmc_write(ssize_t out, int len) "spice wrottn %zd of requested %d"
 spice_vmc_read(int bytes, int len) "spice read %d of requested %d"
-- 
2.5.5




[Qemu-devel] [PULL 33/42] trace: split out trace events for hw/arm/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/arm/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-32-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   | 1 +
 hw/arm/trace-events | 4 
 trace-events| 3 ---
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 hw/arm/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 767ffa3..cc0e1cc 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -148,3 +148,4 @@ trace-events-y += hw/pci/trace-events
 trace-events-y += hw/s390x/trace-events
 trace-events-y += hw/vfio/trace-events
 trace-events-y += hw/acpi/trace-events
+trace-events-y += hw/arm/trace-events
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
new file mode 100644
index 000..d0dad16
--- /dev/null
+++ b/hw/arm/trace-events
@@ -0,0 +1,4 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/arm/virt-acpi-build.c
+virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out."
diff --git a/trace-events b/trace-events
index 8b7ffa7..6972f28 100644
--- a/trace-events
+++ b/trace-events
@@ -239,9 +239,6 @@ cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d 
state to %" PRIu8
 cpu_halt(int cpu_index) "halting cpu %d"
 cpu_unhalt(int cpu_index) "unhalting cpu %d"
 
-# hw/arm/virt-acpi-build.c
-virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out."
-
 # hw/alpha/pci.c
 alpha_pci_iack_write(void) ""
 
-- 
2.5.5




[Qemu-devel] [PULL 30/42] trace: split out trace events for hw/s390x/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/s390x/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Acked-by: Cornelia Huck 
Message-id: 1466066426-16657-29-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 hw/s390x/trace-events | 15 +++
 trace-events  | 14 --
 3 files changed, 16 insertions(+), 14 deletions(-)
 create mode 100644 hw/s390x/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index c046e53..551e73e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -145,3 +145,4 @@ trace-events-y += hw/i386/trace-events
 trace-events-y += hw/9pfs/trace-events
 trace-events-y += hw/ppc/trace-events
 trace-events-y += hw/pci/trace-events
+trace-events-y += hw/s390x/trace-events
diff --git a/hw/s390x/trace-events b/hw/s390x/trace-events
new file mode 100644
index 000..72c4549
--- /dev/null
+++ b/hw/s390x/trace-events
@@ -0,0 +1,15 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/s390x/css.c
+css_enable_facility(const char *facility) "CSS: enable %s"
+css_crw(uint8_t rsc, uint8_t erc, uint16_t rsid, const char *chained) "CSS: 
queueing crw: rsc=%x, erc=%x, rsid=%x %s"
+css_chpid_add(uint8_t cssid, uint8_t chpid, uint8_t type) "CSS: add chpid 
%x.%02x (type %02x)"
+css_new_image(uint8_t cssid, const char *default_cssid) "CSS: add css image 
%02x %s"
+css_assign_subch(const char *do_assign, uint8_t cssid, uint8_t ssid, uint16_t 
schid, uint16_t devno) "CSS: %s %x.%x.%04x (devno %04x)"
+css_io_interrupt(int cssid, int ssid, int schid, uint32_t intparm, uint8_t 
isc, const char *conditional) "CSS: I/O interrupt on sch %x.%x.%04x (intparm 
%08x, isc %x) %s"
+css_adapter_interrupt(uint8_t isc) "CSS: adapter I/O interrupt (isc %x)"
+
+# hw/s390x/virtio-ccw.c
+virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) 
"VIRTIO-CCW: %x.%x.%04x: interpret command %x"
+virtio_ccw_new_device(int cssid, int ssid, int schid, int devno, const char 
*devno_mode) "VIRTIO-CCW: add subchannel %x.%x.%04x, devno %04x (%s)"
+virtio_ccw_set_ind(uint64_t ind_loc, uint8_t ind_old, uint8_t ind_new) 
"VIRTIO-CCW: indicator at %" PRIu64 ": %x->%x"
diff --git a/trace-events b/trace-events
index 720fc8f..b05be3c 100644
--- a/trace-events
+++ b/trace-events
@@ -194,20 +194,6 @@ ioinst_sch_id(const char *insn, int cssid, int ssid, int 
schid) "IOINST: %s (%x.
 ioinst_chp_id(const char *insn, int cssid, int chpid) "IOINST: %s (%x.%02x)"
 ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chsc command %04x, len 
%04x"
 
-# hw/s390x/css.c
-css_enable_facility(const char *facility) "CSS: enable %s"
-css_crw(uint8_t rsc, uint8_t erc, uint16_t rsid, const char *chained) "CSS: 
queueing crw: rsc=%x, erc=%x, rsid=%x %s"
-css_chpid_add(uint8_t cssid, uint8_t chpid, uint8_t type) "CSS: add chpid 
%x.%02x (type %02x)"
-css_new_image(uint8_t cssid, const char *default_cssid) "CSS: add css image 
%02x %s"
-css_assign_subch(const char *do_assign, uint8_t cssid, uint8_t ssid, uint16_t 
schid, uint16_t devno) "CSS: %s %x.%x.%04x (devno %04x)"
-css_io_interrupt(int cssid, int ssid, int schid, uint32_t intparm, uint8_t 
isc, const char *conditional) "CSS: I/O interrupt on sch %x.%x.%04x (intparm 
%08x, isc %x) %s"
-css_adapter_interrupt(uint8_t isc) "CSS: adapter I/O interrupt (isc %x)"
-
-# hw/s390x/virtio-ccw.c
-virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) 
"VIRTIO-CCW: %x.%x.%04x: interpret command %x"
-virtio_ccw_new_device(int cssid, int ssid, int schid, int devno, const char 
*devno_mode) "VIRTIO-CCW: add subchannel %x.%x.%04x, devno %04x (%s)"
-virtio_ccw_set_ind(uint64_t ind_loc, uint8_t ind_old, uint8_t ind_new) 
"VIRTIO-CCW: indicator at %" PRIu64 ": %x->%x"
-
 # kvm-all.c
 kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
 kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
-- 
2.5.5




[Qemu-devel] [PULL 25/42] trace: split out trace events for hw/isa/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/isa/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-24-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   | 1 +
 hw/isa/trace-events | 9 +
 trace-events| 8 
 3 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 hw/isa/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 175af1c..764e6fd 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -140,3 +140,4 @@ trace-events-y += hw/timer/trace-events
 trace-events-y += hw/dma/trace-events
 trace-events-y += hw/sparc/trace-events
 trace-events-y += hw/sd/trace-events
+trace-events-y += hw/isa/trace-events
diff --git a/hw/isa/trace-events b/hw/isa/trace-events
new file mode 100644
index 000..686282f
--- /dev/null
+++ b/hw/isa/trace-events
@@ -0,0 +1,9 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/isa/pc87312.c
+pc87312_io_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
+pc87312_io_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
+pc87312_info_floppy(uint32_t base) "base 0x%x"
+pc87312_info_ide(uint32_t base) "base 0x%x"
+pc87312_info_parallel(uint32_t base, uint32_t irq) "base 0x%x, irq %u"
+pc87312_info_serial(int n, uint32_t base, uint32_t irq) "id=%d, base 0x%x, irq 
%u"
diff --git a/trace-events b/trace-events
index 5fa6d54..5cefe28 100644
--- a/trace-events
+++ b/trace-events
@@ -57,14 +57,6 @@ spice_vmc_register_interface(void *scd) "spice vmc 
registered interface %p"
 spice_vmc_unregister_interface(void *scd) "spice vmc unregistered interface %p"
 spice_vmc_event(int event) "spice vmc event %d"
 
-# hw/isa/pc87312.c
-pc87312_io_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
-pc87312_io_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
-pc87312_info_floppy(uint32_t base) "base 0x%x"
-pc87312_info_ide(uint32_t base) "base 0x%x"
-pc87312_info_parallel(uint32_t base, uint32_t irq) "base 0x%x, irq %u"
-pc87312_info_serial(int n, uint32_t base, uint32_t irq) "id=%d, base 0x%x, irq 
%u"
-
 # xen-hvm.c
 xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: %#lx, 
size %#lx"
 xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) 
"%#"PRIx64" size %#lx, log_dirty %i"
-- 
2.5.5




[Qemu-devel] [PULL 37/42] trace: split out trace events for net/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the net/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-36-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs| 1 +
 net/trace-events | 4 
 trace-events | 3 ---
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 net/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 562acfa..22f45b9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -152,3 +152,4 @@ trace-events-y += hw/arm/trace-events
 trace-events-y += hw/alpha/trace-events
 trace-events-y += ui/trace-events
 trace-events-y += audio/trace-events
+trace-events-y += net/trace-events
diff --git a/net/trace-events b/net/trace-events
new file mode 100644
index 000..32a0a8a
--- /dev/null
+++ b/net/trace-events
@@ -0,0 +1,4 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# net/vhost-user.c
+vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
diff --git a/trace-events b/trace-events
index 1a6bf2f..a681ff1 100644
--- a/trace-events
+++ b/trace-events
@@ -192,9 +192,6 @@ cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d 
state to %" PRIu8
 cpu_halt(int cpu_index) "halting cpu %d"
 cpu_unhalt(int cpu_index) "unhalting cpu %d"
 
-# net/vhost-user.c
-vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
-
 # linux-user/signal.c
 user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
 user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
-- 
2.5.5




[Qemu-devel] [PULL 35/42] trace: split out trace events for ui/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the ui/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-34-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |  1 +
 trace-events| 47 ---
 ui/trace-events | 48 
 3 files changed, 49 insertions(+), 47 deletions(-)
 create mode 100644 ui/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index c5e03bc..32b5265 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -150,3 +150,4 @@ trace-events-y += hw/vfio/trace-events
 trace-events-y += hw/acpi/trace-events
 trace-events-y += hw/arm/trace-events
 trace-events-y += hw/alpha/trace-events
+trace-events-y += ui/trace-events
diff --git a/trace-events b/trace-events
index e610e4a..1ddf7a7 100644
--- a/trace-events
+++ b/trace-events
@@ -137,53 +137,6 @@ dma_complete(void *dbs, int ret, void *cb) "dbs=%p ret=%d 
cb=%p"
 dma_blk_cb(void *dbs, int ret) "dbs=%p ret=%d"
 dma_map_wait(void *dbs) "dbs=%p"
 
-# ui/console.c
-console_gfx_new(void) ""
-console_putchar_csi(int esc_param0, int esc_param1, int ch, int nb_esc_params) 
"escape sequence CSI%d;%d%c, %d parameters"
-console_putchar_unhandled(int ch) "unhandled escape character '%c'"
-console_txt_new(int w, int h) "%dx%d"
-console_select(int nr) "%d"
-console_refresh(int interval) "interval %d ms"
-displaysurface_create(void *display_surface, int w, int h) "surface=%p, %dx%d"
-displaysurface_create_from(void *display_surface, int w, int h, uint32_t 
format) "surface=%p, %dx%d, format 0x%x"
-displaysurface_create_pixman(void *display_surface) "surface=%p"
-displaysurface_free(void *display_surface) "surface=%p"
-displaychangelistener_register(void *dcl, const char *name) "%p [ %s ]"
-displaychangelistener_unregister(void *dcl, const char *name) "%p [ %s ]"
-ppm_save(const char *filename, void *display_surface) "%s surface=%p"
-
-# ui/gtk.c
-gd_switch(const char *tab, int width, int height) "tab=%s, width=%d, height=%d"
-gd_update(const char *tab, int x, int y, int w, int h) "tab=%s, x=%d, y=%d, 
w=%d, h=%d"
-gd_key_event(const char *tab, int gdk_keycode, int qemu_keycode, const char 
*action) "tab=%s, translated GDK keycode %d to QEMU keycode %d (%s)"
-gd_grab(const char *tab, const char *device, const char *reason) "tab=%s, 
dev=%s, reason=%s"
-gd_ungrab(const char *tab, const char *device) "tab=%s, dev=%s"
-
-# ui/vnc.c
-vnc_key_guest_leds(bool caps, bool num, bool scroll) "caps %d, num %d, scroll 
%d"
-vnc_key_map_init(const char *layout) "%s"
-vnc_key_event_ext(bool down, int sym, int keycode, const char *name) "down %d, 
sym 0x%x, keycode 0x%x [%s]"
-vnc_key_event_map(bool down, int sym, int keycode, const char *name) "down %d, 
sym 0x%x -> keycode 0x%x [%s]"
-vnc_key_sync_numlock(bool on) "%d"
-vnc_key_sync_capslock(bool on) "%d"
-
-# ui/input.c
-input_event_key_number(int conidx, int number, const char *qcode, bool down) 
"con %d, key number 0x%x [%s], down %d"
-input_event_key_qcode(int conidx, const char *qcode, bool down) "con %d, key 
qcode %s, down %d"
-input_event_btn(int conidx, const char *btn, bool down) "con %d, button %s, 
down %d"
-input_event_rel(int conidx, const char *axis, int value) "con %d, axis %s, 
value %d"
-input_event_abs(int conidx, const char *axis, int value) "con %d, axis %s, 
value 0x%x"
-input_event_sync(void) ""
-input_mouse_mode(int absolute) "absolute %d"
-
-# ui/spice-display.c
-qemu_spice_add_memslot(int qid, uint32_t slot_id, unsigned long virt_start, 
unsigned long virt_end, int async) "%d %u: host virt 0x%lx - 0x%lx async=%d"
-qemu_spice_del_memslot(int qid, uint32_t gid, uint32_t slot_id) "%d gid=%u 
sid=%u"
-qemu_spice_create_primary_surface(int qid, uint32_t sid, void *surface, int 
async) "%d sid=%u surface=%p async=%d"
-qemu_spice_destroy_primary_surface(int qid, uint32_t sid, int async) "%d 
sid=%u async=%d"
-qemu_spice_wakeup(uint32_t qid) "%d"
-qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint32_t 
bottom) "lr %d -> %d,  tb -> %d -> %d"
-
 # target-s390x/mmu_helper.c
 get_skeys_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d"
 set_skeys_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"
diff --git a/ui/trace-events b/ui/trace-events
new file mode 100644
index 000..d36dbbb
--- /dev/null
+++ b/ui/trace-events
@@ -0,0 +1,48 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# ui/console.c
+console_gfx_new(void) ""
+console_putchar_csi(int esc_param0, int esc_param1, int ch, int nb_esc_params) 
"escape sequence CSI%d;%d%c, %d parameters"
+console_putchar_unhandled(int ch) "unhandled escape character '%c'"
+console_txt_new(int w, int h) "%dx%d"
+console_select(int nr) "%d"
+console_refresh(int interval) "interval %d ms"
+displaysurface_create(void *display_surface, int w, int h) "surface=%p, %dx%d"
+displaysurface_create_from(void *display_surface, int w, in

[Qemu-devel] [PULL 29/42] trace: split out trace events for hw/pci/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the hw/pci/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-28-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   | 1 +
 hw/pci/trace-events | 9 +
 trace-events| 8 
 3 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 hw/pci/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 388e2e9..c046e53 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -144,3 +144,4 @@ trace-events-y += hw/isa/trace-events
 trace-events-y += hw/i386/trace-events
 trace-events-y += hw/9pfs/trace-events
 trace-events-y += hw/ppc/trace-events
+trace-events-y += hw/pci/trace-events
diff --git a/hw/pci/trace-events b/hw/pci/trace-events
new file mode 100644
index 000..285338a
--- /dev/null
+++ b/hw/pci/trace-events
@@ -0,0 +1,9 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# hw/pci/pci.c
+pci_update_mappings_del(void *d, uint32_t bus, uint32_t slot, uint32_t func, 
int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x 
%d,%#"PRIx64"+%#"PRIx64
+pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, uint32_t func, 
int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x 
%d,%#"PRIx64"+%#"PRIx64
+
+# hw/pci/pci_host.c
+pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x -> 0x%x"
+pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x <- 0x%x"
diff --git a/trace-events b/trace-events
index 607c9a7..720fc8f 100644
--- a/trace-events
+++ b/trace-events
@@ -184,10 +184,6 @@ qemu_spice_destroy_primary_surface(int qid, uint32_t sid, 
int async) "%d sid=%u
 qemu_spice_wakeup(uint32_t qid) "%d"
 qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint32_t 
bottom) "lr %d -> %d,  tb -> %d -> %d"
 
-# hw/pci/pci.c
-pci_update_mappings_del(void *d, uint32_t bus, uint32_t slot, uint32_t func, 
int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x 
%d,%#"PRIx64"+%#"PRIx64
-pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, uint32_t func, 
int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x 
%d,%#"PRIx64"+%#"PRIx64
-
 # target-s390x/mmu_helper.c
 get_skeys_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d"
 set_skeys_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"
@@ -246,10 +242,6 @@ memory_region_tb_write(int cpu_index, uint64_t addr, 
uint64_t value, unsigned si
 object_dynamic_cast_assert(const char *type, const char *target, const char 
*file, int line, const char *func) "%s->%s (%s:%d:%s)"
 object_class_dynamic_cast_assert(const char *type, const char *target, const 
char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
 
-# hw/pci/pci_host.c
-pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x -> 0x%x"
-pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, 
unsigned val) "%s %02u:%u @0x%x <- 0x%x"
-
 # hw/vfio/pci.c
 vfio_intx_interrupt(const char *name, char line) " (%s) Pin %c"
 vfio_intx_eoi(const char *name) " (%s) EOI"
-- 
2.5.5




[Qemu-devel] [PULL 36/42] trace: split out trace events for audio/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the audio/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-35-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs  |  1 +
 audio/trace-events | 17 +
 trace-events   | 16 
 3 files changed, 18 insertions(+), 16 deletions(-)
 create mode 100644 audio/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 32b5265..562acfa 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -151,3 +151,4 @@ trace-events-y += hw/acpi/trace-events
 trace-events-y += hw/arm/trace-events
 trace-events-y += hw/alpha/trace-events
 trace-events-y += ui/trace-events
+trace-events-y += audio/trace-events
diff --git a/audio/trace-events b/audio/trace-events
new file mode 100644
index 000..5638ea1
--- /dev/null
+++ b/audio/trace-events
@@ -0,0 +1,17 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# audio/alsaaudio.c
+alsa_revents(int revents) "revents = %d"
+alsa_pollout(int i, int fd) "i = %d fd = %d"
+alsa_set_handler(int events, int index, int fd, int err) "events=%#x index=%d 
fd=%d err=%d"
+alsa_wrote_zero(int len) "Failed to write %d frames (wrote zero)"
+alsa_read_zero(long len) "Failed to read %ld frames (read zero)"
+alsa_xrun_out(void) "Recovering from playback xrun"
+alsa_xrun_in(void) "Recovering from capture xrun"
+alsa_resume_out(void) "Resuming suspended output stream"
+alsa_resume_in(void) "Resuming suspended input stream"
+alsa_no_frames(int state) "No frames available and ALSA state is %d"
+
+# audio/ossaudio.c
+oss_version(int version) "OSS version = %#x"
+oss_invalid_available_size(int size, int bufsize) "Invalid available size, 
size=%d bufsize=%d"
diff --git a/trace-events b/trace-events
index 1ddf7a7..1a6bf2f 100644
--- a/trace-events
+++ b/trace-events
@@ -192,22 +192,6 @@ cpu_set_state(int cpu_index, uint8_t state) "setting cpu 
%d state to %" PRIu8
 cpu_halt(int cpu_index) "halting cpu %d"
 cpu_unhalt(int cpu_index) "unhalting cpu %d"
 
-# audio/alsaaudio.c
-alsa_revents(int revents) "revents = %d"
-alsa_pollout(int i, int fd) "i = %d fd = %d"
-alsa_set_handler(int events, int index, int fd, int err) "events=%#x index=%d 
fd=%d err=%d"
-alsa_wrote_zero(int len) "Failed to write %d frames (wrote zero)"
-alsa_read_zero(long len) "Failed to read %ld frames (read zero)"
-alsa_xrun_out(void) "Recovering from playback xrun"
-alsa_xrun_in(void) "Recovering from capture xrun"
-alsa_resume_out(void) "Resuming suspended output stream"
-alsa_resume_in(void) "Resuming suspended input stream"
-alsa_no_frames(int state) "No frames available and ALSA state is %d"
-
-# audio/ossaudio.c
-oss_version(int version) "OSS version = %#x"
-oss_invalid_available_size(int size, int bufsize) "Invalid available size, 
size=%d bufsize=%d"
-
 # net/vhost-user.c
 vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
 
-- 
2.5.5




[Qemu-devel] [PULL 39/42] trace: split out trace events for target-s390x/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the target-s390x/ directory to
their own file.

[Added missing newline in target-s390x/trace-events as suggested by
Cornelia Huck .
--Stefan]

Signed-off-by: Daniel P. Berrange 
Acked-by: Cornelia Huck 
Message-id: 1466066426-16657-38-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 target-s390x/trace-events | 22 ++
 trace-events  | 21 -
 3 files changed, 23 insertions(+), 21 deletions(-)
 create mode 100644 target-s390x/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 16c84c2..f1e8646 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -154,3 +154,4 @@ trace-events-y += ui/trace-events
 trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
 trace-events-y += target-sparc/trace-events
+trace-events-y += target-s390x/trace-events
diff --git a/target-s390x/trace-events b/target-s390x/trace-events
new file mode 100644
index 000..9589b16
--- /dev/null
+++ b/target-s390x/trace-events
@@ -0,0 +1,22 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# target-s390x/mmu_helper.c
+get_skeys_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d"
+set_skeys_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"
+
+# target-s390x/ioinst.c
+ioinst(const char *insn) "IOINST: %s"
+ioinst_sch_id(const char *insn, int cssid, int ssid, int schid) "IOINST: %s 
(%x.%x.%04x)"
+ioinst_chp_id(const char *insn, int cssid, int chpid) "IOINST: %s (%x.%02x)"
+ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chsc command %04x, len 
%04x"
+
+# target-s390x/kvm.c
+kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
+kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
+kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) 
"Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s"
+kvm_sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SIGP: 
Finished order %u on cpu %d -> cpu %d with cc=%d"
+
+# target-s390x/cpu.c
+cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PRIu8
+cpu_halt(int cpu_index) "halting cpu %d"
+cpu_unhalt(int cpu_index) "unhalting cpu %d"
diff --git a/trace-events b/trace-events
index 3ac3f6f..e1f8502 100644
--- a/trace-events
+++ b/trace-events
@@ -110,16 +110,6 @@ dma_complete(void *dbs, int ret, void *cb) "dbs=%p ret=%d 
cb=%p"
 dma_blk_cb(void *dbs, int ret) "dbs=%p ret=%d"
 dma_map_wait(void *dbs) "dbs=%p"
 
-# target-s390x/mmu_helper.c
-get_skeys_nonzero(int rc) "SKEY: Call to get_skeys unexpectedly returned %d"
-set_skeys_nonzero(int rc) "SKEY: Call to set_skeys unexpectedly returned %d"
-
-# target-s390x/ioinst.c
-ioinst(const char *insn) "IOINST: %s"
-ioinst_sch_id(const char *insn, int cssid, int ssid, int schid) "IOINST: %s 
(%x.%x.%04x)"
-ioinst_chp_id(const char *insn, int cssid, int chpid) "IOINST: %s (%x.%02x)"
-ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chsc command %04x, len 
%04x"
-
 # kvm-all.c
 kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
 kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
@@ -154,17 +144,6 @@ memory_region_tb_write(int cpu_index, uint64_t addr, 
uint64_t value, unsigned si
 object_dynamic_cast_assert(const char *type, const char *target, const char 
*file, int line, const char *func) "%s->%s (%s:%d:%s)"
 object_class_dynamic_cast_assert(const char *type, const char *target, const 
char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
 
-# target-s390x/kvm.c
-kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
-kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
-kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) 
"Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s"
-kvm_sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SIGP: 
Finished order %u on cpu %d -> cpu %d with cc=%d"
-
-# target-s390x/cpu.c
-cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PRIu8
-cpu_halt(int cpu_index) "halting cpu %d"
-cpu_unhalt(int cpu_index) "unhalting cpu %d"
-
 # linux-user/signal.c
 user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
 user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
-- 
2.5.5




[Qemu-devel] [PULL 40/42] trace: split out trace events for target-ppc/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the target-ppc/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Reviewed-by: Thomas Huth 
Message-id: 1466066426-16657-39-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   | 1 +
 target-ppc/trace-events | 5 +
 trace-events| 4 
 3 files changed, 6 insertions(+), 4 deletions(-)
 create mode 100644 target-ppc/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index f1e8646..ad7419b 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -155,3 +155,4 @@ trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
 trace-events-y += target-sparc/trace-events
 trace-events-y += target-s390x/trace-events
+trace-events-y += target-ppc/trace-events
diff --git a/target-ppc/trace-events b/target-ppc/trace-events
new file mode 100644
index 000..d37da2b
--- /dev/null
+++ b/target-ppc/trace-events
@@ -0,0 +1,5 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# target-ppc/kvm.c
+kvm_failed_spr_set(int str, const char *msg) "Warning: Unable to set SPR %d to 
KVM: %s"
+kvm_failed_spr_get(int str, const char *msg) "Warning: Unable to retrieve SPR 
%d from KVM: %s"
diff --git a/trace-events b/trace-events
index e1f8502..932fd40 100644
--- a/trace-events
+++ b/trace-events
@@ -119,10 +119,6 @@ kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, 
type 0x%x, arg %p"
 kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retrieve 
ONEREG %" PRIu64 " from KVM: %s"
 kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set 
ONEREG %" PRIu64 " to KVM: %s"
 
-# target-ppc/kvm.c
-kvm_failed_spr_set(int str, const char *msg) "Warning: Unable to set SPR %d to 
KVM: %s"
-kvm_failed_spr_get(int str, const char *msg) "Warning: Unable to retrieve SPR 
%d from KVM: %s"
-
 # TCG related tracing (mostly disabled by default)
 # cpu-exec.c
 disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
-- 
2.5.5




[Qemu-devel] [PULL 42/42] trace: split out trace events for linux-user/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the linux-user/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Reviewed-by: Laurent Vivier 
Message-id: 1466066426-16657-41-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs   |  1 +
 linux-user/trace-events | 12 
 trace-events| 11 ---
 3 files changed, 13 insertions(+), 11 deletions(-)
 create mode 100644 linux-user/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 9f2c260..7f1f0a3 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -157,3 +157,4 @@ trace-events-y += target-sparc/trace-events
 trace-events-y += target-s390x/trace-events
 trace-events-y += target-ppc/trace-events
 trace-events-y += qom/trace-events
+trace-events-y += linux-user/trace-events
diff --git a/linux-user/trace-events b/linux-user/trace-events
new file mode 100644
index 000..80a2e07
--- /dev/null
+++ b/linux-user/trace-events
@@ -0,0 +1,12 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# linux-user/signal.c
+user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
+user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
+user_do_rt_sigreturn(void *env, uint64_t frame_addr) "env=%p 
frame_addr=%"PRIx64
+user_do_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
+user_force_sig(void *env, int target_sig, int host_sig) "env=%p signal %d 
(host %d)"
+user_handle_signal(void *env, int target_sig) "env=%p signal %d"
+user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d 
(target %d("
+user_queue_signal(void *env, int target_sig) "env=%p signal %d"
+user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t 
env_psw_addr) "env=%p frame psw.addr %"PRIx64 " current psw.addr %"PRIx64
diff --git a/trace-events b/trace-events
index e6632df..9d76de8 100644
--- a/trace-events
+++ b/trace-events
@@ -136,17 +136,6 @@ memory_region_subpage_write(int cpu_index, void *mr, 
uint64_t offset, uint64_t v
 memory_region_tb_read(int cpu_index, uint64_t addr, uint64_t value, unsigned 
size) "cpu %d addr %#"PRIx64" value %#"PRIx64" size %u"
 memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsigned 
size) "cpu %d addr %#"PRIx64" value %#"PRIx64" size %u"
 
-# linux-user/signal.c
-user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
-user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
-user_do_rt_sigreturn(void *env, uint64_t frame_addr) "env=%p 
frame_addr=%"PRIx64
-user_do_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
-user_force_sig(void *env, int target_sig, int host_sig) "env=%p signal %d 
(host %d)"
-user_handle_signal(void *env, int target_sig) "env=%p signal %d"
-user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d 
(target %d("
-user_queue_signal(void *env, int target_sig) "env=%p signal %d"
-user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t 
env_psw_addr) "env=%p frame psw.addr %"PRIx64 " current psw.addr %"PRIx64
-
 ### Guest events, keep at bottom
 
 # @vaddr: Access' virtual address.
-- 
2.5.5




[Qemu-devel] [PULL 38/42] trace: split out trace events for target-sparc/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the target-sparc/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-37-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs |  1 +
 target-sparc/trace-events | 28 
 trace-events  | 27 ---
 3 files changed, 29 insertions(+), 27 deletions(-)
 create mode 100644 target-sparc/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 22f45b9..16c84c2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -153,3 +153,4 @@ trace-events-y += hw/alpha/trace-events
 trace-events-y += ui/trace-events
 trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
+trace-events-y += target-sparc/trace-events
diff --git a/target-sparc/trace-events b/target-sparc/trace-events
new file mode 100644
index 000..c75faf9
--- /dev/null
+++ b/target-sparc/trace-events
@@ -0,0 +1,28 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# target-sparc/mmu_helper.c
+mmu_helper_dfault(uint64_t address, uint64_t context, int mmu_idx, uint32_t 
tl) "DFAULT at %"PRIx64" context %"PRIx64" mmu_idx=%d tl=%d"
+mmu_helper_dprot(uint64_t address, uint64_t context, int mmu_idx, uint32_t tl) 
"DPROT at %"PRIx64" context %"PRIx64" mmu_idx=%d tl=%d"
+mmu_helper_dmiss(uint64_t address, uint64_t context) "DMISS at %"PRIx64" 
context %"PRIx64
+mmu_helper_tfault(uint64_t address, uint64_t context) "TFAULT at %"PRIx64" 
context %"PRIx64
+mmu_helper_tmiss(uint64_t address, uint64_t context) "TMISS at %"PRIx64" 
context %"PRIx64
+mmu_helper_get_phys_addr_code(uint32_t tl, int mmu_idx, uint64_t prim_context, 
uint64_t sec_context, uint64_t address) "tl=%d mmu_idx=%d primary 
context=%"PRIx64" secondary context=%"PRIx64" address=%"PRIx64
+mmu_helper_get_phys_addr_data(uint32_t tl, int mmu_idx, uint64_t prim_context, 
uint64_t sec_context, uint64_t address) "tl=%d mmu_idx=%d primary 
context=%"PRIx64" secondary context=%"PRIx64" address=%"PRIx64
+mmu_helper_mmu_fault(uint64_t address, uint64_t paddr, int mmu_idx, uint32_t 
tl, uint64_t prim_context, uint64_t sec_context) "Translate at %"PRIx64" -> 
%"PRIx64", mmu_idx=%d tl=%d primary context=%"PRIx64" secondary context=%"PRIx64
+
+# target-sparc/int64_helper.c
+int_helper_set_softint(uint32_t softint) "new %08x"
+int_helper_clear_softint(uint32_t softint) "new %08x"
+int_helper_write_softint(uint32_t softint) "new %08x"
+
+# target-sparc/int32_helper.c
+int_helper_icache_freeze(void) "Instruction cache: freeze"
+int_helper_dcache_freeze(void) "Data cache: freeze"
+
+# target-sparc/win_helper.c
+win_helper_gregset_error(uint32_t pstate) "ERROR in get_gregset: active pstate 
bits=%x"
+win_helper_switch_pstate(uint32_t pstate_regs, uint32_t new_pstate_regs) 
"change_pstate: switching regs old=%x new=%x"
+win_helper_no_switch_pstate(uint32_t new_pstate_regs) "change_pstate: regs 
new=%x (unchanged)"
+win_helper_wrpil(uint32_t psrpil, uint32_t new_pil) "old=%x new=%x"
+win_helper_done(uint32_t tl) "tl=%d"
+win_helper_retry(uint32_t tl) "tl=%d"
diff --git a/trace-events b/trace-events
index a681ff1..3ac3f6f 100644
--- a/trace-events
+++ b/trace-events
@@ -103,33 +103,6 @@ monitor_protocol_event_emit(uint32_t event, void *data) 
"event=%d data=%p"
 monitor_protocol_event_queue(uint32_t event, void *qdict, uint64_t rate) 
"event=%d data=%p rate=%" PRId64
 monitor_protocol_event_throttle(uint32_t event, uint64_t rate) "event=%d 
rate=%" PRId64
 
-# target-sparc/mmu_helper.c
-mmu_helper_dfault(uint64_t address, uint64_t context, int mmu_idx, uint32_t 
tl) "DFAULT at %"PRIx64" context %"PRIx64" mmu_idx=%d tl=%d"
-mmu_helper_dprot(uint64_t address, uint64_t context, int mmu_idx, uint32_t tl) 
"DPROT at %"PRIx64" context %"PRIx64" mmu_idx=%d tl=%d"
-mmu_helper_dmiss(uint64_t address, uint64_t context) "DMISS at %"PRIx64" 
context %"PRIx64
-mmu_helper_tfault(uint64_t address, uint64_t context) "TFAULT at %"PRIx64" 
context %"PRIx64
-mmu_helper_tmiss(uint64_t address, uint64_t context) "TMISS at %"PRIx64" 
context %"PRIx64
-mmu_helper_get_phys_addr_code(uint32_t tl, int mmu_idx, uint64_t prim_context, 
uint64_t sec_context, uint64_t address) "tl=%d mmu_idx=%d primary 
context=%"PRIx64" secondary context=%"PRIx64" address=%"PRIx64
-mmu_helper_get_phys_addr_data(uint32_t tl, int mmu_idx, uint64_t prim_context, 
uint64_t sec_context, uint64_t address) "tl=%d mmu_idx=%d primary 
context=%"PRIx64" secondary context=%"PRIx64" address=%"PRIx64
-mmu_helper_mmu_fault(uint64_t address, uint64_t paddr, int mmu_idx, uint32_t 
tl, uint64_t prim_context, uint64_t sec_context) "Translate at %"PRIx64" -> 
%"PRIx64", mmu_idx=%d tl=%d primary context=%"PRIx64" secondary context=%"PRIx64
-
-# target-sparc/int64_helper.c
-int_helper_set_softint(uint32_t softint) "new %08x"
-int_helper_clear_softint(uint32_t softint) "new %08x"
-int_helper_write_softint(uint32_t softint) "new %08x"
-
-# target-sparc/int32_

[Qemu-devel] [PULL 41/42] trace: split out trace events for qom/ directory

2016-06-20 Thread Stefan Hajnoczi
From: "Daniel P. Berrange" 

Move all trace-events for files in the qom/ directory to
their own file.

Signed-off-by: Daniel P. Berrange 
Message-id: 1466066426-16657-40-git-send-email-berra...@redhat.com
Signed-off-by: Stefan Hajnoczi 
---
 Makefile.objs| 1 +
 qom/trace-events | 5 +
 trace-events | 4 
 3 files changed, 6 insertions(+), 4 deletions(-)
 create mode 100644 qom/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index ad7419b..9f2c260 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -156,3 +156,4 @@ trace-events-y += net/trace-events
 trace-events-y += target-sparc/trace-events
 trace-events-y += target-s390x/trace-events
 trace-events-y += target-ppc/trace-events
+trace-events-y += qom/trace-events
diff --git a/qom/trace-events b/qom/trace-events
new file mode 100644
index 000..350fc1f
--- /dev/null
+++ b/qom/trace-events
@@ -0,0 +1,5 @@
+# See docs/trace-events.txt for syntax documentation.
+
+# qom/object.c
+object_dynamic_cast_assert(const char *type, const char *target, const char 
*file, int line, const char *func) "%s->%s (%s:%d:%s)"
+object_class_dynamic_cast_assert(const char *type, const char *target, const 
char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
diff --git a/trace-events b/trace-events
index 932fd40..e6632df 100644
--- a/trace-events
+++ b/trace-events
@@ -136,10 +136,6 @@ memory_region_subpage_write(int cpu_index, void *mr, 
uint64_t offset, uint64_t v
 memory_region_tb_read(int cpu_index, uint64_t addr, uint64_t value, unsigned 
size) "cpu %d addr %#"PRIx64" value %#"PRIx64" size %u"
 memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsigned 
size) "cpu %d addr %#"PRIx64" value %#"PRIx64" size %u"
 
-# qom/object.c
-object_dynamic_cast_assert(const char *type, const char *target, const char 
*file, int line, const char *func) "%s->%s (%s:%d:%s)"
-object_class_dynamic_cast_assert(const char *type, const char *target, const 
char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
-
 # linux-user/signal.c
 user_setup_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
 user_setup_rt_frame(void *env, uint64_t frame_addr) "env=%p frame_addr=%"PRIx64
-- 
2.5.5




[Qemu-devel] [PULL] qemu-sparc update

2016-06-20 Thread Mark Cave-Ayland
Hi Peter,

This update simply amends the MAINTAINERS entries for SPARC. Please pull.


ATB,

Mark.


The following changes since commit 7e13ea57f47710de2c19f22b27b34ab9fb045700:

  Merge remote-tracking branch 'remotes/mwalle/tags/lm32-queue/20160620' into 
staging (2016-06-20 18:14:26 +0100)

are available in the git repository at:


  https://github.com/mcayland/qemu.git tags/qemu-sparc-signed

for you to fetch changes up to 3a978051b249e52ec3f45e56e1bf1db868364a82:

  MAINTAINERS: remove Blue Swirl as SPARC maintainer (2016-06-20 21:55:16 +0100)


qemu-sparc update


Mark Cave-Ayland (2):
  MAINTAINERS: add Artyom Tarasenko as SPARC maintainer
  MAINTAINERS: remove Blue Swirl as SPARC maintainer

 MAINTAINERS |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



Re: [Qemu-devel] [RFC v3 PATCH 01/14] Introduce TCGOpcode for memory barrier

2016-06-20 Thread Sergey Fedorov
On 18/06/16 07:03, Pranith Kumar wrote:
> diff --git a/tcg/tcg.h b/tcg/tcg.h
> index db6a062..36feca9 100644
> --- a/tcg/tcg.h
> +++ b/tcg/tcg.h
> @@ -408,6 +408,20 @@ static inline intptr_t QEMU_ARTIFICIAL 
> GET_TCGV_PTR(TCGv_ptr t)
>  #define TCG_CALL_DUMMY_TCGV MAKE_TCGV_I32(-1)
>  #define TCG_CALL_DUMMY_ARG  ((TCGArg)(-1))
>  
> +typedef enum {
> +TCG_MO_LD_LD= 1,
> +TCG_MO_ST_LD= 2,
> +TCG_MO_LD_ST= 4,
> +TCG_MO_ST_ST= 8,
> +TCG_MO_ALL  = 0xF, // OR of all above

So TCG_MO_ALL specifies a so called "full" memory barrier?

> +} TCGOrder;
> +
> +typedef enum {
> +TCG_BAR_ACQ = 32,
> +TCG_BAR_REL = 64,

I'm convinced that the only practical way to represent a standalone
acquire memory barrier is to order all previous loads with all
subsequent loads and stores. Similarly, a standalone release memory
barrier would order all previous loads and stores with all subsequent
stores. [1]

On the other hand, acquire or release semantic associated with a memory
operation itself can be directly mapped into e.g. AArch64's Load-Acquire
(LDAR) and Store-Release (STLR) instructions. A standalone barrier
adjacent to a memory operation shouldn't be mapped this way because it
should provide more strict guarantees than e.g. AArch64 instructions
mentioned above.

Therefore, I advocate for clear distinction between standalone memory
barriers and implicit memory ordering semantics associated with memory
operations themselves.

[1] http://preshing.com/20130922/acquire-and-release-fences/

> +TCG_BAR_SC  = 128,

How's that different from TCG_MO_ALL?

> +} TCGBar;
> +
>  /* Conditions.  Note that these are laid out for easy manipulation by
> the functions below:
>   bit 0 is used for inverting;

Kind regards,
Sergey



Re: [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments in execve

2016-06-20 Thread Joel Holdsworth

On 20/06/16 21:29, Laurent Vivier wrote:


Le 20/06/2016 à 21:51, Joel Holdsworth a écrit :

On 15/06/16 20:59, Laurent Vivier wrote:

Le 14/06/2016 à 21:26, Joel Holdsworth a écrit :

Previously, when emulating execve(2), qemu would execute a child
instance of the emulator with the environment variables provided by
the parent process. This caused problems with qemu if any of the
variables affected the child emulator's behaviour e.g.
LD_LIBRARY_PATH.

The best way to avoid that is to use a statically linked qemu.

Stepping back a bit; the problem I'm trying to solve is this...

There are some processes that invoke a helper process to do some work
for them e.g. gstreamer's gst-plugin-scanner. Previously qemu would
attempt to execute the helper executable as if it were machine-native,
which won't work. These patches modify qemu so that it will (optionally)
run the child process inside a child instance of qemu.

If the context is to use qemu to have a cross build/test environment, I
like the idea, but you should use chroot/binfmt to do that.

Even without the architecture change, the build/test environment must be
isolated (chroot) from the host environment to know exactly what you
build/test.
I do know what we test though: (a gstreamer unit test) -> 
(gst-plugin-scanner).


chroot+binfmt is a fine solution for testing a whole user-space, but 
rather overkill for just a single program.


Also, chroot and binfmt require root permissions. Also the libraries 
have to be installed in a rootfs tree - which isn't how my use case works.





My experience as a user was that it took a couple of hours of searching
through strace logs to figure out what the issue was. gstreamer would
just fail with a generic error about the helper. These patches are meant
to make qemu do the right thing.

Saying to the user that they should make a static linked build of qemu
isn't very practical. Having a command line argument is a much easier
solution for the user, that doesn't force them not to used
shared-library builds. The distros aren't going to go for that.

You can provide the RPM/DEB with the statically linked qemu.
(it will have no dependencies)


Users could do that, but as far as I'm concerned that isn't really 
satisfactory.


The current behaviour was quite unexpected to me - there were no 
warnings, and the need to link qemu statically isn't documented 
anywhere. If you really believe that static linking is the best answer 
here, then shouldn't the shared library option be removed? Because with 
the shared-library build, qemu-user is somewhat "broken".


But the distros won't like that because of the induced bloat.


Moreover, LD_LIBRARY_PATH is just one example. LD_PRELOAD is another.
Timezone and locale environment variables are also an issue.

all LD_ are for the ld.so, the dynamic loader, and with a statically
linked qemu, you don't use the host ld.so (see ld.so(8)).

Why timezone and local environment variables are also an issue?
All these environment variables affect the behaviour of qemu's glibc - 
these are examples of the the parent-guest being able to modify the 
behaviour of the child-host if the execve qemu wrapper patch is 
integrated. The correct way to pass the execve environ to the child qemu 
wrapper is through -E and -U arguments.



Child qemu instance should just ignore it. Thanks, Laurent 


The child qemu can't control what glibc will respond to.

There are a lot of environment variables that can affect it: 
http://www.scratchbox.org/documentation/general/tutorials/glibcenv.html


For example with LANG=, the parent-guest process might want to run the 
child-guest in Japanese, but the child-qemu should still run in English.





Re: [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments in execve

2016-06-20 Thread Peter Maydell
On 20 June 2016 at 22:27, Joel Holdsworth
 wrote:
> The current behaviour was quite unexpected to me - there were no warnings,
> and the need to link qemu statically isn't documented anywhere. If you
> really believe that static linking is the best answer here, then shouldn't
> the shared library option be removed? Because with the shared-library build,
> qemu-user is somewhat "broken".

Shared library QEMU works fine for simple use cases ("run a gcc
test case", for instance) or where the guest binary is linked
statically and doesn't much care where it runs.

> But the distros won't like that because of the induced bloat.

I don't know of a distro which doesn't ship a statically linked
QEMU offhand. Debian, Ubuntu and SUSE certainly all do. You
basically need it for the chroot case, which is a really common one.
[These days if your distro-in-the-chroot is multiarch you could
put all the dynamic libraries for the QEMU binary in it too,
but in practice being able to just copy a single binary in is much
easier.]

thanks
-- PMM



[Qemu-devel] [PATCH] vfio/pci: Hide SR-IOV capability

2016-06-20 Thread Alex Williamson
The kernel currently exposes the SR-IOV capability as read-only
through vfio-pci.  This is sufficient to protect the host kernel, but
has the potential to confuse guests without further virtualization.
In particular, OVMF tries to size the VF BARs and comes up with absurd
results, ending with an assert.  There's not much point in adding
virtualization to a read-only capability, so we simply hide it for
now.  If the kernel ever enables SR-IOV virtualization, we should
easily be able to test it through VF BAR sizing or explicit flags.

Testing whether we should parse extended capabilities is also pulled
into the function to keep these assumptions in one place.

Signed-off-by: Alex Williamson 
---

This depends on Chen Fan's patch "vfio: add pcie extended capability
support", which I'll pull from Zhou Jie's latest series unless there
are comments to the contrary.  Otherwise based on Stefan's tracing
pull request so as not to conflict.

 hw/vfio/pci.c|   49 +++--
 hw/vfio/trace-events |1 +
 2 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index a171056b..36d5e00 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1772,6 +1772,12 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
 uint8_t cap_ver;
 uint8_t *config;
 
+/* Only add extended caps if we have them and the guest can see them */
+if (!pci_is_express(pdev) || !pci_bus_is_express(pdev->bus) ||
+!pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) {
+return 0;
+}
+
 /*
  * pcie_add_capability always inserts the new capability at the tail
  * of the chain.  Therefore to end up with a chain that matches the
@@ -1780,6 +1786,25 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
  */
 config = g_memdup(pdev->config, vdev->config_size);
 
+/*
+ * Extended capabilities are chained with each pointing to the next, so we
+ * can drop anything other than the head of the chain simply by modifying
+ * the previous next pointer.  For the head of the chain, we can modify the
+ * capability ID to something that cannot match a valid capability.  ID
+ * 0 is reserved for this since absence of capabilities is indicated by
+ * 0 for the ID, version, AND next pointer.  However, pcie_add_capability()
+ * uses ID 0 as reserved for list management and will incorrectly match and
+ * assert if we attempt to pre-load the head of the chain with with this
+ * ID.  Use ID 0x temporarily since it is also seems to be reserved in
+ * part for identifying abscense of capabilities in a root complex register
+ * block.  If the ID still exists after adding capabilities, switch back to
+ * zero.  We'll mark this entire first dword as emulated for this purpose.
+ */
+pci_set_long(pdev->config + PCI_CONFIG_SPACE_SIZE,
+ PCI_EXT_CAP(0x, 0, 0));
+pci_set_long(pdev->wmask + PCI_CONFIG_SPACE_SIZE, 0);
+pci_set_long(vdev->emulated_config_bits + PCI_CONFIG_SPACE_SIZE, ~0);
+
 for (next = PCI_CONFIG_SPACE_SIZE; next;
  next = PCI_EXT_CAP_NEXT(pci_get_long(config + next))) {
 header = pci_get_long(config + next);
@@ -1794,12 +1819,23 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
  */
 size = vfio_ext_cap_max_size(config, next);
 
-pcie_add_capability(pdev, cap_id, cap_ver, next, size);
-pci_set_long(pdev->config + next, PCI_EXT_CAP(cap_id, cap_ver, 0));
-
 /* Use emulated next pointer to allow dropping extended caps */
 pci_long_test_and_set_mask(vdev->emulated_config_bits + next,
PCI_EXT_CAP_NEXT_MASK);
+
+switch (cap_id) {
+case PCI_EXT_CAP_ID_SRIOV: /* Read-only VF BARs confuses OVMF */
+trace_vfio_add_ext_cap_dropped(vdev->vbasedev.name, cap_id, next);
+break;
+default:
+pcie_add_capability(pdev, cap_id, cap_ver, next, size);
+}
+
+}
+
+/* Cleanup chain head ID if necessary */
+if (pci_get_word(pdev->config + PCI_CONFIG_SPACE_SIZE) == 0x) {
+pci_set_word(pdev->config + PCI_CONFIG_SPACE_SIZE, 0);
 }
 
 g_free(config);
@@ -1821,13 +1857,6 @@ static int vfio_add_capabilities(VFIOPCIDevice *vdev)
 return ret;
 }
 
-/* on PCI bus, it doesn't make sense to expose extended capabilities. */
-if (!pci_is_express(pdev) ||
-!pci_bus_is_express(pdev->bus) ||
-!pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) {
-return 0;
-}
-
 return vfio_add_ext_cap(vdev);
 }
 
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
index 9da0ff9..a768fb5 100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -37,6 +37,7 @@ vfio_pci_hot_reset_result(const char *name, const char 
*result) "%s hot reset: %
 vfio_populate_device_config(const char *name, unsigned long size, unsigned 
long offset, unsigned long f

Re: [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments in execve

2016-06-20 Thread Joel Holdsworth

On 20/06/16 22:40, Peter Maydell wrote:

On 20 June 2016 at 22:27, Joel Holdsworth
 wrote:

The current behaviour was quite unexpected to me - there were no warnings,
and the need to link qemu statically isn't documented anywhere. If you
really believe that static linking is the best answer here, then shouldn't
the shared library option be removed? Because with the shared-library build,
qemu-user is somewhat "broken".

Shared library QEMU works fine for simple use cases ("run a gcc
test case", for instance) or where the guest binary is linked
statically and doesn't much care where it runs.


But the distros won't like that because of the induced bloat.

I don't know of a distro which doesn't ship a statically linked
QEMU offhand. Debian, Ubuntu and SUSE certainly all do. You
basically need it for the chroot case, which is a really common one.
[These days if your distro-in-the-chroot is multiarch you could
put all the dynamic libraries for the QEMU binary in it too,
but in practice being able to just copy a single binary in is much
easier.]

thanks
-- PMM


Fair enough. It sounds like this is the way needs to be!

Even so, there is still the issue of the other glibc environment 
variables - see my LANG= example of the parent-guest wanting to run a 
child-guest Japanese, but the child-qemu should still run in English.




Re: [Qemu-devel] [PATCH] vfio/pci: Hide SR-IOV capability

2016-06-20 Thread Eric Blake
On 06/20/2016 04:04 PM, Alex Williamson wrote:
> The kernel currently exposes the SR-IOV capability as read-only
> through vfio-pci.  This is sufficient to protect the host kernel, but
> has the potential to confuse guests without further virtualization.
> In particular, OVMF tries to size the VF BARs and comes up with absurd
> results, ending with an assert.  There's not much point in adding
> virtualization to a read-only capability, so we simply hide it for
> now.  If the kernel ever enables SR-IOV virtualization, we should
> easily be able to test it through VF BAR sizing or explicit flags.
> 
> Testing whether we should parse extended capabilities is also pulled
> into the function to keep these assumptions in one place.
> 
> Signed-off-by: Alex Williamson 
> ---

> + * Extended capabilities are chained with each pointing to the next, so 
> we
> + * can drop anything other than the head of the chain simply by modifying
> + * the previous next pointer.  For the head of the chain, we can modify 
> the
> + * capability ID to something that cannot match a valid capability.  ID
> + * 0 is reserved for this since absence of capabilities is indicated by
> + * 0 for the ID, version, AND next pointer.  However, 
> pcie_add_capability()
> + * uses ID 0 as reserved for list management and will incorrectly match 
> and
> + * assert if we attempt to pre-load the head of the chain with with this
> + * ID.  Use ID 0x temporarily since it is also seems to be reserved 
> in
> + * part for identifying abscense of capabilities in a root complex 
> register

s/abscense/absence/

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] vfio/pci: Hide SR-IOV capability

2016-06-20 Thread Alex Williamson
On Mon, 20 Jun 2016 16:23:07 -0600
Eric Blake  wrote:

> On 06/20/2016 04:04 PM, Alex Williamson wrote:
> > The kernel currently exposes the SR-IOV capability as read-only
> > through vfio-pci.  This is sufficient to protect the host kernel, but
> > has the potential to confuse guests without further virtualization.
> > In particular, OVMF tries to size the VF BARs and comes up with absurd
> > results, ending with an assert.  There's not much point in adding
> > virtualization to a read-only capability, so we simply hide it for
> > now.  If the kernel ever enables SR-IOV virtualization, we should
> > easily be able to test it through VF BAR sizing or explicit flags.
> > 
> > Testing whether we should parse extended capabilities is also pulled
> > into the function to keep these assumptions in one place.
> > 
> > Signed-off-by: Alex Williamson 
> > ---  
> 
> > + * Extended capabilities are chained with each pointing to the next, 
> > so we
> > + * can drop anything other than the head of the chain simply by 
> > modifying
> > + * the previous next pointer.  For the head of the chain, we can 
> > modify the
> > + * capability ID to something that cannot match a valid capability.  ID
> > + * 0 is reserved for this since absence of capabilities is indicated by
> > + * 0 for the ID, version, AND next pointer.  However, 
> > pcie_add_capability()
> > + * uses ID 0 as reserved for list management and will incorrectly 
> > match and
> > + * assert if we attempt to pre-load the head of the chain with with 
> > this
> > + * ID.  Use ID 0x temporarily since it is also seems to be 
> > reserved in
> > + * part for identifying abscense of capabilities in a root complex 
> > register  
> 
> s/abscense/absence/
> 

Thanks, updated:

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 36d5e00..2418b93 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1796,7 +1796,7 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
  * uses ID 0 as reserved for list management and will incorrectly match and
  * assert if we attempt to pre-load the head of the chain with with this
  * ID.  Use ID 0x temporarily since it is also seems to be reserved in
- * part for identifying abscense of capabilities in a root complex register
+ * part for identifying absence of capabilities in a root complex register
  * block.  If the ID still exists after adding capabilities, switch back to
  * zero.  We'll mark this entire first dword as emulated for this purpose.
  */



Re: [Qemu-devel] [PATCH 1/1] block: ignore flush requests when storage is clean

2016-06-20 Thread Eric Blake
On 06/20/2016 09:19 AM, Denis V. Lunev wrote:
> From: Evgeny Yakovlev 
> 
> Some guests (win2008 server for example) do a lot of unnecessary
> flushing when underlying media has not changed. This adds additional
> overhead on host when calling fsync/fdatasync.
> 
> This change introduces a dirty flag in BlockDriverState which is set
> in bdrv_set_dirty and is checked in bdrv_co_flush. This allows us to
> avoid unnessesary flushing when storage is clean.

s/unnessesary/unnecessary/

> 
> The problem with excessive flushing was found by a performance test
> which does parallel directory tree creation (from 2 processes).
> Results improved from 0.424 loops/sec to 0.432 loops/sec.
> Each loop creates 10^3 directories with 10 files in each.
> 
> Signed-off-by: Evgeny Yakovlev 
> Signed-off-by: Denis V. Lunev 
> CC: Kevin Wolf 
> CC: Max Reitz 
> CC: Stefan Hajnoczi 
> CC: Fam Zheng 
> ---
>  block.c   | 1 +
>  block/dirty-bitmap.c  | 3 +++
>  block/io.c| 6 ++
>  include/block/block_int.h | 1 +
>  4 files changed, 11 insertions(+)

Otherwise seems reasonable, but I'll let others with more experience on
flush semantics chime in.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments in execve

2016-06-20 Thread Peter Maydell
On 20 June 2016 at 23:15, Joel Holdsworth
 wrote:
> Even so, there is still the issue of the other glibc environment variables -
> see my LANG= example of the parent-guest wanting to run a child-guest
> Japanese, but the child-qemu should still run in English.

That particular example is easy in that I don't think qemu
user-mode cares about LANG at all :-)

Needing to be root to set up a chroot is genuinely awkward,
though. proot (https://github.com/proot-me/PRoot) is one
approach to that which uses and wraps around a stock QEMU
to do many of the things you'd need a chroot for without
requiring root to set it up. (it uses the ptrace API to
intercept various syscalls and fix up paths, etc.)

Mostly I think the set of possible solutions QEMU has to
"run a guest binary" are the way they are for historical
reasons:
 * we have "-L sysroot" which works for simple cases where
   you have the dynamic libraries to hand, but which has
   some bad failure modes if the directory tree you point
   it at is large or has symlinks (including QEMU just
   going into an infinite loop at startup)
 * the chroot approach is the most flexible, and handily
   doesn't need much support in QEMU at all, but needing
   root support to set it up is a pain
and this hasn't much changed in many years.

I think my main concern is that if we add a third model of
how usermode works (or extend one of the existing ones)
that we do it with a clear idea of where we're going with that,
rather than adding bits and pieces ad-hoc. [I haven't read the
rest of this patchset, so this isn't a specific comment
on it, just a general observation.]

We could certainly stand to document things better too.

thanks
-- PMM



[Qemu-devel] [PATCH 0/5] Auto-fragment large transactions at the block layer

2016-06-20 Thread Eric Blake
We have max_transfer documented in BlockLimits, but while we
honor it during pwrite_zeroes, we were blindly ignoring it
during pwritev and preadv, leading to multiple drivers having
to implement fragmentation themselves.  This series moves
fragmentation to the block layer, then fixes the NBD driver to
use it; if you like this but it needs a v2, you can request that
I further do other drivers (I know at least iscsi and qcow2 do
some self-fragmenting and/or error reporting that can be
simplified by deferring fragmentation to the block layer).

Prequisite: Kevin's block branch, plus my work on byte-based
block limits (v2 at the moment):
https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg04006.html

Also available as a tag at:
git fetch git://repo.or.cz/qemu/ericb.git nbd-fragment-v1

Eric Blake (5):
  block: Fragment reads to max transfer length
  block: Fragment writes to max transfer length
  raw_bsd: Don't advertise flags not supported by protocol layer
  nbd: Rely on block layer to break up large requests
  nbd: Drop unused offset parameter

 include/block/nbd.h |  1 -
 nbd/nbd-internal.h  |  4 +--
 block/io.c  | 84 +++--
 block/nbd-client.c  | 78 ++---
 block/nbd.c | 12 ++--
 block/raw_bsd.c |  6 ++--
 nbd/common.c|  3 +-
 7 files changed, 95 insertions(+), 93 deletions(-)

-- 
2.5.5




[Qemu-devel] [PATCH 5/5] nbd: Drop unused offset parameter

2016-06-20 Thread Eric Blake
Now that NBD relies on the block layer to fragment things, we no
longer need to track an offset argument for which fragment of
a request we are actually servicing.

While at it, use true and false instead of 0 and 1 for a bool
parameter.

Signed-off-by: Eric Blake 
---
 include/block/nbd.h |  1 -
 nbd/nbd-internal.h  |  4 ++--
 block/nbd-client.c  | 31 ---
 nbd/common.c|  3 +--
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/include/block/nbd.h b/include/block/nbd.h
index eeda3eb..503f514 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -89,7 +89,6 @@ enum {
 ssize_t nbd_wr_syncv(QIOChannel *ioc,
  struct iovec *iov,
  size_t niov,
- size_t offset,
  size_t length,
  bool do_read);
 int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index 26a9f4d..93a6ca8 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -101,14 +101,14 @@ static inline ssize_t read_sync(QIOChannel *ioc, void 
*buffer, size_t size)
  * our request/reply.  Synchronization is done with recv_coroutine, so
  * that this is coroutine-safe.
  */
-return nbd_wr_syncv(ioc, &iov, 1, 0, size, true);
+return nbd_wr_syncv(ioc, &iov, 1, size, true);
 }

 static inline ssize_t write_sync(QIOChannel *ioc, void *buffer, size_t size)
 {
 struct iovec iov = { .iov_base = buffer, .iov_len = size };

-return nbd_wr_syncv(ioc, &iov, 1, 0, size, false);
+return nbd_wr_syncv(ioc, &iov, 1, size, false);
 }

 struct NBDTLSHandshakeData {
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 9f023f8..5841a32 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -116,7 +116,7 @@ static void nbd_restart_write(void *opaque)

 static int nbd_co_send_request(BlockDriverState *bs,
struct nbd_request *request,
-   QEMUIOVector *qiov, int offset)
+   QEMUIOVector *qiov)
 {
 NbdClientSession *s = nbd_get_client_session(bs);
 AioContext *aio_context;
@@ -149,8 +149,8 @@ static int nbd_co_send_request(BlockDriverState *bs,
 qio_channel_set_cork(s->ioc, true);
 rc = nbd_send_request(s->ioc, request);
 if (rc >= 0) {
-ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov,
-   offset, request->len, 0);
+ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov, request->len,
+   false);
 if (ret != request->len) {
 rc = -EIO;
 }
@@ -167,8 +167,9 @@ static int nbd_co_send_request(BlockDriverState *bs,
 }

 static void nbd_co_receive_reply(NbdClientSession *s,
-struct nbd_request *request, struct nbd_reply *reply,
-QEMUIOVector *qiov, int offset)
+ struct nbd_request *request,
+ struct nbd_reply *reply,
+ QEMUIOVector *qiov)
 {
 int ret;

@@ -181,8 +182,8 @@ static void nbd_co_receive_reply(NbdClientSession *s,
 reply->error = EIO;
 } else {
 if (qiov && reply->error == 0) {
-ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov,
-   offset, request->len, 1);
+ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov, request->len,
+   true);
 if (ret != request->len) {
 reply->error = EIO;
 }
@@ -230,11 +231,11 @@ int nbd_client_co_readv(BlockDriverState *bs, int64_t 
sector_num,
 request.len = nb_sectors * 512;

 nbd_coroutine_start(client, &request);
-ret = nbd_co_send_request(bs, &request, NULL, 0);
+ret = nbd_co_send_request(bs, &request, NULL);
 if (ret < 0) {
 reply.error = -ret;
 } else {
-nbd_co_receive_reply(client, &request, &reply, qiov, 0);
+nbd_co_receive_reply(client, &request, &reply, qiov);
 }
 nbd_coroutine_end(client, &request);
 return -reply.error;
@@ -259,11 +260,11 @@ int nbd_client_co_writev(BlockDriverState *bs, int64_t 
sector_num,
 request.len = nb_sectors * 512;

 nbd_coroutine_start(client, &request);
-ret = nbd_co_send_request(bs, &request, qiov, 0);
+ret = nbd_co_send_request(bs, &request, qiov);
 if (ret < 0) {
 reply.error = -ret;
 } else {
-nbd_co_receive_reply(client, &request, &reply, NULL, 0);
+nbd_co_receive_reply(client, &request, &reply, NULL);
 }
 nbd_coroutine_end(client, &request);
 return -reply.error;
@@ -284,11 +285,11 @@ int nbd_client_co_flush(BlockDriverState *bs)
 request.len = 0;

 nbd_coroutine_start(client, &request);
-ret = nbd_co_send_request(bs, &request, NULL, 0);
+ret = nbd_co_send_request(bs, &request, NULL);
 if (ret < 0) {
 reply.

[Qemu-devel] [PATCH 2/5] block: Fragment writes to max transfer length

2016-06-20 Thread Eric Blake
Drivers should be able to rely on the block layer honoring the
max transfer length, rather than needing to return -EINVAL
(iscsi) or manually fragment things (nbd).  We already fragment
write zeroes at the block layer; this patch adds the fragmentation
for normal writes, after requests have been aligned (fragmenting
before alignment would lead to multiple unaligned requests, rather
than just the head and tail).

When fragmenting a large request where FUA was requested, but
where we know that FUA is implemented by flushing all requests
rather than the given request, then we can still get by with
only one flush.  Note, however, that we need a followup patch
to the raw format driver to avoid a regression in the number of
flushes actually issued.

Signed-off-by: Eric Blake 
---
 block/io.c | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/block/io.c b/block/io.c
index a1443e3..727a2d4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1280,6 +1280,8 @@ static int coroutine_fn 
bdrv_aligned_pwritev(BlockDriverState *bs,

 int64_t start_sector = offset >> BDRV_SECTOR_BITS;
 int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
+uint64_t bytes_remaining = bytes;
+int max_transfer;

 assert(is_power_of_2(align));
 assert((offset & (align - 1)) == 0);
@@ -1287,6 +1289,8 @@ static int coroutine_fn 
bdrv_aligned_pwritev(BlockDriverState *bs,
 assert(!qiov || bytes == qiov->size);
 assert((bs->open_flags & BDRV_O_NO_IO) == 0);
 assert(!(flags & ~BDRV_REQ_MASK));
+max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
+   align);

 waited = wait_serialising_requests(req);
 assert(!waited || !req->serialising);
@@ -1309,9 +1313,34 @@ static int coroutine_fn 
bdrv_aligned_pwritev(BlockDriverState *bs,
 } else if (flags & BDRV_REQ_ZERO_WRITE) {
 bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO);
 ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags);
-} else {
+} else if (bytes <= max_transfer) {
 bdrv_debug_event(bs, BLKDBG_PWRITEV);
 ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, flags);
+} else {
+bdrv_debug_event(bs, BLKDBG_PWRITEV);
+while (bytes_remaining) {
+int num = MIN(bytes_remaining, max_transfer);
+QEMUIOVector local_qiov;
+int local_flags = flags;
+
+assert(num);
+if (num < bytes_remaining && (flags & BDRV_REQ_FUA) &&
+!(bs->supported_write_flags & BDRV_REQ_FUA)) {
+/* If FUA is going to be emulated by flush, we only
+ * need to flush on the last iteration */
+local_flags &= ~BDRV_REQ_FUA;
+}
+qemu_iovec_init(&local_qiov, qiov->niov);
+qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num);
+
+ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining,
+  num, &local_qiov, local_flags);
+qemu_iovec_destroy(&local_qiov);
+if (ret < 0) {
+break;
+}
+bytes_remaining -= num;
+}
 }
 bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE);

-- 
2.5.5




[Qemu-devel] [PATCH 1/5] block: Fragment reads to max transfer length

2016-06-20 Thread Eric Blake
Drivers should be able to rely on the block layer honoring the
max transfer length, rather than needing to return -EINVAL
(iscsi) or manually fragment things (nbd).  This patch adds
the fragmentation in the block layer, after requests have been
aligned (fragmenting before alignment would lead to multiple
unaligned requests, rather than just the head and tail).

Signed-off-by: Eric Blake 
---
 block/io.c | 53 +
 1 file changed, 33 insertions(+), 20 deletions(-)

diff --git a/block/io.c b/block/io.c
index 4e19868..a1443e3 100644
--- a/block/io.c
+++ b/block/io.c
@@ -971,8 +971,8 @@ err:

 /*
  * Forwards an already correctly aligned request to the BlockDriver. This
- * handles copy on read and zeroing after EOF; any other features must be
- * implemented by the caller.
+ * handles copy on read, zeroing after EOF, and fragmentation of large
+ * reads; any other features must be implemented by the caller.
  */
 static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
 BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
@@ -980,12 +980,16 @@ static int coroutine_fn 
bdrv_aligned_preadv(BlockDriverState *bs,
 {
 int64_t total_bytes, max_bytes;
 int ret;
+uint64_t bytes_remaining = bytes;
+int max_transfer;

 assert(is_power_of_2(align));
 assert((offset & (align - 1)) == 0);
 assert((bytes & (align - 1)) == 0);
 assert(!qiov || bytes == qiov->size);
 assert((bs->open_flags & BDRV_O_NO_IO) == 0);
+max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX),
+   align);

 /* TODO: We would need a per-BDS .supported_read_flags and
  * potential fallback support, if we ever implement any read flags
@@ -1024,7 +1028,7 @@ static int coroutine_fn 
bdrv_aligned_preadv(BlockDriverState *bs,
 }
 }

-/* Forward the request to the BlockDriver */
+/* Forward the request to the BlockDriver, possibly fragmenting it */
 total_bytes = bdrv_getlength(bs);
 if (total_bytes < 0) {
 ret = total_bytes;
@@ -1032,26 +1036,35 @@ static int coroutine_fn 
bdrv_aligned_preadv(BlockDriverState *bs,
 }

 max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
-if (bytes <= max_bytes) {
+if (bytes <= max_bytes && bytes <= max_transfer) {
 ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0);
-} else if (max_bytes > 0) {
-QEMUIOVector local_qiov;
-
-qemu_iovec_init(&local_qiov, qiov->niov);
-qemu_iovec_concat(&local_qiov, qiov, 0, max_bytes);
-
-ret = bdrv_driver_preadv(bs, offset, max_bytes, &local_qiov, 0);
-
-qemu_iovec_destroy(&local_qiov);
-} else {
-ret = 0;
+goto out;
 }

-/* Reading beyond end of file is supposed to produce zeroes */
-if (ret == 0 && total_bytes < offset + bytes) {
-uint64_t zero_offset = MAX(0, total_bytes - offset);
-uint64_t zero_bytes = offset + bytes - zero_offset;
-qemu_iovec_memset(qiov, zero_offset, 0, zero_bytes);
+while (bytes_remaining) {
+int num;
+
+if (max_bytes) {
+QEMUIOVector local_qiov;
+
+num = MIN(bytes_remaining, MIN(max_bytes, max_transfer));
+assert(num);
+qemu_iovec_init(&local_qiov, qiov->niov);
+qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num);
+
+ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining,
+ num, &local_qiov, 0);
+max_bytes -= num;
+qemu_iovec_destroy(&local_qiov);
+if (ret < 0) {
+break;
+}
+} else {
+num = bytes_remaining;
+qemu_iovec_memset(qiov, bytes - bytes_remaining, 0,
+  bytes_remaining);
+}
+bytes_remaining -= num;
 }

 out:
-- 
2.5.5




[Qemu-devel] [PATCH 4/5] nbd: Rely on block layer to break up large requests

2016-06-20 Thread Eric Blake
Now that the block layer will honor max_transfer, we can simplify
our code to rely on that guarantee.

The readv code can call directly into nbd-client, just as the
writev code has done since commit 52a4650.

Interestingly enough, while qemu-io 'w 0 40m' splits into a 32M
and 8M transaction, 'w -z 0 40m' splits into two 16M and an 8M,
because the block layer caps the bounce buffer for writing zeroes
at 16M.  When we later introduce support for NBD_CMD_WRITE_ZEROES,
we can get a full 32M zero write (or larger, if the client and
server negotiate that write zeroes can use a larger size than
ordinary writes).

Signed-off-by: Eric Blake 
---
 block/nbd-client.c | 51 ---
 block/nbd.c| 12 +++-
 2 files changed, 11 insertions(+), 52 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 420bce8..9f023f8 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -217,15 +217,15 @@ static void nbd_coroutine_end(NbdClientSession *s,
 }
 }

-static int nbd_co_readv_1(BlockDriverState *bs, int64_t sector_num,
-  int nb_sectors, QEMUIOVector *qiov,
-  int offset)
+int nbd_client_co_readv(BlockDriverState *bs, int64_t sector_num,
+int nb_sectors, QEMUIOVector *qiov)
 {
 NbdClientSession *client = nbd_get_client_session(bs);
 struct nbd_request request = { .type = NBD_CMD_READ };
 struct nbd_reply reply;
 ssize_t ret;

+assert(nb_sectors <= NBD_MAX_SECTORS);
 request.from = sector_num * 512;
 request.len = nb_sectors * 512;

@@ -234,16 +234,15 @@ static int nbd_co_readv_1(BlockDriverState *bs, int64_t 
sector_num,
 if (ret < 0) {
 reply.error = -ret;
 } else {
-nbd_co_receive_reply(client, &request, &reply, qiov, offset);
+nbd_co_receive_reply(client, &request, &reply, qiov, 0);
 }
 nbd_coroutine_end(client, &request);
 return -reply.error;

 }

-static int nbd_co_writev_1(BlockDriverState *bs, int64_t sector_num,
-   int nb_sectors, QEMUIOVector *qiov,
-   int offset, int flags)
+int nbd_client_co_writev(BlockDriverState *bs, int64_t sector_num,
+ int nb_sectors, QEMUIOVector *qiov, int flags)
 {
 NbdClientSession *client = nbd_get_client_session(bs);
 struct nbd_request request = { .type = NBD_CMD_WRITE };
@@ -255,11 +254,12 @@ static int nbd_co_writev_1(BlockDriverState *bs, int64_t 
sector_num,
 request.type |= NBD_CMD_FLAG_FUA;
 }

+assert(nb_sectors <= NBD_MAX_SECTORS);
 request.from = sector_num * 512;
 request.len = nb_sectors * 512;

 nbd_coroutine_start(client, &request);
-ret = nbd_co_send_request(bs, &request, qiov, offset);
+ret = nbd_co_send_request(bs, &request, qiov, 0);
 if (ret < 0) {
 reply.error = -ret;
 } else {
@@ -269,41 +269,6 @@ static int nbd_co_writev_1(BlockDriverState *bs, int64_t 
sector_num,
 return -reply.error;
 }

-int nbd_client_co_readv(BlockDriverState *bs, int64_t sector_num,
-int nb_sectors, QEMUIOVector *qiov)
-{
-int offset = 0;
-int ret;
-while (nb_sectors > NBD_MAX_SECTORS) {
-ret = nbd_co_readv_1(bs, sector_num, NBD_MAX_SECTORS, qiov, offset);
-if (ret < 0) {
-return ret;
-}
-offset += NBD_MAX_SECTORS * 512;
-sector_num += NBD_MAX_SECTORS;
-nb_sectors -= NBD_MAX_SECTORS;
-}
-return nbd_co_readv_1(bs, sector_num, nb_sectors, qiov, offset);
-}
-
-int nbd_client_co_writev(BlockDriverState *bs, int64_t sector_num,
- int nb_sectors, QEMUIOVector *qiov, int flags)
-{
-int offset = 0;
-int ret;
-while (nb_sectors > NBD_MAX_SECTORS) {
-ret = nbd_co_writev_1(bs, sector_num, NBD_MAX_SECTORS, qiov, offset,
-  flags);
-if (ret < 0) {
-return ret;
-}
-offset += NBD_MAX_SECTORS * 512;
-sector_num += NBD_MAX_SECTORS;
-nb_sectors -= NBD_MAX_SECTORS;
-}
-return nbd_co_writev_1(bs, sector_num, nb_sectors, qiov, offset, flags);
-}
-
 int nbd_client_co_flush(BlockDriverState *bs)
 {
 NbdClientSession *client = nbd_get_client_session(bs);
diff --git a/block/nbd.c b/block/nbd.c
index 08e5b67..8a13078 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -349,12 +349,6 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
 return ret;
 }

-static int nbd_co_readv(BlockDriverState *bs, int64_t sector_num,
-int nb_sectors, QEMUIOVector *qiov)
-{
-return nbd_client_co_readv(bs, sector_num, nb_sectors, qiov);
-}
-
 static int nbd_co_flush(BlockDriverState *bs)
 {
 return nbd_client_co_flush(bs);
@@ -450,7 +444,7 @@ static BlockDriver bdrv_nbd = {
 .instance_size  = sizeof(BDRVNBDState),
 .bdrv_parse_filename= nbd_parse_filename,
 .b

[Qemu-devel] [PATCH 3/5] raw_bsd: Don't advertise flags not supported by protocol layer

2016-06-20 Thread Eric Blake
The raw format layer supports all flags via passthrough - but
it only makes sense to pass through flags that the lower layer
actually supports.

Thanks to the previous patch, the raw format layer now attempts
to fragment writes at the max_transfer limit it inherits from
the NBD protocol layer, recently set to 32m.  An attempt to do
'w -f 0 40m' to an NBD server that lacks FUA thus changed from
flushing once (after NBD fragmented a single 40m write itself)
to instead flushing twice (the format layer sees BDRV_REQ_FUA
in supported_write_flags, so it sends the flag on to both
fragments, and then the block layer emulates FUA by flushing
for both the 32m and 8m fragments at the protocol layer).
This patch fixes the performance regression (now that the
format layer no longer advertises a flag not present at the
protocol layer, the flush to emulate FUA is deferred to the
last fragment).

Note that 'w -f -z 0 40m' does not currently exhibit the same
problem, because there, the fragmentation does not occur until
at the NBD layer (the raw layer has .bdrv_co_pwrite_zeroes, and
the NBD layer doesn't advertise max_pwrite_zeroes to constrain
things at the raw layer) - but that problem is latent and would
have the same problem with too many flushes without this patch
once the NBD layer implements support for using the new
NBD_CMD_WRITE_ZEROES and sets max_pwrite_zeroes to the same 32m
limit as recommended by the NBD protocol.

Signed-off-by: Eric Blake 
---
 block/raw_bsd.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index 351ed2a..47a8352 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -197,8 +197,10 @@ static int raw_open(BlockDriverState *bs, QDict *options, 
int flags,
 Error **errp)
 {
 bs->sg = bs->file->bs->sg;
-bs->supported_write_flags = BDRV_REQ_FUA;
-bs->supported_zero_flags = BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP;
+bs->supported_write_flags = BDRV_REQ_FUA &
+bs->file->bs->supported_write_flags;
+bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
+bs->file->bs->supported_zero_flags;

 if (bs->probed && !bdrv_is_read_only(bs)) {
 fprintf(stderr,
-- 
2.5.5




Re: [Qemu-devel] [PATCH] vfio/pci: Hide SR-IOV capability

2016-06-20 Thread Laszlo Ersek
On 06/21/16 00:04, Alex Williamson wrote:
> The kernel currently exposes the SR-IOV capability as read-only
> through vfio-pci.  This is sufficient to protect the host kernel, but
> has the potential to confuse guests without further virtualization.
> In particular, OVMF tries to size the VF BARs and comes up with absurd
> results, ending with an assert.  There's not much point in adding
> virtualization to a read-only capability, so we simply hide it for
> now.  If the kernel ever enables SR-IOV virtualization, we should
> easily be able to test it through VF BAR sizing or explicit flags.
> 
> Testing whether we should parse extended capabilities is also pulled
> into the function to keep these assumptions in one place.
> 
> Signed-off-by: Alex Williamson 
> ---
> 
> This depends on Chen Fan's patch "vfio: add pcie extended capability
> support", which I'll pull from Zhou Jie's latest series unless there
> are comments to the contrary.  Otherwise based on Stefan's tracing
> pull request so as not to conflict.
> 
>  hw/vfio/pci.c|   49 +++--
>  hw/vfio/trace-events |1 +
>  2 files changed, 40 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index a171056b..36d5e00 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -1772,6 +1772,12 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
>  uint8_t cap_ver;
>  uint8_t *config;
>  
> +/* Only add extended caps if we have them and the guest can see them */
> +if (!pci_is_express(pdev) || !pci_bus_is_express(pdev->bus) ||
> +!pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) {
> +return 0;
> +}
> +
>  /*
>   * pcie_add_capability always inserts the new capability at the tail
>   * of the chain.  Therefore to end up with a chain that matches the
> @@ -1780,6 +1786,25 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
>   */
>  config = g_memdup(pdev->config, vdev->config_size);
>  
> +/*
> + * Extended capabilities are chained with each pointing to the next, so 
> we
> + * can drop anything other than the head of the chain simply by modifying
> + * the previous next pointer.  For the head of the chain, we can modify 
> the
> + * capability ID to something that cannot match a valid capability.  ID
> + * 0 is reserved for this since absence of capabilities is indicated by
> + * 0 for the ID, version, AND next pointer.  However, 
> pcie_add_capability()
> + * uses ID 0 as reserved for list management and will incorrectly match 
> and
> + * assert if we attempt to pre-load the head of the chain with with this
> + * ID.  Use ID 0x temporarily since it is also seems to be reserved 
> in
> + * part for identifying abscense of capabilities in a root complex 
> register
> + * block.  If the ID still exists after adding capabilities, switch back 
> to
> + * zero.  We'll mark this entire first dword as emulated for this 
> purpose.
> + */
> +pci_set_long(pdev->config + PCI_CONFIG_SPACE_SIZE,
> + PCI_EXT_CAP(0x, 0, 0));
> +pci_set_long(pdev->wmask + PCI_CONFIG_SPACE_SIZE, 0);
> +pci_set_long(vdev->emulated_config_bits + PCI_CONFIG_SPACE_SIZE, ~0);
> +
>  for (next = PCI_CONFIG_SPACE_SIZE; next;
>   next = PCI_EXT_CAP_NEXT(pci_get_long(config + next))) {
>  header = pci_get_long(config + next);
> @@ -1794,12 +1819,23 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
>   */
>  size = vfio_ext_cap_max_size(config, next);
>  
> -pcie_add_capability(pdev, cap_id, cap_ver, next, size);
> -pci_set_long(pdev->config + next, PCI_EXT_CAP(cap_id, cap_ver, 0));
> -
>  /* Use emulated next pointer to allow dropping extended caps */
>  pci_long_test_and_set_mask(vdev->emulated_config_bits + next,
> PCI_EXT_CAP_NEXT_MASK);
> +
> +switch (cap_id) {
> +case PCI_EXT_CAP_ID_SRIOV: /* Read-only VF BARs confuses OVMF */

I think s/confuses/confuse/.

Other than that, this is mostly black magic to me, so I can't even ACK
it with a straight face :)

I would like to test it, and report back, but then again, I don't have a
NIC with virtual functions. :/

Thank you!
Laszlo

> +trace_vfio_add_ext_cap_dropped(vdev->vbasedev.name, cap_id, 
> next);
> +break;
> +default:
> +pcie_add_capability(pdev, cap_id, cap_ver, next, size);
> +}
> +
> +}
> +
> +/* Cleanup chain head ID if necessary */
> +if (pci_get_word(pdev->config + PCI_CONFIG_SPACE_SIZE) == 0x) {
> +pci_set_word(pdev->config + PCI_CONFIG_SPACE_SIZE, 0);
>  }
>  
>  g_free(config);
> @@ -1821,13 +1857,6 @@ static int vfio_add_capabilities(VFIOPCIDevice *vdev)
>  return ret;
>  }
>  
> -/* on PCI bus, it doesn't make sense to expose extended capabilities. */
> -if (!pci_is_express(pdev) ||

Re: [Qemu-devel] [PATCH v6 03/13] register: Add Memory API glue

2016-06-20 Thread Alistair Francis
On Thu, Jun 9, 2016 at 12:03 PM, Peter Maydell  wrote:
> On 12 May 2016 at 23:45, Alistair Francis  wrote:
>> Add memory io handlers that glue the register API to the memory API.
>> Just translation functions at this stage. Although it does allow for
>> devices to be created without all-in-one mmio r/w handlers.
>>
>> This patch also adds the RegisterInfoArray struct, which allows all of
>> the individual RegisterInfo structs to be grouped into a single memory
>> region.
>>
>> Signed-off-by: Peter Crosthwaite 
>> Signed-off-by: Alistair Francis 
>> ---
>> V6:
>>  - Add the memory region later
>> V5:
>>  - Convert to using only one memory region
>>
>>  hw/core/register.c| 72 
>> +++
>>  include/hw/register.h | 50 +++
>>  2 files changed, 122 insertions(+)
>>
>> diff --git a/hw/core/register.c b/hw/core/register.c
>> index 5e6f621..25196e6 100644
>> --- a/hw/core/register.c
>> +++ b/hw/core/register.c
>> @@ -147,3 +147,75 @@ void register_reset(RegisterInfo *reg)
>>
>>  register_write_val(reg, reg->access->reset);
>>  }
>> +
>> +static inline void register_write_memory(void *opaque, hwaddr addr,
>> + uint64_t value, unsigned size, 
>> bool be)
>> +{
>> +RegisterInfoArray *reg_array = opaque;
>> +RegisterInfo *reg = NULL;
>> +uint64_t we = ~0;
>> +int i, shift = 0;
>> +
>> +for (i = 0; i < reg_array->num_elements; i++) {
>> +if (reg_array->r[i]->access->decode.addr == addr) {
>> +reg = reg_array->r[i];
>> +break;
>> +}
>> +}
>> +assert(reg);
>
> I'm surprised we don't support having the register array have
> gaps for unimplemented/undefined registers. Presumably users
> have to specify a lot of unimplemented entries ?
>
> If you're going to assert() on undecoded addresses it would be
> better to do a scan through at device init to sanity check
> the register array, so missing elements are an obvious failure
> rather than only showing up if the guest happens to access them.

You're right, this is a little harsh. I'm thinking I'll change it to a
qemu_log() (unimplemented, although it also could be a guest error)
and remove the assert().

>
>> +
>> +/* Generate appropriate write enable mask and shift values */
>> +if (reg->data_size < size) {
>> +we = MAKE_64BIT_MASK(0, reg->data_size * 8);
>> +shift = 8 * (be ? reg->data_size - size : 0);
>> +} else if (reg->data_size >= size) {
>> +we = MAKE_64BIT_MASK(0, size * 8);
>> +}
>> +
>> +register_write(reg, value << shift, we << shift, reg_array->prefix,
>> +   reg_array->debug);
>> +}
>> +
>> +void register_write_memory_be(void *opaque, hwaddr addr, uint64_t value,
>> +  unsigned size)
>> +{
>> +register_write_memory(opaque, addr, value, size, true);
>> +}
>> +
>> +
>> +void register_write_memory_le(void *opaque, hwaddr addr, uint64_t value,
>> +  unsigned size)
>> +{
>> +register_write_memory(opaque, addr, value, size, false);
>> +}
>> +
>> +static inline uint64_t register_read_memory(void *opaque, hwaddr addr,
>> +unsigned size, bool be)
>> +{
>> +RegisterInfoArray *reg_array = opaque;
>> +RegisterInfo *reg = NULL;
>> +int i, shift;
>> +
>> +for (i = 0; i < reg_array->num_elements; i++) {
>> +if (reg_array->r[i]->access->decode.addr == addr) {
>> +reg = reg_array->r[i];
>> +break;
>> +}
>> +}
>> +assert(reg);
>> +
>> +shift = 8 * (be ? reg->data_size - size : 0);
>> +
>> +return (register_read(reg, reg_array->prefix, reg_array->debug) >> 
>> shift) &
>> +   MAKE_64BIT_MASK(0, size * 8);
>
> This kind of thing is reimplementing extract64().

Ok, I'll update it to use extract64()

>
>> +}
>> +
>> +uint64_t register_read_memory_be(void *opaque, hwaddr addr, unsigned size)
>> +{
>> +return register_read_memory(opaque, addr, size, true);
>> +}
>> +
>> +uint64_t register_read_memory_le(void *opaque, hwaddr addr, unsigned size)
>> +{
>> +return register_read_memory(opaque, addr, size, false);
>> +}
>
> Why do we need to handle big vs little endian separately rather
> than just having the memory region say which it is and letting
> the core memory system handle things appropriately ?

I didn't realise that is an option. So I can remove all the endianess
handling from here and the core will handle it?

Thanks,

Alistair

>
> thanks
> -- PMM
>



[Qemu-devel] [PATCH qemu v18 0/5] spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)

2016-06-20 Thread Alexey Kardashevskiy
Each Partitionable Endpoint (IOMMU group) has an address range on a PCI bus
where devices are allowed to do DMA. These ranges are called DMA windows.
By default, there is a single DMA window, 1 or 2GB big, mapped at zero
on a PCI bus.

PAPR defines a DDW RTAS API which allows pseries guests
querying the hypervisor about DDW support and capabilities (page size mask
for now). A pseries guest may request an additional (to the default)
DMA windows using this RTAS API.
The existing pseries Linux guests request an additional window as big as
the guest RAM and map the entire guest window which effectively creates
direct mapping of the guest memory to a PCI bus.

This patchset reworks PPC64 IOMMU code and adds necessary structures
to support big windows on pseries.

This patchset is based on David's ppc-for-2.7 branch, sha1 8dc2e5e.

This patchset does not contain guest view table reallocation as
it is not a part of DDW and it depends on
"memory: Add MemoryRegionIOMMUOps.notify_started/stopped callbacks"
which went to the VFIO tree; will repost spapr part when the prerequisite
is merged into David's queue.

Please comment. Thanks!


Alexey Kardashevskiy (5):
  memory: Add reporting of supported page sizes
  vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)
  vfio: Add host side DMA window capabilities
  vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2)
  spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)

 hw/ppc/Makefile.objs  |   1 +
 hw/ppc/spapr.c|   7 +-
 hw/ppc/spapr_iommu.c  |   8 ++
 hw/ppc/spapr_pci.c|  77 ---
 hw/ppc/spapr_rtas_ddw.c   | 295 ++
 hw/vfio/Makefile.objs |   1 +
 hw/vfio/common.c  | 180 --
 hw/vfio/spapr.c   | 210 ++
 include/exec/memory.h |  19 ++-
 include/hw/pci-host/spapr.h   |   8 +-
 include/hw/ppc/spapr.h|  16 ++-
 include/hw/vfio/vfio-common.h |  20 ++-
 memory.c  |  16 ++-
 trace-events  |  12 ++
 14 files changed, 800 insertions(+), 70 deletions(-)
 create mode 100644 hw/ppc/spapr_rtas_ddw.c
 create mode 100644 hw/vfio/spapr.c

-- 
2.5.0.rc3




[Qemu-devel] [PATCH qemu v18 1/5] memory: Add reporting of supported page sizes

2016-06-20 Thread Alexey Kardashevskiy
Every IOMMU has some granularity which MemoryRegionIOMMUOps::translate
uses when translating, however this information is not available outside
the translate context for various checks.

This adds a get_min_page_size callback to MemoryRegionIOMMUOps and
a wrapper for it so IOMMU users (such as VFIO) can know the minimum
actual page size supported by an IOMMU.

As IOMMU MR represents a guest IOMMU, this uses TARGET_PAGE_SIZE
as fallback.

This removes vfio_container_granularity() and uses new helper in
memory_region_iommu_replay() when replaying IOMMU mappings on added
IOMMU memory region.

Signed-off-by: Alexey Kardashevskiy 
Reviewed-by: David Gibson 
Acked-by: Alex Williamson 
---
Changes:
v18:
* fixed unnecessary line wrap
* s/get_page_sizes/get_min_page_size/

v16:
* used memory_region_iommu_get_page_sizes() instead of
mr->iommu_ops->get_page_sizes() in memory_region_iommu_replay()

v15:
* s/qemu_real_host_page_size/TARGET_PAGE_SIZE/ in 
memory_region_iommu_get_page_sizes

v14:
* removed vfio_container_granularity(), changed memory_region_iommu_replay()

v4:
* s/1page_shift);
 }
 
+static uint64_t spapr_tce_get_min_page_size(MemoryRegion *iommu)
+{
+sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
+
+return 1ULL << tcet->page_shift;
+}
+
 static int spapr_tce_table_post_load(void *opaque, int version_id)
 {
 sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque);
@@ -228,6 +235,7 @@ static const VMStateDescription vmstate_spapr_tce_table = {
 
 static MemoryRegionIOMMUOps spapr_iommu_ops = {
 .translate = spapr_tce_translate_iommu,
+.get_min_page_size = spapr_tce_get_min_page_size,
 };
 
 static int spapr_tce_table_realize(DeviceState *dev)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 1898f1f..27cc159 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -321,11 +321,6 @@ out:
 rcu_read_unlock();
 }
 
-static hwaddr vfio_container_granularity(VFIOContainer *container)
-{
-return (hwaddr)1 << ctz64(container->iova_pgsizes);
-}
-
 static void vfio_listener_region_add(MemoryListener *listener,
  MemoryRegionSection *section)
 {
@@ -392,9 +387,7 @@ static void vfio_listener_region_add(MemoryListener 
*listener,
 QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
 
 memory_region_register_iommu_notifier(giommu->iommu, &giommu->n);
-memory_region_iommu_replay(giommu->iommu, &giommu->n,
-   vfio_container_granularity(container),
-   false);
+memory_region_iommu_replay(giommu->iommu, &giommu->n, false);
 
 return;
 }
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 4ab6800..e3829f7 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -151,6 +151,8 @@ typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
 struct MemoryRegionIOMMUOps {
 /* Return a TLB entry that contains a given address. */
 IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool 
is_write);
+/* Returns minimum supported page size */
+uint64_t (*get_min_page_size)(MemoryRegion *iommu);
 };
 
 typedef struct CoalescedMemoryRange CoalescedMemoryRange;
@@ -573,6 +575,16 @@ static inline bool memory_region_is_iommu(MemoryRegion *mr)
 
 
 /**
+ * memory_region_iommu_get_min_page_size: get minimum supported page size
+ * for an iommu
+ *
+ * Returns minimum supported page size for an iommu.
+ *
+ * @mr: the memory region being queried
+ */
+uint64_t memory_region_iommu_get_min_page_size(MemoryRegion *mr);
+
+/**
  * memory_region_notify_iommu: notify a change in an IOMMU translation entry.
  *
  * @mr: the memory region that was changed
@@ -596,16 +608,15 @@ void memory_region_register_iommu_notifier(MemoryRegion 
*mr, Notifier *n);
 
 /**
  * memory_region_iommu_replay: replay existing IOMMU translations to
- * a notifier
+ * a notifier with the minimum page granularity returned by
+ * mr->iommu_ops->get_page_size().
  *
  * @mr: the memory region to observe
  * @n: the notifier to which to replay iommu mappings
- * @granularity: Minimum page granularity to replay notifications for
  * @is_write: Whether to treat the replay as a translate "write"
  * through the iommu
  */
-void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n,
-hwaddr granularity, bool is_write);
+void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_write);
 
 /**
  * memory_region_unregister_iommu_notifier: unregister a notifier for
diff --git a/memory.c b/memory.c
index 8ba496d..fe44e29 100644
--- a/memory.c
+++ b/memory.c
@@ -1502,12 +1502,22 @@ void memory_region_register_iommu_notifier(MemoryRegion 
*mr, Notifier *n)
 notifier_list_add(&mr->iommu_notify, n);
 }
 
-void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n,
-hwaddr granularity, bool is_write)
+uint64_t memory_region_iommu_get_min_page

[Qemu-devel] [PATCH qemu v18 3/5] vfio: Add host side DMA window capabilities

2016-06-20 Thread Alexey Kardashevskiy
There are going to be multiple IOMMUs per a container. This moves
the single host IOMMU parameter set to a list of VFIOHostDMAWindow.

This should cause no behavioral change and will be used later by
the SPAPR TCE IOMMU v2 which will also add a vfio_host_win_del() helper.

Signed-off-by: Alexey Kardashevskiy 
Reviewed-by: David Gibson 
---
Changes:
v18:
* vfio_host_win_add() checks for non-overlapping windows instead of calling
vfio_host_win_lookup() which checks for inclusion
* inlined vfio_host_win_lookup() as I ended up using it just once
* put VFIOHostDMAWindow::max_iova in new line in include/hw/vfio/vfio-common.h

v17:
* vfio_host_win_add() uses vfio_host_win_lookup() for overlap check and
aborts if any found instead of returning an error (as recovery is not
possible anyway)
* hw_error() when overlapped iommu is detected

v16:
* adjusted commit log with changes from v15

v15:
* s/vfio_host_iommu_add/vfio_host_win_add/
* s/VFIOHostIOMMU/VFIOHostDMAWindow/
---
 hw/vfio/common.c  | 60 +++
 include/hw/vfio/vfio-common.h | 10 ++--
 2 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 22be48b..b53a1db 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -28,6 +28,7 @@
 #include "exec/memory.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
+#include "qemu/range.h"
 #include "sysemu/kvm.h"
 #ifdef CONFIG_KVM
 #include "linux/kvm.h"
@@ -241,6 +242,29 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr 
iova,
 return -errno;
 }
 
+static void vfio_host_win_add(VFIOContainer *container,
+  hwaddr min_iova, hwaddr max_iova,
+  uint64_t iova_pgsizes)
+{
+VFIOHostDMAWindow *hostwin;
+
+QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
+if (ranges_overlap(hostwin->min_iova,
+   hostwin->max_iova - hostwin->min_iova + 1,
+   min_iova,
+   max_iova - min_iova + 1)) {
+hw_error("%s: Overlapped IOMMU are not enabled", __func__);
+}
+}
+
+hostwin = g_malloc0(sizeof(*hostwin));
+
+hostwin->min_iova = min_iova;
+hostwin->max_iova = max_iova;
+hostwin->iova_pgsizes = iova_pgsizes;
+QLIST_INSERT_HEAD(&container->hostwin_list, hostwin, hostwin_next);
+}
+
 static bool vfio_listener_skipped_section(MemoryRegionSection *section)
 {
 return (!memory_region_is_ram(section->mr) &&
@@ -329,6 +353,8 @@ static void vfio_listener_region_add(MemoryListener 
*listener,
 Int128 llend, llsize;
 void *vaddr;
 int ret;
+VFIOHostDMAWindow *hostwin;
+bool hostwin_found;
 
 if (vfio_listener_skipped_section(section)) {
 trace_vfio_listener_region_add_skip(
@@ -354,7 +380,15 @@ static void vfio_listener_region_add(MemoryListener 
*listener,
 }
 end = int128_get64(int128_sub(llend, int128_one()));
 
-if ((iova < container->min_iova) || (end > container->max_iova)) {
+hostwin_found = false;
+QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
+if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
+hostwin_found = true;
+break;
+}
+}
+
+if (!hostwin_found) {
 error_report("vfio: IOMMU container %p can't map guest IOVA region"
  " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx,
  container, iova, end);
@@ -369,10 +403,6 @@ static void vfio_listener_region_add(MemoryListener 
*listener,
 
 trace_vfio_listener_region_add_iommu(iova, end);
 /*
- * FIXME: We should do some checking to see if the
- * capabilities of the host VFIO IOMMU are adequate to model
- * the guest IOMMU
- *
  * FIXME: For VFIO iommu types which have KVM acceleration to
  * avoid bouncing all map/unmaps through qemu this way, this
  * would be the right place to wire that up (tell the KVM
@@ -878,17 +908,14 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
  * existing Type1 IOMMUs generally support any IOVA we're
  * going to actually try in practice.
  */
-container->min_iova = 0;
-container->max_iova = (hwaddr)-1;
-
-/* Assume just 4K IOVA page size */
-container->iova_pgsizes = 0x1000;
 info.argsz = sizeof(info);
 ret = ioctl(fd, VFIO_IOMMU_GET_INFO, &info);
 /* Ignore errors */
-if ((ret == 0) && (info.flags & VFIO_IOMMU_INFO_PGSIZES)) {
-container->iova_pgsizes = info.iova_pgsizes;
+if (ret || !(info.flags & VFIO_IOMMU_INFO_PGSIZES)) {
+/* Assume 4k IOVA page size */
+info.iova_pgsizes = 4096;
 }
+vfio_host_win_add(container, 0, (hwaddr)-1, info.iova_pgsizes);
 } else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU) ||
ioc

[Qemu-devel] [PATCH qemu v18 2/5] vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)

2016-06-20 Thread Alexey Kardashevskiy
This makes use of the new "memory registering" feature. The idea is
to provide the userspace ability to notify the host kernel about pages
which are going to be used for DMA. Having this information, the host
kernel can pin them all once per user process, do locked pages
accounting (once) and not spent time on doing that in real time with
possible failures which cannot be handled nicely in some cases.

This adds a prereg memory listener which listens on address_space_memory
and notifies a VFIO container about memory which needs to be
pinned/unpinned. VFIO MMIO regions (i.e. "skip dump" regions) are skipped.

The feature is only enabled for SPAPR IOMMU v2. The host kernel changes
are required. Since v2 does not need/support VFIO_IOMMU_ENABLE, this does
not call it when v2 is detected and enabled.

This enforces guest RAM blocks to be host page size aligned; however
this is not new as KVM already requires memory slots to be host page
size aligned.

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v18:
* made a copy of listener trace points in spapr.c
* fixed cleanup in vfio_connect_container
* removed assert in vfio_prereg_listener_region_add()
* created "prereg" copy of traces

v17:
* s/prereg\.c/spapr.c/
* s/vfio_prereg_gpa_to_ua/vfio_prereg_gpa_to_vaddr/
* vfio_prereg_listener_skipped_section does hw_error() on IOMMUs

v16:
* switched to 64bit math everywhere as there is no chance to see
region_add on RAM blocks even remotely close to 1<<64bytes.

v15:
* banned unaligned sections
* added an vfio_prereg_gpa_to_ua() helper

v14:
* s/free_container_exit/listener_release_exit/g
* added "if memory_region_is_iommu()" to vfio_prereg_listener_skipped_section
---
 hw/vfio/Makefile.objs |   1 +
 hw/vfio/common.c  |  42 ++---
 hw/vfio/spapr.c   | 139 ++
 include/hw/vfio/vfio-common.h |   4 ++
 trace-events  |   6 ++
 5 files changed, 182 insertions(+), 10 deletions(-)
 create mode 100644 hw/vfio/spapr.c

diff --git a/hw/vfio/Makefile.objs b/hw/vfio/Makefile.objs
index ceddbb8..c25e32b 100644
--- a/hw/vfio/Makefile.objs
+++ b/hw/vfio/Makefile.objs
@@ -4,4 +4,5 @@ obj-$(CONFIG_PCI) += pci.o pci-quirks.o
 obj-$(CONFIG_SOFTMMU) += platform.o
 obj-$(CONFIG_SOFTMMU) += calxeda-xgmac.o
 obj-$(CONFIG_SOFTMMU) += amd-xgbe.o
+obj-$(CONFIG_SOFTMMU) += spapr.o
 endif
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 27cc159..22be48b 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -502,6 +502,9 @@ static const MemoryListener vfio_memory_listener = {
 static void vfio_listener_release(VFIOContainer *container)
 {
 memory_listener_unregister(&container->listener);
+if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
+memory_listener_unregister(&container->prereg_listener);
+}
 }
 
 static struct vfio_info_cap_header *
@@ -860,8 +863,8 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
 goto free_container_exit;
 }
 
-ret = ioctl(fd, VFIO_SET_IOMMU,
-v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU);
+container->iommu_type = v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU;
+ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
 if (ret) {
 error_report("vfio: failed to set iommu for container: %m");
 ret = -errno;
@@ -886,8 +889,10 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
 if ((ret == 0) && (info.flags & VFIO_IOMMU_INFO_PGSIZES)) {
 container->iova_pgsizes = info.iova_pgsizes;
 }
-} else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) {
+} else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU) ||
+   ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU)) {
 struct vfio_iommu_spapr_tce_info info;
+bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU);
 
 ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd);
 if (ret) {
@@ -895,7 +900,9 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
 ret = -errno;
 goto free_container_exit;
 }
-ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_SPAPR_TCE_IOMMU);
+container->iommu_type =
+v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
+ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
 if (ret) {
 error_report("vfio: failed to set iommu for container: %m");
 ret = -errno;
@@ -907,11 +914,23 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
  * when container fd is closed so we do not call it explicitly
  * in this file.
  */
-ret = ioctl(fd, VFIO_IOMMU_ENABLE);
-if (ret) {
-error_report("vfio: failed to enable container: %m");
-ret = -errno;
-goto free_container_exit;
+if (!v2) {
+

[Qemu-devel] [PATCH qemu v18 4/5] vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2)

2016-06-20 Thread Alexey Kardashevskiy
New VFIO_SPAPR_TCE_v2_IOMMU type supports dynamic DMA window management.
This adds ability to VFIO common code to dynamically allocate/remove
DMA windows in the host kernel when new VFIO container is added/removed.

This adds a helper to vfio_listener_region_add which makes
VFIO_IOMMU_SPAPR_TCE_CREATE ioctl and adds just created IOMMU into
the host IOMMU list; the opposite action is taken in
vfio_listener_region_del.

When creating a new window, this uses heuristic to decide on the TCE table
levels number.

This should cause no guest visible change in behavior.

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v18:
* moved trace definitions under hw/vfio/spapr.c section
* moved trace_vfio_spapr_remove_window to vfio_spapr_remove_window()
* vfio_host_win_del() now checks for exact window size
* one ctz() less in vfio_spapr_create_window()

v17:
* moved spapr window create/remove helpers to separate file
* added hw_error() if vfio_host_win_del() failed

v16:
* used memory_region_iommu_get_page_sizes() in vfio_listener_region_add()
* enforced no intersections between windows

v14:
* new to the series
---
 hw/vfio/common.c  | 79 +--
 hw/vfio/spapr.c   | 71 ++
 include/hw/vfio/vfio-common.h |  6 
 trace-events  |  2 ++
 4 files changed, 148 insertions(+), 10 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index b53a1db..8e3466c 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -265,6 +265,21 @@ static void vfio_host_win_add(VFIOContainer *container,
 QLIST_INSERT_HEAD(&container->hostwin_list, hostwin, hostwin_next);
 }
 
+static int vfio_host_win_del(VFIOContainer *container, hwaddr min_iova,
+ hwaddr max_iova)
+{
+VFIOHostDMAWindow *hostwin;
+
+QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
+if (hostwin->min_iova == min_iova && hostwin->max_iova == max_iova) {
+QLIST_REMOVE(hostwin, hostwin_next);
+return 0;
+}
+}
+
+return -1;
+}
+
 static bool vfio_listener_skipped_section(MemoryRegionSection *section)
 {
 return (!memory_region_is_ram(section->mr) &&
@@ -380,6 +395,30 @@ static void vfio_listener_region_add(MemoryListener 
*listener,
 }
 end = int128_get64(int128_sub(llend, int128_one()));
 
+if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
+VFIOHostDMAWindow *hostwin;
+hwaddr pgsize = 0;
+
+/* For now intersections are not allowed, we may relax this later */
+QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
+if (ranges_overlap(hostwin->min_iova,
+   hostwin->max_iova - hostwin->min_iova + 1,
+   section->offset_within_address_space,
+   int128_get64(section->size))) {
+goto fail;
+}
+}
+
+ret = vfio_spapr_create_window(container, section, &pgsize);
+if (ret) {
+goto fail;
+}
+
+vfio_host_win_add(container, section->offset_within_address_space,
+  section->offset_within_address_space +
+  int128_get64(section->size) - 1, pgsize);
+}
+
 hostwin_found = false;
 QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
 if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
@@ -522,6 +561,18 @@ static void vfio_listener_region_del(MemoryListener 
*listener,
  "0x%"HWADDR_PRIx") = %d (%m)",
  container, iova, int128_get64(llsize), ret);
 }
+
+if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
+vfio_spapr_remove_window(container,
+ section->offset_within_address_space);
+if (vfio_host_win_del(container,
+  section->offset_within_address_space,
+  section->offset_within_address_space +
+  int128_get64(section->size) - 1) < 0) {
+hw_error("%s: Cannot delete missing window at %"HWADDR_PRIx,
+ __func__, section->offset_within_address_space);
+}
+}
 }
 
 static const MemoryListener vfio_memory_listener = {
@@ -960,11 +1011,6 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
 }
 }
 
-/*
- * This only considers the host IOMMU's 32-bit window.  At
- * some point we need to add support for the optional 64-bit
- * window and dynamic windows
- */
 info.argsz = sizeof(info);
 ret = ioctl(fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);
 if (ret) {
@@ -976,11 +1022,24 @@ static int vfio_connect_container(VFIOGroup *group, 
AddressSpace *as)
 goto listener_release_exit;
 }
 
-/* The default table uses 4K pag

[Qemu-devel] [PATCH qemu v18 5/5] spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)

2016-06-20 Thread Alexey Kardashevskiy
This adds support for Dynamic DMA Windows (DDW) option defined by
the SPAPR specification which allows to have additional DMA window(s)

The "ddw" property is enabled by default on a PHB but for compatibility
the pseries-2.6 machine and older disable it.
This also creates a single DMA window for the older machines to
maintain backward migration.

This implements DDW for PHB with emulated and VFIO devices. The host
kernel support is required. The advertised IOMMU page sizes are 4K and
64K; 16M pages are supported but not advertised by default, in order to
enable them, the user has to specify "pgsz" property for PHB and
enable huge pages for RAM.

The existing linux guests try creating one additional huge DMA window
with 64K or 16MB pages and map the entire guest RAM to. If succeeded,
the guest switches to dma_direct_ops and never calls TCE hypercalls
(H_PUT_TCE,...) again. This enables VFIO devices to use the entire RAM
and not waste time on map/unmap later. This adds a "dma64_win_addr"
property which is a bus address for the 64bit window and by default
set to 0x800... as this is what the modern POWER8 hardware
uses and this allows having emulated and VFIO devices on the same bus.

This adds 4 RTAS handlers:
* ibm,query-pe-dma-window
* ibm,create-pe-dma-window
* ibm,remove-pe-dma-window
* ibm,reset-pe-dma-window
These are registered from type_init() callback.

These RTAS handlers are implemented in a separate file to avoid polluting
spapr_iommu.c with PCI.

This changes sPAPRPHBState::dma_liobn to an array to allow 2 LIOBNs.

Signed-off-by: Alexey Kardashevskiy 
---
Changes:
v18:
* fixed bug when ddw-create rtas call was always creating window at 1<<59
offset
* update minimum supported machine version
* s/dma64_window_addr/dma_win_addr/ to match dma_win_addr

v17:
* fixed: "query" did return non-page-shifted value when memory hotplug is 
enabled

v16:
* s/dma_liobn/dma_liobn[SPAPR_PCI_DMA_MAX_WINDOWS]/
* s/SPAPR_PCI_LIOBN()/dma_liobn[]/

v15:
* moved page mask filtering to PHB realize(), use "-mempath" to know
if there are huge pages
* fixed error reporting in RTAS handlers
* max window size accounts now hotpluggable memory boundaries
---
 hw/ppc/Makefile.objs|   1 +
 hw/ppc/spapr.c  |   7 +-
 hw/ppc/spapr_pci.c  |  77 +---
 hw/ppc/spapr_rtas_ddw.c | 295 
 include/hw/pci-host/spapr.h |   8 +-
 include/hw/ppc/spapr.h  |  16 ++-
 trace-events|   4 +
 7 files changed, 386 insertions(+), 22 deletions(-)
 create mode 100644 hw/ppc/spapr_rtas_ddw.c

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 5cc6608..91a3420 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -8,6 +8,7 @@ obj-$(CONFIG_PSERIES) += spapr_cpu_core.o
 ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
 obj-y += spapr_pci_vfio.o
 endif
+obj-$(CONFIG_PSERIES) += spapr_rtas_ddw.o
 # PowerPC 4xx boards
 obj-y += ppc405_boards.o ppc4xx_devs.o ppc405_uc.o ppc440_bamboo.o
 obj-y += ppc4xx_pci.o
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 778fa25..f7cff27 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2485,7 +2485,12 @@ DEFINE_SPAPR_MACHINE(2_7, "2.7", true);
  * pseries-2.6
  */
 #define SPAPR_COMPAT_2_6 \
-HW_COMPAT_2_6
+HW_COMPAT_2_6 \
+{ \
+.driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,\
+.property = "ddw",\
+.value= stringify(off),\
+},
 
 static void spapr_machine_2_6_instance_options(MachineState *machine)
 {
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 9f28fb3..0cb51dd 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -35,6 +35,7 @@
 #include "hw/ppc/spapr.h"
 #include "hw/pci-host/spapr.h"
 #include "exec/address-spaces.h"
+#include "exec/ram_addr.h"
 #include 
 #include "trace.h"
 #include "qemu/error-report.h"
@@ -45,6 +46,7 @@
 #include "hw/ppc/spapr_drc.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/kvm.h"
+#include "sysemu/hostmem.h"
 
 #include "hw/vfio/vfio.h"
 
@@ -1088,7 +1090,7 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector 
*drc,
 int fdt_start_offset = 0, fdt_size;
 
 if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
-sPAPRTCETable *tcet = spapr_tce_find_by_liobn(phb->dma_liobn);
+sPAPRTCETable *tcet = spapr_tce_find_by_liobn(phb->dma_liobn[0]);
 
 spapr_tce_set_need_vfio(tcet, true);
 }
@@ -1310,11 +1312,14 @@ static void spapr_phb_realize(DeviceState *dev, Error 
**errp)
 PCIBus *bus;
 uint64_t msi_window_size = 4096;
 sPAPRTCETable *tcet;
+const unsigned windows_supported =
+sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1;
 
 if (sphb->index != (uint32_t)-1) {
 hwaddr windows_base;
 
-if ((sphb->buid != (uint64_t)-1) || (sphb->dma_liobn != (uint32_t)-1)
+if ((sphb->buid != (uint64_t)-1) || (sphb->dma_liobn[0] != 
(uint32_t)-1)
+|| (sphb->dma_liobn[1] != (uint32_t)-1 && windows_supported == 

Re: [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support

2016-06-20 Thread Fam Zheng
On Mon, 06/20 20:36, Stefan Hajnoczi wrote:
> Attempting to cancel a dma_blk_io() request causes an abort(3):
> 
>   void bdrv_aio_cancel(BlockAIOCB *acb)
>   {
>   ...
>   while (acb->refcnt > 1) {
>   if (acb->aiocb_info->get_aio_context) {
>   aio_poll(acb->aiocb_info->get_aio_context(acb), true);
>   } else if (acb->bs) {
>   aio_poll(bdrv_get_aio_context(acb->bs), true);
>   } else {
>   abort();
>   }
>   }
>   ...
>   }
> 
> This happens because DMAAIOCB->bs is NULL and
> dma_aiocb_info.get_aio_context() is also NULL.
> 
> This patch trivially implements dma_aiocb_info.get_aio_context() by
> fetching the DMAAIOCB->ctx field.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  dma-helpers.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/dma-helpers.c b/dma-helpers.c
> index b521d84..9defc10 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -185,10 +185,17 @@ static void dma_aio_cancel(BlockAIOCB *acb)
>  }
>  }
>  
> +static AioContext *dma_get_aio_context(BlockAIOCB *acb)
> +{
> +DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
> +
> +return dbs->ctx;
> +}
>  
>  static const AIOCBInfo dma_aiocb_info = {
>  .aiocb_size = sizeof(DMAAIOCB),
>  .cancel_async   = dma_aio_cancel,
> +.get_aio_context= dma_get_aio_context,
>  };
>  
>  BlockAIOCB *dma_blk_io(AioContext *ctx,
> -- 
> 2.5.5
> 
> 

Reviewed-by: Fam Zheng 



Re: [Qemu-devel] [RFC PATCH] Change g_source_attach(xx, NULL) to g_souce_attach(xx, g_main_context_get_thread_default())

2016-06-20 Thread Zhang Chen



On 06/21/2016 12:45 AM, Eric Blake wrote:

On 06/20/2016 02:23 AM, Zhang Chen wrote:

Subject line is too long, missing a 'topic:' prefix, and has a typo
(souce).  Suggest:

qemu-char: Fix context for g_source_attach()


OK~~ I will fix it in next version.




We want to poll and handle chardev in another thread
other than main loop. But qemu_chr_add_handlers() can only
work for global default context other than thread default context.
So we use g_souce_attach(xx, g_main_context_get_thread_default())

s/souce/source/


will fix...




replace g_source_attach(xx, NULL) to attach g_source.
Comments form jason.

s/form/from/ ?


Yes...will fix in next version.

Thanks
Zhang Chen




Signed-off-by: Zhang Chen 
Signed-off-by: Jason Wang 
---
  io/channel.c | 2 +-
  qemu-char.c  | 6 +++---
  2 files changed, 4 insertions(+), 4 deletions(-)



--
Thanks
zhangchen






Re: [Qemu-devel] [RFC 0/9] Introduce light weight PC platform pc-lite

2016-06-20 Thread Chao Peng
> It would be nice to at least see the patches. :)
> 
> I think a lightweight q35 platform that can run the usual firmware could
> be acceptable in QEMU.

OK, I will send out v2.

> 
> >> 2) this:
> >>
> >>> - it loads guest kernel directly, no BIOS, no bootloader, no realmode
> >>>   code;
> >>
> >> ... which is related to Linux-only support.  How much does this gain
> >> over a minimal firmware (either SeaBIOS with the fw_cfg DMA interface,
> >> or qboot with cbfs in parallel flash)?
> > 
> > We have tried Q35 version (as described above) with both SeaBIOS and qboot.
> > The 'perfect' time with optimized BIOS we have seen is ~15ms, with the
> > additional time in kernel real mode code, the total time overhead comparing
> > to current Linux-aware implementation is more than 40ms. This sounds still
> > a little too much for us.
> 
> I guess it is related to real mode decompression code?

Yes, that's the major part.

> 
> My main issue is that there are other things that the firmware does.
> Not all of them are necessary (e.g. SMRAM is not needed, most PCI
> devices need not be initialized), but in general we don't like putting
> code in QEMU that modifies the guest state.  For example another Intel
> person is adding code to SeaBIOS that initializes the feature control MSR.
> 
> I wonder if Linux could run as a multiboot-compliant ELF file, and what
> the performance would be...  Multiboot omits the real mode stub.
> 

I can look into this. Thanks.

Chao



Re: [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)

2016-06-20 Thread Jason Wang



On 2016年06月21日 01:53, David Vrabel wrote:

Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
TallyCounters to vmstate) introduced in incompatibility in the v4
format as it omitted the RxOkMul counter.

There are presumably no users that were impacted by the v4 to v4'
breakage, so increase the save version to 5 and re-add the field,
keeping backward compatibility with v4'.

We can't have a field conditional on the section version in
vmstate_tally_counters since this version checked would not be the
section version (but the version defined in this structure).  So, move
all the fields into the main state structure.

Signed-off-by: David Vrabel 


Migration to old version is important for the user and this patch seems 
to break this. How about something like:


- introduce a subsection for RXOKMul
- only migrate it for new version (e.g >= 2.7)

Thanks


---
Cc: Jason Wang 
---
  hw/net/rtl8139.c | 40 ++--
  1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 562c1fd..8ccd1d3 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -1352,29 +1352,6 @@ static void RTL8139TallyCounters_dma_write(RTL8139State 
*s, dma_addr_t tc_addr)
  pci_dma_write(d, tc_addr + 62,(uint8_t *)&val16, 2);
  }
  
-/* Loads values of tally counters from VM state file */

-
-static const VMStateDescription vmstate_tally_counters = {
-.name = "tally_counters",
-.version_id = 1,
-.minimum_version_id = 1,
-.fields = (VMStateField[]) {
-VMSTATE_UINT64(TxOk, RTL8139TallyCounters),
-VMSTATE_UINT64(RxOk, RTL8139TallyCounters),
-VMSTATE_UINT64(TxERR, RTL8139TallyCounters),
-VMSTATE_UINT32(RxERR, RTL8139TallyCounters),
-VMSTATE_UINT16(MissPkt, RTL8139TallyCounters),
-VMSTATE_UINT16(FAE, RTL8139TallyCounters),
-VMSTATE_UINT32(Tx1Col, RTL8139TallyCounters),
-VMSTATE_UINT32(TxMCol, RTL8139TallyCounters),
-VMSTATE_UINT64(RxOkPhy, RTL8139TallyCounters),
-VMSTATE_UINT64(RxOkBrd, RTL8139TallyCounters),
-VMSTATE_UINT16(TxAbt, RTL8139TallyCounters),
-VMSTATE_UINT16(TxUndrn, RTL8139TallyCounters),
-VMSTATE_END_OF_LIST()
-}
-};
-
  static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)
  {
  DeviceState *d = DEVICE(s);
@@ -3222,7 +3199,7 @@ static void rtl8139_pre_save(void *opaque)
  
  static const VMStateDescription vmstate_rtl8139 = {

  .name = "rtl8139",
-.version_id = 4,
+.version_id = 5,
  .minimum_version_id = 3,
  .post_load = rtl8139_post_load,
  .pre_save  = rtl8139_pre_save,
@@ -3293,8 +3270,19 @@ static const VMStateDescription vmstate_rtl8139 = {
  VMSTATE_UINT32(TimerInt, RTL8139State),
  VMSTATE_INT64(TCTR_base, RTL8139State),
  
-VMSTATE_STRUCT(tally_counters, RTL8139State, 0,

-   vmstate_tally_counters, RTL8139TallyCounters),
+VMSTATE_UINT64(tally_counters.TxOk, RTL8139State),
+VMSTATE_UINT64(tally_counters.RxOk, RTL8139State),
+VMSTATE_UINT64(tally_counters.TxERR, RTL8139State),
+VMSTATE_UINT32(tally_counters.RxERR, RTL8139State),
+VMSTATE_UINT16(tally_counters.MissPkt, RTL8139State),
+VMSTATE_UINT16(tally_counters.FAE, RTL8139State),
+VMSTATE_UINT32(tally_counters.Tx1Col, RTL8139State),
+VMSTATE_UINT32(tally_counters.TxMCol, RTL8139State),
+VMSTATE_UINT64(tally_counters.RxOkPhy, RTL8139State),
+VMSTATE_UINT64(tally_counters.RxOkBrd, RTL8139State),
+VMSTATE_UINT32_V(tally_counters.RxOkMul, RTL8139State, 5),
+VMSTATE_UINT16(tally_counters.TxAbt, RTL8139State),
+VMSTATE_UINT16(tally_counters.TxUndrn, RTL8139State),
  
  VMSTATE_UINT32_V(cplus_enabled, RTL8139State, 4),

  VMSTATE_END_OF_LIST()





Re: [Qemu-devel] [PATCH v2] Change net/socket.c to use socket_*() functions

2016-06-20 Thread Jason Wang



On 2016年06月20日 23:09, Peter Maydell wrote:

On 20 June 2016 at 15:55, Paolo Bonzini  wrote:


On 18/06/2016 09:54, Ashijeet Acharya wrote:

Use socket_*() functions from include/qemu/sockets.h instead of
listen()/bind()/ connect()/parse_host_port(). socket_*() fucntions are
QAPI based and this patch performs this api conversion since everything
will be using QAPI based sockets in the future. Also add a helper
function socket_address_to_string() in util/qemu-sockets.c which returns
the string representation of socket address. Thetask was listed on
http://wiki.qemu.org/BiteSizedTasks page.

Signed-off-by: Ashijeet Acharya 

Reviewed-by: Paolo Bonzini 

Jason, are you going to take this through the net tree?

Can you fix up the long lines/space issues in the commit
message if you do, please?

thanks
-- PMM


Fixed and apply in -net.

Thanks



Re: [Qemu-devel] [PATCH v8 11/12] vfio: register aer resume notification handler for aer resume

2016-06-20 Thread Zhou Jie

Hi, Alex


I was really hoping to hear your opinion, or at least some further
discussion of pros and cons rather than simply parroting back my idea.

I understand.


My current thinking is that a resume notifier to userspace is poorly
defined, it's not clear what the user can and cannot do between an
error notification and the resume notification.

Yes, do nothing between that time is better.


One approach to solve
that might be that the kernel internally handles the resume
notifications.  Maybe that means blocking the ioctl (interruptible
timeout) until the internal resume occurs, or maybe that means
returning -EAGAIN.

I don't think it is a good idea.
The kernel give the error and resume notifications, it's enough.
It's up to user to how to use them.


Probably implementations of each need to be worked
through to determine which is better.  We don't want to add complexity
to the kernel simply to make things easier for userspace, but we also
don't want a poorly specified interface that is difficult for
userspace to use correctly.  Thanks,

In qemu, the aer recovery process:
  1. Detect support for resume notification
 If host vfio driver does not support for resume notification,
 directly fail to boot up VM as with aer enabled.
  2. Immediately notify the VM on error detected.
  3. Disable the device.
 Unmap the config space and bar region.
  4. Delay the guest directed bus reset.
  5. Wait for resume notification.
 If we don't get the resume notification from the host after
 some timeout, we would abort the guest directed bus reset
 altogether and unplug of the device to prevent it from further
 interacting with the VM.
  6. After get the resume notification reset bus and enable the device.

I think we only make sure the disabled device
 will not interact with the VM.

Sincerely
Zhou jie



Alex


.



--

周潔
Dept 1
No. 6 Wenzhu Road,
Nanjing, 210012, China
TEL:+86+25-86630566-8557
FUJITSU INTERNAL:7998-8557
E-Mail:zhoujie2...@cn.fujitsu.com






Re: [Qemu-devel] [PATCH v8 11/12] vfio: register aer resume notification handler for aer resume

2016-06-20 Thread Alex Williamson
On Tue, 21 Jun 2016 10:16:25 +0800
Zhou Jie  wrote:

> Hi, Alex
> 
> > I was really hoping to hear your opinion, or at least some further
> > discussion of pros and cons rather than simply parroting back my idea.  
> I understand.
> 
> > My current thinking is that a resume notifier to userspace is poorly
> > defined, it's not clear what the user can and cannot do between an
> > error notification and the resume notification.  
> Yes, do nothing between that time is better.
> 
> > One approach to solve
> > that might be that the kernel internally handles the resume
> > notifications.  Maybe that means blocking the ioctl (interruptible
> > timeout) until the internal resume occurs, or maybe that means
> > returning -EAGAIN.  
> I don't think it is a good idea.
> The kernel give the error and resume notifications, it's enough.
> It's up to user to how to use them.

Well that's exactly why it's poorly defined.  What does a resume
notification signal a user that they're allowed to do?  What can they
not do between error and resume notification.  Clearly you had issues
attempting to perform a reset during this time period since it was
racing with the kernel reset, so is a user allowed to do a hot reset
between error and resume?  Where do we define it?  Do we prevent it if
they try?  Why?  What about the reset ioctl?  How and why is that
different from a hot reset?  (hint, they can be the same)  Do we define
that resets are not allowed between error and resume, but other
operations like read/write or interrupt setup ioctls are allowed? Why?
Clearly we can't do anything that manipulates the device between error
and resume since it might be lost or ineffective, but where do we
define it and do we need to actively enforce those rules?  I'm arguing
that it's poorly defined, so "it's up to the user how to use them"
doesn't not give me any additional confidence in that approach.  We
can't trust the user to be polite, we can't even trust the user not to
be malicious.
 
> > Probably implementations of each need to be worked
> > through to determine which is better.  We don't want to add complexity
> > to the kernel simply to make things easier for userspace, but we also
> > don't want a poorly specified interface that is difficult for
> > userspace to use correctly.  Thanks,  
> In qemu, the aer recovery process:
>1. Detect support for resume notification
>   If host vfio driver does not support for resume notification,
>   directly fail to boot up VM as with aer enabled.
>2. Immediately notify the VM on error detected.
>3. Disable the device.
>   Unmap the config space and bar region.
>4. Delay the guest directed bus reset.
>5. Wait for resume notification.
>   If we don't get the resume notification from the host after
>   some timeout, we would abort the guest directed bus reset
>   altogether and unplug of the device to prevent it from further
>   interacting with the VM.
>6. After get the resume notification reset bus and enable the device.
> 
> I think we only make sure the disabled device
>   will not interact with the VM.

Should interrupt irqfds then also be disabled so they trap into QEMU
and we can prevent that interaction?  Also, QEMU can be polite, but as
above, QEMU is just one user, the API is open to anyone and QEMU might
be exploited to not be so polite.  So if there are points where the
user can interfere with the kernel or exploit the knowledge that the
device is going through a reset, the kernel can't rely on a friendly
user.  Thanks,

Alex



[Qemu-devel] [PATCH 6/5] iscsi: Rely on block layer to break up large requests

2016-06-20 Thread Eric Blake
Now that the block layer honors max_request, we don't need to
bother with an EINVAL on overlarge requests, but can instead
assert that requests are well-behaved.

Signed-off-by: Eric Blake 
---
 block/iscsi.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 16d7522..0f027ce 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -473,11 +473,8 @@ iscsi_co_writev_flags(BlockDriverState *bs, int64_t 
sector_num, int nb_sectors,
 return -EINVAL;
 }

-if (bs->bl.max_transfer &&
-nb_sectors << BDRV_SECTOR_BITS > bs->bl.max_transfer) {
-error_report("iSCSI Error: Write of %d sectors exceeds max_xfer_len "
- "of %" PRIu32 " bytes", nb_sectors, bs->bl.max_transfer);
-return -EINVAL;
+if (bs->bl.max_transfer) {
+assert(nb_sectors << BDRV_SECTOR_BITS <= bs->bl.max_transfer);
 }

 lba = sector_qemu2lun(sector_num, iscsilun);
@@ -651,11 +648,8 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState 
*bs,
 return -EINVAL;
 }

-if (bs->bl.max_transfer &&
-nb_sectors << BDRV_SECTOR_BITS > bs->bl.max_transfer) {
-error_report("iSCSI Error: Read of %d sectors exceeds max_xfer_len "
- "of %" PRIu32 " bytes", nb_sectors, bs->bl.max_transfer);
-return -EINVAL;
+if (bs->bl.max_transfer) {
+assert(nb_sectors << BDRV_SECTOR_BITS <= bs->bl.max_transfer);
 }

 if (iscsilun->lbprz && nb_sectors >= ISCSI_CHECKALLOC_THRES &&
-- 
2.5.5




Re: [Qemu-devel] [PATCH 1/2] hw/misc: Add a model for the ASPEED System Control Unit

2016-06-20 Thread Andrew Jeffery
On Mon, 2016-06-20 at 14:57 +0100, Peter Maydell wrote:
> On 20 June 2016 at 04:44, Andrew Jeffery  wrote:
> > 
> > On Fri, 2016-06-17 at 15:22 +0100, Peter Maydell wrote:
> > > 
> > > +static Property aspeed_scu_properties[] = {
> > > +DEFINE_PROP_ARRAY("reset", AspeedSCUState, num_resets, reset,
> > > +  qdev_prop_uint32, uint32_t),
> > > +DEFINE_PROP_END_OF_LIST(),
> > > +};
> > > +
> > > +#define ASPEED_SCU_NR_REGS (0x1A8 >> 2)
> > > This seems like a very unwieldy way of specifying the reset values
> > > for this device. Are they really all fully configurable in the
> > > hardware? It seems unlikely. I'd much rather see something that
> > > looks more like what you might plausibly be configuring when wiring
> > > up the SoC, which might be some version/revision numbers and/or
> > > some particular tweakable parameters.
> > Right. I left out some context which may clear things up: We are
> > working with two SoCs at the moment, the AST2400 and AST2500 (hopefully
> > the AST2500 patches will be sent to the list soon). I wanted to
> > abstract the configuration to cater for the differences in register
> > values between the SoCs, less so for wiring the one SoC up in a
> > different fashion. For what it's worth, out of 86 registers defined in
> > the IO space between the two SoCs, 37 take the same value and 49
> > differ.
> I think there are a couple of plausible ways you might model this:
> 
> (a) just have a single property for "revision" which corresponds
> to the revision of this bit of silicon IP within the SoC; the
> model of the device itself then knows what the reset state is
> for this revision of the device.
> (b) ditto, but also have some configurable flags where relevant
> (ie approximately where it's the same IP rev within the SoC
> but it's been configured by tying down different config lines;
> for instance hw/dma/pl330.c has a collection of properties
> which match the configurable knobs for the hardware.)

Okay. I think (b) is the most appropriate. The board-controllable bits
are primarily in the hardware strapping register. The register is
composed of fields of mostly unrelated bits, so we could go two ways
here:

(1) expose the register through a single 32bit property
(2) break out a property for each bitfield

Do you have a preference? grepping the tree suggests there isn't a
precedent for "large" numbers of properties* so maybe (2) is overkill,
but (1) feels like it might fit into the overly-general-interface
problem that we're trying to eliminate.

* Seems the microblaze CPU defines the most with 9 properties? Approach
(2) will leave us with 21 properties for the SCU.

$ git grep -c DEFINE_PROP | sort -t: -k2 -r | head -n1
target-microblaze/cpu.c:9

> 
> You might or might not have enough visibility into the thing to
> know which of these is closest to what the real hardware is doing;
> if not then it's a matter of taste, looking at what is varying
> between the two and what isn't, etc. But "board level specifies
> all the register reset values" is definitely far too broad
> and generalised an API, I think.
> 
> > 
> > Separately, the qdev array approach was lifted from your commit
> > 9c7d489379c2 hw/vexpress: Set reset values for daughterboard
> > oscillators.
> You'll notice that we only configure the specific things
> that need configuring with interfaces specific to those things
> (eg "daughterboard clocks" and "daughterboard voltages" are
> separate), not a single "have a complete set of register values" API.

Yes, I appreciate that now. Thanks.

Andrew

signature.asc
Description: This is a digitally signed message part


Re: [Qemu-devel] [PATCH] vfio/pci: Hide SR-IOV capability

2016-06-20 Thread Alex Williamson
On Tue, 21 Jun 2016 02:15:23 +0200
Laszlo Ersek  wrote:

> On 06/21/16 00:04, Alex Williamson wrote:
> > The kernel currently exposes the SR-IOV capability as read-only
> > through vfio-pci.  This is sufficient to protect the host kernel, but
> > has the potential to confuse guests without further virtualization.
> > In particular, OVMF tries to size the VF BARs and comes up with absurd
> > results, ending with an assert.  There's not much point in adding
> > virtualization to a read-only capability, so we simply hide it for
> > now.  If the kernel ever enables SR-IOV virtualization, we should
> > easily be able to test it through VF BAR sizing or explicit flags.
> > 
> > Testing whether we should parse extended capabilities is also pulled
> > into the function to keep these assumptions in one place.
> > 
> > Signed-off-by: Alex Williamson 
> > ---
> > 
> > This depends on Chen Fan's patch "vfio: add pcie extended capability
> > support", which I'll pull from Zhou Jie's latest series unless there
> > are comments to the contrary.  Otherwise based on Stefan's tracing
> > pull request so as not to conflict.
> > 
> >  hw/vfio/pci.c|   49 
> > +++--
> >  hw/vfio/trace-events |1 +
> >  2 files changed, 40 insertions(+), 10 deletions(-)
> > 
> > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> > index a171056b..36d5e00 100644
> > --- a/hw/vfio/pci.c
> > +++ b/hw/vfio/pci.c
> > @@ -1772,6 +1772,12 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
> >  uint8_t cap_ver;
> >  uint8_t *config;
> >  
> > +/* Only add extended caps if we have them and the guest can see them */
> > +if (!pci_is_express(pdev) || !pci_bus_is_express(pdev->bus) ||
> > +!pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) {
> > +return 0;
> > +}
> > +
> >  /*
> >   * pcie_add_capability always inserts the new capability at the tail
> >   * of the chain.  Therefore to end up with a chain that matches the
> > @@ -1780,6 +1786,25 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
> >   */
> >  config = g_memdup(pdev->config, vdev->config_size);
> >  
> > +/*
> > + * Extended capabilities are chained with each pointing to the next, 
> > so we
> > + * can drop anything other than the head of the chain simply by 
> > modifying
> > + * the previous next pointer.  For the head of the chain, we can 
> > modify the
> > + * capability ID to something that cannot match a valid capability.  ID
> > + * 0 is reserved for this since absence of capabilities is indicated by
> > + * 0 for the ID, version, AND next pointer.  However, 
> > pcie_add_capability()
> > + * uses ID 0 as reserved for list management and will incorrectly 
> > match and
> > + * assert if we attempt to pre-load the head of the chain with with 
> > this
> > + * ID.  Use ID 0x temporarily since it is also seems to be 
> > reserved in
> > + * part for identifying abscense of capabilities in a root complex 
> > register
> > + * block.  If the ID still exists after adding capabilities, switch 
> > back to
> > + * zero.  We'll mark this entire first dword as emulated for this 
> > purpose.
> > + */
> > +pci_set_long(pdev->config + PCI_CONFIG_SPACE_SIZE,
> > + PCI_EXT_CAP(0x, 0, 0));
> > +pci_set_long(pdev->wmask + PCI_CONFIG_SPACE_SIZE, 0);
> > +pci_set_long(vdev->emulated_config_bits + PCI_CONFIG_SPACE_SIZE, ~0);
> > +
> >  for (next = PCI_CONFIG_SPACE_SIZE; next;
> >   next = PCI_EXT_CAP_NEXT(pci_get_long(config + next))) {
> >  header = pci_get_long(config + next);
> > @@ -1794,12 +1819,23 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev)
> >   */
> >  size = vfio_ext_cap_max_size(config, next);
> >  
> > -pcie_add_capability(pdev, cap_id, cap_ver, next, size);
> > -pci_set_long(pdev->config + next, PCI_EXT_CAP(cap_id, cap_ver, 0));
> > -
> >  /* Use emulated next pointer to allow dropping extended caps */
> >  pci_long_test_and_set_mask(vdev->emulated_config_bits + next,
> > PCI_EXT_CAP_NEXT_MASK);
> > +
> > +switch (cap_id) {
> > +case PCI_EXT_CAP_ID_SRIOV: /* Read-only VF BARs confuses OVMF */  
> 
> I think s/confuses/confuse/.

Thanks, fixed.

> Other than that, this is mostly black magic to me, so I can't even ACK
> it with a straight face :)
> 
> I would like to test it, and report back, but then again, I don't have a
> NIC with virtual functions. :/

Time to justify one for OVMF testing? ;)  Thanks,

Alex



Re: [Qemu-devel] [PATCH] i386: pci-assign: Fix MSI-X table size

2016-06-20 Thread Michael S. Tsirkin
On Sat, Jun 18, 2016 at 04:42:05PM -0400, Ido Yariv wrote:
> The current code creates a whole page mmio region for the MSI-X table
> size.
> 
> However, the page containing the MSI-X table may contain other registers
> not related to MSI-X. Creating an mmio region for the whole page masks
> such registers and may break drivers in the guest OS.
> 
> Since maximal number of entries is known, use that instead to deduce the
> table size when setting up the mmio region.
> 
> Signed-off-by: Ido Yariv 

I personally don't want to spend cycles maintaining
the old pci-assign but if someone does I don't have
an issue with that.

I remember why I coded up MSIX_PAGE_SIZE - this was before
the new memory API which made it very tricky to support
sub-page mappings.

The PCI spec stringly recommends against sharing a page between page
table and other registers but I guess if a device violates that rule
it's a better idea to make it work slowly than fail.

Patch looks good to me so:

Reviewed-by: Michael S. Tsirkin 

> ---
>  hw/i386/kvm/pci-assign.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
> index f9c9014..98997d1 100644
> --- a/hw/i386/kvm/pci-assign.c
> +++ b/hw/i386/kvm/pci-assign.c
> @@ -36,8 +36,6 @@
>  #include "kvm_i386.h"
>  #include "hw/pci/pci-assign.h"
>  
> -#define MSIX_PAGE_SIZE 0x1000
> -
>  /* From linux/ioport.h */
>  #define IORESOURCE_IO   0x0100  /* Resource type */
>  #define IORESOURCE_MEM  0x0200
> @@ -122,6 +120,7 @@ typedef struct AssignedDevice {
>  int *msi_virq;
>  MSIXTableEntry *msix_table;
>  hwaddr msix_table_addr;
> +uint16_t msix_table_size;
>  uint16_t msix_max;
>  MemoryRegion mmio;
>  char *configfd_name;
> @@ -1310,6 +1309,7 @@ static int assigned_device_pci_cap_init(PCIDevice 
> *pci_dev, Error **errp)
>  bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;
>  msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;
>  dev->msix_table_addr = pci_region[bar_nr].base_addr + 
> msix_table_entry;
> +dev->msix_table_size = msix_max * sizeof(MSIXTableEntry);
>  dev->msix_max = msix_max;
>  }
>  
> @@ -1633,7 +1633,7 @@ static void assigned_dev_msix_reset(AssignedDevice *dev)
>  return;
>  }
>  
> -memset(dev->msix_table, 0, MSIX_PAGE_SIZE);
> +memset(dev->msix_table, 0, dev->msix_table_size);
>  
>  for (i = 0, entry = dev->msix_table; i < dev->msix_max; i++, entry++) {
>  entry->ctrl = cpu_to_le32(0x1); /* Masked */
> @@ -1642,8 +1642,8 @@ static void assigned_dev_msix_reset(AssignedDevice *dev)
>  
>  static void assigned_dev_register_msix_mmio(AssignedDevice *dev, Error 
> **errp)
>  {
> -dev->msix_table = mmap(NULL, MSIX_PAGE_SIZE, PROT_READ|PROT_WRITE,
> -   MAP_ANONYMOUS|MAP_PRIVATE, 0, 0);
> +dev->msix_table = mmap(NULL, dev->msix_table_size, PROT_READ | 
> PROT_WRITE,
> +   MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
>  if (dev->msix_table == MAP_FAILED) {
>  error_setg_errno(errp, errno, "failed to allocate msix_table");
>  dev->msix_table = NULL;
> @@ -1653,7 +1653,7 @@ static void 
> assigned_dev_register_msix_mmio(AssignedDevice *dev, Error **errp)
>  assigned_dev_msix_reset(dev);
>  
>  memory_region_init_io(&dev->mmio, OBJECT(dev), 
> &assigned_dev_msix_mmio_ops,
> -  dev, "assigned-dev-msix", MSIX_PAGE_SIZE);
> +  dev, "assigned-dev-msix", dev->msix_table_size);
>  }
>  
>  static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
> @@ -1662,7 +1662,7 @@ static void 
> assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
>  return;
>  }
>  
> -if (munmap(dev->msix_table, MSIX_PAGE_SIZE) == -1) {
> +if (munmap(dev->msix_table, dev->msix_table_size) == -1) {
>  error_report("error unmapping msix_table! %s", strerror(errno));
>  }
>  dev->msix_table = NULL;
> -- 
> 2.5.5



Re: [Qemu-devel] [PATCH 0/5] Auto-fragment large transactions at the block layer

2016-06-20 Thread Eric Blake
On 06/20/2016 05:39 PM, Eric Blake wrote:
> We have max_transfer documented in BlockLimits, but while we
> honor it during pwrite_zeroes, we were blindly ignoring it
> during pwritev and preadv, leading to multiple drivers having
> to implement fragmentation themselves.  This series moves
> fragmentation to the block layer, then fixes the NBD driver to
> use it; if you like this but it needs a v2, you can request that
> I further do other drivers (I know at least iscsi and qcow2 do
> some self-fragmenting and/or error reporting that can be
> simplified by deferring fragmentation to the block layer).

iscsi turned out to be easy (see 6/5), but qcow2 is too tricky (we still
have to fragment in qcow2_alloc_cluster_offset() if cluster allocation
is not contiguous, so there is no one good value of max_transfer to use)

> 
> Prequisite: Kevin's block branch, plus my work on byte-based
> block limits (v2 at the moment):
> https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg04006.html
> 
> Also available as a tag at:
> git fetch git://repo.or.cz/qemu/ericb.git nbd-fragment-v1
> 
> Eric Blake (5):
>   block: Fragment reads to max transfer length
>   block: Fragment writes to max transfer length
>   raw_bsd: Don't advertise flags not supported by protocol layer
>   nbd: Rely on block layer to break up large requests
>   nbd: Drop unused offset parameter
> 
>  include/block/nbd.h |  1 -
>  nbd/nbd-internal.h  |  4 +--
>  block/io.c  | 84 
> +++--
>  block/nbd-client.c  | 78 ++---
>  block/nbd.c | 12 ++--
>  block/raw_bsd.c |  6 ++--
>  nbd/common.c|  3 +-
>  7 files changed, 95 insertions(+), 93 deletions(-)
> 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [RFC PATCH v0 1/1] spapr: Support setting of compat CPU type for CPU cores

2016-06-20 Thread David Gibson
On Sat, Jun 18, 2016 at 02:04:06PM +0530, Bharata B Rao wrote:
> Compat CPU type is typically specified on -cpu cmdline option like:
> -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc.
> With the introduction of sPAPR CPU core devices, we need to support
> the same for core devices too.
> 
> Support the specification of CPU compat type on device_add command for
> sPAPRCPUCore devices like:
> (qemu) device_add POWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24
> 
> Signed-off-by: Bharata B Rao 
> ---
> Applies on ppc-for-2.7 branch of David Gibson's tree.

The implementation looks ok apart from a few nits noted below.

There's a larger problem here, though, in that this doesn't advertise
the necessary compat= property via query-hotpluggable-cpus qmp and hmp
interfaces.  Which means that management has no good way of knowing
it's necessary.

> 
>  hw/ppc/spapr.c  |  8 +
>  hw/ppc/spapr_cpu_core.c | 73 
> +
>  include/hw/ppc/spapr_cpu_core.h |  2 ++
>  3 files changed, 83 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 778fa25..2049d7d 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1807,6 +1807,7 @@ static void ppc_spapr_init(MachineState *machine)
>  if (i < spapr_cores) {
>  char *type = spapr_get_cpu_core_type(machine->cpu_model);
>  Object *core;
> +char *compat;
>  
>  if (!object_class_by_name(type)) {
>  error_report("Unable to find sPAPR CPU Core definition");
> @@ -1818,6 +1819,13 @@ static void ppc_spapr_init(MachineState *machine)
>  &error_fatal);
>  object_property_set_int(core, core_dt_id, 
> CPU_CORE_PROP_CORE_ID,
>  &error_fatal);
> +compat = spapr_get_cpu_compat_type(machine->cpu_model);
> +if (compat) {
> +object_property_set_str(core, compat, "compat",
> +&error_fatal);
> +g_free(compat);
> +}
> +
>  object_property_set_bool(core, true, "realized", 
> &error_fatal);
>  }
>  }
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index 3a5da09..9eb63cc 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)
>  return core_type;
>  }
>  
> +/*
> + * Returns the CPU compat type specified in -cpu @model.
> + */
> +char *spapr_get_cpu_compat_type(const char *model)
> +{
> +char *compat_type = NULL;
> +gchar **model_pieces = g_strsplit(model, ",", 2);
> +
> +if (model_pieces[1]) {
> +gchar **compat_pieces = g_strsplit(model_pieces[1], "=", 2);
> +
> +compat_type = g_strdup_printf("%s", compat_pieces[1]);
> +}
> +
> +g_strfreev(model_pieces);
> +return compat_type;
> +}
> +
>  static void spapr_core_release(DeviceState *dev, void *opaque)
>  {
>  sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
> @@ -223,12 +241,31 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, 
> DeviceState *dev,
>  CPUCore *cc = CPU_CORE(dev);
>  char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
>  const char *type = object_get_typename(OBJECT(dev));
> +char *base_compat_type = NULL;
> +char *compat = NULL;
> +bool compat_set;
>  
>  if (strcmp(base_core_type, type)) {
>  error_setg(&local_err, "CPU core type should be %s", base_core_type);
>  goto out;
>  }
>  
> +base_compat_type = spapr_get_cpu_compat_type(machine->cpu_model);

This can go in the initializer to match the base_core_type.

> +compat = object_property_get_str(OBJECT(dev), "compat", NULL);
> +compat_set = (compat && *compat) ? true : false;

You don't need the ?:, the condition is already a boolean.

> +
> +if (base_compat_type) {
> +if ((compat_set && strcmp(base_compat_type, compat)) ||
> +!compat_set) {
> +error_setg(&local_err, "CPU compat type should be %s",
> +   base_compat_type);
> +goto out;
> +}
> +} else if (compat_set) {
> +error_setg(&local_err, "CPU compat type shouldn't be set");
> +goto out;
> +}
> +
>  if (!smc->dr_cpu_enabled && dev->hotplugged) {
>  error_setg(&local_err, "CPU hotplug not supported for this machine");
>  goto out;
> @@ -256,6 +293,8 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, 
> DeviceState *dev,
>  }
>  
>  out:
> +g_free(compat);
> +g_free(base_compat_type);
>  g_free(base_core_type);
>  error_propagate(errp, local_err);
>  }
> @@ -288,6 +327,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, 
> Error **errp)
>  Error *local_err = NULL;
>  Object *obj;
>  in

[Qemu-devel] [RFC PATCH 1/1] OpenBIOS: Switch over to official OpenBIOS git repo

2016-06-20 Thread Jeff Cody
This update should preserve git history, and allow seamless switching
over to the official openbios git repo, rather than pulling from the
svn mirror.  All prior history from the svn repository should still be
preserved (i.e., commit hashes are the same for historical commits).

In the roms/openbios submodule, the branch "origin/official" is the
latest mirror of the official git repository (fetched daily).

Signed-off-by: Jeff Cody 
---
 roms/openbios | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/roms/openbios b/roms/openbios
index 422b916..36785d7 16
--- a/roms/openbios
+++ b/roms/openbios
@@ -1 +1 @@
-Subproject commit 422b916649aa0db8c5edadccb22387b3e807e3b2
+Subproject commit 36785d7b59726beca320a0b99cfa0a903782c6f3
-- 
1.9.3




[Qemu-devel] [Bug 1357440] Re: qemu-img: Assert for 'amend' command and the fuzzed image

2016-06-20 Thread T. Huth
** Changed in: qemu
   Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1357440

Title:
  qemu-img: Assert for 'amend' command and the fuzzed image

Status in QEMU:
  Fix Released

Bug description:
  'qemu-img amend' failed with the assert on the fuzzed image.

  Sequence:
   1. Unpack the attached archive, make a copy of test.img
   2. Put copy.img and backing_img.vdi in the same directory
   3. Execute
 qemu-img amend -o compat=0.10 -f qcow2 copy.img

  Result: qemu-img was killed by SIGIOT with the reason:

  qemu-img: block/qcow2-cluster.c:1598: expand_zero_clusters_in_l1:
  Assertion `(cluster_index >= 0) && (cluster_index < *nb_clusters)'
  failed.

  qemu.git HEAD 2d591ce2aeebf

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1357440/+subscriptions



Re: [Qemu-devel] [RFC PATCH 1/1] OpenBIOS: Switch over to official OpenBIOS git repo

2016-06-20 Thread Jeff Cody
On Tue, Jun 21, 2016 at 01:40:42AM -0400, Jeff Cody wrote:
> This update should preserve git history, and allow seamless switching
> over to the official openbios git repo, rather than pulling from the
> svn mirror.  All prior history from the svn repository should still be
> preserved (i.e., commit hashes are the same for historical commits).
> 
> In the roms/openbios submodule, the branch "origin/official" is the
> latest mirror of the official git repository (fetched daily).
> 
> Signed-off-by: Jeff Cody 
> ---
>  roms/openbios | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/roms/openbios b/roms/openbios
> index 422b916..36785d7 16
> --- a/roms/openbios
> +++ b/roms/openbios
> @@ -1 +1 @@
> -Subproject commit 422b916649aa0db8c5edadccb22387b3e807e3b2
> +Subproject commit 36785d7b59726beca320a0b99cfa0a903782c6f3
> -- 
> 1.9.3
> 

I marked this as RFC, because I did not want to this to get merged without
making sure that this is the correct approach.




[Qemu-devel] [Bug 1370585] Re: qemu-img cannot create fixed vhdx

2016-06-20 Thread T. Huth
** Changed in: qemu
   Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1370585

Title:
  qemu-img cannot create fixed vhdx

Status in QEMU:
  Fix Released

Bug description:
  When trying to create a fixed vhdx image, qemu-img fails with the
  following error:

   qemu-img: test.vhdx: Could not create image: Cannot allocate
  memory

  This happens because of a incorrect check in vhdx.c

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1370585/+subscriptions



[Qemu-devel] [Bug 1402802] Re: target-tricore/translate.c:3812: possible bad expression ?

2016-06-20 Thread T. Huth
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=7f13420ec000ad7644b65e

** Changed in: qemu
   Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1402802

Title:
  target-tricore/translate.c:3812: possible bad expression ?

Status in QEMU:
  Fix Released

Bug description:
  
  From a run of cppcheck, a static analysis checker, over the
  source code of qemu trunk, dated 20141215, is the new error:

  [qemu/target-tricore/translate.c:3812]: (style) Expression '(X & 0x3f)
  == 0x6f' is always false.

  Source code is

  if (unlikely((op1 & 0x3f) == OPCM_32_BRN_JTT)) {

  Suggest code rework.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1402802/+subscriptions



Re: [Qemu-devel] [RFC PATCH v0 1/1] spapr: Support setting of compat CPU type for CPU cores

2016-06-20 Thread Thomas Huth
On 18.06.2016 10:34, Bharata B Rao wrote:
> Compat CPU type is typically specified on -cpu cmdline option like:
> -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc.
> With the introduction of sPAPR CPU core devices, we need to support
> the same for core devices too.
> 
> Support the specification of CPU compat type on device_add command for
> sPAPRCPUCore devices like:
> (qemu) device_add POWER8E-spapr-cpu-core,id=core3,compat=power7,core-id=24
>
> Signed-off-by: Bharata B Rao 
> ---
> Applies on ppc-for-2.7 branch of David Gibson's tree.
> 
>  hw/ppc/spapr.c  |  8 +
>  hw/ppc/spapr_cpu_core.c | 73 
> +
>  include/hw/ppc/spapr_cpu_core.h |  2 ++
>  3 files changed, 83 insertions(+)
[...]
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index 3a5da09..9eb63cc 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -96,6 +96,24 @@ char *spapr_get_cpu_core_type(const char *model)
>  return core_type;
>  }
>  
> +/*
> + * Returns the CPU compat type specified in -cpu @model.
> + */
> +char *spapr_get_cpu_compat_type(const char *model)
> +{
> +char *compat_type = NULL;
> +gchar **model_pieces = g_strsplit(model, ",", 2);
> +
> +if (model_pieces[1]) {
> +gchar **compat_pieces = g_strsplit(model_pieces[1], "=", 2);
> +
> +compat_type = g_strdup_printf("%s", compat_pieces[1]);
> +}
> +
> +g_strfreev(model_pieces);
> +return compat_type;
> +}

Shouldn't you check for "compat=" somewhere in this function (and
properly iterate over all parts of the comma separated string)? In case
we support more properties than "compat=" some day, this will go wrong
otherwise...

 Thomas




Re: [Qemu-devel] [PATCH 0/3] qmp: query-host-cpu command

2016-06-20 Thread David Hildenbrand
> Add QMP command to allow management software to query for
> CPU information for the running host.
> 
> The data returned by the command is in the form of a dictionary
> of QOM properties.
> 
> This series depends on the "Add runnability info to
> query-cpu-definitions" series I sent 2 weeks ago.
> 
> Git tree:
>   https://github.com/ehabkost/qemu-hacks.git work/query-host-cpu
> 

I like that interface, I'm going to post (maybe today? :) ) a similar interface
that allows to also expand other cpu models, not just the host model.

Maybe we can then decide which one makes sense for all of us. But in general,
this interface is much better compared to what we had before. 

David




Re: [Qemu-devel] [PATCH v2] vmxnet3: Fix reading/writing guest memory specially when behind an IOMMU

2016-06-20 Thread Dmitry Fleytman


> On 20 Jun 2016, at 16:50 PM, KarimAllah Ahmed  wrote:
> 
> When a PCI device lives behind an IOMMU, it should use 'pci_dma_*' family of
> functions when any transfer from/to guest memory is required while
> 'cpu_physical_memory_*' family of functions completely bypass any MMU/IOMMU in
> the system.
> 
> vmxnet3 in some places was using 'cpu_physical_memory_*' family of functions
> which works fine with the default QEMU setup where IOMMU is not enabled but
> fails miserably when IOMMU is enabled. This commit converts all such instances
> in favor of 'pci_dma_*’

Acked-by: Dmitry Fleytman mailto:dmi...@daynix.com>>

> 
> Cc: Dmitry Fleytman 
> Cc: Jason Wang 
> Cc: qemu-devel@nongnu.org
> Cc: Anthony Liguori 
> Signed-off-by: KarimAllah Ahmed 
> 
> —

...



Re: [Qemu-devel] [PATCH qemu v18 1/5] memory: Add reporting of supported page sizes

2016-06-20 Thread David Gibson
On Tue, Jun 21, 2016 at 11:14:01AM +1000, Alexey Kardashevskiy wrote:
> Every IOMMU has some granularity which MemoryRegionIOMMUOps::translate
> uses when translating, however this information is not available outside
> the translate context for various checks.
> 
> This adds a get_min_page_size callback to MemoryRegionIOMMUOps and
> a wrapper for it so IOMMU users (such as VFIO) can know the minimum
> actual page size supported by an IOMMU.
> 
> As IOMMU MR represents a guest IOMMU, this uses TARGET_PAGE_SIZE
> as fallback.
> 
> This removes vfio_container_granularity() and uses new helper in
> memory_region_iommu_replay() when replaying IOMMU mappings on added
> IOMMU memory region.
> 
> Signed-off-by: Alexey Kardashevskiy 
> Reviewed-by: David Gibson 
> Acked-by: Alex Williamson 

One remaining nit..

[snip]
> +void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_write)
> +{
> +hwaddr addr, granularity;
>  IOMMUTLBEntry iotlb;
>  
> +granularity = (hwaddr)1 << 
> ctz64(memory_region_iommu_get_min_page_size(mr));

Because this is now a plain size, rather than some sort of pagemask,
you don't need the ctz64() business.

>  for (addr = 0; addr < memory_region_size(mr); addr += granularity) {
>  iotlb = mr->iommu_ops->translate(mr, addr, is_write);
>  if (iotlb.perm != IOMMU_NONE) {

Paolo, are you ok for me to make that small change and take this
through my tree?

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v6 03/13] register: Add Memory API glue

2016-06-20 Thread Peter Maydell
On 21 June 2016 at 01:46, Alistair Francis  wrote:
> On Thu, Jun 9, 2016 at 12:03 PM, Peter Maydell  
> wrote:
>> Why do we need to handle big vs little endian separately rather
>> than just having the memory region say which it is and letting
>> the core memory system handle things appropriately ?
>
> I didn't realise that is an option. So I can remove all the endianess
> handling from here and the core will handle it?

It should do, though you should test that it behaves the way you
expect.

thanks
-- PMM



Re: [Qemu-devel] [PATCH 1/2] hw/misc: Add a model for the ASPEED System Control Unit

2016-06-20 Thread Peter Maydell
On 21 June 2016 at 04:49, Andrew Jeffery  wrote:
> On Mon, 2016-06-20 at 14:57 +0100, Peter Maydell wrote:
>> I think there are a couple of plausible ways you might model this:
>>
>> (a) just have a single property for "revision" which corresponds
>> to the revision of this bit of silicon IP within the SoC; the
>> model of the device itself then knows what the reset state is
>> for this revision of the device.
>> (b) ditto, but also have some configurable flags where relevant
>> (ie approximately where it's the same IP rev within the SoC
>> but it's been configured by tying down different config lines;
>> for instance hw/dma/pl330.c has a collection of properties
>> which match the configurable knobs for the hardware.)
>
> Okay. I think (b) is the most appropriate. The board-controllable bits
> are primarily in the hardware strapping register. The register is
> composed of fields of mostly unrelated bits, so we could go two ways
> here:
>
> (1) expose the register through a single 32bit property
> (2) break out a property for each bitfield
>
> Do you have a preference? grepping the tree suggests there isn't a
> precedent for "large" numbers of properties* so maybe (2) is overkill,
> but (1) feels like it might fit into the overly-general-interface
> problem that we're trying to eliminate.
>
> * Seems the microblaze CPU defines the most with 9 properties?

(You forgot '-n' on your sort rune.)
hw/dma/pl330.c has 15.

> Approach (2) will leave us with 21 properties for the SCU.

What would the 21 properties be in this case?

But yes, a single 32 bit property would probably be better.

thanks
-- PMM



<    1   2   3   4