summaryrefslogtreecommitdiff
path: root/accel
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-10-19 15:38:07 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-10-19 15:38:07 +0100
commita8b392ac9a158ff26cbbc2c2d205c370c35f64a2 (patch)
treebfcf54bd4969defa337523797afa73d835aa9c4e /accel
parentf2a48d696c12aaac12993364371daae9f6233c37 (diff)
parent3da023b5827543ee4c022986ea2ad9d1274410b2 (diff)
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* TCG 8-byte atomic accesses bugfix (Andrew) * Report disk rotation rate (Daniel) * Report invalid scsi-disk block size configuration (Mark) * KVM and memory API MemoryListener fixes (David, Maxime, Peter Xu) * x86 CPU hotplug crash fix (Igor) * Load/store API documentation (Peter Maydell) * Small fixes by myself and Thomas * qdev DEVICE_DELETED deferral (Michael) # gpg: Signature made Wed 18 Oct 2017 10:56:24 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (29 commits) scsi: reject configurations with logical block size > physical block size qdev: defer DEVICE_DEL event until instance_finalize() Revert "qdev: Free QemuOpts when the QOM path goes away" qdev: store DeviceState's canonical path to use when unparenting qemu-pr-helper: use new libmultipath API watch_mem_write: implement 8-byte accesses notdirty_mem_write: implement 8-byte accesses memory: reuse section_from_flat_range() kvm: simplify kvm_align_section() kvm: region_add and region_del is not called on updates kvm: fix error message when failing to unregister slot kvm: tolerate non-existing slot for log_start/log_stop/log_sync kvm: fix alignment of ram address memory: call log_start after region_add target/i386: trap on instructions longer than >15 bytes target/i386: introduce x86_ld*_code tco: add trace events docs/devel/loads-stores.rst: Document our various load and store APIs nios2: define tcg_env build: remove CONFIG_LIBDECNUMBER ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'accel')
-rw-r--r--accel/kvm/kvm-all.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 90c88b517d..f290f487a5 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -197,26 +197,20 @@ static hwaddr kvm_align_section(MemoryRegionSection *section,
hwaddr *start)
{
hwaddr size = int128_get64(section->size);
- hwaddr delta;
-
- *start = section->offset_within_address_space;
+ hwaddr delta, aligned;
/* kvm works in page size chunks, but the function may be called
with sub-page size and unaligned start address. Pad the start
address to next and truncate size to previous page boundary. */
- delta = qemu_real_host_page_size - (*start & ~qemu_real_host_page_mask);
- delta &= ~qemu_real_host_page_mask;
- *start += delta;
+ aligned = ROUND_UP(section->offset_within_address_space,
+ qemu_real_host_page_size);
+ delta = aligned - section->offset_within_address_space;
+ *start = aligned;
if (delta > size) {
return 0;
}
- size -= delta;
- size &= qemu_real_host_page_mask;
- if (*start & ~qemu_real_host_page_mask) {
- return 0;
- }
- return size;
+ return (size - delta) & qemu_real_host_page_mask;
}
int kvm_physical_memory_addr_from_host(KVMState *s, void *ram,
@@ -394,8 +388,8 @@ static int kvm_section_update_flags(KVMMemoryListener *kml,
mem = kvm_lookup_matching_slot(kml, start_addr, size);
if (!mem) {
- fprintf(stderr, "%s: error finding slot\n", __func__);
- abort();
+ /* We don't have a slot if we want to trap every access. */
+ return 0;
}
return kvm_slot_update_flags(kml, mem, section->mr);
@@ -470,8 +464,8 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
if (size) {
mem = kvm_lookup_matching_slot(kml, start_addr, size);
if (!mem) {
- fprintf(stderr, "%s: error finding slot\n", __func__);
- abort();
+ /* We don't have a slot if we want to trap every access. */
+ return 0;
}
/* XXX bad kernel interface alert
@@ -717,11 +711,12 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
return;
}
+ /* use aligned delta to align the ram address */
ram = memory_region_get_ram_ptr(mr) + section->offset_within_region +
- (section->offset_within_address_space - start_addr);
+ (start_addr - section->offset_within_address_space);
- mem = kvm_lookup_matching_slot(kml, start_addr, size);
if (!add) {
+ mem = kvm_lookup_matching_slot(kml, start_addr, size);
if (!mem) {
return;
}
@@ -733,19 +728,13 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
mem->memory_size = 0;
err = kvm_set_user_memory_region(kml, mem);
if (err) {
- fprintf(stderr, "%s: error unregistering overlapping slot: %s\n",
+ fprintf(stderr, "%s: error unregistering slot: %s\n",
__func__, strerror(-err));
abort();
}
return;
}
- if (mem) {
- /* update the slot */
- kvm_slot_update_flags(kml, mem, mr);
- return;
- }
-
/* register the new slot */
mem = kvm_alloc_slot(kml);
mem->memory_size = size;