qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone
@ 2013-05-28 15:05 Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 1/7] target-i386: Fix mask of pte index in memory mapping Andreas Färber
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jens Freimann, Vincent Rabin, Qiao Nuohan, pbonzini,
	Andreas Färber

Hello,

This series is an alternative to patches previously queued or posted,
based on virgin master.

As requested by Paolo, this replaces Kate's previous memory_mapping split
and my follow-ups and instead goes directly for moving things to CPUState.

All knowledge about dump / memory mapping are moved away from configure.

Regards,
Andreas

v1 -> v2:
* Dropped Kate's memory_mapping split
* Dropped target_ulong cleanup and replaced with typedef
* Amended CPUArchState cleanups with introducing hooks in CPUClass
* Drop memory_memory stubs instead of moving them

Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Cc: Jens Freimann <jfrei@linux.vnet.ibm.com>
Cc: Vincent Rabin <rabin@rab.in>
Cc: Paolo Bonzini <pbonzini@redhat.com>

Andreas Färber (6):
  dump: Move stubs into libqemustub.a
  cpu: Turn cpu_paging_enabled() into a CPUState hook
  memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h
  cpu: Turn cpu_get_memory_mapping() into a CPUState hook
  memory_mapping: Drop qemu_get_memory_mapping() stub
  dump: Unconditionally compile

Qiao Nuohan (1):
  target-i386: Fix mask of pte index in memory mapping

 Makefile.target                   |  8 ++------
 configure                         |  8 --------
 hmp-commands.hx                   |  2 --
 include/qemu/typedefs.h           |  2 ++
 include/qom/cpu.h                 | 21 +++++++++++++++++++++
 include/sysemu/memory_mapping.h   |  8 +++-----
 memory_mapping-stub.c             | 33 ---------------------------------
 memory_mapping.c                  |  4 ++--
 qom/cpu.c                         | 27 +++++++++++++++++++++++++++
 stubs/Makefile.objs               |  1 +
 dump-stub.c => stubs/dump.c       |  8 --------
 target-i386/arch_memory_mapping.c | 13 ++++++-------
 target-i386/cpu-qom.h             |  2 ++
 target-i386/cpu.c                 | 12 ++++++++++--
 14 files changed, 76 insertions(+), 73 deletions(-)
 delete mode 100644 memory_mapping-stub.c
 rename dump-stub.c => stubs/dump.c (65%)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 1/7] target-i386: Fix mask of pte index in memory mapping
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 2/7] dump: Move stubs into libqemustub.a Andreas Färber
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Qiao Nuohan, Andreas Färber

From: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>

Function walk_pte() needs pte index to calculate virtual address.
However, pte index of PAE paging or IA-32e paging is 9 bit, so the mask
should be 0x1ff.

Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Reviewed-by: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-i386/arch_memory_mapping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c
index 844893f..a2eb7e7 100644
--- a/target-i386/arch_memory_mapping.c
+++ b/target-i386/arch_memory_mapping.c
@@ -38,7 +38,7 @@ static void walk_pte(MemoryMappingList *list, hwaddr pte_start_addr,
             continue;
         }
 
-        start_vaddr = start_line_addr | ((i & 0x1fff) << 12);
+        start_vaddr = start_line_addr | ((i & 0x1ff) << 12);
         memory_mapping_list_add_merge_sorted(list, start_paddr,
                                              start_vaddr, 1 << 12);
     }
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 2/7] dump: Move stubs into libqemustub.a
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 1/7] target-i386: Fix mask of pte index in memory mapping Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 3/7] cpu: Turn cpu_paging_enabled() into a CPUState hook Andreas Färber
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Andreas Färber

This allows us to drop CONFIG_NO_CORE_DUMP with its indirect dependency
on CONFIG_HAVE_CORE_DUMP.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 Makefile.target             | 2 --
 stubs/Makefile.objs         | 1 +
 dump-stub.c => stubs/dump.c | 0
 3 files changed, 1 insertion(+), 2 deletions(-)
 rename dump-stub.c => stubs/dump.c (100%)

diff --git a/Makefile.target b/Makefile.target
index ce4391f..1cafb17 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -64,7 +64,6 @@ CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
 CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
 CONFIG_NO_GET_MEMORY_MAPPING = $(if $(subst n,,$(CONFIG_HAVE_GET_MEMORY_MAPPING)),n,y)
