From 91138037cb341a04a66e4c43b6cb31d5d8a43a73 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 31 Jul 2013 15:11:08 +0200 Subject: exec: Simplify the guest physical memory allocation hook Make it a generic hook rather than a KVM hook. Less code and ifdeffery. Since the only user of the hook is old S390 KVM, there's hope we can get rid of it some day. Acked-by: Christian Borntraeger Signed-off-by: Markus Armbruster Acked-by: Laszlo Ersek Acked-by: Stefano Stabellini Message-id: 1375276272-15988-5-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori --- exec.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 0a6dd2e..a3dfd1d 100644 --- a/exec.c +++ b/exec.c @@ -749,6 +749,18 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, uint16_t section); static subpage_t *subpage_init(AddressSpace *as, hwaddr base); +static void *(*phys_mem_alloc)(ram_addr_t size) = qemu_anon_ram_alloc; + +/* + * Set a custom physical guest memory alloator. + * Accelerators with unusual needs may need this. Hopefully, we can + * get rid of it eventually. + */ +void phys_mem_set_alloc(void *(*alloc)(ram_addr_t)) +{ + phys_mem_alloc = alloc; +} + static uint16_t phys_section_add(MemoryRegionSection *section) { /* The physical section number is ORed with a page-aligned @@ -1124,12 +1136,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, #endif } if (!new_block->host) { - if (kvm_enabled()) { - /* some s390/kvm configurations have special constraints */ - new_block->host = kvm_ram_alloc(size); - } else { - new_block->host = qemu_anon_ram_alloc(size); - } + new_block->host = phys_mem_alloc(size); memory_try_enable_merging(new_block->host, size); } } -- cgit v1.1