Initial tree and candidates for stable-1.1
Subsystems (2)
cover Initial tree and candidates for stable-1.1
Hi everyone,
I've set up a tree for stable-1.1 at:
git://github.com/mdroth/qemu.git stable-1.1
That is simply the initial commit for v1.1.0
I've set up a staging tree for the first batch of commits at:
git://github.com/mdroth/qemu.git stable-1.1-staging
This should capture everything explicitly tagged for stable/1.1. I've also pulled in relevant build fixes and a handful of applicable bug fixes.
Please let me know if I've missed any patches, or if any of these shouldn't be applied.
Testing so far has been all-target builds on x86, make check, qemu-test, and installation + old(current stable-1.1)->new and new->old migration for fc15/fc16/winxp. I plan on doing a more extensive final round of testing later next week before committing, as that will more or less be QEMU v1.1.1
For the next release I plan on doing weekly or bi-weekly testing of staged patches and emails of this sort before committing to stable-1.1, depending on the number of patches and code churn, and will continue working off my stable-1.1-staging tree on github for those.
The following changes since commit 78260a5f085d34e4ae46e42bdc010dfcd6f6cc31:
Update version for 1.1.0 release (2012-06-01 16:55:34 +0800)
Bruce Rogers (1):
build: install qmp-commands.txt
Christian Borntraeger (1):
virtio-blk: Fix geometry sector calculation
Fernando Luis Vazquez Cao (1):
rtl8139: honor RxOverflow flag in can_receive method
Harsh Prateek Bora (2):
trace/simple.c: fix deprecated glib2 interface
configure: report missing libraries for virtfs
Jan Kiszka (3):
kvm: i8254: Fix conversion of in-kernel to userspace state
ahci: Fix reset of MSI function
intel-hda: Fix reset of MSI function
Jason Baron (2):
qdev: release parent properties on dc->init failure
pci_bridge_dev: fix error path in pci_bridge_dev_initfn()
Jim Meyering (1):
kvm/apic: correct short memset
Kevin Wolf (1):
qcow2: Silence false warning
Max Filippov (8):
target-xtensa: flush TLB page for new MMU mapping
target-xtensa: update EXCVADDR in case of page table lookup
target-xtensa: extract TLB entry setting method
target-xtensa: update autorefill TLB entries conditionally
target-xtensa: control page table lookup explicitly
target-xtensa: add MMU pagewalking tests
exec: fix TB invalidation after breakpoint insertion/deletion
target-xtensa: fix CCOUNT for conditional branches
Pavel Dovgaluk (1):
Prevent disk data loss when closing qemu
Pavel Hrdina (1):
fdc: fix implied seek while there is no media in drive
Stefan Hajnoczi (1):
qcow2: fix autoclear image header update
Stefan Weil (2):
monitor: Fix memory leak with readline completion
configure: Fix build for some versions of glibc (9pfs)
Zhi Yong Wu (1):
qcow2: fix endianness conversion
Makefile | 1 + block/qcow2-cluster.c | 2 + block/qcow2-refcount.c | 2 +- block/qcow2.c | 17 ++-- configure | 7 +- exec.c | 3 +- hw/fdc.c | 4 + hw/ide/ich.c | 12 ++- hw/intel-hda.c | 3 + hw/kvm/apic.c | 2 +- hw/kvm/i8254.c | 57 ++++++++++- hw/pci_bridge_dev.c | 4 +- hw/qdev.c | 1 + hw/rtl8139.c | 2 +- hw/virtio-blk.c | 17 +++- os-win32.c | 8 ++- readline.c | 3 + target-xtensa/cpu.h | 5 +- target-xtensa/helper.c | 61 +++++++----- target-xtensa/op_helper.c | 20 +++- target-xtensa/translate.c | 2 + tests/tcg/xtensa/test_mmu.S | 221 ++++++++++++++++++++++++++++++++++++++++--- trace/simple.c | 5 +- 23 files changed, 388 insertions(+), 71 deletions(-)
PATCH 1/26 virtio-blk: Fix geometry sector calculation
From: Christian Borntraeger <[email protected]>
Currently the sector value for the geometry is masked, even if the user usesa command line parameter that explicitely gives a number. This breaks dasd devices on s390. A dasd device can have a physical block size of 4096 (== same for logical block size) and a typcial geometry of 15 heads and 12 sectors per cyl. The ibm partition detection relies on a correct geometry reported by the device. Unfortunately the current code changes 12 to 8. This would be necessary if the total size is not a multiple of logical sector size, but for dasd this is not the case.
This patch checks the device size and only applies sector mask if necessary.
--- hw/virtio-blk.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-)
hw/virtio-blk.c +16 -1
@@ -489,7 +489,22 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)stw_raw (&blkcfg.min_io_size, s->conf->min_io_size / blk_size);stw_raw (&blkcfg.opt_io_size, s->conf->opt_io_size / blk_size); blkcfg.heads = heads; - blkcfg.sectors = secs & ~s->sector_mask; +/* +* We must ensure that the block device capacity is a multiple of +* the logical block size. If that is not the case, lets use +* sector_mask to adopt the geometry to have a correct picture. +* For those devices where the capacity is ok for the given geometry +* we dont touch the sector value of the geometry, since some devices +* (like s390 dasd) need a specific value. Here the capacity is already +* cyls*heads*secs*blk_size and the sector value is not block size +* divided by 512 - instead it is the amount of blk_size blocks +* per track (cylinder). +*/ +if (bdrv_getlength (s->bs) / heads / secs % blk_size) { + blkcfg.sectors = secs & ~s->sector_mask; + }else { + blkcfg.sectors = secs; + } blkcfg.size_max =0 ; blkcfg.physical_block_exp =get_physical_block_exp (s->conf); blkcfg.alignment_offset =0 ;
Signature · 1 line
1.7.4.1
PATCH 2/26 target-xtensa: flush TLB page for new MMU mapping
In reply to Michael RothFrom: Max Filippov <[email protected]>
Both old and new mappings need flushing because their VPN may be different in MMU case.
--- target-xtensa/op_helper.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
target-xtensa/op_helper.c +1 -0
@@ -669,6 +669,7 @@ void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb, entry->paddr = pte &xtensa_tlb_get_addr_mask (env, dtlb, wi); entry->asid = (env->sregs[RASID ] >> ((pte >>1 ) &0x18 )) &0xff ; entry->attr = pte &0xf ; +tlb_flush_page (env, entry->vaddr); }else {qemu_log ("%s %d, %d, %d trying to set immutable entry\n" , __func__, dtlb, wi, ei);
Signature · 1 line
1.7.4.1
PATCH 3/26 target-xtensa: update EXCVADDR in case of page table lookup
In reply to Michael RothFrom: Max Filippov <[email protected]>
According to ISA, 4.4.2.6, EXCVADDR may be changed by any TLB miss, even if the miss is handled entirely by processor hardware.
--- target-xtensa/helper.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
target-xtensa/helper.c +1 -0
@@ -516,6 +516,7 @@ static int autorefill_mmu(CPUXtensaState *env, uint32_t vaddr, bool dtlb, *wi = (++env->autorefill_idx) &0x3 ;split_tlb_entry_spec_way (env, vaddr, dtlb, &vpn, *wi, ei);xtensa_tlb_set_entry (env, dtlb, *wi, *ei, vpn, pte); + env->sregs[EXCVADDR ] = vaddr;qemu_log ("%s: autorefill(%08x): %08x -> %08x\n" , __func__, vaddr, vpn, pte); }
Signature · 1 line
1.7.4.1
PATCH 4/26 target-xtensa: extract TLB entry setting method
In reply to Michael RothFrom: Max Filippov <[email protected]>
--- target-xtensa/cpu.h | 3 +++ target-xtensa/op_helper.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
target-xtensa/cpu.h +3 -0
@@ -370,6 +370,9 @@ void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v, bool dtlb, uint32_t *vpn, uint32_t wi, uint32_t *ei);int xtensa_tlb_lookup (const CPUXtensaState *env,uint32_t addr,bool dtlb,uint32_t *pwi,uint32_t *pei,uint8_t *pring); +void xtensa_tlb_set_entry_mmu (const CPUXtensaState *env, +xtensa_tlb_entry *entry,bool dtlb, +unsigned wi,unsigned ei,uint32_t vpn,uint32_t pte);void xtensa_tlb_set_entry (CPUXtensaState *env,bool dtlb,unsigned wi,unsigned ei,uint32_t vpn,uint32_t pte); int xtensa_get_physical_addr(CPUXtensaState *env,
target-xtensa/op_helper.c +11 -4
@@ -655,6 +655,16 @@ uint32_t HELPER(ptlb)(uint32_t v, uint32_t dtlb) } } +void xtensa_tlb_set_entry_mmu (const CPUXtensaState *env, +xtensa_tlb_entry *entry,bool dtlb, +unsigned wi,unsigned ei,uint32_t vpn,uint32_t pte) +{ + entry->vaddr = vpn; + entry->paddr = pte &xtensa_tlb_get_addr_mask (env, dtlb, wi); + entry->asid = (env->sregs[RASID ] >> ((pte >>1 ) &0x18 )) &0xff ; + entry->attr = pte &0xf ; +} +void xtensa_tlb_set_entry (CPUXtensaState *env,bool dtlb,unsigned wi,unsigned ei,uint32_t vpn,uint32_t pte) {
@@ -665,10 +675,7 @@ void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,if (entry->asid) {tlb_flush_page (env, entry->vaddr); } - entry->vaddr = vpn; - entry->paddr = pte &xtensa_tlb_get_addr_mask (env, dtlb, wi); - entry->asid = (env->sregs[RASID ] >> ((pte >>1 ) &0x18 )) &0xff ; - entry->attr = pte &0xf ; +xtensa_tlb_set_entry_mmu (env, entry, dtlb, wi, ei, vpn, pte);tlb_flush_page (env, entry->vaddr); }else { qemu_log("%s %d, %d, %d trying to set immutable entry\n",
Signature · 1 line
1.7.4.1
PATCH 5/26 target-xtensa: update autorefill TLB entries conditionally
In reply to Michael RothFrom: Max Filippov <[email protected]>
This is to avoid interference of internal QEMU helpers (cpu_get_phys_page_debug, tb_invalidate_virtual_addr) with guest-visible TLB state.
--- target-xtensa/cpu.h | 2 +- target-xtensa/helper.c | 56 +++++++++++++++++++++++++------------------- target-xtensa/op_helper.c | 4 +- 3 files changed, 35 insertions(+), 27 deletions(-)
target-xtensa/cpu.h +1 -1
@@ -375,7 +375,7 @@ void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env, unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte);void xtensa_tlb_set_entry (CPUXtensaState *env,bool dtlb,unsigned wi,unsigned ei,uint32_t vpn,uint32_t pte); -int xtensa_get_physical_addr (CPUXtensaState *env, +int xtensa_get_physical_addr (CPUXtensaState *env,bool update_tlb,uint32_t vaddr,int is_write,int mmu_idx,uint32_t *paddr,uint32_t *page_size,unsigned *access);void reset_mmu (CPUXtensaState *env);
target-xtensa/helper.c +32 -24
116 lines not on this page · raw message
target-xtensa/op_helper.c +2 -2
@@ -79,7 +79,7 @@ void tlb_fill(CPUXtensaState *env1, target_ulong vaddr, int is_write, int mmu_iduint32_t paddr;uint32_t page_size;unsigned access; -int ret =xtensa_get_physical_addr (env, vaddr, is_write, mmu_idx, +int ret =xtensa_get_physical_addr (env, true, vaddr, is_write, mmu_idx, &paddr, &page_size, &access); qemu_log("%s(%08x, %d, %d) -> %08x, ret = %d\n", __func__,
@@ -103,7 +103,7 @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr)uint32_t paddr;uint32_t page_size;unsigned access; -int ret =xtensa_get_physical_addr (env, vaddr,2 ,0 , +int ret =xtensa_get_physical_addr (env, false, vaddr,2 ,0 , &paddr, &page_size, &access);if (ret ==0 ) {tb_invalidate_phys_addr (paddr);
Signature · 1 line
1.7.4.1
PATCH 6/26 target-xtensa: control page table lookup explicitly
In reply to Michael RothFrom: Max Filippov <[email protected]>
Hardware pagetable walking may not be nested. Stop guessing and pass explicit flag to the get_physical_addr_mmu function that controls page table lookup.
--- target-xtensa/helper.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
target-xtensa/helper.c +5 -5
@@ -452,7 +452,8 @@ static int get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte);static int get_physical_addr_mmu (CPUXtensaState *env,bool update_tlb,uint32_t vaddr,int is_write,int mmu_idx, -uint32_t *paddr,uint32_t *page_size,unsigned *access) +uint32_t *paddr,uint32_t *page_size,unsigned *access, +bool may_lookup_pt) {bool dtlb = is_write !=2 ;uint32_t wi;
@@ -465,8 +466,7 @@ static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb,int ret =xtensa_tlb_lookup (env, vaddr, dtlb, &wi, &ei, &ring);if ((ret ==INST_TLB_MISS_CAUSE || ret ==LOAD_STORE_TLB_MISS_CAUSE ) && - (mmu_idx !=0 || ((vaddr ^ env->sregs[PTEVADDR ]) &0xffc00000 )) && -get_pte (env, vaddr, &pte) ==0 ) { + may_lookup_pt &&get_pte (env, vaddr, &pte) ==0 ) { ring = (pte >>4 ) &0x3 ; wi =0 ;split_tlb_entry_spec_way (env, vaddr, dtlb, &vpn, wi, &ei);
@@ -520,7 +520,7 @@ static int get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte)uint32_t pt_vaddr = (env->sregs[PTEVADDR ] | (vaddr >>10 )) &0xfffffffc ;int ret =get_physical_addr_mmu (env, false, pt_vaddr,0 ,0 , - &paddr, &page_size, &access); + &paddr, &page_size, &access, false);qemu_log ("%s: trying autorefill(%08x) -> %08x\n" , __func__, vaddr, ret ? ~0 : paddr);
@@ -568,7 +568,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, {if (xtensa_option_enabled (env->config,XTENSA_OPTION_MMU )) {return get_physical_addr_mmu (env, update_tlb, - vaddr, is_write, mmu_idx, paddr, page_size, access); + vaddr, is_write, mmu_idx, paddr, page_size, access, true); }else if (xtensa_option_bits_enabled (env->config,XTENSA_OPTION_BIT (XTENSA_OPTION_REGION_PROTECTION ) |XTENSA_OPTION_BIT (XTENSA_OPTION_REGION_TRANSLATION ))) {
Signature · 1 line
1.7.4.1
PATCH 7/26 target-xtensa: add MMU pagewalking tests
In reply to Michael RothFrom: Max Filippov <[email protected]>
--- tests/tcg/xtensa/test_mmu.S | 221 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 207 insertions(+), 14 deletions(-)
tests/tcg/xtensa/test_mmu.S +207 -14
@@ -293,26 +293,219 @@ test store_prohibited assert eq, a2, a3 test_end -test dtlb_autoload - set_vector kernel, 0 - - movi a2, 0xd4000000 +/* Set up page table entry vaddr->paddr, ring=pte_ring, attr=pte_attr + * and DTLB way 7 to cover this PTE, ring=pt_ring, attr=pt_attr + */ +.macro pt_setup pt_ring, pt_attr, pte_ring, vaddr, paddr, pte_attr + movi a2, 0x80000000 wsr a2, ptevaddr - movi a3, 0x00001013 - s32i a3, a2, 4 + + movi a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */ + movi a4, 0x04000003 | ((\pt_ring) << 4) /* PADDR 64M */ + wdtlb a4, a3 + isync + + movi a3, ((\paddr) & 0xfffff000) | ((\pte_ring) << 4) | (\pte_attr) + movi a1, ((\vaddr) >> 12) << 2 + add a2, a1, a2 + s32i a3, a2, 0 + + movi a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */ + movi a4, 0x04000000 | ((\pt_ring) << 4) | (\pt_attr) /* PADDR 64M */ + wdtlb a4, a3 + isync + + movi a3, (\vaddr) +.endm + +/* out: PS.RING=ring, PS.EXCM=excm, a3=vaddr */ +.macro go_ring ring, excm, vaddr + movi a3, 10f + pitlb a3, a3 + ritlb1 a2, a3 + movi a1, 0x10 + or a2, a2, a1 + movi a1, 0x000ff000 + and a3, a3, a1 + movi a1, 4 + or a3, a3, a1 + witlb a2, a3 + movi a3, 10f + movi a1, 0x000fffff + and a1, a3, a1 + + movi a2, 0 + wsr a2, excvaddr + + movi a3, \vaddr + movi a2, 0x4000f | ((\ring) << 6) | ((\excm) << 4) + jx a1 +10: + wsr a2, ps + isync +.endm + +/* in: a3 -- virtual address to test */ +.macro assert_auto_tlb + movi a2, 0x4000f + wsr a2, ps + isync + pdtlb a2, a3 + movi a1, 0xfffff01f + and a2, a2, a1 + movi a1, 0xfffff000 + and a1, a1, a3 + xor a1, a1, a2 + assert gei, a1, 0x10 + movi a2, 0x14 + assert lt, a1, a2 +.endm + +/* in: a3 -- virtual address to test */ +.macro assert_no_auto_tlb + movi a2, 0x4000f + wsr a2, ps + isync pdtlb a2, a3 movi a1, 0x10 and a1, a1, a2 assert eqi, a1, 0 - l8ui a1, a3, 0 - pdtlb a2, a3 - movi a1, 0xfffff010 - and a1, a1, a2 - movi a3, 0x00001010 - assert eq, a1, a3 - movi a1, 0xf +.endm + +.macro assert_sr sr, v + rsr a2, \sr + movi a1, (\v) + assert eq, a1, a2 +.endm + +.macro assert_epc1_1m vaddr + movi a2, (\vaddr) + movi a1, 0xfffff and a1, a1, a2 - assert lti, a1, 4 + rsr a2, epc1 + assert eq, a1, a2 +.endm + +test dtlb_autoload + set_vector kernel, 0 + + pt_setup 0, 3, 1, 0x1000, 0x1000, 3 + assert_no_auto_tlb + + l8ui a1, a3, 0 + + rsr a2, excvaddr + assert eq, a2, a3 + + assert_auto_tlb +test_end + +test autoload_load_store_privilege + set_vector kernel, 0 + set_vector double, 2f + + pt_setup 0, 3, 0, 0x2000, 0x2000, 3 + movi a3, 0x2004 + assert_no_auto_tlb + + movi a2, 0x4005f /* ring 1 + excm => cring == 0 */ + wsr a2, ps + isync +1: + l32e a2, a3, -4 /* ring used */ + test_fail +2: + rsr a2, excvaddr + addi a1, a3, -4 + assert eq, a1, a2 + + assert_auto_tlb + assert_sr depc, 1b + assert_sr exccause, 26 +test_end + +test autoload_pte_load_prohibited + set_vector kernel, 2f + + pt_setup 0, 3, 0, 0x3000, 0, 0xc + assert_no_auto_tlb +1: + l32i a2, a3, 0 + test_fail +2: + rsr a2, excvaddr + assert eq, a2, a3 + + assert_auto_tlb + assert_sr epc1, 1b + assert_sr exccause, 28 +test_end + +test autoload_pt_load_prohibited + set_vector kernel, 2f + + pt_setup 0, 0xc, 0, 0x4000, 0x4000, 3 + assert_no_auto_tlb +1: + l32i a2, a3, 0 + test_fail +2: + rsr a2, excvaddr + assert eq, a2, a3 + + assert_no_auto_tlb + assert_sr epc1, 1b + assert_sr exccause, 24 +test_end + +test autoload_pt_privilege + set_vector kernel, 2f + pt_setup 0, 3, 1, 0x5000, 0, 3 + go_ring 1, 0, 0x5001 + + l8ui a2, a3, 0 +1: + syscall +2: + rsr a2, excvaddr + assert eq, a2, a3 + + assert_auto_tlb + assert_epc1_1m 1b + assert_sr exccause, 1 +test_end + +test autoload_pte_privilege + set_vector kernel, 2f + pt_setup 0, 3, 0, 0x6000, 0, 3 + go_ring 1, 0, 0x6001 +1: + l8ui a2, a3, 0 + syscall +2: + rsr a2, excvaddr + assert eq, a2, a3 + + assert_auto_tlb + assert_epc1_1m 1b + assert_sr exccause, 26 +test_end + +test autoload_3_level_pt + set_vector kernel, 2f + pt_setup 1, 3, 1, 0x00400000, 0, 3 + pt_setup 1, 3, 1, 0x80001000, 0x2000000, 3 + go_ring 1, 0, 0x00400001 +1: + l8ui a2, a3, 0 + syscall +2: + rsr a2, excvaddr + assert eq, a2, a3 + + assert_no_auto_tlb + assert_epc1_1m 1b + assert_sr exccause, 24 test_end test_suite_end
Signature · 1 line
1.7.4.1
PATCH 8/26 exec: fix TB invalidation after breakpoint insertion/deletion
In reply to Michael RothFrom: Max Filippov <[email protected]>
tb_invalidate_phys_addr has to be called with the exact physical address of the breakpoint we add/remove, not just the page's base address. Otherwise we easily fail to flush the right TB.
This breakage was introduced by the commit f3705d5329 "memory: make phys_page_find() return an unadjusted".
This appeared to work for some guest architectures because their cpu_get_phys_page_debug implementation returns full translated physical address, not just the base of the TARGET_PAGE_SIZE-sized page.
--- exec.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
exec.c +2 -1
@@ -1492,7 +1492,8 @@ void tb_invalidate_phys_addr(target_phys_addr_t addr)static void breakpoint_invalidate (CPUArchState *env,target_ulong pc) { -tb_invalidate_phys_addr (cpu_get_phys_page_debug (env, pc)); +tb_invalidate_phys_addr (cpu_get_phys_page_debug (env, pc) | + (pc & ~TARGET_PAGE_MASK )); }#endif #endif /* TARGET_HAS_ICE */
Signature · 1 line
1.7.4.1
PATCH 9/26 target-xtensa: fix CCOUNT for conditional branches
In reply to Michael RothFrom: Max Filippov <[email protected]>
Taken conditional branches fail to update CCOUNT register because accumulated ccount_delta is reset during translation of non-taken branch. To fix it only update CCOUNT once per conditional branch instruction translation.
This fixes guest linux freeze on LTP waitpid06 test.
--- target-xtensa/translate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
target-xtensa/translate.c +2 -0
@@ -388,6 +388,7 @@ static bool gen_check_loop_end(DisasContext *dc, int slot) dc->next_pc == dc->lend) {int label =gen_new_label (); +gen_advance_ccount (dc);tcg_gen_brcondi_i32 (TCG_COND_EQ , cpu_SR[LCOUNT ],0 , label);tcg_gen_subi_i32 (cpu_SR[LCOUNT ], cpu_SR[LCOUNT ],1 );gen_jumpi (dc, dc->lbeg, slot);
@@ -410,6 +411,7 @@ static void gen_brcond(DisasContext *dc, TCGCond cond, {int label =gen_new_label (); +gen_advance_ccount (dc);tcg_gen_brcond_i32 (cond, t0, t1, label);gen_jumpi_check_loop_end (dc,0 );gen_set_label (label);
Signature · 1 line
1.7.4.1
PATCH 10/26 trace/simple.c: fix deprecated glib2 interface
In reply to Michael RothFrom: Harsh Prateek Bora <[email protected]>
--- trace/simple.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
trace/simple.c +4 -1
@@ -161,8 +161,11 @@ static void trace(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, } timestamp =get_clock (); - +#if GLIB_CHECK_VERSION (2 ,30 ,0 ) + idx =g_atomic_int_add ((gint *)&trace_idx,1 ) %TRACE_BUF_LEN ; +#else idx =g_atomic_int_exchange_and_add ((gint *)&trace_idx,1 ) %TRACE_BUF_LEN ; +#endif trace_buf[idx] = (TraceRecord ){ .event = event, .timestamp_ns = timestamp,
Signature · 1 line
1.7.4.1
PATCH 11/26 configure: report missing libraries for virtfs
In reply to Michael RothFrom: Harsh Prateek Bora <[email protected]>
--- configure | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
configure +2 -1
@@ -2915,7 +2915,8 @@ if test "$softmmu" = yes ; then tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" = yes; then - feature_not_found "virtfs" + echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel" + exit 1 fi virtfs=no fi
Signature · 1 line
1.7.4.1
PATCH 12/26 kvm/apic: correct short memset
In reply to Michael RothFrom: Jim Meyering <[email protected]>
kvm_put_apic_state's attempt to clear *kapic before setting its bits cleared sizeof(void*) bytes (no more than 8) rather than the intended 1024 (KVM_APIC_REG_SIZE) bytes. Spotted by coverity.
--- hw/kvm/apic.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/kvm/apic.c +1 -1
@@ -29,7 +29,7 @@ void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic)APICCommonState *s =DO_UPCAST (APICCommonState, busdev.qdev, d);int i; -memset (kapic,0 ,sizeof (kapic)); +memset (kapic,0 ,sizeof (*kapic));kvm_apic_set_reg (kapic,0x2 , s->id <<24 );kvm_apic_set_reg (kapic,0x8 , s->tpr);kvm_apic_set_reg (kapic,0xd , s->log_dest <<24 );
Signature · 1 line
1.7.4.1
PATCH 13/26 kvm: i8254: Fix conversion of in-kernel to userspace state
In reply to Michael RothFrom: Jan Kiszka <[email protected]>
Due to a offset between the clock used to generate the in-kernel count_load_time (CLOCK_MONOTONIC) and the clock used for processing this in userspace (vm_clock), reading back the output of PIT channel 2 via port 0x61 was broken. One use cases that suffered from it was the CPU frequency calibration of SeaBIOS, which also affected IDE/AHCI timeouts.
This fixes it by calibrating the offset between both clocks on kvm_pit_get and adjusting the kernel value before saving it in the userspace state. As the calibration only works while the vm_clock is running, we cache the in-kernel state across stopped phases.
--- hw/kvm/i8254.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 52 insertions(+), 5 deletions(-)
hw/kvm/i8254.c +52 -5
@@ -23,31 +23,63 @@* THE SOFTWARE. */ #include "qemu-timer.h" +#include "sysemu.h" #include "hw/i8254.h" #include "hw/i8254_internal.h" #include "kvm.h" #define KVM_PIT_REINJECT_BIT 0 +#define CALIBRATION_ROUNDS 3 +typedef struct KVMPITState {PITCommonState pit;LostTickPolicy lost_tick_policy; +bool state_valid; }KVMPITState ; -static void kvm_pit_get (PITCommonState *s) +static int64_t abs64 (int64_t v) { +return v <0 ? -v : v; +} + +static void kvm_pit_get (PITCommonState *pit) +{ +KVMPITState *s =DO_UPCAST (KVMPITState, pit, pit);struct kvm_pit_state2 kpit;struct kvm_pit_channel_state *kchan;struct PITChannelState *sc; +int64_t offset, clock_offset; +struct timespec ts;int i, ret; +if (s->state_valid) { +return ; + } + +/* +* Measure the delta between CLOCK_MONOTONIC, the base used for +* kvm_pit_channel_state::count_load_time, and vm_clock. Take the +* minimum of several samples to filter out scheduling noise. +*/ + clock_offset =INT64_MAX ; +for (i =0 ; i <CALIBRATION_ROUNDS ; i++) { + offset =qemu_get_clock_ns (vm_clock); +clock_gettime (CLOCK_MONOTONIC , &ts); + offset -= ts.tv_nsec; + offset -= (int64_t )ts.tv_sec *1000000000 ; +if (abs64 (offset) <abs64 (clock_offset)) { + clock_offset = offset; + } + } +if (kvm_has_pit_state2 ()) { ret =kvm_vm_ioctl (kvm_state,KVM_GET_PIT2 , &kpit);if (ret <0 ) {fprintf (stderr,"KVM_GET_PIT2 failed: %s\n" ,strerror (ret));abort (); } - s->channels[0 ].irq_disabled = kpit.flags &KVM_PIT_FLAGS_HPET_LEGACY ; + pit->channels[0 ].irq_disabled = kpit.flags &KVM_PIT_FLAGS_HPET_LEGACY ; }else {/* * kvm_pit_state2 is superset of kvm_pit_state struct,
@@ -61,7 +93,7 @@ static void kvm_pit_get(PITCommonState *s) }for (i =0 ; i <3 ; i++) { kchan = &kpit.channels[i]; - sc = &s->channels[i]; + sc = &pit->channels[i]; sc->count = kchan->count; sc->latched_count = kchan->latched_count; sc->count_latched = kchan->count_latched;
@@ -74,10 +106,10 @@ static void kvm_pit_get(PITCommonState *s) sc->mode = kchan->mode; sc->bcd = kchan->bcd; sc->gate = kchan->gate; - sc->count_load_time = kchan->count_load_time; + sc->count_load_time = kchan->count_load_time + clock_offset; } - sc = &s->channels[0 ]; + sc = &pit->channels[0 ]; sc->next_transition_time =pit_get_next_transition_time (sc, sc->count_load_time); }
@@ -173,6 +205,19 @@ static void kvm_pit_irq_control(void *opaque, int n, int enable)kvm_pit_put (pit); } +static void kvm_pit_vm_state_change (void *opaque,int running, +RunState state) +{ +KVMPITState *s = opaque; + +if (running) { + s->state_valid = false; + }else { +kvm_pit_get (&s->pit); + s->state_valid = true; + } +} +static int kvm_pit_initfn (PITCommonState *pit) {KVMPITState *s =DO_UPCAST (KVMPITState, pit, pit);
@@ -215,6 +260,8 @@ static int kvm_pit_initfn(PITCommonState *pit)qdev_init_gpio_in (&pit->dev.qdev, kvm_pit_irq_control,1 ); +qemu_add_vm_change_state_handler (kvm_pit_vm_state_change, s); +return 0 ; }
Signature · 1 line
1.7.4.1
PATCH 14/26 qcow2: Silence false warning
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
Some gcc versions seem not to be able to figure out that the switch statement covers all possible values and that c is therefore always initialised. Add a default branch for them.
--- block/qcow2-cluster.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
block/qcow2-cluster.c +2 -0
@@ -471,6 +471,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, QCOW_OFLAG_COMPRESSED | QCOW_OFLAG_ZERO); *cluster_offset &=L2E_OFFSET_MASK ;break ; +default : +abort (); }qcow2_cache_put (bs, s->l2_table_cache, (void **) &l2_table);
Signature · 1 line
1.7.4.1
PATCH 15/26 monitor: Fix memory leak with readline completion
In reply to Michael RothFrom: Stefan Weil <[email protected]>
Each string which is shown during readline completion in the QEMU monitor is allocated dynamically but currently never deallocated.
Add the missing loop which calls g_free for the allocated strings.
--- readline.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
readline.c +3 -0
@@ -337,6 +337,9 @@ static void readline_completion(ReadLineState *rs) }readline_show_prompt (rs); } +for (i =0 ; i < rs->nb_completions; i++) { +g_free (rs->completions[i]); + } }/* return true if command handled */
Signature · 1 line
1.7.4.1
PATCH 16/26 configure: Fix build for some versions of glibc (9pfs)
In reply to Michael RothFrom: Stefan Weil <[email protected]>
Some versions declare open_by_handle_at, but don't define AT_EMPTY_PATH. Extend the check in configure to test both preconditions.
--- configure | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
configure +4 -0
@@ -2811,7 +2811,11 @@ fi open_by_hande_at=no cat > $TMPC << EOF #include <fcntl.h> +#if !defined(AT_EMPTY_PATH) +# error missing definition +#else int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); } +#endif EOF if compile_prog "" "" ; then open_by_handle_at=yes
Signature · 1 line
1.7.4.1
PATCH 17/26 rtl8139: honor RxOverflow flag in can_receive method
In reply to Michael RothFrom: Fernando Luis Vazquez Cao <[email protected]>
Some drivers (Linux' 8139too among them) rely on the NIC injecting an interrupt in the event of a receive buffer overflow and, accordingly, set the RxOverflow bit in the interrupt mask. Unfortunately rtl8139's can_receive method ignores the RxOverflow flag, which may lead to a situation where rtl8139 stops receiving packets (can_receive returns 0) when the receive buffer becomes full.
If the driver eventually read from the receive buffer or reset the card the emulator could recover from this situation. However some implementations only do this upon receiving an interrupt with either RxOK or RxOverflow set in the ISR; interrupt that will never come because QEMU's flow control mechanisms would prevent rtl8139 from receiving any packet.
Letting packets go through when the overflow interrupt is enabled makes the QEMU emulator compliant to the spec and solves the problem.
This patch should fix a relatively common (in our experience) network stall observed when running enterprise distros with rtl8139 as the NIC; in some cases the 8139too device driver gets loaded and when under heavy load the network eventually stops working.
--- hw/rtl8139.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/rtl8139.c +1 -1
@@ -802,7 +802,7 @@ static int rtl8139_can_receive(VLANClientState *nc) }else { avail =MOD2 (s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); -return (avail ==0 || avail >=1514 ); +return (avail ==0 || avail >=1514 || (s->IntrMask & RxOverflow)); } }
Signature · 1 line
1.7.4.1
PATCH 18/26 ahci: Fix reset of MSI function
In reply to Michael RothFrom: Jan Kiszka <[email protected]>
Call msi_reset on device reset as still required by the core.
--- hw/ide/ich.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
hw/ide/ich.c +10 -2
@@ -84,6 +84,14 @@ static const VMStateDescription vmstate_ahci = { .unmigratable = 1, }; +static void pci_ich9_reset (void *opaque) +{ +struct AHCIPCIState *d = opaque; + +msi_reset (&d->card); +ahci_reset (opaque); +} +static int pci_ich9_ahci_init (PCIDevice *dev) {struct AHCIPCIState *d;
@@ -102,7 +110,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)/* XXX Software should program this register */ d->card.config[0x90 ] =1 <<6 ;/* Address Map Register - AHCI mode */ -qemu_register_reset (ahci_reset, d); +qemu_register_reset (pci_ich9_reset, d);msi_init (dev,0x50 ,1 , true, false); d->ahci.irq = d->card.irq[0 ];
@@ -133,7 +141,7 @@ static int pci_ich9_uninit(PCIDevice *dev) d = DO_UPCAST(struct AHCIPCIState, card, dev);msi_uninit (dev); -qemu_unregister_reset (ahci_reset, d); +qemu_unregister_reset (pci_ich9_reset, d);ahci_uninit (&d->ahci);return 0 ;
Signature · 1 line
1.7.4.1
PATCH 19/26 intel-hda: Fix reset of MSI function
In reply to Michael RothFrom: Jan Kiszka <[email protected]>
Call msi_reset on device reset as still required by the core.
--- hw/intel-hda.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
hw/intel-hda.c +3 -0
@@ -1107,6 +1107,9 @@ static void intel_hda_reset(DeviceState *dev)DeviceState *qdev;HDACodecDevice *cdev; +if (d->msi) { +msi_reset (&d->pci); + }intel_hda_regs_reset (d); d->wall_base_ns =qemu_get_clock_ns (vm_clock);
Signature · 1 line
1.7.4.1
PATCH 20/26 qdev: release parent properties on dc->init failure
In reply to Michael RothFrom: Jason Baron <[email protected]>
While looking into hot-plugging bridges, I can create a qemu segfault via:
$ device_add pci-bridge
Bridge chassis not specified. Each bridge is required to be assigned a unique chassis id > 0. **
ERROR:qom/object.c:389:object_delete: assertion failed: (obj->ref == 0)
I'm proposing to fix this by adding a call to 'object_unparent()', before the call to qdev_free(). I see there is already a precedent for this usage pattern as seen in qdev_simple_unplug_cb():
/* can be used as ->unplug() callback for the simple cases */ int qdev_simple_unplug_cb(DeviceState *dev)
{
/* just zap it */
object_unparent(OBJECT(dev));
qdev_free(dev);
return 0;
}--- hw/qdev.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/qdev.c +1 -0
@@ -150,6 +150,7 @@ int qdev_init(DeviceState *dev) rc = dc->init (dev);if (rc <0 ) { +object_unparent (OBJECT (dev));qdev_free (dev);return rc; }
Signature · 1 line
1.7.4.1
PATCH 21/26 pci_bridge_dev: fix error path in pci_bridge_dev_initfn()
In reply to Michael RothFrom: Jason Baron <[email protected]>
Currently, we do not properly cleanup, if pci_bridge_dev_initfn fails to initialize properly. Make sure to call pci_bridge_exitfn() in the error path.
--- hw/pci_bridge_dev.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/pci_bridge_dev.c +3 -1
@@ -52,7 +52,7 @@ static int pci_bridge_dev_initfn(PCIDevice *dev) {PCIBridge *br =DO_UPCAST (PCIBridge, dev, dev);PCIBridgeDev *bridge_dev =DO_UPCAST (PCIBridgeDev, bridge, br); -int err; +int err, ret;pci_bridge_map_irq (br,NULL , pci_bridge_dev_map_irq_fn); err =pci_bridge_initfn (dev);if (err) {
@@ -86,6 +86,8 @@ slotid_error:shpc_cleanup (dev, &bridge_dev->bar); shpc_error:memory_region_destroy (&bridge_dev->bar); + ret =pci_bridge_exitfn (dev); +assert (!ret); bridge_error:return err; }
Signature · 1 line
1.7.4.1
PATCH 22/26 qcow2: fix endianness conversion
In reply to Michael RothFrom: Zhi Yong Wu <[email protected]>
--- block/qcow2-refcount.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block/qcow2-refcount.c +1 -1
@@ -367,7 +367,7 @@ static int alloc_refcount_block(BlockDriverState *bs, }for (i =0 ; i < table_size; i++) { -cpu_to_be64s (&new_table[i]); +be64_to_cpus (&new_table[i]); }/* Hook up the new refcount table in the qcow2 header */
Signature · 1 line
1.7.4.1
PATCH 23/26 Prevent disk data loss when closing qemu
In reply to Michael RothFrom: Pavel Dovgaluk <[email protected]>
Prevent disk data loss when closing qemu console window under Windows 7.
v3. Comment for Sleep() parameter was updated.
--- os-win32.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
os-win32.c +7 -1
@@ -57,7 +57,13 @@ int setenv(const char *name, const char *value, int overwrite) static BOOL WINAPI qemu_ctrl_handler(DWORD type) { -exit (STATUS_CONTROL_C_EXIT ); +qemu_system_shutdown_request (); +/* Windows 7 kills application when the function returns. +Sleep here to give QEMU a try for closing. +Sleep period is 10000ms because Windows kills the program +after 10 seconds anyway. */ +Sleep (10000 ); +return TRUE; }
Signature · 1 line
1.7.4.1
PATCH 24/26 qcow2: fix autoclear image header update
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
The autoclear feature bits can be used for qcow2 file format features that are safe to "drop" by old programs that do not understand the feature. Upon opening the image file unknown autoclear feature bits are cleared and the image file header is rewritten, but this was happening too early in the code when critical header fields were not yet loaded.
Process autoclear feature bits after all necessary header information has been loaded.
--- block/qcow2.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
block/qcow2.c +9 -8
@@ -298,14 +298,6 @@ static int qcow2_open(BlockDriverState *bs, int flags) goto fail; } -if (!bs->read_only && s->autoclear_features !=0 ) { - s->autoclear_features =0 ; - ret =qcow2_update_header (bs); -if (ret <0 ) { - goto fail; - } - } -/* Check support for various header values */ if (header.refcount_order !=4 ) { report_unsupported(bs, "%d bit reference counts",
@@ -411,6 +403,15 @@ static int qcow2_open(BlockDriverState *bs, int flags) goto fail; } +/* Clear unknown autoclear feature bits */ +if (!bs->read_only && s->autoclear_features !=0 ) { + s->autoclear_features =0 ; + ret =qcow2_update_header (bs); +if (ret <0 ) { + goto fail; + } + } +/* Initialise locks */ qemu_co_mutex_init (&s->lock);
Signature · 1 line
1.7.4.1
PATCH 25/26 fdc: fix implied seek while there is no media in drive
In reply to Michael RothFrom: Pavel Hrdina <[email protected]>
The Windows uses 'READ' command at the start of an instalation without checking the 'dir' register. We have to abort the transfer with an abnormal termination if there is no media in the drive.
--- hw/fdc.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
hw/fdc.c +4 -0
@@ -159,6 +159,10 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect, drv->sect = sect; } +if (drv->bs ==NULL || !bdrv_is_inserted (drv->bs)) { + ret =2 ; + } +return ret; }
Signature · 1 line
1.7.4.1
PATCH 26/26 build: install qmp-commands.txt
In reply to Michael RothFrom: Bruce Rogers <[email protected]>
File is targeted for install, but is never installed.
--- Makefile | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile +1 -0
@@ -271,6 +271,7 @@ endif install-doc: $(DOCS) $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)" $(INSTALL_DATA) qemu-doc.html qemu-tech.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) QMP/qmp-commands.txt "$(DESTDIR)$(qemu_docdir)" ifdef CONFIG_POSIX $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" $(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
Signature · 1 line
1.7.4.1