-CONFIG_NO_CORE_DUMP = $(if $(subst n,,$(CONFIG_HAVE_CORE_DUMP)),n,y)
 
 #########################################################
 # cpu emulator library
@@ -114,7 +113,6 @@ obj-y += memory.o savevm.o cputlb.o
 obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o
 obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o
 obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o
-obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o
 LIBS+=$(libs_softmmu)
 
 # xen support
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 03dff20..9b701b4 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -2,6 +2,7 @@ stub-obj-y += arch-query-cpu-def.o
 stub-obj-y += clock-warp.o
 stub-obj-y += cpu-get-clock.o
 stub-obj-y += cpu-get-icount.o
+stub-obj-y += dump.o
 stub-obj-y += fdset-add-fd.o
 stub-obj-y += fdset-find-fd.o
 stub-obj-y += fdset-get-fd.o
diff --git a/dump-stub.c b/stubs/dump.c
similarity index 100%
rename from dump-stub.c
rename to stubs/dump.c
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 3/7] cpu: Turn cpu_paging_enabled() into a CPUState hook
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 1/7] target-i386: Fix mask of pte index in memory mapping Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 2/7] dump: Move stubs into libqemustub.a Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 4/7] memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h Andreas Färber
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Andreas Färber

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qom/cpu.h                 | 10 ++++++++++
 include/sysemu/memory_mapping.h   |  1 -
 memory_mapping-stub.c             |  6 ------
 memory_mapping.c                  |  2 +-
 qom/cpu.c                         | 13 +++++++++++++
 target-i386/arch_memory_mapping.c |  6 +-----
 target-i386/cpu.c                 | 11 +++++++++--
 7 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 7cd9442..cf5fec2 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -48,6 +48,7 @@ typedef struct CPUState CPUState;
  * @reset: Callback to reset the #CPUState to its initial state.
  * @do_interrupt: Callback for interrupt handling.
  * @get_arch_id: Callback for getting architecture-dependent CPU ID.
+ * @get_paging_enabled: Callback for inquiring whether paging is enabled.
  * @vmsd: State description for migration.
  *
  * Represents a CPU family or model.
@@ -62,6 +63,7 @@ typedef struct CPUClass {
     void (*reset)(CPUState *cpu);
     void (*do_interrupt)(CPUState *cpu);
     int64_t (*get_arch_id)(CPUState *cpu);
+    bool (*get_paging_enabled)(CPUState *cpu);
 
     const struct VMStateDescription *vmsd;
     int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
@@ -138,6 +140,14 @@ struct CPUState {
 };
 
 /**
+ * cpu_paging_enabled:
+ * @cpu: The CPU whose state is to be inspected.
+ *
+ * Returns: %true if paging is enabled, %false otherwise.
+ */
+bool cpu_paging_enabled(CPUState *cpu);
+
+/**
  * cpu_write_elf64_note:
  * @f: pointer to a function that writes memory to a file
  * @cpu: The CPU whose memory is to be dumped
diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
index 1256125..6f01524 100644
--- a/include/sysemu/memory_mapping.h
+++ b/include/sysemu/memory_mapping.h
@@ -31,7 +31,6 @@ typedef struct MemoryMappingList {
 } MemoryMappingList;
 
 int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
-bool cpu_paging_enabled(CPUArchState *env);
 
 /*
  * add or merge the memory region [phys_addr, phys_addr + length) into the
diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c
index 24d5d67..6c0dfeb 100644
--- a/memory_mapping-stub.c
+++ b/memory_mapping-stub.c
@@ -25,9 +25,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list,
 {
     return -1;
 }
-
-bool cpu_paging_enabled(CPUArchState *env)
-{
-    return true;
-}
-
diff --git a/memory_mapping.c b/memory_mapping.c
index ff45b3a..0790aac 100644
--- a/memory_mapping.c
+++ b/memory_mapping.c
@@ -170,7 +170,7 @@ static CPUArchState *find_paging_enabled_cpu(CPUArchState *start_cpu)
     CPUArchState *env;
 
     for (env = start_cpu; env != NULL; env = env->next_cpu) {
-        if (cpu_paging_enabled(env)) {
+        if (cpu_paging_enabled(ENV_GET_CPU(env))) {
             return env;
         }
     }
diff --git a/qom/cpu.c b/qom/cpu.c
index 04aefbb..ea7e676 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -50,6 +50,18 @@ bool cpu_exists(int64_t id)
     return data.found;
 }
 
+bool cpu_paging_enabled(CPUState *cpu)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    return cc->get_paging_enabled(cpu);
+}
+
+static bool cpu_common_get_paging_enabled(CPUState *cpu)
+{
+    return true;
+}
+
 /* CPU hot-plug notifiers */
 static NotifierList cpu_added_notifiers =
     NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers);
