memory_mapping: Clean up stubs
PATCH 1/4 memory_mapping: Use hwaddr type for MemoryMapping virt_addr field
In reply to Andreas FärberThe memory mapping API uses hwaddr, so use it in the struct, too. This avoids a header dependency on target_ulong type.
--- include/sysemu/memory_mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/memory_mapping.h +1 -1
@@ -19,7 +19,7 @@/* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping {hwaddr phys_addr; -target_ulong virt_addr; +hwaddr virt_addr;ram_addr_t length;QTAILQ_ENTRY (MemoryMapping) next; }MemoryMapping ;
Signature · 1 line
1.8.1.4
cover memory_mapping: Clean up stubs
Hello,
This mini-series cleans up the remaining guest-memory-dump related -stub.c file in making it compile-once.
The next step would then be to turn some of the per-target functions into CPUState hooks.
Regards,
Andreas
Andreas Färber (4):
memory_mapping: Use hwaddr type for MemoryMapping virt_addr field
memory_mapping: Change cpu_get_memory_mapping() argument to CPUState
memory_mapping: Change cpu_paging_enabled() argument to CPUState
memory_mapping: Move stubs to libqemustub.a
Makefile.target | 2 -- include/sysemu/memory_mapping.h | 6 +++--- memory_mapping.c | 4 ++-- stubs/Makefile.objs | 1 + memory_mapping-stub.c => stubs/memory_mapping.c | 5 +++-- target-i386/arch_memory_mapping.c | 12 +++++++++--- 6 files changed, 18 insertions(+), 12 deletions(-) rename memory_mapping-stub.c => stubs/memory_mapping.c (85%)
Signature · 1 line
1.8.1.4
PATCH 2/4 memory_mapping: Change cpu_get_memory_mapping() argument to CPUState
Eliminates an occurrence of CPUArchState from sysemu/memory_mapping.h.
--- include/sysemu/memory_mapping.h | 2 +- memory_mapping.c | 2 +- target-i386/arch_memory_mapping.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-)
include/sysemu/memory_mapping.h +1 -1
@@ -30,7 +30,7 @@ typedef struct MemoryMappingList { QTAILQ_HEAD(, MemoryMapping) head; } MemoryMappingList; -int cpu_get_memory_mapping (MemoryMappingList *list,CPUArchState *env); +int cpu_get_memory_mapping (MemoryMappingList *list,CPUState *cpu);bool cpu_paging_enabled (CPUArchState *env);/*
memory_mapping.c +1 -1
@@ -138,7 +138,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 (list,ENV_GET_CPU (env));if (ret <0 ) {return -1 ; }
target-i386/arch_memory_mapping.c +4 -1
@@ -237,8 +237,11 @@ static void walk_pml4e(MemoryMappingList *list, }#endif -int cpu_get_memory_mapping (MemoryMappingList *list,CPUArchState *env) +int cpu_get_memory_mapping (MemoryMappingList *list,CPUState *cs) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; +if (!cpu_paging_enabled (env)) {/* paging is disabled */ return 0 ;
Signature · 1 line
1.8.1.4
PATCH 3/4 memory_mapping: Change cpu_paging_enabled() argument to CPUState
In reply to Andreas FärberRemoves the last occurrence of CPUArchState from sysemu/memory_mapping.h.
--- include/sysemu/memory_mapping.h | 2 +- memory_mapping.c | 2 +- target-i386/arch_memory_mapping.c | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-)
include/sysemu/memory_mapping.h +1 -1
@@ -31,7 +31,7 @@ typedef struct MemoryMappingList { } MemoryMappingList;int cpu_get_memory_mapping (MemoryMappingList *list,CPUState *cpu); -bool cpu_paging_enabled (CPUArchState *env); +bool cpu_paging_enabled (CPUState *cpu);/* * add or merge the memory region [phys_addr, phys_addr + length) into the
memory_mapping.c +1 -1
@@ -120,7 +120,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; } }
target-i386/arch_memory_mapping.c +5 -2
@@ -242,7 +242,7 @@ int cpu_get_memory_mapping(MemoryMappingList *list, CPUState *cs)X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env; -if (!cpu_paging_enabled (env)) { +if (!cpu_paging_enabled (cs)) {/* paging is disabled */ return 0 ; }
@@ -274,7 +274,10 @@ int cpu_get_memory_mapping(MemoryMappingList *list, CPUState *cs)return 0 ; } -bool cpu_paging_enabled (CPUArchState *env) +bool cpu_paging_enabled (CPUState *cs) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; +return env->cr[0 ] &CR0_PG_MASK ; }
Signature · 1 line
1.8.1.4
PATCH 4/4 memory_mapping: Move stubs to libqemustub.a
In reply to Andreas FärberAllows us to drop CONFIG_NO_GET_MEMORY_MAPPING with its indirect dependency on CONFIG_HAVE_GET_MEMORY_MAPPING in Makefile.target.
--- Makefile.target | 2 -- stubs/Makefile.objs | 1 + memory_mapping-stub.c => stubs/memory_mapping.c | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename memory_mapping-stub.c => stubs/memory_mapping.c (85%)
Makefile.target +0 -2
@@ -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
@@ -112,7 +111,6 @@ 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 += dump.o memory_mapping_common.o -obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o LIBS+=$(libs_softmmu) # xen support
stubs/Makefile.objs +1 -0
@@ -10,6 +10,7 @@ stub-obj-y += fdset-remove-fd.o stub-obj-y += get-fd.o stub-obj-y += get-vm-name.o stub-obj-y += iothread-lock.o +stub-obj-y += memory_mapping.o stub-obj-y += migr-blocker.o stub-obj-y += mon-is-qmp.o stub-obj-y += mon-printf.o
stubs/memory_mapping.c renamed from memory_mapping-stub.c +3 -2
@@ -11,8 +11,9 @@* */ -#include "cpu.h" -#include "exec/cpu-all.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" +#include "qom/cpu.h" #include "sysemu/memory_mapping.h" int qemu_get_guest_memory_mapping (MemoryMappingList *list)
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-cpu 4/4] memory_mapping: Move stubs to libqemustub.a
Il 22/05/2013 15:09, Andreas Färber ha scritto:
Quoted 53 lines
Allows us to drop
CONFIG_NO_GET_MEMORY_MAPPINGwith its indirect dependency onCONFIG_HAVE_GET_MEMORY_MAPPINGin Makefile.target.Signed-off-by Andreas Färber <[email protected]>--- Makefile.target | 2 -- stubs/Makefile.objs | 1 + memory_mapping-stub.c => stubs/memory_mapping.c | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename memory_mapping-stub.c => stubs/memory_mapping.c (85%)Makefile.target +0
-2@@ -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@@ -112,7 +111,6 @@ 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 += dump.o memory_mapping_common.o -obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o LIBS+=$(libs_softmmu) # xen supportstubs/Makefile.objs +1
-0@@ -10,6 +10,7 @@ stub-obj-y += fdset-remove-fd.o stub-obj-y += get-fd.o stub-obj-y += get-vm-name.o stub-obj-y += iothread-lock.o +stub-obj-y += memory_mapping.o stub-obj-y += migr-blocker.o stub-obj-y += mon-is-qmp.o stub-obj-y += mon-printf.ostubs/memory_mapping.c renamed from memory_mapping-stub.c +0
-0@@ -11,8 +11,9 @@*
stubs/memory_mapping.c line 19
Quoted 10 lines
stubs/memory_mapping.c renamed from memory_mapping-stub.c +3
-2*/ -#include "cpu.h" -#include "exec/cpu-all.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" +#include "qom/cpu.h" #include "sysemu/memory_mapping.h" int qemu_get_guest_memory_mapping (MemoryMappingList *list)
Patches 1-3 are fine. But I wonder if a better replacement for stubs is methods in CPU.
Paolo
Re: [Qemu-devel] [PATCH qom-cpu 4/4] memory_mapping: Move stubs to libqemustub.a
Am 23.05.2013 12:08, schrieb Paolo Bonzini:
Quoted 11 lines
Il 22/05/2013 15:09, Andreas Färber ha scritto:
Quoted 10 lines
Allows us to drop
CONFIG_NO_GET_MEMORY_MAPPINGwith its indirect dependency onCONFIG_HAVE_GET_MEMORY_MAPPINGin Makefile.target.Signed-off-by Andreas Färber <[email protected]>--- Makefile.target | 2 -- stubs/Makefile.objs | 1 + memory_mapping-stub.c => stubs/memory_mapping.c | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename memory_mapping-stub.c => stubs/memory_mapping.c (85%)
[...]
Quoted 18 lines
Quoted 18 lines
stubs/memory_mapping.c renamed from memory_mapping-stub.c +3
-2@@ -11,8 +11,9 @@* */ -#include "cpu.h" -#include "exec/cpu-all.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" +#include "qom/cpu.h" #include "sysemu/memory_mapping.h"
Quoted 4 lines
stubs/memory_mapping.c line 19
Quoted 2 lines
stubs/memory_mapping.c renamed from memory_mapping-stub.c +0
-0int qemu_get_guest_memory_mapping (MemoryMappingList *list)Patches 1-3 are fine.
Thanks.
Quoted 2 lines
But I wonder if a better replacement for stubs is
methods in CPU.
None of the functions I have moved from *-stub.c to stubs/ operate on a single CPU, so now that the conflict with the kdump format support has been resolved I'd like to move them as a step towards dropping per-target configure changes for guest-memory-dump support.
With my note in the cover letter I was rather referring to cpu_paging_enabled(), which is mandatory currently without any stub.
Do you have a concrete suggestion what else to do for these stubs?
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH qom-cpu 4/4] memory_mapping: Move stubs to libqemustub.a
Il 28/05/2013 11:39, Andreas Färber ha scritto:
Quoted 36 lines
Am 23.05.2013 12:08, schrieb Paolo Bonzini:
Quoted 11 lines
Il 22/05/2013 15:09, Andreas Färber ha scritto:
Quoted 10 lines
Allows us to drop
CONFIG_NO_GET_MEMORY_MAPPINGwith its indirect dependency onCONFIG_HAVE_GET_MEMORY_MAPPINGin Makefile.target.Signed-off-by Andreas Färber <[email protected]>--- Makefile.target | 2 -- stubs/Makefile.objs | 1 + memory_mapping-stub.c => stubs/memory_mapping.c | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename memory_mapping-stub.c => stubs/memory_mapping.c (85%)[...]
Quoted 18 lines
Quoted 18 lines
stubs/memory_mapping.c renamed from memory_mapping-stub.c +3
-2@@ -11,8 +11,9 @@* */ -#include "cpu.h" -#include "exec/cpu-all.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" +#include "qom/cpu.h" #include "sysemu/memory_mapping.h" Quoted 4 lines
stubs/memory_mapping.c line 19
Quoted 2 lines
stubs/memory_mapping.c renamed from memory_mapping-stub.c +0
-0int qemu_get_guest_memory_mapping (MemoryMappingList *list)Patches 1-3 are fine.
Quoted 7 lines
Thanks.
Quoted 2 lines
But I wonder if a better replacement for stubs is
methods in CPU.None of the functions I have moved from *-stub.c to stubs/ operate on a single CPU,
cpu_get_memory_mapping and cpu_paging_enabled can be made methods in CPU, can't they?
And as far as this patch is concerned, this only leaves out qemu_get_guest_memory_mapping. If you make cpu_paging_enabled and cpu_get_memory_mapping return a different value for "not supported" (e.g. -ENOSYS), qemu_get_guest_memory_mapping need not be a stub at all.
Paolo
so now that the conflict with the kdump format support has
Quoted 10 lines
been resolved I'd like to move them as a step towards dropping per-target configure changes for guest-memory-dump support.
With my note in the cover letter I was rather referring to
cpu_paging_enabled(), which is mandatory currently without any stub.Do you have a concrete suggestion what else to do for these stubs?
Andreas