First round of misc patches for QEMU 2.8
Subsystems (9)
The following changes since commit fa9701240951093907076db0943f96972a396ef5:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20160913-1' into staging (2016-09-13 13:56:35 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git
for you to fetch changes up to 083d012a388e7e2a8bfd9144c2c9bcceb29a78fc:
cutils: Add generic prefetch (2016-09-13 19:13:32 +0200)
----------------------------------------------------------------
* minor patches here and there
* MTTCG: lock-free TB lookup
* SCSI: bugfixes for MPTSAS, MegaSAS, LSI53c, vmw_pvscsi
* buffer_is_zero rewrite (except for one patch)
* chardev: qemu_chr_fe_write checks
* checkpatch improvement for markdown preformatted text
* default-configs cleanups
* atomics cleanups
----------------------------------------------------------------
Alex Bennée (2):
tcg: set up tb->page_addr before insertion
tcg: cpu-exec: remove tb_lock from the hot-path
Cao jin (7):
util/qemu-sockets: revert Yoda Conditions to normal
util: fix some coding style issue
timer: update comments
cpus: rename local variable to meaningful one
cpus: update comments
doc/rcu: fix typo
kvm-all: drop kvm_setup_guest_memory
Colin Lord (1):
help: Update help to remove misleading display information
Daniel P. Berrange (7):
default-configs: remove CONFIG_PAM
default-configs: removed obsolete CONFIG_ISA_MMIO
default-configs: remove CONFIG_PIIX_PCI
ipmi: check return of qemu_chr_fe_write() for errors
sclpconsolelm: remove bogus check for -EAGAIN
hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all
char: convert qemu_chr_fe_write to qemu_chr_fe_write_all
Dr. David Alan Gilbert (1):
x86/lapic: Load LAPIC state at post_load
Eduardo Habkost (2):
vmxcap: Show raw MSR value
vmxcap: Add TSC scaling bit
Fam Zheng (1):
rules.mak: Don't extract libs from .mo-libs in link command
Hervé Poussineau (4):
lsi: print register names in debug prints
lsi: do not exit QEMU if reading invalid register
lsi: implement I/O memory space for Memory Move instructions
lsi: never set DMA FIFO Empty (DFE) bit in DSTAT register
Igor Mammedov (1):
qtail: clean up direct access to tqe_prev field
Lin Ma (1):
chardev: Add 'help' option to print all available chardev backend types
Lluís Vilanova (1):
checkpatch: Fix whitespace checks for documentation code blocks
Markus Armbruster (1):
i8257: Make device "i8257" unavailable with -device
Paolo Bonzini (7):
tcg: Prepare TB invalidation for lockless TB lookup
MAINTAINERS: add myself as stubs maintainers
scsi: mptconfig: fix misuse of MPTSAS_CONFIG_PACK Revert "megasas: remove useless check for cmd->frame"
optionrom: do not rely on compiler's bswap optimization
ppc: do not redefine CPUPPCState
cutils: Add SSE4 version
Pranith Kumar (2):
atomics: Remove redundant barrier()'s
atomics: Use __atomic_*_n() variant primitives
Prasad J Pandit (3):
vmw_pvscsi: check page count while initialising descriptor rings
scsi: mptconfig: fix an assert expression
scsi: pvscsi: limit loop to fetch SG list
Richard Henderson (8):
cutils: Move buffer_is_zero and subroutines to a new file
cutils: Remove SPLAT macro
cutils: Export only buffer_is_zero
cutils: Rearrange buffer_is_zero acceleration
cutils: Remove aarch64 buffer zero checking
cutils: Remove ppc buffer zero checking
cutils: Add test for buffer_is_zero
cutils: Add generic prefetch
Rony Weng (1):
scsi-disk: change disk serial length from 20 to 36
Sergey Fedorov (6):
tcg: Pass last_tb by value to tb_find_fast()
tcg: Prepare safe tb_jmp_cache lookup out of tb_lock
tcg: Prepare safe access to tb_flushed out of tb_lock
tcg: Avoid bouncing tb_lock between tb_gen_code() and tb_add_jump()
tcg: Merge tb_find_slow() and tb_find_fast()
tcg: rename tb_find_physical()
Thomas Huth (2):
MAINTAINERS: Fix wildcard for scsi headers
MAINTAINERS: Add some header files to the PC chipset section
MAINTAINERS | 11 +- backends/rng-egd.c | 4 +- blockdev.c | 2 +- configure | 21 +-- cpu-exec.c | 115 +++++++-------- cpus.c | 19 ++- default-configs/arm-softmmu.mak | 1 - default-configs/i386-softmmu.mak | 2 - default-configs/ppc-softmmu.mak | 1 - default-configs/ppc64-softmmu.mak | 1 - default-configs/sparc64-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 2 - docs/rcu.txt | 2 +- exec.c | 7 +- gdbstub.c | 4 +- hw/arm/omap2.c | 8 +- hw/arm/pxa2xx.c | 4 +- hw/arm/strongarm.c | 4 +- hw/char/bcm2835_aux.c | 4 +- hw/char/debugcon.c | 4 +- hw/char/digic-uart.c | 2 + hw/char/escc.c | 4 +- hw/char/etraxfs_ser.c | 4 +- hw/char/exynos4210_uart.c | 4 +- hw/char/grlib_apbuart.c | 4 +- hw/char/imx_serial.c | 4 +- hw/char/ipoctal232.c | 4 +- hw/char/lm32_juart.c | 2 + hw/char/lm32_uart.c | 2 + hw/char/mcf_uart.c | 4 +- hw/char/parallel.c | 4 +- hw/char/pl011.c | 4 +- hw/char/sclpconsole-lm.c | 25 +--- hw/char/sclpconsole.c | 2 + hw/char/sh_serial.c | 4 +- hw/char/spapr_vty.c | 5 +- hw/char/stm32f2xx_usart.c | 2 + hw/char/virtio-console.c | 21 +++ hw/char/xilinx_uartlite.c | 4 +- hw/dma/i8257.c | 2 + hw/i386/kvm/apic.c | 27 +++- hw/ipmi/ipmi_bmc_extern.c | 8 +- hw/scsi/lsi53c895a.c | 280 +++++++++++++++++++++++++----------- hw/scsi/megasas.c | 6 +- hw/scsi/mptconfig.c | 6 +- hw/scsi/scsi-disk.c | 4 +- hw/scsi/vmw_pvscsi.c | 30 ++-- hw/usb/ccid-card-passthru.c | 7 +- hw/usb/dev-serial.c | 4 +- include/exec/exec-all.h | 2 + include/hw/ppc/fdt.h | 3 +- include/qemu/atomic.h | 32 ++--- include/qemu/cutils.h | 3 +- include/qemu/queue.h | 2 + include/qemu/timer.h | 19 +-- include/sysemu/kvm.h | 2 - kvm-all.c | 15 +- kvm-stub.c | 4 - migration/ram.c | 2 +- migration/rdma.c | 5 +- net/filter.c | 2 +- pc-bios/linuxboot_dma.bin | Bin 1536 -> 1536 bytes pc-bios/optionrom/linuxboot_dma.c | 18 +-- qemu-char.c | 39 +++-- qemu-options.hx | 41 +++--- rules.mak | 2 +- scripts/checkpatch.pl | 10 ++ scripts/kvm/vmxcap | 2 + slirp/slirp.c | 4 +- target-i386/kvm.c | 17 --- tests/Makefile.include | 3 + tests/test-bufferiszero.c | 78 ++++++++++ translate-all.c | 25 ++-- util/Makefile.objs | 1 + util/bufferiszero.c | 230 +++++++++++++++++++++++++++++ util/cutils.c | 244 ------------------------------- util/qemu-sockets.c | 26 ++-- 77 files changed, 884 insertions(+), 643 deletions(-) create mode 100644 tests/test-bufferiszero.c create mode 100644 util/bufferiszero.c
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 01/58] qtail: clean up direct access to tqe_prev field
From: Igor Mammedov <[email protected]>
instead of accessing tqe_prev field dircetly outside of queue.h use macros to check if element is in list and make sure that afer element is removed from list tqe_prev field could be used to do the same check.
Message-Id: <[email protected]>
--- blockdev.c | 2 +- exec.c | 3 +-- include/qemu/queue.h | 2 ++ net/filter.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
blockdev.c +1 -1
@@ -3907,7 +3907,7 @@ void qmp_x_blockdev_del(bool has_id, const char *id, goto out; } -if (!blk && !bs->monitor_list.tqe_prev) { +if (!blk && !QTAILQ_IN_USE (bs, monitor_list)) {error_setg (errp,"Node %s is not owned by the monitor" , bs->node_name); goto out;
exec.c +1 -2
@@ -617,7 +617,7 @@ void cpu_exec_exit(CPUState *cpu)CPUClass *cc =CPU_GET_CLASS (cpu);cpu_list_lock (); -if (cpu->node.tqe_prev ==NULL ) { +if (!QTAILQ_IN_USE (cpu, node)) {/* there is nothing to undo since cpu_exec_init() hasn't been called */ cpu_list_unlock ();return ;
@@ -626,7 +626,6 @@ void cpu_exec_exit(CPUState *cpu)assert (!(cpu_index_auto_assigned && cpu !=QTAILQ_LAST (&cpus, CPUTailQ)));QTAILQ_REMOVE (&cpus, cpu, node); - cpu->node.tqe_prev =NULL ; cpu->cpu_index =UNASSIGNED_CPU_INDEX ;cpu_list_unlock ();
include/qemu/queue.h +2 -0
@@ -407,6 +407,7 @@ struct { \else \ (head)->tqh_last = (elm)->field.tqe_prev; \ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + (elm)->field.tqe_prev =NULL ; \ }while (/*CONSTCOND*/ 0 ) #define QTAILQ_FOREACH(var, head, field) \
@@ -430,6 +431,7 @@ struct { \#define QTAILQ_EMPTY (head) ((head)->tqh_first == NULL)#define QTAILQ_FIRST (head) ((head)->tqh_first)#define QTAILQ_NEXT (elm, field) ((elm)->field.tqe_next) +#define QTAILQ_IN_USE (elm, field) ((elm)->field.tqe_prev != NULL)#define QTAILQ_LAST (head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last))
net/filter.c +1 -1
@@ -239,7 +239,7 @@ static void netfilter_finalize(Object *obj) }if (nf->netdev && !QTAILQ_EMPTY (&nf->netdev->filters) && - nf->next.tqe_prev) { +QTAILQ_IN_USE (nf, next)) {QTAILQ_REMOVE (&nf->netdev->filters, nf, next); }g_free (nf->netdev_id);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 02/58] util/qemu-sockets: revert Yoda Conditions to normal
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
Follow CODING_STYLE
Message-Id: <[email protected]>
--- util/qemu-sockets.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
util/qemu-sockets.c +5 -5
@@ -491,7 +491,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, goto err; } -if (0 != (rc =getaddrinfo (addr, port, &ai, &peer))) { +if ((rc =getaddrinfo (addr, port, &ai, &peer)) !=0 ) {error_setg (errp,"address resolution failed for %s:%s: %s" , addr, port,gai_strerror (rc)); goto err;
@@ -517,7 +517,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, port ="0" ; } -if (0 != (rc =getaddrinfo (addr, port, &ai, &local))) { +if ((rc =getaddrinfo (addr, port, &ai, &local)) !=0 ) {error_setg (errp,"address resolution failed for %s:%s: %s" , addr, port,gai_strerror (rc)); goto err;
@@ -573,20 +573,20 @@ InetSocketAddress *inet_parse(const char *str, Error **errp)if (str[0 ] ==':' ) {/* no host given */ host[0 ] ='\0' ; -if (1 !=sscanf (str,":%32[^,]%n" , port, &pos)) { +if (sscanf (str,":%32[^,]%n" , port, &pos) !=1 ) {error_setg (errp,"error parsing port in address '%s'" , str); goto fail; } }else if (str[0 ] =='[' ) {/* IPv6 addr */ -if (2 !=sscanf (str,"[%64[^]]]:%32[^,]%n" , host, port, &pos)) { +if (sscanf (str,"[%64[^]]]:%32[^,]%n" , host, port, &pos) !=2 ) {error_setg (errp,"error parsing IPv6 address '%s'" , str); goto fail; } addr->ipv6 = addr->has_ipv6 = true; }else {/* hostname or IPv4 addr */ -if (2 !=sscanf (str,"%64[^:]:%32[^,]%n" , host, port, &pos)) { +if (sscanf (str,"%64[^:]:%32[^,]%n" , host, port, &pos) !=2 ) {error_setg (errp,"error parsing address '%s'" , str); goto fail; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 03/58] util: fix some coding style issue
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
Fix some coding style issues found in removing NonBlockingConnectHandler.
Message-Id: <[email protected]>
--- util/qemu-sockets.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
util/qemu-sockets.c +11 -5
@@ -494,7 +494,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,if ((rc =getaddrinfo (addr, port, &ai, &peer)) !=0 ) {error_setg (errp,"address resolution failed for %s:%s: %s" , addr, port,gai_strerror (rc)); - goto err; + goto err; }/* lookup local addr */
@@ -548,12 +548,16 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr,return sock; err: -if (-1 != sock) +if (sock !=-1 ) {closesocket (sock); -if (local) + } +if (local) {freeaddrinfo (local); -if (peer) + } +if (peer) {freeaddrinfo (peer); + } +return -1 ; }
@@ -816,8 +820,10 @@ int unix_listen(const char *str, char *ostr, int olen, Error **errp) sock =unix_listen_saddr (saddr, true, errp); -if (sock !=-1 && ostr) +if (sock !=-1 && ostr) {snprintf (ostr, olen,"%s%s" , saddr->path, optstr ? optstr :"" ); + } +qapi_free_UnixSocketAddress (saddr);return sock; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 04/58] tcg: Pass last_tb by value to tb_find_fast()
In reply to Paolo BonziniFrom: Sergey Fedorov <[email protected]>
This is a small clean up. tb_find_fast() is a final consumer of this variable so no need to pass it by reference. 'last_tb' is always updated by subsequent cpu_loop_exec_tb() in cpu_exec().
This change also simplifies calling cpu_exec_nocache() in cpu_handle_exception().
Message-Id: <[email protected]>
--- cpu-exec.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
cpu-exec.c +7 -8
@@ -320,7 +320,7 @@ found: }static inline TranslationBlock *tb_find_fast (CPUState *cpu, -TranslationBlock **last_tb, +TranslationBlock *last_tb,int tb_exit) {CPUArchState *env = (CPUArchState *)cpu->env_ptr;
@@ -342,7 +342,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,/* Ensure that no TB jump will be modified as the * translation buffer has been flushed. */ - *last_tb =NULL ; + last_tb =NULL ; cpu->tb_flushed = false; }#ifndef CONFIG_USER_ONLY
@@ -351,12 +351,12 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,* spanning two pages because the mapping for the second page can change. */ if (tb->page_addr[1 ] !=-1 ) { - *last_tb =NULL ; + last_tb =NULL ; }#endif /* See if we can patch the calling TB. */ -if (*last_tb && !qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { -tb_add_jump (*last_tb, tb_exit, tb); +if (last_tb && !qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { +tb_add_jump (last_tb, tb_exit, tb); }tb_unlock ();return tb;
@@ -437,8 +437,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) } else if (replay_has_exception() && cpu->icount_decr.u16.low + cpu->icount_extra ==0 ) {/* try to cause an exception pending in the log */ -TranslationBlock *last_tb =NULL ;/* Avoid chaining TBs */ -cpu_exec_nocache (cpu,1 ,tb_find_fast (cpu, &last_tb,0 ), true); +cpu_exec_nocache (cpu,1 ,tb_find_fast (cpu,NULL ,0 ), true); *ret =-1 ;return true;#endif
@@ -621,7 +620,7 @@ int cpu_exec(CPUState *cpu) cpu->tb_flushed = false;/* reset before first TB lookup */ for (;;) {cpu_handle_interrupt (cpu, &last_tb); - tb =tb_find_fast (cpu, &last_tb, tb_exit); + tb =tb_find_fast (cpu, last_tb, tb_exit);cpu_loop_exec_tb (cpu, tb, &last_tb, &tb_exit, &sc);/* Try to align the host and virtual clocks if the guest is in advance */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 05/58] tcg: Prepare safe tb_jmp_cache lookup out of tb_lock
In reply to Paolo BonziniFrom: Sergey Fedorov <[email protected]>
Ensure atomicity of CPU's 'tb_jmp_cache' access for future translation block lookup out of 'tb_lock'.
Note that this patch does *not* make CPU's TLB invalidation safe if it is done from some other thread while the CPU is in its execution loop.
Message-Id: <[email protected]>
--- cpu-exec.c | 4 ++-- translate-all.c | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-)
cpu-exec.c +2 -2
@@ -315,7 +315,7 @@ static TranslationBlock *tb_find_slow(CPUState *cpu, found:/* we add the TB in the virtual pc hash table */ - cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)] = tb; +atomic_set (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)], tb);return tb; }
@@ -333,7 +333,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,is executed. */ cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags);tb_lock (); - tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]; + tb =atomic_rcu_read (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]);if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { tb =tb_find_slow (cpu, pc, cs_base, flags);
translate-all.c +7 -3
@@ -851,7 +851,11 @@ void tb_flush(CPUState *cpu) tcg_ctx.tb_ctx.nb_tbs =0 ;CPU_FOREACH (cpu) { -memset (cpu->tb_jmp_cache,0 ,sizeof (cpu->tb_jmp_cache)); +int i; + +for (i =0 ; i <TB_JMP_CACHE_SIZE ; ++i) { +atomic_set (&cpu->tb_jmp_cache[i],NULL ); + } cpu->tb_flushed = true; }
@@ -1010,8 +1014,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)/* remove the TB from the hash list */ h =tb_jmp_cache_hash_func (tb->pc);CPU_FOREACH (cpu) { -if (cpu->tb_jmp_cache[h] == tb) { - cpu->tb_jmp_cache[h] =NULL ; +if (atomic_read (&cpu->tb_jmp_cache[h]) == tb) { +atomic_set (&cpu->tb_jmp_cache[h],NULL ); } }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 06/58] tcg: Prepare safe access to tb_flushed out of tb_lock
In reply to Paolo BonziniFrom: Sergey Fedorov <[email protected]>
Ensure atomicity and ordering of CPU's 'tb_flushed' access for future translation block lookup out of 'tb_lock'.
This field can only be touched from another thread by tb_flush() in user mode emulation. So the only access to be sequential atomic is:
* a single write in tb_flush();
* reads/writes out of 'tb_lock'.
In future, before enabling MTTCG in system mode, tb_flush() must be safe and this field becomes unnecessary.
Message-Id: <[email protected]>
--- cpu-exec.c | 16 +++++++--------- translate-all.c | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-)
cpu-exec.c +7 -9
@@ -338,13 +338,6 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, tb->flags != flags)) { tb =tb_find_slow (cpu, pc, cs_base, flags); } -if (cpu->tb_flushed) { -/* Ensure that no TB jump will be modified as the -* translation buffer has been flushed. -*/ - last_tb =NULL ; - cpu->tb_flushed = false; - }#ifndef CONFIG_USER_ONLY /* We don't take care of direct jumps when address mapping changes in * system emulation. So it's not safe to make a direct jump to a TB
@@ -356,7 +349,12 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,#endif /* See if we can patch the calling TB. */ if (last_tb && !qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { -tb_add_jump (last_tb, tb_exit, tb); +/* Check if translation buffer has been flushed */ +if (cpu->tb_flushed) { + cpu->tb_flushed = false; + }else { +tb_add_jump (last_tb, tb_exit, tb); + } }tb_unlock ();return tb;
@@ -617,7 +615,7 @@ int cpu_exec(CPUState *cpu)break ; } - cpu->tb_flushed = false;/* reset before first TB lookup */ +atomic_mb_set (&cpu->tb_flushed, false);/* reset before first TB lookup */ for (;;) {cpu_handle_interrupt (cpu, &last_tb); tb =tb_find_fast (cpu, last_tb, tb_exit);
translate-all.c +2 -2
@@ -848,7 +848,6 @@ void tb_flush(CPUState *cpu) > tcg_ctx.code_gen_buffer_size) {cpu_abort (cpu,"Internal error: code buffer overflow\n" ); } - tcg_ctx.tb_ctx.nb_tbs =0 ;CPU_FOREACH (cpu) {int i;
@@ -856,9 +855,10 @@ void tb_flush(CPUState *cpu)for (i =0 ; i <TB_JMP_CACHE_SIZE ; ++i) {atomic_set (&cpu->tb_jmp_cache[i],NULL ); } - cpu->tb_flushed = true; +atomic_mb_set (&cpu->tb_flushed, true); } + tcg_ctx.tb_ctx.nb_tbs =0 ;qht_reset_size (&tcg_ctx.tb_ctx.htable,CODE_GEN_HTABLE_SIZE );page_flush_tb ();
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 07/58] tcg: Prepare TB invalidation for lockless TB lookup
In reply to Paolo BonziniWhen invalidating a translation block, set an invalid flag into the TranslationBlock structure first. It is also necessary to check whether the target TB is still valid after acquiring 'tb_lock' but before calling tb_add_jump() since TB lookup is to be performed out of 'tb_lock' in future. Note that we don't have to check 'last_tb'; an already invalidated TB will not be executed anyway and it is thus safe to patch it.
--- cpu-exec.c | 5 +++-- include/exec/exec-all.h | 2 ++ translate-all.c | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-)
cpu-exec.c +3 -2
@@ -241,7 +241,8 @@ static bool tb_cmp(const void *p, const void *d)if (tb->pc == desc->pc && tb->page_addr[0 ] == desc->phys_page1 && tb->cs_base == desc->cs_base && - tb->flags == desc->flags) { + tb->flags == desc->flags && + !atomic_read (&tb->invalid)) {/* check next page if needed */ if (tb->page_addr[1 ] ==-1 ) {return true;
@@ -352,7 +353,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,/* Check if translation buffer has been flushed */ if (cpu->tb_flushed) { cpu->tb_flushed = false; - }else { + }else if (!tb->invalid) {tb_add_jump (last_tb, tb_exit, tb); } }
include/exec/exec-all.h +2 -0
@@ -225,6 +225,8 @@ struct TranslationBlock {#define CF_USE_ICOUNT 0x20000#define CF_IGNORE_ICOUNT 0x40000/* Do not generate icount code */ +uint16_t invalid; +void *tc_ptr;/* pointer to the translated code */ uint8_t *tc_search;/* pointer to search data */ /* original tb when cflags has CF_NOCACHE */
translate-all.c +3 -0
@@ -773,6 +773,7 @@ static TranslationBlock *tb_alloc(target_ulong pc) tb = &tcg_ctx.tb_ctx.tbs[tcg_ctx.tb_ctx.nb_tbs++]; tb->pc = pc; tb->cflags =0 ; + tb->invalid = false;return tb; }
@@ -994,6 +995,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)uint32_t h;tb_page_addr_t phys_pc; +atomic_set (&tb->invalid, true); +/* remove the TB from the hash list */ phys_pc = tb->page_addr[0 ] + (tb->pc & ~TARGET_PAGE_MASK ); h =tb_hash_func (phys_pc, tb->pc, tb->flags);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 08/58] tcg: set up tb->page_addr before insertion
In reply to Paolo BonziniFrom: Alex Bennée <[email protected]>
This ensures that if we find the TB on the slow path that tb->page_addr is correctly set before being tested.
Message-Id: <[email protected]>
--- translate-all.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
translate-all.c +4 -4
@@ -1131,10 +1131,6 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, {uint32_t h; -/* add in the hash table */ - h =tb_hash_func (phys_pc, tb->pc, tb->flags); -qht_insert (&tcg_ctx.tb_ctx.htable, tb, h); -/* add in the page list */ tb_alloc_page (tb,0 , phys_pc &TARGET_PAGE_MASK );if (phys_page2 !=-1 ) {
@@ -1143,6 +1139,10 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, tb->page_addr[1 ] =-1 ; } +/* add in the hash table */ + h =tb_hash_func (phys_pc, tb->pc, tb->flags); +qht_insert (&tcg_ctx.tb_ctx.htable, tb, h); +#ifdef DEBUG_TB_CHECK tb_page_check ();#endif
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 10/58] tcg: Avoid bouncing tb_lock between tb_gen_code() and tb_add_jump()
In reply to Paolo BonziniFrom: Sergey Fedorov <[email protected]>
Message-Id: <[email protected]>
--- cpu-exec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
cpu-exec.c +11 -4
@@ -282,7 +282,8 @@ static TranslationBlock *tb_find_physical(CPUState *cpu,static TranslationBlock *tb_find_slow (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint32_t flags) +uint32_t flags, +bool *have_tb_lock) {TranslationBlock *tb;
@@ -295,6 +296,7 @@ static TranslationBlock *tb_find_slow(CPUState *cpu,*/ mmap_lock ();tb_lock (); + *have_tb_lock = true;/* There's a chance that our desired tb has been translated while * taking the locks so we check again inside the lock.
@@ -305,7 +307,6 @@ static TranslationBlock *tb_find_slow(CPUState *cpu, tb =tb_gen_code (cpu, pc, cs_base, flags,0 ); } -tb_unlock ();mmap_unlock (); }
@@ -322,6 +323,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,TranslationBlock *tb;target_ulong cs_base, pc;uint32_t flags; +bool have_tb_lock = false;/* we record a subset of the CPU state. It will always be the same before a given translated block
@@ -330,7 +332,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, tb =atomic_rcu_read (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]);if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { - tb =tb_find_slow (cpu, pc, cs_base, flags); + tb =tb_find_slow (cpu, pc, cs_base, flags, &have_tb_lock); }#ifndef CONFIG_USER_ONLY /* We don't take care of direct jumps when address mapping changes in
@@ -343,13 +345,18 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,#endif /* See if we can patch the calling TB. */ if (last_tb && !qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { -tb_lock (); +if (!have_tb_lock) { +tb_lock (); + have_tb_lock = true; + }/* Check if translation buffer has been flushed */ if (cpu->tb_flushed) { cpu->tb_flushed = false; }else if (!tb->invalid) {tb_add_jump (last_tb, tb_exit, tb); } + } +if (have_tb_lock) {tb_unlock (); }return tb;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 09/58] tcg: cpu-exec: remove tb_lock from the hot-path
In reply to Paolo BonziniFrom: Alex Bennée <[email protected]>
Lock contention in the hot path of moving between existing patched TranslationBlocks is the main drag in multithreaded performance. This patch pushes the tb_lock() usage down to the two places that really need it:
- code generation (tb_gen_code)
- jump patching (tb_add_jump)
The rest of the code doesn't really need to hold a lock as it is either using per-CPU structures, atomically updated or designed to be used in concurrent read situations (qht_lookup).
To keep things simple I removed the #ifdef CONFIG_USER_ONLY stuff as the locks become NOPs anyway until the MTTCG work is completed.
Message-Id: <[email protected]>
--- cpu-exec.c | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-)
cpu-exec.c +21 -27
@@ -287,35 +287,29 @@ static TranslationBlock *tb_find_slow(CPUState *cpu,TranslationBlock *tb; tb =tb_find_physical (cpu, pc, cs_base, flags); -if (tb) { - goto found; - } +if (!tb) { -#ifdef CONFIG_USER_ONLY -/* mmap_lock is needed by tb_gen_code, and mmap_lock must be -* taken outside tb_lock. Since we're momentarily dropping -* tb_lock, there's a chance that our desired tb has been -* translated. -*/ -tb_unlock (); -mmap_lock (); -tb_lock (); - tb =tb_find_physical (cpu, pc, cs_base, flags); -if (tb) { -mmap_unlock (); - goto found; - } -#endif +/* mmap_lock is needed by tb_gen_code, and mmap_lock must be +* taken outside tb_lock. As system emulation is currently +* single threaded the locks are NOPs. +*/ +mmap_lock (); +tb_lock (); -/* if no translated code available, then translate it now */ - tb =tb_gen_code (cpu, pc, cs_base, flags,0 ); +/* There's a chance that our desired tb has been translated while +* taking the locks so we check again inside the lock. +*/ + tb =tb_find_physical (cpu, pc, cs_base, flags); +if (!tb) { +/* if no translated code available, then translate it now */ + tb =tb_gen_code (cpu, pc, cs_base, flags,0 ); + } -#ifdef CONFIG_USER_ONLY -mmap_unlock (); -#endif +tb_unlock (); +mmap_unlock (); + } -found: -/* we add the TB in the virtual pc hash table */ +/* We add the TB in the virtual pc hash table for the fast lookup */ atomic_set (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)], tb);return tb; }
@@ -333,7 +327,6 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,always be the same before a given translated block is executed. */ cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); -tb_lock (); tb =atomic_rcu_read (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]);if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) {
@@ -350,14 +343,15 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,#endif /* See if we can patch the calling TB. */ if (last_tb && !qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { +tb_lock ();/* Check if translation buffer has been flushed */ if (cpu->tb_flushed) { cpu->tb_flushed = false; }else if (!tb->invalid) {tb_add_jump (last_tb, tb_exit, tb); } +tb_unlock (); } -tb_unlock ();return tb; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 11/58] tcg: Merge tb_find_slow() and tb_find_fast()
In reply to Paolo BonziniFrom: Sergey Fedorov <[email protected]>
These functions are not too big and can be merged together. This makes locking scheme more clear and easier to follow.
Message-Id: <[email protected]>
--- cpu-exec.c | 72 ++++++++++++++++++++++++++------------------------------------ 1 file changed, 30 insertions(+), 42 deletions(-)
cpu-exec.c +30 -42
@@ -279,45 +279,9 @@ static TranslationBlock *tb_find_physical(CPUState *cpu,return qht_lookup (&tcg_ctx.tb_ctx.htable, tb_cmp, &desc, h); } -static TranslationBlock *tb_find_slow (CPUState *cpu, -target_ulong pc, -target_ulong cs_base, -uint32_t flags, -bool *have_tb_lock) -{ -TranslationBlock *tb; - - tb =tb_find_physical (cpu, pc, cs_base, flags); -if (!tb) { - -/* mmap_lock is needed by tb_gen_code, and mmap_lock must be -* taken outside tb_lock. As system emulation is currently -* single threaded the locks are NOPs. -*/ -mmap_lock (); -tb_lock (); - *have_tb_lock = true; - -/* There's a chance that our desired tb has been translated while -* taking the locks so we check again inside the lock. -*/ - tb =tb_find_physical (cpu, pc, cs_base, flags); -if (!tb) { -/* if no translated code available, then translate it now */ - tb =tb_gen_code (cpu, pc, cs_base, flags,0 ); - } - -mmap_unlock (); - } - -/* We add the TB in the virtual pc hash table for the fast lookup */ -atomic_set (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)], tb); -return tb; -} - -static inline TranslationBlock *tb_find_fast (CPUState *cpu, -TranslationBlock *last_tb, -int tb_exit) +static inline TranslationBlock *tb_find (CPUState *cpu, +TranslationBlock *last_tb, +int tb_exit) {CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb;
@@ -332,7 +296,31 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, tb =atomic_rcu_read (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]);if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { - tb =tb_find_slow (cpu, pc, cs_base, flags, &have_tb_lock); + tb =tb_find_physical (cpu, pc, cs_base, flags); +if (!tb) { + +/* mmap_lock is needed by tb_gen_code, and mmap_lock must be +* taken outside tb_lock. As system emulation is currently +* single threaded the locks are NOPs. +*/ +mmap_lock (); +tb_lock (); + have_tb_lock = true; + +/* There's a chance that our desired tb has been translated while +* taking the locks so we check again inside the lock. +*/ + tb =tb_find_physical (cpu, pc, cs_base, flags); +if (!tb) { +/* if no translated code available, then translate it now */ + tb =tb_gen_code (cpu, pc, cs_base, flags,0 ); + } + +mmap_unlock (); + } + +/* We add the TB in the virtual pc hash table for the fast lookup */ +atomic_set (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)], tb); }#ifndef CONFIG_USER_ONLY /* We don't take care of direct jumps when address mapping changes in
@@ -437,7 +425,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) } else if (replay_has_exception() && cpu->icount_decr.u16.low + cpu->icount_extra ==0 ) {/* try to cause an exception pending in the log */ -cpu_exec_nocache (cpu,1 ,tb_find_fast (cpu,NULL ,0 ), true); +cpu_exec_nocache (cpu,1 ,tb_find (cpu,NULL ,0 ), true); *ret =-1 ;return true;#endif
@@ -620,7 +608,7 @@ int cpu_exec(CPUState *cpu)atomic_mb_set (&cpu->tb_flushed, false);/* reset before first TB lookup */ for (;;) {cpu_handle_interrupt (cpu, &last_tb); - tb =tb_find_fast (cpu, last_tb, tb_exit); + tb =tb_find (cpu, last_tb, tb_exit);cpu_loop_exec_tb (cpu, tb, &last_tb, &tb_exit, &sc);/* Try to align the host and virtual clocks if the guest is in advance */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 12/58] tcg: rename tb_find_physical()
In reply to Paolo BonziniFrom: Sergey Fedorov <[email protected]>
In fact, this function does not exactly perform a lookup by physical address as it is descibed for comment on get_page_addr_code(). Thus it may be a bit confusing to have "physical" in it's name. So rename it to tb_htable_lookup() to better reflect its actual functionality.
Message-Id: <[email protected]>
--- cpu-exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
cpu-exec.c +3 -3
@@ -260,7 +260,7 @@ static bool tb_cmp(const void *p, const void *d)return false; } -static TranslationBlock *tb_find_physical (CPUState *cpu, +static TranslationBlock *tb_htable_lookup (CPUState *cpu,target_ulong pc,target_ulong cs_base,uint32_t flags)
@@ -296,7 +296,7 @@ static inline TranslationBlock *tb_find(CPUState *cpu, tb =atomic_rcu_read (&cpu->tb_jmp_cache[tb_jmp_cache_hash_func (pc)]);if (unlikely (!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { - tb =tb_find_physical (cpu, pc, cs_base, flags); + tb =tb_htable_lookup (cpu, pc, cs_base, flags);if (!tb) {/* mmap_lock is needed by tb_gen_code, and mmap_lock must be
@@ -310,7 +310,7 @@ static inline TranslationBlock *tb_find(CPUState *cpu,/* There's a chance that our desired tb has been translated while * taking the locks so we check again inside the lock. */ - tb =tb_find_physical (cpu, pc, cs_base, flags); + tb =tb_htable_lookup (cpu, pc, cs_base, flags);if (!tb) {/* if no translated code available, then translate it now */ tb =tb_gen_code (cpu, pc, cs_base, flags,0 );
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 13/58] rules.mak: Don't extract libs from .mo-libs in link command
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
For module build, .mo objects are passed to LINK and consumed in process-archive-undefs. The reason behind that is documented in the comment above process-archive-undefs.
Similarly, extract-libs should be called with .mo filtered out too. Otherwise, the .mo-libs are added to the link command incorrectly, spoiling the purpose of modularization.
Currently we don't have any .mo-libs usage, but it will be used soon when we modularize more multi-source objects, like sdl and gtk.
Message-Id: <[email protected]>
--- rules.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rules.mak +1 -1
@@ -51,7 +51,7 @@ process-archive-undefs = $(filter-out %.a %.mo,$1) \ $(call undefined-symbols,$(filter %.mo,$1)))) \ $(filter %.a,$1) -extract-libs = $(strip $(foreach o,$1,$($o-libs))) +extract-libs = $(strip $(foreach o,$(filter-out %.mo,$1),$($o-libs))) expand-objs = $(strip $(sort $(filter %.o,$1)) \ $(foreach o,$(filter %.mo,$1),$($o-objs)) \ $(filter-out %.o %.mo,$1))
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 14/58] timer: update comments
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
The comments is outdated. The patch has following changes:
1. tense correction.
2. all clock time value is returned in nanoseconds, so, they are same in precision.
3. virtual clock doesn't use cpu cycles.
Message-Id: <[email protected]>
--- include/qemu/timer.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
include/qemu/timer.h +6 -13
@@ -22,23 +22,20 @@* @QEMU_CLOCK_REALTIME: Real time clock * * The real time clock should be used only for stuff which does not -* change the virtual machine state, as it is run even if the virtual -* machine is stopped. The real time clock has a frequency of 1000 -* Hz. +* change the virtual machine state, as it runs even if the virtual +* machine is stopped. * * @QEMU_CLOCK_VIRTUAL: virtual clock * -* The virtual clock is only run during the emulation. It is stopped -* when the virtual machine is stopped. Virtual timers use a high -* precision clock, usually cpu cycles (use ticks_per_sec). +* The virtual clock only runs during the emulation. It stops +* when the virtual machine is stopped. * * @QEMU_CLOCK_HOST: host clock * -* The host clock should be use for device models that emulate accurate +* The host clock should be used for device models that emulate accurate * real time sources. It will continue to run when the virtual machine * is suspended, and it will reflect system time changes the host may -* undergo (e.g. due to NTP). The host clock has the same precision as -* the virtual clock. +* undergo (e.g. due to NTP). * * @QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp *
@@ -77,10 +74,6 @@ struct QEMUTimer {extern QEMUTimerListGroup main_loop_tlg;/* -* QEMUClockType -*/ - -/* * qemu_clock_get_ns; * @type: the clock type *
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 15/58] cpus: rename local variable to meaningful one
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
The function actually returns monotonic time value in nanosecond, the "ticks" is not suitable.
Cc: Paolo Bonzini <[email protected]>
Cc Peter Crosthwaite <[email protected]>
Message-Id: <[email protected]>
--- cpus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
cpus.c +4 -4
@@ -219,14 +219,14 @@ int64_t cpu_get_ticks(void)static int64_t cpu_get_clock_locked (void ) { -int64_t ticks; +int64_t time; - ticks = timers_state.cpu_clock_offset; + time = timers_state.cpu_clock_offset;if (timers_state.cpu_ticks_enabled) { - ticks +=get_clock (); + time +=get_clock (); } -return ticks; +return time; }/* return the host CPU monotonic timer and handle stop/restart */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 16/58] cpus: update comments
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
The returned value of cpu_get_clock() is plused with the offset, so it is the time elapsed in virtual machine when vm is active.
Cc: Paolo Bonzini <[email protected]>
Cc Peter Crosthwaite <[email protected]>
Message-Id: <[email protected]>
--- cpus.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
cpus.c +8 -3
@@ -191,8 +191,12 @@ int64_t cpu_icount_to_ns(int64_t icount)return icount << icount_time_shift; } -/* return the host CPU cycle counter and handle stop/restart */ -/* Caller must hold the BQL */ +/* return the time elapsed in VM between vm_start and vm_stop. Unless +* icount is active, cpu_get_ticks() uses units of the host CPU cycle +* counter. +* +* Caller must hold the BQL +*/ int64_t cpu_get_ticks (void ) {int64_t ticks;
@@ -229,7 +233,8 @@ static int64_t cpu_get_clock_locked(void)return time; } -/* return the host CPU monotonic timer and handle stop/restart */ +/* Return the monotonic time elapsed in VM, i.e., +* the time between vm_start and vm_stop */ int64_t cpu_get_clock (void ) {int64_t ti;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 19/58] lsi: do not exit QEMU if reading invalid register
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
When guest accesses invalid register, return 0xff instead of exiting. Also add a log when reading or writing invalid registers.
Message-Id: <[email protected]>
--- hw/scsi/lsi53c895a.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
hw/scsi/lsi53c895a.c +13 -5
@@ -19,6 +19,7 @@#include "hw/pci/pci.h" #include "hw/scsi/scsi.h" #include "sysemu/dma.h" +#include "qemu/log.h" //#define DEBUG_LSI //#define DEBUG_LSI_REG
@@ -34,7 +35,6 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); exit(1);} while do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0)#endif -#ifdef DEBUG_LSI_REG static const char *names[] = {"SCNTL0" ,"SCNTL1" ,"SCNTL2" ,"SCNTL3" ,"SCID" ,"SXFER" ,"SDID" ,"GPREG" ,"SFBR" ,"SOCL" ,"SSID" ,"SBCL" ,"DSTAT" ,"SSTAT0" ,"SSTAT1" ,"SSTAT2" ,
@@ -49,7 +49,6 @@ static const char *names[] = {"SIDL" ,"0x51" ,"0x52" ,"0x53" ,"SODL" ,"0x55" ,"0x56" ,"0x57" , "SBDL", "0x59", "0x5a", "0x5b", "SCRATCHB0", "SCRATCHB1", "SCRATCHB2", "SCRATCHB3", }; -#endif #define LSI_MAX_DEVS 7
@@ -1715,8 +1714,14 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset)break ; }default : -BADF ("readb 0x%x\n" , offset); -exit (1 ); + { +qemu_log_mask (LOG_GUEST_ERROR , +"lsi_scsi: invalid read from reg %s %x\n" , + offset <ARRAY_SIZE (names) ? names[offset] :"???" , + offset); + ret =0xff ; +break ; + } }#undef CASE_GET_REG24#undef CASE_GET_REG32
@@ -1959,7 +1964,10 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val) shift = (offset &3 ) *8 ; s->scratch[n] =deposit32 (s->scratch[n], shift,8 , val); }else { -BADF ("Unhandled writeb 0x%x = 0x%x\n" , offset, val); +qemu_log_mask (LOG_GUEST_ERROR , +"lsi_scsi: invalid write to reg %s %x (0x%02x)\n" , + offset <ARRAY_SIZE (names) ? names[offset] :"???" , + offset, val); } }#undef CASE_SET_REG24
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 17/58] help: Update help to remove misleading display information
In reply to Paolo BonziniFrom: Colin Lord <[email protected]>
Updates the help messages to remove misleading information about SDL being the normal display used.
Message-Id: <[email protected]>
--- qemu-options.hx | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-)
qemu-options.hx +21 -17
@@ -982,13 +982,14 @@ DEF("nographic", 0, QEMU_OPTION_nographic, STEXI @item -nographic @findex -nographic -Normally, QEMU uses SDL to display the VGA output. With this option, -you can totally disable graphical output so that QEMU is a simple -command line application. The emulated serial port is redirected on -the console and muxed with the monitor (unless redirected elsewhere -explicitly). Therefore, you can still use QEMU to debug a Linux kernel -with a serial console. Use @key{C-a h} for help on switching between -the console and monitor. +Normally, if QEMU is compiled with graphical window support, it displays +output such as guest graphics, guest console, and the QEMU monitor in a +window. With this option, you can totally disable graphical output so +that QEMU is a simple command line application. The emulated serial port +is redirected on the console and muxed with the monitor (unless +redirected elsewhere explicitly). Therefore, you can still use QEMU to +debug a Linux kernel with a serial console. Use @key{C-a h} for help on +switching between the console and monitor. ETEXI DEF("curses", 0, QEMU_OPTION_curses,
@@ -997,9 +998,11 @@ DEF("curses", 0, QEMU_OPTION_curses, STEXI @item -curses @findex -curses -Normally, QEMU uses SDL to display the VGA output. With this option, -QEMU can display the VGA output when in text mode using a -curses/ncurses interface. Nothing is displayed in graphical mode. +Normally, if QEMU is compiled with graphical window support, it displays +output such as guest graphics, guest console, and the QEMU monitor in a +window. With this option, QEMU can display the VGA output when in text +mode using a curses/ncurses interface. Nothing is displayed in graphical +mode. ETEXI DEF("no-frame", 0, QEMU_OPTION_no_frame,
@@ -1243,13 +1246,14 @@ DEF("vnc", HAS_ARG, QEMU_OPTION_vnc , STEXI @item -vnc @var{display}[,@var{option}[,@var{option}[,...]]] @findex -vnc -Normally, QEMU uses SDL to display the VGA output. With this option, -you can have QEMU listen on VNC display @var{display} and redirect the VGA -display over the VNC session. It is very useful to enable the usb -tablet device when using this option (option @option{-usbdevice -tablet}). When using the VNC display, you must use the @option{-k} -parameter to set the keyboard layout if you are not using en-us. Valid -syntax for the @var{display} is +Normally, if QEMU is compiled with graphical window support, it displays +output such as guest graphics, guest console, and the QEMU monitor in a +window. With this option, you can have QEMU listen on VNC display +@var{display} and redirect the VGA display over the VNC session. It is +very useful to enable the usb tablet device when using this option +(option @option{-usbdevice tablet}). When using the VNC display, you +must use the @option{-k} parameter to set the keyboard layout if you are +not using en-us. Valid syntax for the @var{display} is @table @option
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 18/58] lsi: print register names in debug prints
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
Modify lsi_reg_readb function to have a single exit point. Debug print can now contain the returned value.
Message-Id: <[email protected]>
--- hw/scsi/lsi53c895a.c | 219 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 146 insertions(+), 73 deletions(-)
hw/scsi/lsi53c895a.c +146 -73
@@ -34,6 +34,23 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); exit(1);} while do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0)#endif +#ifdef DEBUG_LSI_REG +static const char *names[] = { +"SCNTL0" ,"SCNTL1" ,"SCNTL2" ,"SCNTL3" ,"SCID" ,"SXFER" ,"SDID" ,"GPREG" , +"SFBR" ,"SOCL" ,"SSID" ,"SBCL" ,"DSTAT" ,"SSTAT0" ,"SSTAT1" ,"SSTAT2" , +"DSA0" ,"DSA1" ,"DSA2" ,"DSA3" ,"ISTAT" ,"0x15" ,"0x16" ,"0x17" , +"CTEST0" ,"CTEST1" ,"CTEST2" ,"CTEST3" ,"TEMP0" ,"TEMP1" ,"TEMP2" ,"TEMP3" , +"DFIFO" ,"CTEST4" ,"CTEST5" ,"CTEST6" ,"DBC0" ,"DBC1" ,"DBC2" ,"DCMD" , +"DNAD0" ,"DNAD1" ,"DNAD2" ,"DNAD3" ,"DSP0" ,"DSP1" ,"DSP2" ,"DSP3" , +"DSPS0" ,"DSPS1" ,"DSPS2" ,"DSPS3" ,"SCRATCHA0" ,"SCRATCHA1" ,"SCRATCHA2" ,"SCRATCHA3" , +"DMODE" ,"DIEN" ,"SBR" ,"DCNTL" ,"ADDER0" ,"ADDER1" ,"ADDER2" ,"ADDER3" , +"SIEN0" ,"SIEN1" ,"SIST0" ,"SIST1" ,"SLPAR" ,"0x45" ,"MACNTL" ,"GPCNTL" , +"STIME0" ,"STIME1" ,"RESPID" ,"0x4b" ,"STEST0" ,"STEST1" ,"STEST2" ,"STEST3" , +"SIDL" ,"0x51" ,"0x52" ,"0x53" ,"SODL" ,"0x55" ,"0x56" ,"0x57" , +"SBDL" ,"0x59" ,"0x5a" ,"0x5b" ,"SCRATCHB0" ,"SCRATCHB1" ,"SCRATCHB2" ,"SCRATCHB3" , +}; +#endif +#define LSI_MAX_DEVS 7#define LSI_SCNTL0_TRG 0x01
@@ -1480,155 +1497,200 @@ again:static uint8_t lsi_reg_readb (LSIState *s,int offset) { -uint8_t tmp; +uint8_t ret; +#define CASE_GET_REG24 (name, addr) \ - case addr: return s->name & 0xff; \ - case addr + 1: return (s->name >> 8) & 0xff; \ - case addr + 2: return (s->name >> 16) & 0xff; + case addr: ret = s->name & 0xff; break; \ + case addr + 1: ret = (s->name >> 8) & 0xff; break; \ + case addr + 2: ret = (s->name >> 16) & 0xff; break;#define CASE_GET_REG32 (name, addr) \ - case addr: return s->name & 0xff; \ - case addr + 1: return (s->name >> 8) & 0xff; \ - case addr + 2: return (s->name >> 16) & 0xff; \ - case addr + 3: return (s->name >> 24) & 0xff; + case addr: ret = s->name & 0xff; break; \ + case addr + 1: ret = (s->name >> 8) & 0xff; break; \ + case addr + 2: ret = (s->name >> 16) & 0xff; break; \ + case addr + 3: ret = (s->name >> 24) & 0xff; break; -#ifdef DEBUG_LSI_REG -DPRINTF ("Read reg %x\n" , offset); -#endif switch (offset) {case 0x00 :/* SCNTL0 */ -return s->scntl0; + ret = s->scntl0; +break ;case 0x01 :/* SCNTL1 */ -return s->scntl1; + ret = s->scntl1; +break ;case 0x02 :/* SCNTL2 */ -return s->scntl2; + ret = s->scntl2; +break ;case 0x03 :/* SCNTL3 */ -return s->scntl3; + ret = s->scntl3; +break ;case 0x04 :/* SCID */ -return s->scid; + ret = s->scid; +break ;case 0x05 :/* SXFER */ -return s->sxfer; + ret = s->sxfer; +break ;case 0x06 :/* SDID */ -return s->sdid; + ret = s->sdid; +break ;case 0x07 :/* GPREG0 */ -return 0x7f ; + ret =0x7f ; +break ;case 0x08 :/* Revision ID */ -return 0x00 ; + ret =0x00 ; +break ;case 0x09 :/* SOCL */ -return s->socl; + ret = s->socl; +break ;case 0xa :/* SSID */ -return s->ssid; + ret = s->ssid; +break ;case 0xb :/* SBCL */ /* ??? This is not correct. However it's (hopefully) only used for diagnostics, so should be ok. */ -return 0 ; + ret =0 ; +break ;case 0xc :/* DSTAT */ - tmp = s->dstat |LSI_DSTAT_DFE ; + ret = s->dstat |LSI_DSTAT_DFE ;if ((s->istat0 &LSI_ISTAT0_INTF ) ==0 ) s->dstat =0 ;lsi_update_irq (s); -return tmp; +break ;case 0x0d :/* SSTAT0 */ -return s->sstat0; + ret = s->sstat0; +break ;case 0x0e :/* SSTAT1 */ -return s->sstat1; + ret = s->sstat1; +break ;case 0x0f :/* SSTAT2 */ -return s->scntl1 &LSI_SCNTL1_CON ?0 :2 ; + ret = s->scntl1 &LSI_SCNTL1_CON ?0 :2 ; +break ; CASE_GET_REG32(dsa, 0x10)case 0x14 :/* ISTAT0 */ -return s->istat0; + ret = s->istat0; +break ;case 0x15 :/* ISTAT1 */ -return s->istat1; + ret = s->istat1; +break ;case 0x16 :/* MBOX0 */ -return s->mbox0; + ret = s->mbox0; +break ;case 0x17 :/* MBOX1 */ -return s->mbox1; + ret = s->mbox1; +break ;case 0x18 :/* CTEST0 */ -return 0xff ; + ret =0xff ; +break ;case 0x19 :/* CTEST1 */ -return 0 ; + ret =0 ; +break ;case 0x1a :/* CTEST2 */ - tmp = s->ctest2 |LSI_CTEST2_DACK |LSI_CTEST2_CM ; + ret = s->ctest2 |LSI_CTEST2_DACK |LSI_CTEST2_CM ;if (s->istat0 &LSI_ISTAT0_SIGP ) { s->istat0 &= ~LSI_ISTAT0_SIGP ; - tmp |=LSI_CTEST2_SIGP ; + ret |=LSI_CTEST2_SIGP ; } -return tmp; +break ;case 0x1b :/* CTEST3 */ -return s->ctest3; + ret = s->ctest3; +break ; CASE_GET_REG32(temp, 0x1c)case 0x20 :/* DFIFO */ -return 0 ; + ret =0 ; +break ;case 0x21 :/* CTEST4 */ -return s->ctest4; + ret = s->ctest4; +break ;case 0x22 :/* CTEST5 */ -return s->ctest5; + ret = s->ctest5; +break ;case 0x23 :/* CTEST6 */ -return 0 ; + ret =0 ; +break ; CASE_GET_REG24(dbc, 0x24)case 0x27 :/* DCMD */ -return s->dcmd; + ret = s->dcmd; +break ; CASE_GET_REG32(dnad, 0x28) CASE_GET_REG32(dsp, 0x2c) CASE_GET_REG32(dsps, 0x30) CASE_GET_REG32(scratch[0], 0x34)case 0x38 :/* DMODE */ -return s->dmode; + ret = s->dmode; +break ;case 0x39 :/* DIEN */ -return s->dien; + ret = s->dien; +break ;case 0x3a :/* SBR */ -return s->sbr; + ret = s->sbr; +break ;case 0x3b :/* DCNTL */ -return s->dcntl; + ret = s->dcntl; +break ;/* ADDER Output (Debug of relative jump address) */ CASE_GET_REG32(adder, 0x3c)case 0x40 :/* SIEN0 */ -return s->sien0; + ret = s->sien0; +break ;case 0x41 :/* SIEN1 */ -return s->sien1; + ret = s->sien1; +break ;case 0x42 :/* SIST0 */ - tmp = s->sist0; + ret = s->sist0; s->sist0 =0 ;lsi_update_irq (s); -return tmp; +break ;case 0x43 :/* SIST1 */ - tmp = s->sist1; + ret = s->sist1; s->sist1 =0 ;lsi_update_irq (s); -return tmp; +break ;case 0x46 :/* MACNTL */ -return 0x0f ; + ret =0x0f ; +break ;case 0x47 :/* GPCNTL0 */ -return 0x0f ; + ret =0x0f ; +break ;case 0x48 :/* STIME0 */ -return s->stime0; + ret = s->stime0; +break ;case 0x4a :/* RESPID0 */ -return s->respid0; + ret = s->respid0; +break ;case 0x4b :/* RESPID1 */ -return s->respid1; + ret = s->respid1; +break ;case 0x4d :/* STEST1 */ -return s->stest1; + ret = s->stest1; +break ;case 0x4e :/* STEST2 */ -return s->stest2; + ret = s->stest2; +break ;case 0x4f :/* STEST3 */ -return s->stest3; + ret = s->stest3; +break ;case 0x50 :/* SIDL */ /* This is needed by the linux drivers. We currently only update it during the MSG IN phase. */ -return s->sidl; + ret = s->sidl; +break ;case 0x52 :/* STEST4 */ -return 0xe0 ; + ret =0xe0 ; +break ;case 0x56 :/* CCNTL0 */ -return s->ccntl0; + ret = s->ccntl0; +break ;case 0x57 :/* CCNTL1 */ -return s->ccntl1; + ret = s->ccntl1; +break ;case 0x58 :/* SBDL */ /* Some drivers peek at the data bus during the MSG IN phase. */ if ((s->sstat1 &PHASE_MASK ) ==PHASE_MI )return s->msg[0 ]; -return 0 ; + ret =0 ; +break ;case 0x59 :/* SBDL high */ -return 0 ; + ret =0 ; +break ; CASE_GET_REG32(mmrs, 0xa0) CASE_GET_REG32(mmws, 0xa4)CASE_GET_REG32 (sfs,0xa8 )
@@ -1643,18 +1705,28 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset) CASE_GET_REG32(ia, 0xd4) CASE_GET_REG32(sbc, 0xd8) CASE_GET_REG32(csbc, 0xdc) - } -if (offset >=0x5c && offset <0xa0 ) { + case 0x5c ... 0x9f: + {int n;int shift; n = (offset -0x58 ) >>2 ; shift = (offset &3 ) *8 ; -return (s->scratch[n] >> shift) &0xff ; + ret = (s->scratch[n] >> shift) &0xff ; +break ; + } +default : +BADF ("readb 0x%x\n" , offset); +exit (1 ); } -BADF ("readb 0x%x\n" , offset); -exit (1 );#undef CASE_GET_REG24#undef CASE_GET_REG32 + +#ifdef DEBUG_LSI_REG +DPRINTF ("Read reg %s %x = %02x\n" , + offset <ARRAY_SIZE (names) ? names[offset] :"???" , offset, ret); +#endif + +return ret; }static void lsi_reg_writeb (LSIState *s,int offset,uint8_t val)
@@ -1671,7 +1743,8 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)case addr +3 : s->name &=0x00ffffff ; s->name |= val <<24 ;break ;#ifdef DEBUG_LSI_REG -DPRINTF ("Write reg %x = %02x\n" , offset, val); +DPRINTF ("Write reg %s %x = %02x\n" , + offset <ARRAY_SIZE (names) ? names[offset] :"???" , offset, val);#endif switch (offset) {case 0x00 :/* SCNTL0 */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 20/58] lsi: implement I/O memory space for Memory Move instructions
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
Memory Move instructions can read/write data either from PCI memory or from PCI I/O. Implement second case.
Windows 98 now works with LSI 53C810A adapter.
Message-Id: <[email protected]>
--- hw/scsi/lsi53c895a.c | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-)
hw/scsi/lsi53c895a.c +39 -10
@@ -210,6 +210,7 @@ typedef struct {MemoryRegion mmio_io;MemoryRegion ram_io;MemoryRegion io_io; +AddressSpace pci_io_as;int carry;/* ??? Should this be an a visible register somewhere? */ int status;
@@ -407,6 +408,30 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val);static void lsi_execute_script (LSIState *s);static void lsi_reselect (LSIState *s,lsi_request *p); +static inline int lsi_mem_read (LSIState *s,dma_addr_t addr, +void *buf,dma_addr_t len) +{ +if (s->dmode &LSI_DMODE_SIOM ) { +address_space_read (&s->pci_io_as, addr,MEMTXATTRS_UNSPECIFIED , + buf, len); +return 0 ; + }else { +return pci_dma_read (PCI_DEVICE (s), addr, buf, len); + } +} + +static inline int lsi_mem_write (LSIState *s,dma_addr_t addr, +const void *buf,dma_addr_t len) +{ +if (s->dmode &LSI_DMODE_DIOM ) { +address_space_write (&s->pci_io_as, addr,MEMTXATTRS_UNSPECIFIED , + buf, len); +return 0 ; + }else { +return pci_dma_write (PCI_DEVICE (s), addr, buf, len); + } +} +static inline uint32_t read_dword (LSIState *s,uint32_t addr) {uint32_t buf;
@@ -550,7 +575,6 @@ static void lsi_bad_selection(LSIState *s, uint32_t id)/* Initiate a SCSI layer data transfer. */ static void lsi_do_dma (LSIState *s,int out) { -PCIDevice *pci_dev;uint32_t count;dma_addr_t addr;SCSIDevice *dev;
@@ -562,7 +586,6 @@ static void lsi_do_dma(LSIState *s, int out)return ; } - pci_dev =PCI_DEVICE (s); dev = s->current->req->dev;assert (dev);
@@ -588,9 +611,9 @@ static void lsi_do_dma(LSIState *s, int out) }/* ??? Set SFBR to first data byte. */ if (out) { -pci_dma_read (pci_dev, addr, s->current->dma_buf, count); +lsi_mem_read (s, addr, s->current->dma_buf, count); }else { -pci_dma_write (pci_dev, addr, s->current->dma_buf, count); +lsi_mem_write (s, addr, s->current->dma_buf, count); } s->current->dma_len -= count;if (s->current->dma_len ==0 ) {
@@ -1022,15 +1045,14 @@ bad:#define LSI_BUF_SIZE 4096static void lsi_memcpy (LSIState *s,uint32_t dest,uint32_t src,int count) { -PCIDevice *d =PCI_DEVICE (s);int n;uint8_t buf[LSI_BUF_SIZE ];DPRINTF ("memcpy dest 0x%08x src 0x%08x count %d\n" , dest, src, count);while (count) { n = (count >LSI_BUF_SIZE ) ?LSI_BUF_SIZE : count; -pci_dma_read (d, src, buf, n); -pci_dma_write (d, dest, buf, n); +lsi_mem_read (s, src, buf, n); +lsi_mem_write (s, dest, buf, n); src += n; dest += n; count -= n;
@@ -1877,9 +1899,6 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val) CASE_SET_REG32(dsps, 0x30) CASE_SET_REG32(scratch[0], 0x34)case 0x38 :/* DMODE */ -if (val & (LSI_DMODE_SIOM |LSI_DMODE_DIOM )) { -BADF ("IO mappings not implemented\n" ); - } s->dmode = val;break ;case 0x39 :/* DIEN */
@@ -2189,6 +2208,8 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **errp)memory_region_init_io (&s->io_io,OBJECT (s), &lsi_io_ops, s,"lsi-io" ,256 ); +address_space_init (&s->pci_io_as,pci_address_space_io (dev),"lsi-pci-io" ); +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->io_io);pci_register_bar (dev,1 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->mmio_io);pci_register_bar (dev,2 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ram_io);
@@ -2200,6 +2221,13 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **errp) } } +static void lsi_scsi_unrealize (DeviceState *dev,Error **errp) +{ +LSIState *s =LSI53C895A (dev); + +address_space_destroy (&s->pci_io_as); +} +static void lsi_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -2210,6 +2238,7 @@ static void lsi_class_init(ObjectClass *klass, void *data) k->device_id =PCI_DEVICE_ID_LSI_53C895A ; k->class_id =PCI_CLASS_STORAGE_SCSI ; k->subsystem_id =0x1000 ; + dc->unrealize = lsi_scsi_unrealize; dc->reset = lsi_scsi_reset; dc->vmsd = &vmstate_lsi_scsi;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 22/58] MAINTAINERS: add myself as stubs maintainers
In reply to Paolo BonziniLet's just remove some files from the pool of unmaintained files. I am obviously not going to send pull requests only for stubs/, but I will ack them if maintainers want that.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -1257,6 +1257,11 @@ F: net/slirp.c F: include/net/slirp.h T: git git://git.kiszka.org/qemu.git queues/slirp +Stubs +M: Paolo Bonzini <[email protected]> +S: Maintained +F: stubs/ + Tracing M: Stefan Hajnoczi <[email protected]> S: Maintained
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 21/58] lsi: never set DMA FIFO Empty (DFE) bit in DSTAT register
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
53C895A datasheet says:
"This bit (DFE) is a pure status bit and will not cause an interrupt"
This bit is already auto-generated in lsi_read_reg when reading the DSTAT register.
This fixes IBM RS/6000 7020 firmware, which is:
- resetting the adapter
- enabling all interrupt sources (including DIP, ie interrupts from DSTAT)
- waiting for ISTAT0 to become 0 (including DIP=0, ie no interrupt coming from DSTAT)
Message-Id: <[email protected]>
--- hw/scsi/lsi53c895a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/lsi53c895a.c +1 -1
@@ -326,7 +326,7 @@ static void lsi_soft_reset(LSIState *s) s->istat0 =0 ; s->istat1 =0 ; s->dcmd =0x40 ; - s->dstat =LSI_DSTAT_DFE ; + s->dstat =0 ; s->dien =0 ; s->sist0 =0 ; s->sist1 =0 ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 23/58] scsi-disk: change disk serial length from 20 to 36
In reply to Paolo BonziniFrom: Rony Weng <[email protected]>
Openstack Cinder assigns volume a 36 characters uuid as serial. QEMU will shrinks the uuid to 20 characters, which does not match the original uuid.
Note that there is no limit to the length of the serial number in the SCSI spec. 20 was copy-pasted from virtio-blk which in turn was copy-pasted from ATA; 36 is even more arbitrary. However, bumping it up too much might cause issues (e.g. 252 seems to make sense because then the maximum amount of returned data is 256; but who knows there's no off-by-one somewhere for such a nicely rounded number).
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/scsi-disk.c +2 -2
@@ -599,8 +599,8 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) } l =strlen (s->serial); -if (l >20 ) { - l =20 ; +if (l >36 ) { + l =36 ; } DPRINTF("Inquiry EVPD[Serial number] "
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 24/58] vmw_pvscsi: check page count while initialising descriptor rings
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
Vmware Paravirtual SCSI emulation uses command descriptors to process SCSI commands. These descriptors come with their ring buffers. A guest could set the page count for these rings to an arbitrary value, leading to infinite loop or OOB access. Add check to avoid it.
Message-Id: <[email protected]>
--- hw/scsi/vmw_pvscsi.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
hw/scsi/vmw_pvscsi.c +9 -10
@@ -152,7 +152,7 @@ pvscsi_log2(uint32_t input)return log; } -static int +static void pvscsi_ring_init_data (PVSCSIRingInfo *m,PVSCSICmdDescSetupRings *ri) {int i;
@@ -160,10 +160,6 @@ pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)uint32_t req_ring_size, cmp_ring_size; m->rs_pa = ri->ringsStatePPN <<VMW_PAGE_SHIFT ; -if ((ri->reqRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES ) - || (ri->cmpRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES )) { -return -1 ; - } req_ring_size = ri->reqRingNumPages *PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE ; cmp_ring_size = ri->cmpRingNumPages *PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE ; txr_len_log2 =pvscsi_log2 (req_ring_size -1 );
@@ -195,8 +191,6 @@ pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)/* Flush ring state page changes */ smp_wmb (); - -return 0 ; } static int
@@ -746,7 +740,7 @@ pvscsi_dbg_dump_tx_rings_config(PVSCSICmdDescSetupRings *rc)trace_pvscsi_tx_rings_num_pages ("Confirm Ring" , rc->cmpRingNumPages);for (i =0 ; i < rc->cmpRingNumPages; i++) { -trace_pvscsi_tx_rings_ppn ("Confirm Ring" , rc->reqRingPPNs[i]); +trace_pvscsi_tx_rings_ppn ("Confirm Ring" , rc->cmpRingPPNs[i]); } }
@@ -779,11 +773,16 @@ pvscsi_on_cmd_setup_rings(PVSCSIState *s)trace_pvscsi_on_cmd_arrived ("PVSCSI_CMD_SETUP_RINGS" ); -pvscsi_dbg_dump_tx_rings_config (rc); -if (pvscsi_ring_init_data (&s->rings, rc) <0 ) { +if (!rc->reqRingNumPages + || rc->reqRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES + || !rc->cmpRingNumPages + || rc->cmpRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES ) {return PVSCSI_COMMAND_PROCESSING_FAILED ; } +pvscsi_dbg_dump_tx_rings_config (rc); +pvscsi_ring_init_data (&s->rings, rc); + s->rings_info_valid = TRUE;return PVSCSI_COMMAND_PROCESSING_SUCCEEDED ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 25/58] scsi: mptconfig: fix an assert expression
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
When LSI SAS1068 Host Bus emulator builds configuration page headers, mptsas_config_pack() should assert that the size fits in a byte. However, the size is expressed in 32-bit units, so up to 1020 bytes fit. The assertion was only allowing replies up to 252 bytes, so fix it.
Message-Id: <[email protected]>
--- hw/scsi/mptconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/mptconfig.c +1 -1
@@ -158,7 +158,7 @@ static size_t mptsas_config_pack(uint8_t **data, const char *fmt, ...)va_end (ap);if (data) { -assert (ret <256 && (ret %4 ) ==0 ); +assert (ret /4 <256 && (ret %4 ) ==0 );stb_p (*data +1 , ret /4 ); }return ret;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 26/58] scsi: mptconfig: fix misuse of MPTSAS_CONFIG_PACK
In reply to Paolo BonziniThese issues cause respectively a QEMU crash and a leak of 2 bytes of stack. They were discovered by VictorV of 360 Marvel Team.
--- hw/scsi/mptconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/mptconfig.c +2 -2
@@ -203,7 +203,7 @@ size_t mptsas_config_manufacturing_1(MPTSASState *s, uint8_t **data, int address {/* VPD - all zeros */ return MPTSAS_CONFIG_PACK (1 ,MPI_CONFIG_PAGETYPE_MANUFACTURING ,0x00 , -"s256" ); +"*s256" ); } static
@@ -328,7 +328,7 @@ size_t mptsas_config_ioc_0(MPTSASState *s, uint8_t **data, int address)return MPTSAS_CONFIG_PACK (0 ,MPI_CONFIG_PAGETYPE_IOC ,0x01 ,"*l*lwwb*b*b*blww" , pcic->vendor_id, pcic->device_id, pcic->revision, - pcic->subsystem_vendor_id, + pcic->class_id, pcic->subsystem_vendor_id, pcic->subsystem_id); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 27/58] vmxcap: Show raw MSR value
In reply to Paolo BonziniFrom: Eduardo Habkost <[email protected]>
This will be helpful to allow checking of bits that are not in the 'bits' table yet.
Message-Id: <[email protected]>
--- scripts/kvm/vmxcap | 1 + 1 file changed, 1 insertion(+)
scripts/kvm/vmxcap +1 -0
@@ -79,6 +79,7 @@ class Misc(object): def show(self): print self.name value = msr().read(self.msr, 0) + print ' Hex: 0x%x' % (value) def first_bit(key): if type(key) is tuple: return key[0]
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 29/58] doc/rcu: fix typo
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
Message-Id: <[email protected]>
--- docs/rcu.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
docs/rcu.txt +1 -1
@@ -37,7 +37,7 @@ do not matter; as soon as all previous critical sections have finished, there cannot be any readers who hold references to the data structure, and these can now be safely reclaimed (e.g., freed or unref'ed). -Here is a picutre: +Here is a picture: thread 1 thread 2 thread 3 ------------------- ------------------------ -------------------
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 28/58] vmxcap: Add TSC scaling bit
In reply to Paolo BonziniFrom: Eduardo Habkost <[email protected]>
Message-Id: <[email protected]>
--- scripts/kvm/vmxcap | 1 + 1 file changed, 1 insertion(+)
scripts/kvm/vmxcap +1 -0
@@ -173,6 +173,7 @@ controls = [ 16: 'RDSEED exiting', 18: 'EPT-violation #VE', 20: 'Enable XSAVES/XRSTORS', + 25: 'TSC scaling', }, cap_msr = MSR_IA32_VMX_PROCBASED_CTLS2, ),
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 30/58] chardev: Add 'help' option to print all available chardev backend types
In reply to Paolo BonziniFrom: Lin Ma <[email protected]>
Message-Id: <[email protected]>
--- qemu-char.c | 21 ++++++++++++++++----- qemu-options.hx | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-)
qemu-char.c +16 -5
@@ -39,6 +39,7 @@#include "io/channel-file.h" #include "io/channel-tls.h" #include "sysemu/replay.h" +#include "qemu/help_option.h" #include <zlib.h>
@@ -3879,16 +3880,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,const char *id =qemu_opts_id (opts);char *bid =NULL ; -if (id ==NULL ) { -error_setg (errp,"chardev: no id specified" ); - goto err; - } -if (qemu_opt_get (opts,"backend" ) ==NULL ) {error_setg (errp,"chardev: \"%s\" missing backend" ,qemu_opts_id (opts)); goto err; } + +if (is_help_option (qemu_opt_get (opts,"backend" ))) { +fprintf (stderr,"Available chardev backend types:\n" ); +for (i = backends; i; i = i->next) { + cd = i->data; +fprintf (stderr,"%s\n" , cd->name); + } +exit (!is_help_option (qemu_opt_get (opts,"backend" ))); + } + +if (id ==NULL ) { +error_setg (errp,"chardev: no id specified" ); + goto err; + } +for (i = backends; i; i = i->next) { cd = i->data;
qemu-options.hx +3 -0
@@ -2152,6 +2152,7 @@ The general form of a character device option is: ETEXI DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, + "-chardev help\n" "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" "-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n" " [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
@@ -2217,6 +2218,8 @@ Backend is one of: @option{spiceport}. The specific backend will determine the applicable options. +Use "-chardev help" to print all available chardev backend types. + All devices must have an id, which can be any string up to 127 characters long. It is used to uniquely identify this device in other command line directives.
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 31/58] MAINTAINERS: Fix wildcard for scsi headers
In reply to Paolo BonziniFrom: Thomas Huth <[email protected]>
get_maintainer.pl currently thinks that the scsi headers are currrently unmaintained. So let's fix the corresponding wildcard expression.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -831,7 +831,7 @@ T: git git://github.com/jasowang/qemu.git net SCSI M: Paolo Bonzini <[email protected]> S: Supported -F: include/hw/scsi* +F: include/hw/scsi/* F: hw/scsi/* T: git git://github.com/bonzini/qemu.git scsi-next
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 32/58] MAINTAINERS: Add some header files to the PC chipset section
In reply to Paolo BonziniFrom: Thomas Huth <[email protected]>
These header files obviously belong to the PC chipset (since their names match the other .c files in this section).
Message-Id: <[email protected]>
--- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+)
MAINTAINERS +4 -0
@@ -715,6 +715,10 @@ F: hw/misc/pc-testdev.c F: hw/timer/hpet* F: hw/timer/i8254* F: hw/timer/mc146818rtc* +F: include/hw/i2c/pm_smbus.h +F: include/hw/timer/hpet.h +F: include/hw/timer/i8254* +F: include/hw/timer/mc146818rtc* Machine core M: Eduardo Habkost <[email protected]>
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 33/58] scsi: pvscsi: limit loop to fetch SG list
In reply to Paolo BonziniFrom: Prasad J Pandit <[email protected]>
In PVSCSI paravirtual SCSI bus, pvscsi_convert_sglist can take a very long time or go into an infinite loop due to two different bugs:
1) the request descriptor data length is defined to be 64 bit. While building SG list from a request descriptor, it gets truncated to 32bit in routine 'pvscsi_convert_sglist'. This could lead to an infinite loop situation large 'dataLen' values when data_length is cast to uint32_t and chunk_size becomes always zero. Fix this by removing the incorrect cast.
2) pvscsi_get_next_sg_elem can be called arbitrarily many times if the element has a zero length. Get out of the loop early when this happens, by introducing an upper limit on the number of SG list elements.
Message-Id: <[email protected]>
--- hw/scsi/vmw_pvscsi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/scsi/vmw_pvscsi.c +6 -5
@@ -40,6 +40,8 @@#define PVSCSI_MAX_DEVS (64)#define PVSCSI_MSIX_NUM_VECTORS (1) +#define PVSCSI_MAX_SG_ELEM 2048 +#define PVSCSI_MAX_CMD_DATA_WORDS \ (sizeof(PVSCSICmdDescSetupRings)/sizeof(uint32_t))
@@ -628,17 +630,16 @@ pvscsi_queue_pending_descriptor(PVSCSIState *s, SCSIDevice **d,static void pvscsi_convert_sglist (PVSCSIRequest *r) { -int chunk_size; +uint32_t chunk_size, elmcnt =0 ;uint64_t data_length = r->req.dataLen;PVSCSISGState sg = r->sg; -while (data_length) { -while (!sg.resid) { +while (data_length && elmcnt <PVSCSI_MAX_SG_ELEM ) { +while (!sg.resid && elmcnt++ <PVSCSI_MAX_SG_ELEM ) {pvscsi_get_next_sg_elem (&sg);trace_pvscsi_convert_sglist (r->req.context, r->sg.dataAddr, r->sg.resid); } -assert (data_length >0 ); - chunk_size =MIN ((unsigned ) data_length, sg.resid); + chunk_size =MIN (data_length, sg.resid);if (chunk_size) {qemu_sglist_add (&r->sgl, sg.dataAddr, chunk_size); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 35/58] default-configs: removed obsolete CONFIG_ISA_MMIO
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The use of the CONFIG_ISA_MMIO setting was removed in
commit 61fcb628627ea464dc1954f615ae13edfefd284f
Author: Paolo Bonzini <[email protected]>
Date: Mon Jul 22 15:54:24 2013 +0200
isa_mmio: delete
but this commit only removed it from some of the default config files.
Message-Id: <[email protected]>
--- default-configs/arm-softmmu.mak | 1 - default-configs/ppc-softmmu.mak | 1 - default-configs/ppc64-softmmu.mak | 1 - default-configs/sparc64-softmmu.mak | 1 - 4 files changed, 4 deletions(-)
default-configs/arm-softmmu.mak +0 -1
@@ -3,7 +3,6 @@ include pci.mak include usb.mak CONFIG_VGA=y -CONFIG_ISA_MMIO=y CONFIG_NAND=y CONFIG_ECC=y CONFIG_SERIAL=y
default-configs/ppc-softmmu.mak +0 -1
@@ -3,7 +3,6 @@ include pci.mak include sound.mak include usb.mak -CONFIG_ISA_MMIO=y CONFIG_ESCC=y CONFIG_M48T59=y CONFIG_SERIAL=y
default-configs/ppc64-softmmu.mak +0 -1
@@ -4,7 +4,6 @@ include pci.mak include sound.mak include usb.mak CONFIG_VIRTIO_VGA=y -CONFIG_ISA_MMIO=y CONFIG_ESCC=y CONFIG_M48T59=y CONFIG_SERIAL=y
default-configs/sparc64-softmmu.mak +0 -1
@@ -2,7 +2,6 @@ include pci.mak include usb.mak -CONFIG_ISA_MMIO=y CONFIG_M48T59=y CONFIG_PTIMER=y CONFIG_SERIAL=y
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 34/58] default-configs: remove CONFIG_PAM
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The CONFIG_PAM=y setting was added in
commit c0907c9e6417cb959dfd9ef6873221536ec91351
Author: Paolo Bonzini <[email protected]>
Date: Tue Feb 5 15:06:20 2013 +0100
hw: move PCI bridges to hw/pci-* or hw/ARCH
but nothing in that commit, nor anything pre-existing, ever referenced CONFIG_PAM.
Message-Id: <[email protected]>
--- default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - 2 files changed, 2 deletions(-)
default-configs/i386-softmmu.mak +0 -1
@@ -37,7 +37,6 @@ CONFIG_I8259=y CONFIG_PFLASH_CFI01=y CONFIG_TPM_TIS=$(CONFIG_TPM) CONFIG_MC146818RTC=y -CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y CONFIG_XEN_I386=$(CONFIG_XEN)
default-configs/x86_64-softmmu.mak +0 -1
@@ -37,7 +37,6 @@ CONFIG_I8259=y CONFIG_PFLASH_CFI01=y CONFIG_TPM_TIS=$(CONFIG_TPM) CONFIG_MC146818RTC=y -CONFIG_PAM=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y CONFIG_XEN_I386=$(CONFIG_XEN)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 38/58] sclpconsolelm: remove bogus check for -EAGAIN
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The write_console_data() method in sclpconsole-lm.c checks whether the return value of qemu_chr_fe_write() has the value of -EAGAIN and if so then increments the buffer offset by the value of EAGAIN. Fortunately qemu_chr_fe_write() will never return EAGAIN directly, rather it returns -1 with errno set to EAGAIN, so this broken code path was not reachable. The behaviour on EAGAIN was stil bad though, causing the write_console_data() to busy_wait repeatedly calling qemu_chr_fe_write() with no sleep between iters.
Just remove all this loop logic and replace with a call to qemu_chr_fe_write_all().
Message-Id: <[email protected]>
--- hw/char/sclpconsole-lm.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
hw/char/sclpconsole-lm.c +3 -18
@@ -191,9 +191,6 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,*/ static int write_console_data (SCLPEvent *event,const uint8_t *buf,int len) { -int ret =0 ; -const uint8_t *buf_offset; -SCLPConsoleLM *scon =SCLPLM_CONSOLE (event);if (!scon->chr) {
@@ -201,21 +198,9 @@ static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len)return len; } - buf_offset = buf; -while (len >0 ) { - ret =qemu_chr_fe_write (scon->chr, buf, len); -if (ret ==0 ) { -/* a pty doesn't seem to be connected - no error */ - len =0 ; - }else if (ret == -EAGAIN || (ret >0 && ret < len)) { - len -= ret; - buf_offset += ret; - }else { - len =0 ; - } - } - -return ret; +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +return qemu_chr_fe_write_all (scon->chr, buf, len); }static int process_mdb (SCLPEvent *event,MDBO *mdbo)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 36/58] default-configs: remove CONFIG_PIIX_PCI
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The CONFIG_PIIX_PCI=y setting was added in
commit 70615c38ded2a20ad8282b7dcde95482fc0a7744
Author: Blue Swirl <[email protected]>
Date: Mon Mar 22 20:18:40 2010 +0000
Compile sound devices only once
but nothing in that commit, nor anything pre-existing, ever referenced CONFIG_PIIX_PCI.
Message-Id: <[email protected]>
--- default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - 2 files changed, 2 deletions(-)
default-configs/i386-softmmu.mak +0 -1
@@ -30,7 +30,6 @@ CONFIG_I8257=y CONFIG_IDE_ISA=y CONFIG_IDE_PIIX=y CONFIG_NE2000_ISA=y -CONFIG_PIIX_PCI=y CONFIG_HPET=y CONFIG_APPLESMC=y CONFIG_I8259=y
default-configs/x86_64-softmmu.mak +0 -1
@@ -30,7 +30,6 @@ CONFIG_I8257=y CONFIG_IDE_ISA=y CONFIG_IDE_PIIX=y CONFIG_NE2000_ISA=y -CONFIG_PIIX_PCI=y CONFIG_HPET=y CONFIG_APPLESMC=y CONFIG_I8259=y
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 37/58] ipmi: check return of qemu_chr_fe_write() for errors
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The continue_send() method in ipmi_bmc_extern.c directly assigns the return value of qemu_chr_fe_write() to the variable tracking the I/O buffer offset. This ignores the possibility that the return value could be -1 and so will cause I/O go backwards on EAGAIN. Fortunately 'outpos' is unsigned, so can't go negative - it will become MAX_INT which will cause the loop to stop, and avoid an accidental out of bounds array access.
Message-Id: <[email protected]>
--- hw/ipmi/ipmi_bmc_extern.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/ipmi/ipmi_bmc_extern.c +6 -2
@@ -100,12 +100,16 @@ ipmb_checksum(const unsigned char *data, int size, unsigned char start)static void continue_send (IPMIBmcExtern *ibe) { +int ret;if (ibe->outlen ==0 ) { goto check_reset; } send: - ibe->outpos +=qemu_chr_fe_write (ibe->chr, ibe->outbuf + ibe->outpos, - ibe->outlen - ibe->outpos); + ret =qemu_chr_fe_write (ibe->chr, ibe->outbuf + ibe->outpos, + ibe->outlen - ibe->outpos); +if (ret >0 ) { + ibe->outpos += ret; + }if (ibe->outpos < ibe->outlen) {/* Not fully transmitted, try again in a 10ms */ timer_mod_ns(ibe->extern_timer,
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 40/58] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The mux chardev was not checking the return value of any qemu_chr_fe_write() call so would silently loose data on EAGAIN.
Similarly the qemu_chr_fe_printf method would not check errors and was not in a position to retry even if it could check.
Message-Id: <[email protected]>
--- qemu-char.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
qemu-char.c +12 -6
@@ -441,7 +441,9 @@ void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...)va_list ap;va_start (ap, fmt);vsnprintf (buf,sizeof (buf), fmt, ap); -qemu_chr_fe_write (s, (uint8_t *)buf,strlen (buf)); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s, (uint8_t *)buf,strlen (buf));va_end (ap); }
@@ -557,7 +559,9 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) (secs /60 ) %60 , secs %60 , (int)(ti % 1000)); -qemu_chr_fe_write (d->drv, (uint8_t *)buf1,strlen (buf1)); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (d->drv, (uint8_t *)buf1,strlen (buf1)); d->linestart =0 ; } ret +=qemu_chr_fe_write (d->drv, buf+i,1 );
@@ -595,13 +599,15 @@ static void mux_print_help(CharDriverState *chr)"\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r" , term_escape_char); } -qemu_chr_fe_write (chr, (uint8_t *)cbuf,strlen (cbuf)); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (chr, (uint8_t *)cbuf,strlen (cbuf));for (i =0 ; mux_help[i] !=NULL ; i++) {for (j=0 ; mux_help[i][j] !='\0' ; j++) {if (mux_help[i][j] =='%' ) -qemu_chr_fe_write (chr, (uint8_t *)ebuf,strlen (ebuf)); +qemu_chr_fe_write_all (chr, (uint8_t *)ebuf,strlen (ebuf));else -qemu_chr_fe_write (chr, (uint8_t *)&mux_help[i][j],1 ); +qemu_chr_fe_write_all (chr, (uint8_t *)&mux_help[i][j],1 ); } } }
@@ -626,7 +632,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)case 'x' : {const char *term ="QEMU: Terminated\n\r" ; -qemu_chr_fe_write (chr, (uint8_t *)term,strlen (term)); +qemu_chr_fe_write_all (chr, (uint8_t *)term,strlen (term));exit (0 );break ; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 39/58] hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The qemu_chr_fe_write method will return -1 on EAGAIN if the chardev backend write would block. Almost no callers of the qemu_chr_fe_write() method check the return value, instead blindly assuming data was successfully sent. In most cases this will lead to silent data loss on interactive consoles, but in some cases (eg RNG EGD) it'll just cause corruption of the protocol being spoken.
We unfortunately can't fix the virtio-console code, due to a bug in the Linux guest drivers, which would cause the entire Linux kernel to hang if we delay processing of the incoming data in any way. Fixing this requires first fixing the guest driver to not hold spinlocks while writing to the hvc device backend.
Fixes bug: https://bugs.launchpad.net/qemu/+bug/1586756
Message-Id: <[email protected]>
--- backends/rng-egd.c | 4 +++- gdbstub.c | 4 +++- hw/arm/omap2.c | 8 +++++--- hw/arm/pxa2xx.c | 4 +++- hw/arm/strongarm.c | 4 +++- hw/char/bcm2835_aux.c | 4 +++- hw/char/debugcon.c | 4 +++- hw/char/digic-uart.c | 2 ++ hw/char/escc.c | 4 +++- hw/char/etraxfs_ser.c | 4 +++- hw/char/exynos4210_uart.c | 4 +++- hw/char/grlib_apbuart.c | 4 +++- hw/char/imx_serial.c | 4 +++- hw/char/ipoctal232.c | 4 +++- hw/char/lm32_juart.c | 2 ++ hw/char/lm32_uart.c | 2 ++ hw/char/mcf_uart.c | 4 +++- hw/char/parallel.c | 4 +++- hw/char/pl011.c | 4 +++- hw/char/sclpconsole-lm.c | 4 +++- hw/char/sclpconsole.c | 2 ++ hw/char/sh_serial.c | 4 +++- hw/char/spapr_vty.c | 5 +++-- hw/char/stm32f2xx_usart.c | 2 ++ hw/char/virtio-console.c | 21 +++++++++++++++++++++ hw/char/xilinx_uartlite.c | 4 +++- hw/usb/ccid-card-passthru.c | 7 +++++-- hw/usb/dev-serial.c | 4 +++- slirp/slirp.c | 4 +++- 29 files changed, 104 insertions(+), 27 deletions(-)
backends/rng-egd.c +3 -1
@@ -41,7 +41,9 @@ static void rng_egd_request_entropy(RngBackend *b, RngRequest *req) header[0 ] =0x02 ; header[1 ] = len; -qemu_chr_fe_write (s->chr, header,sizeof (header)); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, header,sizeof (header)); size -= len; }
gdbstub.c +3 -1
@@ -402,7 +402,9 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len) } }#else -qemu_chr_fe_write (s->chr, buf, len); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, buf, len);#endif }
hw/arm/omap2.c +5 -3
@@ -769,14 +769,16 @@ static void omap_sti_fifo_write(void *opaque, hwaddr addr,if (ch ==STI_TRACE_CONTROL_CHANNEL ) {/* Flush channel <i>value</i>. */ -qemu_chr_fe_write (s->chr, (const uint8_t *)"\r" ,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, (const uint8_t *)"\r" ,1 ); }else if (ch ==STI_TRACE_CONSOLE_CHANNEL ||1 ) {if (value ==0xc0 || value ==0xc3 ) {/* Open channel <i>ch</i>. */ }else if (value ==0x00 ) -qemu_chr_fe_write (s->chr, (const uint8_t *)"\n" ,1 ); +qemu_chr_fe_write_all (s->chr, (const uint8_t *)"\n" ,1 );else -qemu_chr_fe_write (s->chr, &byte,1 ); +qemu_chr_fe_write_all (s->chr, &byte,1 ); } }
hw/arm/pxa2xx.c +3 -1
@@ -1903,7 +1903,9 @@ static void pxa2xx_fir_write(void *opaque, hwaddr addr,else ch = ~value;if (s->chr && s->enable && (s->control[0 ] & (1 <<3 )))/* TXE */ -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 );break ;case ICSR0 : s->status[0 ] &= ~(value &0x66 );
hw/arm/strongarm.c +3 -1
@@ -1108,7 +1108,9 @@ static void strongarm_uart_tx(void *opaque)if (s->utcr3 &UTCR3_LBM )/* loopback */ {strongarm_uart_receive (s, &s->tx_fifo[s->tx_start],1 ); }else if (s->chr) { -qemu_chr_fe_write (s->chr, &s->tx_fifo[s->tx_start],1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &s->tx_fifo[s->tx_start],1 ); } s->tx_start = (s->tx_start +1 ) %8 ;
hw/char/bcm2835_aux.c +3 -1
@@ -169,7 +169,9 @@ static void bcm2835_aux_write(void *opaque, hwaddr offset, uint64_t value,/* "DLAB bit set means access baudrate register" is NYI */ ch = value;if (s->chr) { -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); }break ;
hw/char/debugcon.c +3 -1
@@ -60,7 +60,9 @@ static void debugcon_ioport_write(void *opaque, hwaddr addr, uint64_t val,printf (" [debugcon: write addr=0x%04" HWADDR_PRIx" val=0x%02" PRIx64"]\n" , addr, val);#endif -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); }
hw/char/digic-uart.c +2 -0
@@ -77,6 +77,8 @@ static void digic_uart_write(void *opaque, hwaddr addr, uint64_t value,switch (addr) {case R_TX :if (s->chr) { +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all (s->chr, &ch,1 ); }break ;
hw/char/escc.c +3 -1
@@ -557,7 +557,9 @@ static void escc_mem_write(void *opaque, hwaddr addr, s->tx = val;if (s->wregs[W_TXCTRL2 ] &TXCTRL2_TXEN ) {// tx enabled if (s->chr) -qemu_chr_fe_write (s->chr, &s->tx,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &s->tx,1 );else if (s->type == kbd && !s->disabled) {handle_kbd_command (s, val); }
hw/char/etraxfs_ser.c +3 -1
@@ -126,7 +126,9 @@ ser_write(void *opaque, hwaddr addr,switch (addr) {case RW_DOUT : -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); s->regs[R_INTR ] |=3 ; s->pending_tx =1 ; s->regs[addr] = value;
hw/char/exynos4210_uart.c +3 -1
@@ -387,7 +387,9 @@ static void exynos4210_uart_write(void *opaque, hwaddr offset, s->reg[I_ (UTRSTAT )] &= ~(UTRSTAT_TRANSMITTER_EMPTY | UTRSTAT_Tx_BUFFER_EMPTY); ch = (uint8_t )val; -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 );#if DEBUG_Tx_DATAfprintf (stderr,"%c" , ch);#endif
hw/char/grlib_apbuart.c +3 -1
@@ -203,7 +203,9 @@ static void grlib_apbuart_write(void *opaque, hwaddr addr,/* Transmit when character device available and transmitter enabled */ if ((uart->chr) && (uart->control &UART_TRANSMIT_ENABLE )) { c = value &0xFF ; -qemu_chr_fe_write (uart->chr, &c,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (uart->chr, &c,1 );/* Generate interrupt */ if (uart->control &UART_TRANSMIT_INTERRUPT ) {qemu_irq_pulse (uart->irq);
hw/char/imx_serial.c +3 -1
@@ -182,7 +182,9 @@ static void imx_serial_write(void *opaque, hwaddr offset, ch = value;if (s->ucr2 &UCR2_TXEN ) {if (s->chr) { -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); } s->usr1 &= ~USR1_TRDY ;imx_update (s);
hw/char/ipoctal232.c +3 -1
@@ -360,7 +360,9 @@ static void io_write(IPackDevice *ip, uint8_t addr, uint16_t val)DPRINTF ("Write THR%c (0x%x)\n" , channel +'a' , reg);if (ch->dev) {uint8_t thr = reg; -qemu_chr_fe_write (ch->dev, &thr,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (ch->dev, &thr,1 ); } }else {DPRINTF ("Write THR%c (0x%x), Tx disabled\n" , channel +'a' , reg);
hw/char/lm32_juart.c +2 -0
@@ -76,6 +76,8 @@ void lm32_juart_set_jtx(DeviceState *d, uint32_t jtx) s->jtx = jtx;if (s->chr) { +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all (s->chr, &ch,1 ); } }
hw/char/lm32_uart.c +2 -0
@@ -178,6 +178,8 @@ static void uart_write(void *opaque, hwaddr addr,switch (addr) {case R_RXTX :if (s->chr) { +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all (s->chr, &ch,1 ); }break ;
hw/char/mcf_uart.c +3 -1
@@ -114,7 +114,9 @@ static void mcf_uart_do_tx(mcf_uart_state *s) {if (s->tx_enabled && (s->sr & MCF_UART_TxEMP) ==0 ) {if (s->chr) -qemu_chr_fe_write (s->chr, (unsigned char *)&s->tb,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, (unsigned char *)&s->tb,1 ); s->sr |= MCF_UART_TxEMP; }if (s->tx_enabled) {
hw/char/parallel.c +3 -1
@@ -129,7 +129,9 @@ parallel_ioport_write_sw(void *opaque, uint32_t addr, uint32_t val)if (val &PARA_CTR_STROBE ) { s->status &= ~PARA_STS_BUSY ;if ((s->control &PARA_CTR_STROBE ) ==0 ) -qemu_chr_fe_write (s->chr, &s->dataw,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &s->dataw,1 ); }else {if (s->control &PARA_CTR_INTEN ) { s->irq_pending =1 ;
hw/char/pl011.c +3 -1
@@ -146,7 +146,9 @@ static void pl011_write(void *opaque, hwaddr offset,/* ??? Check if transmitter is enabled. */ ch = value;if (s->chr) -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); s->int_level |=PL011_INT_TX ;pl011_update (s);break ;
hw/char/sclpconsole-lm.c +3 -1
@@ -89,7 +89,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) scon->buf[scon->length] = *buf; scon->length +=1 ;if (scon->echo) { -qemu_chr_fe_write (scon->chr, buf, size); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (scon->chr, buf, size); } }
hw/char/sclpconsole.c +2 -0
@@ -168,6 +168,8 @@ static ssize_t write_console_data(SCLPEvent *event, const uint8_t *buf,return len; } +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ return qemu_chr_fe_write_all (scon->chr, buf, len); }
hw/char/sh_serial.c +3 -1
@@ -111,7 +111,9 @@ static void sh_serial_write(void *opaque, hwaddr offs,case 0x0c :/* FTDR / TDR */ if (s->chr) { ch = val; -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); } s->dr = val; s->flags &= ~SH_SERIAL_FLAG_TDE ;
hw/char/spapr_vty.c +3 -2
@@ -60,8 +60,9 @@ void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len) {VIOsPAPRVTYDevice *dev =VIO_SPAPR_VTY_DEVICE (sdev); -/* FIXME: should check the qemu_chr_fe_write() return value */ -qemu_chr_fe_write (dev->chardev, buf, len); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (dev->chardev, buf, len); }static void spapr_vty_realize (VIOsPAPRDevice *sdev,Error **errp)
hw/char/stm32f2xx_usart.c +2 -0
@@ -153,6 +153,8 @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr,if (value <0xF000 ) { ch = value;if (s->chr) { +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all (s->chr, &ch,1 ); } s->usart_sr |=USART_SR_TC ;
hw/char/virtio-console.c +21 -0
@@ -68,6 +68,27 @@ static ssize_t flush_buf(VirtIOSerialPort *port,*/ if (ret <0 ) ret =0 ; + +/* XXX we should be queuing data to send later for the +* console devices too rather than silently dropping +* console data on EAGAIN. The Linux virtio-console +* hvc driver though does sends with spinlocks held, +* so if we enable throttling that'll stall the entire +* guest kernel, not merely the process writing to the +* console. +* +* While we could queue data for later write without +* enabling throttling, this would result in the guest +* being able to trigger arbitrary memory usage in QEMU +* buffering data for later writes. +* +* So fixing this problem likely requires fixing the +* Linux virtio-console hvc driver to not hold spinlocks +* while writing, and instead merely block the process +* that's writing. QEMU would then need some way to detect +* if the guest had the fixed driver too, before we can +* use throttling on host side. +*/ if (!k->is_console) {virtio_serial_throttle_port (port, true);if (!vcon->watch) {
hw/char/xilinx_uartlite.c +3 -1
@@ -144,7 +144,9 @@ uart_write(void *opaque, hwaddr addr,case R_TX :if (s->chr) -qemu_chr_fe_write (s->chr, &ch,1 ); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->chr, &ch,1 ); s->regs[addr] = value;
hw/usb/ccid-card-passthru.c +5 -2
@@ -75,8 +75,11 @@ static void ccid_card_vscard_send_msg(PassthruState *s, scr_msg_header.type =htonl (type); scr_msg_header.reader_id =htonl (reader_id); scr_msg_header.length =htonl (length); -qemu_chr_fe_write (s->cs, (uint8_t *)&scr_msg_header,sizeof (VSCMsgHeader)); -qemu_chr_fe_write (s->cs, payload, length); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->cs, (uint8_t *)&scr_msg_header, +sizeof (VSCMsgHeader)); +qemu_chr_fe_write_all (s->cs, payload, length); } static void ccid_card_vscard_send_apdu(PassthruState *s,
hw/usb/dev-serial.c +3 -1
@@ -366,7 +366,9 @@ static void usb_serial_handle_data(USBDevice *dev, USBPacket *p) goto fail;for (i =0 ; i < p->iov.niov; i++) { iov = p->iov.iov + i; -qemu_chr_fe_write (s->cs, iov->iov_base, iov->iov_len); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (s->cs, iov->iov_base, iov->iov_len); } p->actual_length = p->iov.size;break ;
slirp/slirp.c +3 -1
@@ -1072,7 +1072,9 @@ int slirp_add_exec(Slirp *slirp, int do_pty, const void *args,ssize_t slirp_send (struct socket *so,const void *buf,size_t len,int flags) {if (so->s ==-1 && so->extra) { -qemu_chr_fe_write (so->extra, buf, len); +/* XXX this blocks entire thread. Rewrite to use +* qemu_chr_fe_write and background I/O callbacks */ +qemu_chr_fe_write_all (so->extra, buf, len);return len; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 42/58] i8257: Make device "i8257" unavailable with -device
In reply to Paolo BonziniFrom: Markus Armbruster <[email protected]>
The ISA DMA controller needs to be wired up to the ISA bus by isa_bus_dma() to actually work.
Message-Id: <[email protected]>
--- hw/dma/i8257.c | 2 ++ 1 file changed, 2 insertions(+)
hw/dma/i8257.c +2 -0
@@ -600,6 +600,8 @@ static void i8257_class_init(ObjectClass *klass, void *data) idc->release_DREQ = i8257_dma_release_DREQ; idc->schedule = i8257_dma_schedule; idc->register_channel = i8257_dma_register_channel; +/* Reason: needs to be wired up by isa_bus_dma() to work */ + dc->cannot_instantiate_with_device_add_yet = true; }static const TypeInfo i8257_info = {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 41/58] Revert "megasas: remove useless check for cmd->frame"
In reply to Paolo BonziniThis reverts commit 8cc46787b5b58f01a11c919c7ff939ed009e27fc. It turns out that cmd->frame can be NULL and thus the commit can cause a SIGSEGV
--- hw/scsi/megasas.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/scsi/megasas.c +5 -1
@@ -1981,7 +1981,11 @@ static void megasas_handle_frame(MegasasState *s, uint64_t frame_addr,break ; }if (frame_status !=MFI_STAT_INVALID_STATUS ) { - cmd->frame->header.cmd_status = frame_status; +if (cmd->frame) { + cmd->frame->header.cmd_status = frame_status; + }else { +megasas_frame_set_cmd_status (s, frame_addr, frame_status); + }megasas_unmap_frame (s, cmd);megasas_complete_frame (s, cmd->context); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 43/58] kvm-all: drop kvm_setup_guest_memory
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
kvm_setup_guest_memory only does "madvise to QEMU_MADV_DONTFORK" and is only called by ram_block_add, which actually is duplicate code.
Bonus: add simple comment for kvm_has_sync_mmu to make life easier.
Message-Id: <[email protected]>
--- exec.c | 4 +--- include/sysemu/kvm.h | 1 - kvm-all.c | 15 +-------------- kvm-stub.c | 4 ---- 4 files changed, 2 insertions(+), 22 deletions(-)
exec.c +1 -3
@@ -1621,10 +1621,8 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)if (new_block->host) {qemu_ram_setup_dump (new_block->host, new_block->max_length);qemu_madvise (new_block->host, new_block->max_length,QEMU_MADV_HUGEPAGE ); +/* MADV_DONTFORK is also needed by KVM in absence of synchronous MMU */ qemu_madvise (new_block->host, new_block->max_length,QEMU_MADV_DONTFORK ); -if (kvm_enabled ()) { -kvm_setup_guest_memory (new_block->host, new_block->max_length); - } } }
include/sysemu/kvm.h +0 -1
@@ -221,7 +221,6 @@ int kvm_destroy_vcpu(CPUState *cpu);#ifdef NEED_CPU_H #include "cpu.h" -void kvm_setup_guest_memory (void *start,size_t size);void kvm_flush_coalesced_mmio_buffer (void ); int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
kvm-all.c +1 -14
@@ -2148,6 +2148,7 @@ void kvm_device_access(int fd, int group, uint64_t attr, } } +/* Return 1 on success, 0 on failure */ int kvm_has_sync_mmu (void ) {return kvm_check_extension (kvm_state,KVM_CAP_SYNC_MMU );
@@ -2190,20 +2191,6 @@ int kvm_has_intx_set_mask(void)return kvm_state->intx_set_mask; } -void kvm_setup_guest_memory (void *start,size_t size) -{ -if (!kvm_has_sync_mmu ()) { -int ret =qemu_madvise (start, size,QEMU_MADV_DONTFORK ); - -if (ret) { -perror ("qemu_madvise" ); -fprintf (stderr, -"Need MADV_DONTFORK in absence of synchronous KVM MMU\n" ); -exit (1 ); - } - } -} -#ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint *kvm_find_sw_breakpoint (CPUState *cpu,target_ulong pc)
kvm-stub.c +0 -4
@@ -73,10 +73,6 @@ int kvm_has_many_ioeventfds(void)return 0 ; } -void kvm_setup_guest_memory (void *start,size_t size) -{ -} -int kvm_update_guest_debug (CPUState *cpu,unsigned long reinject_trap) {return -ENOSYS ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 45/58] atomics: Use __atomic_*_n() variant primitives
In reply to Paolo BonziniFrom: Pranith Kumar <[email protected]>
Use the __atomic_*_n() primitives which take the value as argument. It is not necessary to store the value locally before calling the primitive, hence saving us a stack store and load.
Message-Id: <[email protected]>
--- include/qemu/atomic.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
include/qemu/atomic.h +8 -16
@@ -96,15 +96,12 @@#define atomic_read (ptr) \ ({ \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof_strip_qual(*ptr) _val; \ - __atomic_load(ptr, &_val, __ATOMIC_RELAXED); \ - _val; \ + __atomic_load_n(ptr, __ATOMIC_RELAXED); \ })#define atomic_set (ptr, i) do { \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof(*ptr) _val = (i); \ - __atomic_store(ptr, &_val, __ATOMIC_RELAXED); \ + __atomic_store_n(ptr, i, __ATOMIC_RELAXED); \ } while(0)/* See above: most compilers currently treat consume and acquire the
@@ -129,8 +126,7 @@#define atomic_rcu_set (ptr, i) do { \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof(*ptr) _val = (i); \ - __atomic_store(ptr, &_val, __ATOMIC_RELEASE); \ + __atomic_store_n(ptr, i, __ATOMIC_RELEASE); \ } while(0)/* atomic_mb_read/set semantics map Java volatile variables. They are
@@ -153,9 +149,8 @@#define atomic_mb_set (ptr, i) do { \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof(*ptr) _val = (i); \ smp_wmb(); \ - __atomic_store(ptr, &_val, __ATOMIC_RELAXED); \ + __atomic_store_n(ptr, i, __ATOMIC_RELAXED); \ smp_mb(); \ } while(0)#else
@@ -169,8 +164,7 @@#define atomic_mb_set (ptr, i) do { \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof(*ptr) _val = (i); \ - __atomic_store(ptr, &_val, __ATOMIC_SEQ_CST); \ + __atomic_store_n(ptr, i, __ATOMIC_SEQ_CST); \ } while(0)#endif
@@ -179,17 +173,15 @@#define atomic_xchg (ptr, i) ({ \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof_strip_qual(*ptr) _new = (i), _old; \ - __atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \ - _old; \ + __atomic_exchange_n(ptr, i, __ATOMIC_SEQ_CST); \ })/* Returns the eventual value, failed or not */ #define atomic_cmpxchg (ptr, old, new) \ ({ \ QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ - typeof_strip_qual(*ptr) _old = (old), _new = (new); \ - __atomic_compare_exchange(ptr, &_old, &_new, false, \ + typeof_strip_qual(*ptr) _old = (old); \ + __atomic_compare_exchange_n(ptr, &_old, new, false, \ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ _old; \ })
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 44/58] atomics: Remove redundant barrier()'s
In reply to Paolo BonziniFrom: Pranith Kumar <[email protected]>
Remove the redundant barrier() after the fence as agreed in previous discussion here:
https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg00489.html
Message-Id: <[email protected]>
--- include/qemu/atomic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/qemu/atomic.h +4 -4
@@ -72,16 +72,16 @@* Add one here, and similarly in smp_rmb() and smp_read_barrier_depends(). */ -#define smp_mb () ({ barrier(); __atomic_thread_fence(__ATOMIC_SEQ_CST); barrier(); }) -#define smp_wmb () ({ barrier(); __atomic_thread_fence(__ATOMIC_RELEASE); barrier(); }) -#define smp_rmb () ({ barrier(); __atomic_thread_fence(__ATOMIC_ACQUIRE); barrier(); }) +#define smp_mb () ({ barrier(); __atomic_thread_fence(__ATOMIC_SEQ_CST); }) +#define smp_wmb () ({ barrier(); __atomic_thread_fence(__ATOMIC_RELEASE); }) +#define smp_rmb () ({ barrier(); __atomic_thread_fence(__ATOMIC_ACQUIRE); })/* Most compilers currently treat consume and acquire the same, but really * no processors except Alpha need a barrier here. Leave it in if * using Thread Sanitizer to avoid warnings, otherwise optimize it away. */ #if defined(__SANITIZE_THREAD__) -#define smp_read_barrier_depends () ({ barrier(); __atomic_thread_fence(__ATOMIC_CONSUME); barrier(); }) +#define smp_read_barrier_depends () ({ barrier(); __atomic_thread_fence(__ATOMIC_CONSUME); })#elsif defined(__alpha__)#define smp_read_barrier_depends () asm volatile("mb":::"memory")#else
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 46/58] checkpatch: Fix whitespace checks for documentation code blocks
In reply to Paolo BonziniFrom: Lluís Vilanova <[email protected]>
Prevent blank lines in documentation code blocks to be signalled as incorrect trailing whitespace.
Code blocks in documentation are 4-column aligned, and blank lines in them should have exactly 4 columns of trailing whitespace to prevent QEMU's wiki to render them as separate code blocks.
Message-Id: <[email protected]>
--- scripts/checkpatch.pl | 10 ++++++++++ 1 file changed, 10 insertions(+)
scripts/checkpatch.pl +10 -0
@@ -1320,6 +1320,16 @@ sub process { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; ERROR("DOS line endings\n" . $herevet); + } elsif ($realfile =~ /^docs\/.+\.txt/ || + $realfile =~ /^docs\/.+\.md/) { + if ($rawline =~ /^\+\s+$/ && $rawline !~ /^\+ {4}$/) { + # TODO: properly check we're in a code block + # (surrounding text is 4-column aligned) + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + ERROR("code blocks in documentation should have " . + "empty lines with exactly 4 columns of " . + "whitespace\n" . $herevet); + } } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; ERROR("trailing whitespace\n" . $herevet);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 47/58] optionrom: do not rely on compiler's bswap optimization
In reply to Paolo BonziniRecent compilers can detect and inline manually-written bswap code, but GCC 4.2.1 (the last GPLv2 version) cannot and generates really awful code. Depending on how the compiler is configured, it might also not want to generate bswap because it was not in i386. Using asm is fine because TCG knows about bswap and all processors with virtualization extensions also do.
--- pc-bios/linuxboot_dma.bin | Bin 1536 -> 1536 bytes pc-bios/optionrom/linuxboot_dma.c | 18 ++++-------------- 2 files changed, 4 insertions(+), 14 deletions(-)
pc-bios/linuxboot_dma.bin binary +0 -0
pc-bios/optionrom/linuxboot_dma.c +4 -14
@@ -122,24 +122,14 @@ static inline void writel_es(uint16_t offset, uint32_t val)static inline uint32_t bswap32 (uint32_t x) { -return - ((x &0x000000ffU ) <<24 ) | - ((x &0x0000ff00U ) <<8 ) | - ((x &0x00ff0000U ) >>8 ) | - ((x &0xff000000U ) >>24 ); + asm("bswapl %0" :"=r" (x) :"0" (x)); +return x; }static inline uint64_t bswap64 (uint64_t x) { -return - ((x &0x00000000000000ffULL ) <<56 ) | - ((x &0x000000000000ff00ULL ) <<40 ) | - ((x &0x0000000000ff0000ULL ) <<24 ) | - ((x &0x00000000ff000000ULL ) <<8 ) | - ((x &0x000000ff00000000ULL ) >>8 ) | - ((x &0x0000ff0000000000ULL ) >>24 ) | - ((x &0x00ff000000000000ULL ) >>40 ) | - ((x &0xff00000000000000ULL ) >>56 ); + asm("bswapl %%eax; bswapl %%edx; xchg %%eax, %%edx" :"=A" (x) :"0" (x)); +return x; }static inline uint64_t cpu_to_be64 (uint64_t x)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 54/58] cutils: Remove aarch64 buffer zero checking
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
The revised integer version is 4 times faster than the neon version on an AppliedMicro Mustang. Even with hand scheduling and additional unrolling I cannot make any neon version run as fast as the integer.
--- util/bufferiszero.c | 15 --------------- 1 file changed, 15 deletions(-)
util/bufferiszero.c +0 -15
@@ -200,21 +200,6 @@ static bool select_accel_fn(const void *buf, size_t len) return buffer_zero_int(buf, len); } -#elif defined(__aarch64__) -#include "arm_neon.h" - -#define DO_NONZERO (X ) (vgetq_lane_u64((X), 0) | vgetq_lane_u64((X), 1)) -ACCEL_BUFFER_ZERO(buffer_zero_neon, 128, uint64x2_t, DO_NONZERO) - -static bool select_accel_fn (const void *buf,size_t len) -{ -uintptr_t ibuf = (uintptr_t )buf; -if (len %128 ==0 && ibuf %sizeof (uint64x2_t) ==0 ) { -return buffer_zero_neon (buf, len); - } -return buffer_zero_int (buf, len); -} -#else #define select_accel_fn buffer_zero_int#endif
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 49/58] ppc: do not redefine CPUPPCState
In reply to Paolo BonziniJust include the file that is supposed to bring it in.
--- include/hw/ppc/fdt.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/hw/ppc/fdt.h +1 -2
@@ -11,8 +11,7 @@#define PPC_FDT_H #include "qemu/error-report.h" - -typedef struct CPUPPCState CPUPPCState ; +#include "target-ppc/cpu-qom.h" #define _FDT (exp) \ do { \
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 50/58] cutils: Move buffer_is_zero and subroutines to a new file
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
--- util/Makefile.objs | 1 + util/bufferiszero.c | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++++ util/cutils.c | 244 ---------------------------------------------- 3 files changed, 273 insertions(+), 244 deletions(-) create mode 100644 util/bufferiszero.c
util/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ util-obj-y = osdep.o cutils.o unicode.o qemu-timer-common.o +util-obj-y += bufferiszero.o util-obj-$(CONFIG_POSIX) += compatfd.o util-obj-$(CONFIG_POSIX) += event_notifier-posix.o util-obj-$(CONFIG_POSIX) += mmap-alloc.o
util/bufferiszero.c new file +272 -0
272 lines not on this page · raw message
util/cutils.c +0 -244
250 lines not on this page · raw message
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 51/58] cutils: Remove SPLAT macro
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
This is unused and complicates the vector interface.
Message-Id: <[email protected]>
--- util/bufferiszero.c | 4 ---- 1 file changed, 4 deletions(-)
util/bufferiszero.c +0 -4
@@ -37,7 +37,6 @@#undef pixel#undef bool#define VECTYPE __vector unsigned char -#define SPLAT (p) vec_splat(vec_ld(0, p), 0)#define ALL_EQ (v1, v2) vec_all_eq(v1, v2)#define VEC_OR (v1, v2) ((v1) | (v2))/* altivec.h may redefine the bool macro as vector type.
@@ -46,7 +45,6 @@#elif defined __SSE2__#include <emmintrin.h> #define VECTYPE __m128i -#define SPLAT (p) _mm_set1_epi8(*(p))#define ALL_EQ (v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF)#define VEC_OR (v1, v2) (_mm_or_si128(v1, v2))#elif defined(__aarch64__)
@@ -58,7 +56,6 @@#define VEC_OR (v1, v2) ((v1) | (v2))#else #define VECTYPE unsigned long -#define SPLAT (p) (*(p) * (~0UL / 255))#define ALL_EQ (v1, v2) ((v1) == (v2))#define VEC_OR (v1, v2) ((v1) | (v2))#endif
@@ -135,7 +132,6 @@ static size_t buffer_find_nonzero_offset_inner(const void *buf, size_t len)#include <immintrin.h> #define AVX2_VECTYPE __m256i -#define AVX2_SPLAT (p) _mm256_set1_epi8(*(p))#define AVX2_ALL_EQ (v1, v2) \ (_mm256_movemask_epi8(_mm256_cmpeq_epi8(v1, v2)) == 0xFFFFFFFF)#define AVX2_VEC_OR (v1, v2) (_mm256_or_si256(v1, v2))
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 52/58] cutils: Export only buffer_is_zero
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
Since the two users don't make use of the returned offset, beyond ensuring that the entire buffer is zero, consider the can_use_buffer_find_nonzero_offset and buffer_find_nonzero_offset functions internal.
Message-Id: <[email protected]>
--- include/qemu/cutils.h | 2 -- migration/ram.c | 2 +- migration/rdma.c | 5 +---- util/bufferiszero.c | 8 ++++---- 4 files changed, 6 insertions(+), 11 deletions(-)
include/qemu/cutils.h +0 -2
@@ -168,8 +168,6 @@ int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end,/* used to print char* safely */ #define STR_OR_NULL (str) ((str) ? (str) : "null") -bool can_use_buffer_find_nonzero_offset (const void *buf,size_t len); -size_t buffer_find_nonzero_offset (const void *buf,size_t len);bool buffer_is_zero (const void *buf,size_t len);/*
migration/ram.c +1 -1
@@ -73,7 +73,7 @@ static const uint8_t ZERO_TARGET_PAGE[TARGET_PAGE_SIZE];static inline bool is_zero_range (uint8_t *p,uint64_t size) { -return buffer_find_nonzero_offset (p, size) == size; +return buffer_is_zero (p, size); }/* struct contains XBZRLE cache and a static page
migration/rdma.c +1 -4
@@ -1934,10 +1934,7 @@ retry:* memset() + madvise() the entire chunk without RDMA. */ -if (can_use_buffer_find_nonzero_offset ((void *)(uintptr_t )sge.addr, - length) - &&buffer_find_nonzero_offset ((void *)(uintptr_t )sge.addr, - length) == length) { +if (buffer_is_zero ((void *)(uintptr_t )sge.addr, length)) {RDMACompress comp = { .offset = current_addr, .value =0 ,
util/bufferiszero.c +4 -4
@@ -192,9 +192,9 @@ static bool avx2_support(void)return b & bit_AVX2; } -bool can_use_buffer_find_nonzero_offset (const void *buf,size_t len) \ +static bool can_use_buffer_find_nonzero_offset (const void *buf,size_t len) \ __attribute__ ((ifunc ("can_use_buffer_find_nonzero_offset_ifunc" ))); -size_t buffer_find_nonzero_offset (const void *buf,size_t len) \ +static size_t buffer_find_nonzero_offset (const void *buf,size_t len) \ __attribute__ ((ifunc ("buffer_find_nonzero_offset_ifunc" )));static void *buffer_find_nonzero_offset_ifunc (void )
@@ -215,12 +215,12 @@ static void *can_use_buffer_find_nonzero_offset_ifunc(void) }#pragma GCC pop_options#else -bool can_use_buffer_find_nonzero_offset (const void *buf,size_t len) +static bool can_use_buffer_find_nonzero_offset (const void *buf,size_t len) {return can_use_buffer_find_nonzero_offset_inner (buf, len); } -size_t buffer_find_nonzero_offset (const void *buf,size_t len) +static size_t buffer_find_nonzero_offset (const void *buf,size_t len) {return buffer_find_nonzero_offset_inner (buf, len); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 53/58] cutils: Rearrange buffer_is_zero acceleration
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
Allow selection of several acceleration functions based on the size and alignment of the buffer. Do not require ifunc support for AVX2 acceleration.
Message-Id: <[email protected]>
--- configure | 21 +--- util/bufferiszero.c | 348 ++++++++++++++++++++++++---------------------------- 2 files changed, 163 insertions(+), 206 deletions(-)
configure +6 -15
@@ -1794,28 +1794,19 @@ fi ########################################## # avx2 optimization requirement check - -if test "$static" = "no" ; then - cat > $TMPC << EOF +cat > $TMPC << EOF #pragma GCC push_options #pragma GCC target("avx2") #include <cpuid.h> #include <immintrin.h> - static int bar(void *a) { - return _mm256_movemask_epi8(_mm256_cmpeq_epi8(*(__m256i *)a, (__m256i){0})); + __m256i x = *(__m256i *)a; + return _mm256_testz_si256(x, x); } -static void *bar_ifunc(void) {return (void*) bar;} -int foo(void *a) __attribute__((ifunc("bar_ifunc"))); -int main(int argc, char *argv[]) { return foo(argv[0]);} +int main(int argc, char *argv[]) { return bar(argv[0]); } EOF - if compile_object "" ; then - if has readelf; then - if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then - avx2_opt="yes" - fi - fi - fi +if compile_object "" ; then + avx2_opt="yes" fi #########################################
util/bufferiszero.c +157 -191
402 lines not on this page · raw message
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 55/58] cutils: Remove ppc buffer zero checking
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
For ppc64le, gcc6 does extremely poorly with the Altivec code. Moreover, on POWER7 and POWER8, a hand-optimized Altivec version turns out to be no faster than the revised integer version, and therefore not worth the effort.
--- util/bufferiszero.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-)
util/bufferiszero.c +1 -25
@@ -94,31 +94,7 @@ buffer_zero_int(const void *buf, size_t len) } } -#if defined(__ALTIVEC__) -#include <altivec.h> -/* The altivec.h header says we're allowed to undef these for -* C++ compatibility. Here we don't care about C++, but we -* undef them anyway to avoid namespace pollution. -* altivec.h may redefine the bool macro as vector type. -* Reset it to POSIX semantics. -*/ -#undef vector -#undef pixel -#undef bool -#define bool _Bool -#define DO_NONZERO (X ) vec_any_ne(X, (__vector unsigned char){ 0 }) -ACCEL_BUFFER_ZERO(buffer_zero_ppc, 128, __vector unsigned char, DO_NONZERO) - -static bool select_accel_fn (const void *buf,size_t len) -{ -uintptr_t ibuf = (uintptr_t )buf; - if (len % 128 == 0 && ibuf % sizeof(__vector unsigned char) == 0) { -return buffer_zero_ppc (buf, len); - } -return buffer_zero_int (buf, len); -} - -#elif defined(CONFIG_AVX2_OPT ) || (defined(CONFIG_CPUID_H ) && defined(__SSE2__)) +#if defined(CONFIG_AVX2_OPT ) || (defined(CONFIG_CPUID_H ) && defined(__SSE2__))#include <cpuid.h> /* Do not use push_options pragmas unnecessarily, because clang
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 56/58] cutils: Add test for buffer_is_zero
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
--- include/qemu/cutils.h | 1 + tests/Makefile.include | 3 ++ tests/test-bufferiszero.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++ util/bufferiszero.c | 20 ++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 tests/test-bufferiszero.c
include/qemu/cutils.h +1 -0
@@ -169,6 +169,7 @@ int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end,#define STR_OR_NULL (str) ((str) ? (str) : "null")bool buffer_is_zero (const void *buf,size_t len); +bool test_buffer_is_zero_next_accel (void );/* * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128)
tests/Makefile.include +3 -0
@@ -112,6 +112,8 @@ check-unit-y += tests/test-crypto-xts$(EXESUF) check-unit-y += tests/test-crypto-block$(EXESUF) gcov-files-test-logging-y = tests/test-logging.c check-unit-y += tests/test-logging$(EXESUF) +check-unit-y += tests/test-bufferiszero$(EXESUF) +gcov-files-check-bufferiszero-y = util/bufferiszero.c check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
@@ -484,6 +486,7 @@ tests/test-qdist$(EXESUF): tests/test-qdist.o $(test-util-obj-y) tests/test-qht$(EXESUF): tests/test-qht.o $(test-util-obj-y) tests/test-qht-par$(EXESUF): tests/test-qht-par.o tests/qht-bench$(EXESUF) $(test-util-obj-y) tests/qht-bench$(EXESUF): tests/qht-bench.o $(test-util-obj-y) +tests/test-bufferiszero$(EXESUF): tests/test-bufferiszero.o $(test-util-obj-y) tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
tests/test-bufferiszero.c new file +78 -0
78 lines not on this page · raw message
util/bufferiszero.c +20 -0
@@ -162,6 +162,19 @@ static void __attribute__((constructor)) init_cpuid_cache(void) cpuid_cache = cache; } +#define HAVE_NEXT_ACCEL +bool test_buffer_is_zero_next_accel (void ) +{ +/* If no bits set, we just tested buffer_zero_int, and there +are no more acceleration options to test. */ +if (cpuid_cache ==0 ) { +return false; + } +/* Disable the accelerator we used before and select a new one. */ + cpuid_cache &= cpuid_cache -1 ; +return true; +} +static bool select_accel_fn (const void *buf,size_t len) {uintptr_t ibuf = (uintptr_t )buf;
@@ -180,6 +193,13 @@ static bool select_accel_fn(const void *buf, size_t len)#define select_accel_fn buffer_zero_int#endif +#ifndef HAVE_NEXT_ACCEL +bool test_buffer_is_zero_next_accel (void ) +{ +return false; +} +#endif +/* * Checks if a buffer is all zeroes */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 57/58] cutils: Add SSE4 version
In reply to Paolo Bonzini--- util/bufferiszero.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
util/bufferiszero.c +10 -0
@@ -114,6 +114,13 @@ ACCEL_BUFFER_ZERO(buffer_zero_sse2, 64, __m128i, SSE2_NONZERO)#ifdef CONFIG_AVX2_OPT #pragma GCC push_options +#pragma GCC target("sse4") +#include <smmintrin.h> +#define SSE4_NONZERO (X ) !_mm_testz_si128((X), (X)) +ACCEL_BUFFER_ZERO(buffer_zero_sse4, 64, __m128i, SSE4_NONZERO) +#pragma GCC pop_options + +#pragma GCC push_options#pragma GCC target("avx2")#include <immintrin.h> #define AVX2_NONZERO (X ) !_mm256_testz_si256((X), (X))
@@ -182,6 +189,9 @@ static bool select_accel_fn(const void *buf, size_t len)if (len %128 ==0 && ibuf %32 ==0 && (cpuid_cache &CACHE_AVX2 )) {return buffer_zero_avx2 (buf, len); } +if (len %64 ==0 && ibuf %16 ==0 && (cpuid_cache &CACHE_SSE4 )) { +return buffer_zero_sse4 (buf, len); + }#endif if (len %64 ==0 && ibuf %16 ==0 && (cpuid_cache &CACHE_SSE2 )) {return buffer_zero_sse2 (buf, len);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 58/58] cutils: Add generic prefetch
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
There's no real knowledge of the cacheline size,
just prefetching one loop ahead.
Message-Id: <[email protected]>
--- util/bufferiszero.c | 5 +++++ 1 file changed, 5 insertions(+)
util/bufferiszero.c +5 -0
@@ -38,6 +38,8 @@ static bool NAME(const void *buf, size_t len) \ do { \ const VECTYPE *p = buf; \ VECTYPE t; \ + __builtin_prefetch(buf + SIZE); \ + barrier(); \ if (SIZE == sizeof(VECTYPE) * 4) { \ t = (p[0] | p[1]) | (p[2] | p[3]); \ } else if (SIZE == sizeof(VECTYPE) * 8) { \
@@ -219,6 +221,9 @@ bool buffer_is_zero(const void *buf, size_t len)return true; } +/* Fetch the beginning of the buffer while we select the accelerator. */ +__builtin_prefetch (buf); +/* Use an optimized zero check if possible. Note that this also includes a check for an unrolled loop over 64-bit integers. */ return select_accel_fn (buf, len);
Signature · 1 line
1.8.3.1
Quoted 8 lines · Paolo Bonzini
The following changes since commit
fa9701240951093907076db0943f96972a396ef5:Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20160913-1' into staging (2016-09-13 13:56:35 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git
This pull request seems to be missing the tag name.
thanks
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Paolo Bonzini
The following changes since commit
fa9701240951093907076db0943f96972a396ef5:Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20160913-1' into staging (2016-09-13 13:56:35 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gitThis pull request seems to be missing the tag name.
Yes, I sent v2 right after.
Paolo