@@ -176,6 +188,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
     k->class_by_name = cpu_common_class_by_name;
     k->reset = cpu_common_reset;
     k->get_arch_id = cpu_common_get_arch_id;
+    k->get_paging_enabled = cpu_common_get_paging_enabled;
     k->write_elf32_qemunote = cpu_common_write_elf32_qemunote;
     k->write_elf32_note = cpu_common_write_elf32_note;
     k->write_elf64_qemunote = cpu_common_write_elf64_qemunote;
diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c
index a2eb7e7..5102356 100644
--- a/target-i386/arch_memory_mapping.c
+++ b/target-i386/arch_memory_mapping.c
@@ -239,7 +239,7 @@ static void walk_pml4e(MemoryMappingList *list,
 
 int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env)
 {
-    if (!cpu_paging_enabled(env)) {
+    if (!cpu_paging_enabled(ENV_GET_CPU(env))) {
         /* paging is disabled */
         return 0;
     }
@@ -271,7 +271,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env)
     return 0;
 }
 
-bool cpu_paging_enabled(CPUArchState *env)
-{
-    return env->cr[0] & CR0_PG_MASK;
-}
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1a501d9..7364e3b 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2505,6 +2505,13 @@ static int64_t x86_cpu_get_arch_id(CPUState *cs)
     return env->cpuid_apic_id;
 }
 
+static bool x86_cpu_get_paging_enabled(CPUState *cs)
+{
+    X86CPU *cpu = X86_CPU(cs);
+
+    return cpu->env.cr[0] & CR0_PG_MASK;
+}
+
 static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 {
     X86CPUClass *xcc = X86_CPU_CLASS(oc);
@@ -2519,6 +2526,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->reset = x86_cpu_reset;
 
     cc->do_interrupt = x86_cpu_do_interrupt;
+    cc->get_arch_id = x86_cpu_get_arch_id;
+    cc->get_paging_enabled = x86_cpu_get_paging_enabled;
 #ifndef CONFIG_USER_ONLY
     cc->write_elf64_note = x86_cpu_write_elf64_note;
     cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
@@ -2526,8 +2535,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote;
 #endif
     cpu_class_set_vmsd(cc, &vmstate_x86_cpu);
-
-    cc->get_arch_id = x86_cpu_get_arch_id;
 }
 
 static const TypeInfo x86_cpu_type_info = {
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 4/7] memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
                   ` (2 preceding siblings ...)
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 3/7] cpu: Turn cpu_paging_enabled() into a CPUState hook Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 5/7] cpu: Turn cpu_get_memory_mapping() into a CPUState hook Andreas Färber
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Andreas Färber

This will avoid issues with hwaddr and ram_addr_t when including
sysemu/memory_mapping.h for CONFIG_USER_ONLY.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qemu/typedefs.h         | 2 ++
 include/sysemu/memory_mapping.h | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 93aae81..1218a61 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -22,6 +22,8 @@ typedef struct AddressSpace AddressSpace;
 typedef struct MemoryRegion MemoryRegion;
 typedef struct MemoryRegionSection MemoryRegionSection;
 
+typedef struct MemoryMappingList MemoryMappingList;
+
 typedef struct NICInfo NICInfo;
 typedef struct HCIInfo HCIInfo;
 typedef struct AudioState AudioState;
diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
index 6f01524..1f71c32 100644
--- a/include/sysemu/memory_mapping.h
+++ b/include/sysemu/memory_mapping.h
@@ -15,6 +15,7 @@
 #define MEMORY_MAPPING_H
 
 #include "qemu/queue.h"
+#include "qemu/typedefs.h"
 
 /* The physical and virtual address in the memory mapping are contiguous. */
 typedef struct MemoryMapping {
@@ -24,11 +25,11 @@ typedef struct MemoryMapping {
     QTAILQ_ENTRY(MemoryMapping) next;
 } MemoryMapping;
 
-typedef struct MemoryMappingList {
+struct MemoryMappingList {
     unsigned int num;
     MemoryMapping *last_mapping;
     QTAILQ_HEAD(, MemoryMapping) head;
-} MemoryMappingList;
+};
 
 int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 5/7] cpu: Turn cpu_get_memory_mapping() into a CPUState hook
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
                   ` (3 preceding siblings ...)
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 4/7] memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 6/7] memory_mapping: Drop qemu_get_memory_mapping() stub Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 7/7] dump: Unconditionally compile Andreas Färber
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Andreas Färber

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qom/cpu.h                 | 11 +++++++++++
 include/sysemu/memory_mapping.h   |  2 --
 memory_mapping-stub.c             |  6 ------
 memory_mapping.c                  |  2 +-
 qom/cpu.c                         | 14 ++++++++++++++
 target-i386/arch_memory_mapping.c |  7 +++++--
 target-i386/cpu-qom.h             |  2 ++
 target-i386/cpu.c                 |  1 +
 8 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index cf5fec2..93a4612 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -23,6 +23,7 @@
 #include <signal.h>
 #include "hw/qdev-core.h"
 #include "qemu/thread.h"
