diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-03-08 04:53:36 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-03-08 04:53:37 +0000 |
commit | 97556fe80e4f7252300b3498b3477fb4295153a3 (patch) | |
tree | 7e49b80e86e59e38d353a8a2f39857780f0fddbe /kvm-all.c | |
parent | 1464ad45cd6cdeb0b5c1a54d3d3791396e47e52f (diff) | |
parent | 4792b7e9d5254daa383cb38d60d79c2b000ca9fc (diff) | |
download | qemu-97556fe80e4f7252300b3498b3477fb4295153a3.zip qemu-97556fe80e4f7252300b3498b3477fb4295153a3.tar.gz qemu-97556fe80e4f7252300b3498b3477fb4295153a3.tar.bz2 |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* RAMBlock vs. MemoryRegion cleanups from Fam
* mru_section optimization from Fam
* memory.txt improvements from Peter and Xiaoqiang
* i8257 fix from Hervé
* -daemonize fix
* Cleanups and small fixes from Alex, Praneith, Wei
# gpg: Signature made Mon 07 Mar 2016 17:08:59 GMT using RSA key ID 78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>"
* remotes/bonzini/tags/for-upstream:
scsi-bus: Remove tape command from scsi_req_xfer
kvm/irqchip: use bitmap utility for gsi tracking
MAINTAINERS: Add entry for include/sysemu/kvm*.h
doc/memory.txt: correct description of MemoryRegionOps fields
doc/memory.txt: correct a logic error
icount: possible options for sleep are on or off
exec: Introduce AddressSpaceDispatch.mru_section
exec: Factor out section_covers_addr
exec: Pass RAMBlock pointer to qemu_ram_free
memory: Drop MemoryRegion.ram_addr
memory: Implement memory_region_get_ram_addr with mr->ram_block
memory: Move assignment to ram_block to memory_region_init_*
exec: Return RAMBlock pointer from allocating functions
i8257: fix Terminal Count status
log: do not log if QEMU is daemonized but without -D
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'kvm-all.c')
-rw-r--r-- | kvm-all.c | 37 |
1 files changed, 12 insertions, 25 deletions
@@ -89,7 +89,7 @@ struct KVMState #ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes; int nr_allocated_irq_routes; - uint32_t *used_gsi_bitmap; + unsigned long *used_gsi_bitmap; unsigned int gsi_count; QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; #endif @@ -366,7 +366,8 @@ static void kvm_log_stop(MemoryListener *listener, static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) { - ram_addr_t start = section->offset_within_region + section->mr->ram_addr; + ram_addr_t start = section->offset_within_region + + memory_region_get_ram_addr(section->mr); ram_addr_t pages = int128_get64(section->size) / getpagesize(); cpu_physical_memory_set_dirty_lebitmap(bitmap, start, pages); @@ -950,12 +951,12 @@ typedef struct KVMMSIRoute { static void set_gsi(KVMState *s, unsigned int gsi) { - s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32); + set_bit(gsi, s->used_gsi_bitmap); } static void clear_gsi(KVMState *s, unsigned int gsi) { - s->used_gsi_bitmap[gsi / 32] &= ~(1U << (gsi % 32)); + clear_bit(gsi, s->used_gsi_bitmap); } void kvm_init_irq_routing(KVMState *s) @@ -964,17 +965,9 @@ void kvm_init_irq_routing(KVMState *s) gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING) - 1; if (gsi_count > 0) { - unsigned int gsi_bits, i; - /* Round up so we can search ints using ffs */ - gsi_bits = ALIGN(gsi_count, 32); - s->used_gsi_bitmap = g_malloc0(gsi_bits / 8); + s->used_gsi_bitmap = bitmap_new(gsi_count); s->gsi_count = gsi_count; - - /* Mark any over-allocated bits as already in use */ - for (i = gsi_count; i < gsi_bits; i++) { - set_gsi(s, i); - } } s->irq_routes = g_malloc0(sizeof(*s->irq_routes)); @@ -1104,9 +1097,7 @@ static void kvm_flush_dynamic_msi_routes(KVMState *s) static int kvm_irqchip_get_virq(KVMState *s) { - uint32_t *word = s->used_gsi_bitmap; - int max_words = ALIGN(s->gsi_count, 32) / 32; - int i, zeroes; + int next_virq; /* * PIC and IOAPIC share the first 16 GSI numbers, thus the available @@ -1119,16 +1110,12 @@ static int kvm_irqchip_get_virq(KVMState *s) } /* Return the lowest unused GSI in the bitmap */ - for (i = 0; i < max_words; i++) { - zeroes = ctz32(~word[i]); - if (zeroes == 32) { - continue; - } - - return zeroes + i * 32; + next_virq = find_first_zero_bit(s->used_gsi_bitmap, s->gsi_count); + if (next_virq >= s->gsi_count) { + return -ENOSPC; + } else { + return next_virq; } - return -ENOSPC; - } static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, MSIMessage msg) |