mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 19:49:43 +00:00
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 <borntraeger@de.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Message-id: 1375276272-15988-5-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
This commit is contained in:
parent
3435f39513
commit
91138037cb
19
exec.c
19
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);
|
||||
}
|
||||
}
|
||||
|
@ -368,6 +368,8 @@ static inline uintptr_t tcg_getra_ext(uintptr_t ra)
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
|
||||
void phys_mem_set_alloc(void *(*alloc)(ram_addr_t));
|
||||
|
||||
struct MemoryRegion *iotlb_to_region(hwaddr index);
|
||||
bool io_mem_read(struct MemoryRegion *mr, hwaddr addr,
|
||||
uint64_t *pvalue, unsigned size);
|
||||
|
@ -161,11 +161,6 @@ int kvm_cpu_exec(CPUState *cpu);
|
||||
|
||||
#ifdef NEED_CPU_H
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
void *kvm_ram_alloc(ram_addr_t size);
|
||||
void *kvm_arch_ram_alloc(ram_addr_t size);
|
||||
#endif
|
||||
|
||||
void kvm_setup_guest_memory(void *start, size_t size);
|
||||
void kvm_flush_coalesced_mmio_buffer(void);
|
||||
|
||||
|
13
kvm-all.c
13
kvm-all.c
@ -1812,19 +1812,6 @@ int kvm_has_intx_set_mask(void)
|
||||
return kvm_state->intx_set_mask;
|
||||
}
|
||||
|
||||
void *kvm_ram_alloc(ram_addr_t size)
|
||||
{
|
||||
#ifdef TARGET_S390X
|
||||
void *mem;
|
||||
|
||||
mem = kvm_arch_ram_alloc(size);
|
||||
if (mem) {
|
||||
return mem;
|
||||
}
|
||||
#endif
|
||||
return qemu_anon_ram_alloc(size);
|
||||
}
|
||||
|
||||
void kvm_setup_guest_memory(void *start, size_t size)
|
||||
{
|
||||
#ifdef CONFIG_VALGRIND_H
|
||||
|
@ -93,9 +93,15 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
||||
|
||||
static int cap_sync_regs;
|
||||
|
||||
static void *legacy_s390_alloc(ram_addr_t size);
|
||||
|
||||
int kvm_arch_init(KVMState *s)
|
||||
{
|
||||
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
|
||||
if (!kvm_check_extension(s, KVM_CAP_S390_GMAP)
|
||||
|| !kvm_check_extension(s, KVM_CAP_S390_COW)) {
|
||||
phys_mem_set_alloc(legacy_s390_alloc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -333,17 +339,6 @@ static void *legacy_s390_alloc(ram_addr_t size)
|
||||
return mem;
|
||||
}
|
||||
|
||||
void *kvm_arch_ram_alloc(ram_addr_t size)
|
||||
{
|
||||
/* Can we use the standard allocation ? */
|
||||
if (kvm_check_extension(kvm_state, KVM_CAP_S390_GMAP) &&
|
||||
kvm_check_extension(kvm_state, KVM_CAP_S390_COW)) {
|
||||
return NULL;
|
||||
} else {
|
||||
return legacy_s390_alloc(size);
|
||||
}
|
||||
}
|
||||
|
||||
int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
|
||||
{
|
||||
static const uint8_t diag_501[] = {0x83, 0x24, 0x05, 0x01};
|
||||
|
Loading…
Reference in New Issue
Block a user