+#include "qemu/typedefs.h"
 
 typedef int (*WriteCoreDumpFunction)(void *buf, size_t size, void *opaque);
 
@@ -49,6 +50,7 @@ typedef struct CPUState CPUState;
  * @do_interrupt: Callback for interrupt handling.
  * @get_arch_id: Callback for getting architecture-dependent CPU ID.
  * @get_paging_enabled: Callback for inquiring whether paging is enabled.
+ * @get_memory_mapping: Callback for obtaining the memory mappings.
  * @vmsd: State description for migration.
  *
  * Represents a CPU family or model.
@@ -64,6 +66,7 @@ typedef struct CPUClass {
     void (*do_interrupt)(CPUState *cpu);
     int64_t (*get_arch_id)(CPUState *cpu);
     bool (*get_paging_enabled)(CPUState *cpu);
+    int (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list);
 
     const struct VMStateDescription *vmsd;
     int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
@@ -148,6 +151,14 @@ struct CPUState {
 bool cpu_paging_enabled(CPUState *cpu);
 
 /**
+ * @cpu: The CPU whose memory mappings are to be obtained.
+ * @list: Where to write the memory mappings to.
+ *
+ * Returns: 0 if successful.
+ */
+int cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list);
+
+/**
  * cpu_write_elf64_note:
  * @f: pointer to a function that writes memory to a file
  * @cpu: The CPU whose memory is to be dumped
diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
index 1f71c32..c47e6ee 100644
--- a/include/sysemu/memory_mapping.h
+++ b/include/sysemu/memory_mapping.h
@@ -31,8 +31,6 @@ struct MemoryMappingList {
     QTAILQ_HEAD(, MemoryMapping) head;
 };
 
-int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
-
 /*
  * add or merge the memory region [phys_addr, phys_addr + length) into the
  * memory mapping's list. The region's virtual address starts with virt_addr,
diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c
index 6c0dfeb..989dc00 100644
--- a/memory_mapping-stub.c
+++ b/memory_mapping-stub.c
@@ -19,9 +19,3 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
 {
     return -2;
 }
-
-int cpu_get_memory_mapping(MemoryMappingList *list,
-					                                          CPUArchState *env)
-{
-    return -1;
-}
diff --git a/memory_mapping.c b/memory_mapping.c
index 0790aac..481530a 100644
--- a/memory_mapping.c
+++ b/memory_mapping.c
@@ -188,7 +188,7 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
     first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
     if (first_paging_enabled_cpu) {
         for (env = first_paging_enabled_cpu; env != NULL; env = env->next_cpu) {
-            ret = cpu_get_memory_mapping(list, env);
+            ret = cpu_get_memory_mapping(ENV_GET_CPU(env), list);
             if (ret < 0) {
                 return -1;
             }
diff --git a/qom/cpu.c b/qom/cpu.c
index ea7e676..e7e1c25 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -62,6 +62,19 @@ static bool cpu_common_get_paging_enabled(CPUState *cpu)
     return true;
 }
 
+int cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    return cc->get_memory_mapping(cpu, list);
+}
+
+static int cpu_common_get_memory_mapping(CPUState *cpu,
+                                         MemoryMappingList *list)
+{
+    return -1;
+}
+
 /* CPU hot-plug notifiers */
 static NotifierList cpu_added_notifiers =
     NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers);
