From 89de4b9138f35bec4e499235babbb15a889fa135 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Mon, 11 Sep 2017 19:49:28 +0200 Subject: [PATCH] kvm: require JOIN_MEMORY_REGIONS_WORKS We already require DESTROY_MEMORY_REGION_WORKS, JOIN_MEMORY_REGIONS_WORKS was added just half a year later. In addition, with flatview overlapping memory regions are first removed before adding the changed one. So we can't really detect joining memory regions this way. Let's just get rid of this special handling. Signed-off-by: David Hildenbrand Message-Id: <20170911174933.20789-2-david@redhat.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f85553a851..985b179ab6 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -79,7 +79,6 @@ struct KVMState int coalesced_mmio; struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; bool coalesced_flush_in_progress; - int broken_set_mem_region; int vcpu_events; int robust_singlestep; int debugregs; @@ -127,6 +126,7 @@ static bool kvm_immediate_exit; static const KVMCapabilityInfo kvm_required_capabilites[] = { KVM_CAP_INFO(USER_MEMORY), KVM_CAP_INFO(DESTROY_MEMORY_REGION_WORKS), + KVM_CAP_INFO(JOIN_MEMORY_REGIONS_WORKS), KVM_CAP_LAST_INFO }; @@ -696,7 +696,6 @@ kvm_check_extension_list(KVMState *s, const KVMCapabilityInfo *list) static void kvm_set_phys_mem(KVMMemoryListener *kml, MemoryRegionSection *section, bool add) { - KVMState *s = kvm_state; KVMSlot *mem, old; int err; MemoryRegion *mr = section->mr; @@ -763,35 +762,6 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, abort(); } - /* Workaround for older KVM versions: we can't join slots, even not by - * unregistering the previous ones and then registering the larger - * slot. We have to maintain the existing fragmentation. Sigh. - * - * This workaround assumes that the new slot starts at the same - * address as the first existing one. If not or if some overlapping - * slot comes around later, we will fail (not seen in practice so far) - * - and actually require a recent KVM version. */ - if (s->broken_set_mem_region && - old.start_addr == start_addr && old.memory_size < size && add) { - mem = kvm_alloc_slot(kml); - mem->memory_size = old.memory_size; - mem->start_addr = old.start_addr; - mem->ram = old.ram; - mem->flags = kvm_mem_flags(mr); - - err = kvm_set_user_memory_region(kml, mem); - if (err) { - fprintf(stderr, "%s: error updating slot: %s\n", __func__, - strerror(-err)); - abort(); - } - - start_addr += old.memory_size; - ram += old.memory_size; - size -= old.memory_size; - continue; - } - /* register prefix slot */ if (old.start_addr < start_addr) { mem = kvm_alloc_slot(kml); @@ -833,10 +803,6 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, } } - /* in case the KVM bug workaround already "consumed" the new slot */ - if (!size) { - return; - } if (!add) { return; } @@ -1692,12 +1658,6 @@ static int kvm_init(MachineState *ms) s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO); - s->broken_set_mem_region = 1; - ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS); - if (ret > 0) { - s->broken_set_mem_region = 0; - } - #ifdef KVM_CAP_VCPU_EVENTS s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS); #endif -- GitLab