diff options
-rw-r--r-- | exec.c | 4 | ||||
-rw-r--r-- | kvm-all.c | 18 | ||||
-rw-r--r-- | kvm.h | 2 |
3 files changed, 24 insertions, 0 deletions
@@ -2386,6 +2386,10 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) } addr = phys_ram_alloc_offset; phys_ram_alloc_offset = TARGET_PAGE_ALIGN(phys_ram_alloc_offset + size); + + if (kvm_enabled()) + kvm_setup_guest_memory(phys_ram_base + addr, size); + return addr; } @@ -656,3 +656,21 @@ int kvm_has_sync_mmu(void) return 0; } + +void kvm_setup_guest_memory(void *start, size_t size) +{ + if (!kvm_has_sync_mmu()) { +#ifdef MADV_DONTFORK + int ret = madvise(start, size, MADV_DONTFORK); + + if (ret) { + perror("madvice"); + exit(1); + } +#else + fprintf(stderr, + "Need MADV_DONTFORK in absence of synchronous KVM MMU\n"); + exit(1); +#endif + } +} @@ -46,6 +46,8 @@ int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t len); int kvm_has_sync_mmu(void); +void kvm_setup_guest_memory(void *start, size_t size); + int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size); int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size); |