@@ -189,6 +202,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
     k->reset = cpu_common_reset;
     k->get_arch_id = cpu_common_get_arch_id;
     k->get_paging_enabled = cpu_common_get_paging_enabled;
+    k->get_memory_mapping = cpu_common_get_memory_mapping;
     k->write_elf32_qemunote = cpu_common_write_elf32_qemunote;
     k->write_elf32_note = cpu_common_write_elf32_note;
     k->write_elf64_qemunote = cpu_common_write_elf64_qemunote;
diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c
index 5102356..244ab1e 100644
--- a/target-i386/arch_memory_mapping.c
+++ b/target-i386/arch_memory_mapping.c
@@ -237,9 +237,12 @@ static void walk_pml4e(MemoryMappingList *list,
 }
 #endif
 
-int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env)
+int x86_cpu_get_memory_mapping(CPUState *cs, MemoryMappingList *list)
 {
-    if (!cpu_paging_enabled(ENV_GET_CPU(env))) {
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+
+    if (!cpu_paging_enabled(cs)) {
         /* paging is disabled */
         return 0;
     }
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 849cedf..11a4b10 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -98,4 +98,6 @@ int x86_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
 int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
                                  void *opaque);
 
+int x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list);
+
 #endif
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7364e3b..1303892 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2529,6 +2529,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->get_arch_id = x86_cpu_get_arch_id;
     cc->get_paging_enabled = x86_cpu_get_paging_enabled;
 #ifndef CONFIG_USER_ONLY
+    cc->get_memory_mapping = x86_cpu_get_memory_mapping;
     cc->write_elf64_note = x86_cpu_write_elf64_note;
     cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
     cc->write_elf32_note = x86_cpu_write_elf32_note;
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 6/7] memory_mapping: Drop qemu_get_memory_mapping() stub
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
                   ` (4 preceding siblings ...)
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 5/7] cpu: Turn cpu_get_memory_mapping() into a CPUState hook Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 7/7] dump: Unconditionally compile Andreas Färber
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Andreas Färber

dump.c:dump_init() never checked for the return code anyway.
If paging is not enabled, it will fall back to an identity map.
If paging is enabled and getting memory mapping list is not
implemented, qemu_get_guest_memory_mapping() will return an error.

Since the targets not implementing memory mapping also don't implement
dump support, we will not reach this code today and can worry about
changing cpu_paging_enabled() default when the need arises.

This allows us to drop CONFIG_HAVE_GET_MEMORY_SUPPORT and thereby keep
configure out of the picture.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 Makefile.target       |  4 +---
 configure             |  4 ----
 memory_mapping-stub.c | 21 ---------------------
 3 files changed, 1 insertion(+), 28 deletions(-)
 delete mode 100644 memory_mapping-stub.c

diff --git a/Makefile.target b/Makefile.target
index 1cafb17..f9e1d89 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -63,7 +63,6 @@ all: $(PROGS) stap
 CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
 CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
-CONFIG_NO_GET_MEMORY_MAPPING = $(if $(subst n,,$(CONFIG_HAVE_GET_MEMORY_MAPPING)),n,y)
 
 #########################################################
 # cpu emulator library
@@ -110,9 +109,8 @@ obj-y += hw/
 obj-$(CONFIG_FDT) += device_tree.o
 obj-$(CONFIG_KVM) += kvm-all.o
 obj-y += memory.o savevm.o cputlb.o
-obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o
+obj-y += memory_mapping.o
 obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o
-obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o
 LIBS+=$(libs_softmmu)
 
 # xen support
diff --git a/configure b/configure
index 5ae7e4a..727a958 100755
--- a/configure
+++ b/configure
@@ -4340,10 +4340,6 @@ case "$target_arch2" in
       fi
     fi
 esac
-case "$target_arch2" in
-  i386|x86_64)
-    echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
-esac
 if test "$target_bigendian" = "yes" ; then
   echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
 fi
diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c
deleted file mode 100644
index 989dc00..0000000
--- a/memory_mapping-stub.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * QEMU memory mapping
- *
- * Copyright Fujitsu, Corp. 2011, 2012
- *
- * Authors:
- *     Wen Congyang <wency@cn.fujitsu.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "cpu.h"
-#include "exec/cpu-all.h"
-#include "sysemu/memory_mapping.h"
-
-int qemu_get_guest_memory_mapping(MemoryMappingList *list)
-{
-    return -2;
-}
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH qom-cpu v2 7/7] dump: Unconditionally compile
  2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
                   ` (5 preceding siblings ...)
  2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 6/7] memory_mapping: Drop qemu_get_memory_mapping() stub Andreas Färber
