|
|
9ae3a8 |
From b84b9552e5d474f237824a33e7211dfac8d2de60 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 18 Sep 2013 09:31:05 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 21/29] exec: Simplify the guest physical memory allocation hook
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1379496669-22778-5-git-send-email-armbru@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54424
|
|
|
9ae3a8 |
O-Subject: [PATCH 7.0 qemu-kvm 4/8] exec: Simplify the guest physical memory allocation hook
|
|
|
9ae3a8 |
Bugzilla: 1009328
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Make it a generic hook rather than a KVM hook. Less code and
|
|
|
9ae3a8 |
ifdeffery.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Since the only user of the hook is old S390 KVM, there's hope we can
|
|
|
9ae3a8 |
get rid of it some day.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
|
|
|
9ae3a8 |
Message-id: 1375276272-15988-5-git-send-email-armbru@redhat.com
|
|
|
9ae3a8 |
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
|
|
|
9ae3a8 |
(cherry picked from commit 91138037cb341a04a66e4c43b6cb31d5d8a43a73)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
exec.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Trivial conflict because we don't have upstream commits acc9d80 and
|
|
|
9ae3a8 |
058bc4b.
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
exec.c | 20 ++++++++++++++------
|
|
|
9ae3a8 |
include/exec/exec-all.h | 2 ++
|
|
|
9ae3a8 |
include/sysemu/kvm.h | 5 -----
|
|
|
9ae3a8 |
kvm-all.c | 13 -------------
|
|
|
9ae3a8 |
target-s390x/kvm.c | 17 ++++++-----------
|
|
|
9ae3a8 |
5 files changed, 22 insertions(+), 35 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
exec.c | 20 ++++++++++++++------
|
|
|
9ae3a8 |
include/exec/exec-all.h | 2 ++
|
|
|
9ae3a8 |
include/sysemu/kvm.h | 5 -----
|
|
|
9ae3a8 |
kvm-all.c | 13 -------------
|
|
|
9ae3a8 |
target-s390x/kvm.c | 17 ++++++-----------
|
|
|
9ae3a8 |
5 files changed, 22 insertions(+), 35 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/exec.c b/exec.c
|
|
|
9ae3a8 |
index 32ed61c..42a0005 100644
|
|
|
9ae3a8 |
--- a/exec.c
|
|
|
9ae3a8 |
+++ b/exec.c
|
|
|
9ae3a8 |
@@ -679,6 +679,19 @@ typedef struct subpage_t {
|
|
|
9ae3a8 |
static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
|
|
|
9ae3a8 |
uint16_t section);
|
|
|
9ae3a8 |
static subpage_t *subpage_init(hwaddr base);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static void *(*phys_mem_alloc)(ram_addr_t size) = qemu_anon_ram_alloc;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+/*
|
|
|
9ae3a8 |
+ * Set a custom physical guest memory alloator.
|
|
|
9ae3a8 |
+ * Accelerators with unusual needs may need this. Hopefully, we can
|
|
|
9ae3a8 |
+ * get rid of it eventually.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+void phys_mem_set_alloc(void *(*alloc)(ram_addr_t))
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ phys_mem_alloc = alloc;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void destroy_page_desc(uint16_t section_index)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
MemoryRegionSection *section = &phys_sections[section_index];
|
|
|
9ae3a8 |
@@ -1070,12 +1083,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (!new_block->host) {
|
|
|
9ae3a8 |
- if (kvm_enabled()) {
|
|
|
9ae3a8 |
- /* some s390/kvm configurations have special constraints */
|
|
|
9ae3a8 |
- new_block->host = kvm_ram_alloc(size);
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- new_block->host = qemu_anon_ram_alloc(size);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ new_block->host = phys_mem_alloc(size);
|
|
|
9ae3a8 |
memory_try_enable_merging(new_block->host, size);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
|
|
|
9ae3a8 |
index 6362074..993c655 100644
|
|
|
9ae3a8 |
--- a/include/exec/exec-all.h
|
|
|
9ae3a8 |
+++ b/include/exec/exec-all.h
|
|
|
9ae3a8 |
@@ -366,6 +366,8 @@ bool is_tcg_gen_code(uintptr_t pc_ptr);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#if !defined(CONFIG_USER_ONLY)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void phys_mem_set_alloc(void *(*alloc)(ram_addr_t));
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
struct MemoryRegion *iotlb_to_region(hwaddr index);
|
|
|
9ae3a8 |
uint64_t io_mem_read(struct MemoryRegion *mr, hwaddr addr,
|
|
|
9ae3a8 |
unsigned size);
|
|
|
9ae3a8 |
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
|
9ae3a8 |
index 08284ef..7fc3844 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/kvm.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/kvm.h
|
|
|
9ae3a8 |
@@ -141,11 +141,6 @@ int kvm_init_vcpu(CPUState *cpu);
|
|
|
9ae3a8 |
#ifdef NEED_CPU_H
|
|
|
9ae3a8 |
int kvm_cpu_exec(CPUArchState *env);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#if !defined(CONFIG_USER_ONLY)
|
|
|
9ae3a8 |
-void *kvm_ram_alloc(ram_addr_t size);
|
|
|
9ae3a8 |
-void *kvm_arch_ram_alloc(ram_addr_t size);
|
|
|
9ae3a8 |
-#endif
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
void kvm_setup_guest_memory(void *start, size_t size);
|
|
|
9ae3a8 |
void kvm_flush_coalesced_mmio_buffer(void);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/kvm-all.c b/kvm-all.c
|
|
|
9ae3a8 |
index 545b470..d0a7c21 100644
|
|
|
9ae3a8 |
--- a/kvm-all.c
|
|
|
9ae3a8 |
+++ b/kvm-all.c
|
|
|
9ae3a8 |
@@ -1794,19 +1794,6 @@ int kvm_has_intx_set_mask(void)
|
|
|
9ae3a8 |
return kvm_state->intx_set_mask;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-void *kvm_ram_alloc(ram_addr_t size)
|
|
|
9ae3a8 |
-{
|
|
|
9ae3a8 |
-#ifdef TARGET_S390X
|
|
|
9ae3a8 |
- void *mem;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- mem = kvm_arch_ram_alloc(size);
|
|
|
9ae3a8 |
- if (mem) {
|
|
|
9ae3a8 |
- return mem;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-#endif
|
|
|
9ae3a8 |
- return qemu_anon_ram_alloc(size);
|
|
|
9ae3a8 |
-}
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
void kvm_setup_guest_memory(void *start, size_t size)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
#ifdef CONFIG_VALGRIND_H
|
|
|
9ae3a8 |
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
|
|
|
9ae3a8 |
index 862fb12..0b18db4 100644
|
|
|
9ae3a8 |
--- a/target-s390x/kvm.c
|
|
|
9ae3a8 |
+++ b/target-s390x/kvm.c
|
|
|
9ae3a8 |
@@ -92,9 +92,15 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int cap_sync_regs;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static void *legacy_s390_alloc(ram_addr_t size);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
int kvm_arch_init(KVMState *s)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
|
|
|
9ae3a8 |
+ if (!kvm_check_extension(s, KVM_CAP_S390_GMAP)
|
|
|
9ae3a8 |
+ || !kvm_check_extension(s, KVM_CAP_S390_COW)) {
|
|
|
9ae3a8 |
+ phys_mem_set_alloc(legacy_s390_alloc);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -332,17 +338,6 @@ static void *legacy_s390_alloc(ram_addr_t size)
|
|
|
9ae3a8 |
return mem;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-void *kvm_arch_ram_alloc(ram_addr_t size)
|
|
|
9ae3a8 |
-{
|
|
|
9ae3a8 |
- /* Can we use the standard allocation ? */
|
|
|
9ae3a8 |
- if (kvm_check_extension(kvm_state, KVM_CAP_S390_GMAP) &&
|
|
|
9ae3a8 |
- kvm_check_extension(kvm_state, KVM_CAP_S390_COW)) {
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- return legacy_s390_alloc(size);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-}
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
S390CPU *cpu = S390_CPU(cs);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|