@ 2013-05-28 15:05 ` Andreas Färber
  6 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-05-28 15:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Andreas Färber

qmp_dump_guest_memory() calls dump_init() and returns an Error when
cpu_get_dump_info() returns an error, as done by the stub.
So there is no need to have a stub for qmp_dump_guest_memory().

Enable the documentation of the always-present dump-guest-memory command.

That way we can drop CONFIG_HAVE_CORE_DUMP.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 Makefile.target | 2 +-
 configure       | 4 ----
 hmp-commands.hx | 2 --
 stubs/dump.c    | 8 --------
 4 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index f9e1d89..b0be124 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -110,7 +110,7 @@ obj-$(CONFIG_FDT) += device_tree.o
 obj-$(CONFIG_KVM) += kvm-all.o
 obj-y += memory.o savevm.o cputlb.o
 obj-y += memory_mapping.o
-obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o
+obj-y += dump.o
 LIBS+=$(libs_softmmu)
 
 # xen support
diff --git a/configure b/configure
index 727a958..a838294 100755
--- a/configure
+++ b/configure
@@ -4345,10 +4345,6 @@ if test "$target_bigendian" = "yes" ; then
 fi
 if test "$target_softmmu" = "yes" ; then
   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
-  case "$target_arch2" in
-    i386|x86_64)
-      echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
-  esac
 fi
 if test "$target_user_only" = "yes" ; then
   echo "CONFIG_USER_ONLY=y" >> $config_target_mak
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 9cea415..074dbe1 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -989,7 +989,6 @@ server will ask the spice/vnc client to automatically reconnect using the
 new parameters (if specified) once the vm migration finished successfully.
 ETEXI
 
-#if defined(CONFIG_HAVE_CORE_DUMP)
     {
         .name       = "dump-guest-memory",
         .args_type  = "paging:-p,filename:F,begin:i?,length:i?",
@@ -1013,7 +1012,6 @@ gdb.
     length: the memory size, in bytes. It's optional, and should be specified
             with begin together.
 ETEXI
-#endif
 
     {
         .name       = "snapshot_blkdev",
diff --git a/stubs/dump.c b/stubs/dump.c
index b3f42cb..43c9a3f 100644
--- a/stubs/dump.c
+++ b/stubs/dump.c
@@ -16,14 +16,6 @@
 #include "qapi/qmp/qerror.h"
 #include "qmp-commands.h"
 
-/* we need this function in hmp.c */
-void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
-                           int64_t begin, bool has_length, int64_t length,
-                           Error **errp)
-{
-    error_set(errp, QERR_UNSUPPORTED);
-}
-
 int cpu_get_dump_info(ArchDumpInfo *info)
 {
     return -1;
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-28 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-28 15:05 [Qemu-devel] [PATCH qom-cpu v2 0/7] dump: Build cleanups redone Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 1/7] target-i386: Fix mask of pte index in memory mapping Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 2/7] dump: Move stubs into libqemustub.a Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 3/7] cpu: Turn cpu_paging_enabled() into a CPUState hook Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 4/7] memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 5/7] cpu: Turn cpu_get_memory_mapping() into a CPUState hook Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 6/7] memory_mapping: Drop qemu_get_memory_mapping() stub Andreas Färber
2013-05-28 15:05 ` [Qemu-devel] [PATCH qom-cpu v2 7/7] dump: Unconditionally compile Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).