From fae001f55190b4de511269ca63eb635646d1c7c9 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 May 2012 12:04:57 +0800 Subject: implement cpu_get_memory_mapping() Walk cpu's page table and collect all virtual address and physical address mapping. Then, add these mapping into memory mapping list. If the guest does not use paging, it will do nothing. Note: the I/O memory will be skipped. Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino --- cpu-all.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cpu-all.h') diff --git a/cpu-all.h b/cpu-all.h index 028528f0be..2688baca8c 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -22,6 +22,7 @@ #include "qemu-common.h" #include "qemu-tls.h" #include "cpu-common.h" +#include "memory_mapping.h" /* some important defines: * @@ -524,4 +525,14 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, uint8_t *buf, int len, int is_write); +#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) +int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); +#else +static inline int cpu_get_memory_mapping(MemoryMappingList *list, + CPUArchState *env) +{ + return -1; +} +#endif + #endif /* CPU_ALL_H */ -- cgit v1.2.1 From 31a2207a8e1c39bcf88e527ac62f4e12316920a4 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 May 2012 12:05:42 +0800 Subject: Add API to check whether paging mode is enabled This API will be used in the following patch. Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino --- cpu-all.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cpu-all.h') diff --git a/cpu-all.h b/cpu-all.h index 2688baca8c..76439b4221 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -527,12 +527,18 @@ int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, #if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); +bool cpu_paging_enabled(CPUArchState *env); #else static inline int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env) { return -1; } + +static inline bool cpu_paging_enabled(CPUArchState *env) +{ + return true; +} #endif #endif /* CPU_ALL_H */ -- cgit v1.2.1 From 9fecbed0c03ddad63c27f1622e2002fdfc2f45e4 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 May 2012 12:07:48 +0800 Subject: target-i386: Add API to write elf notes to core file The core file contains register's value. These APIs write registers to core file, and them will be called in the following patch. Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino --- cpu-all.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cpu-all.h') diff --git a/cpu-all.h b/cpu-all.h index 76439b4221..a71e88718a 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -541,4 +541,26 @@ static inline bool cpu_paging_enabled(CPUArchState *env) } #endif +typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque); +#if defined(CONFIG_HAVE_CORE_DUMP) +int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, + int cpuid, void *opaque); +int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env, + int cpuid, void *opaque); +#else +static inline int cpu_write_elf64_note(write_core_dump_function f, + CPUArchState *env, int cpuid, + void *opaque) +{ + return -1; +} + +static inline int cpu_write_elf32_note(write_core_dump_function f, + CPUArchState *env, int cpuid, + void *opaque) +{ + return -1; +} +#endif + #endif /* CPU_ALL_H */ -- cgit v1.2.1 From 90166b71c4d75823b48a132e9394af35b9c90aaf Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 May 2012 12:08:22 +0800 Subject: target-i386: Add API to write cpu status to core file The core file has register's value. But it does not include all registers value. Store the cpu status into QEMU note, and the user can get more information from vmcore. If you change QEMUCPUState, please count up QEMUCPUSTATE_VERSION. Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino --- cpu-all.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cpu-all.h') diff --git a/cpu-all.h b/cpu-all.h index a71e88718a..a167bacd6d 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -547,6 +547,10 @@ int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, int cpuid, void *opaque); int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env, int cpuid, void *opaque); +int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, + void *opaque); +int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, + void *opaque); #else static inline int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, int cpuid, @@ -561,6 +565,20 @@ static inline int cpu_write_elf32_note(write_core_dump_function f, { return -1; } + +static inline int cpu_write_elf64_qemunote(write_core_dump_function f, + CPUArchState *env, + void *opaque) +{ + return -1; +} + +static inline int cpu_write_elf32_qemunote(write_core_dump_function f, + CPUArchState *env, + void *opaque) +{ + return -1; +} #endif #endif /* CPU_ALL_H */ -- cgit v1.2.1 From 25ae9c1d8bbfeb6c00eccb4297a5937d8375a44a Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 May 2012 12:08:56 +0800 Subject: target-i386: add API to get dump info Dump info contains: endian, class and architecture. The next patch will use these information to create vmcore. Note: on x86 box, the class is ELFCLASS64 if the memory is larger than 4G. Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino --- cpu-all.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cpu-all.h') diff --git a/cpu-all.h b/cpu-all.h index a167bacd6d..7e07c91275 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -23,6 +23,7 @@ #include "qemu-tls.h" #include "cpu-common.h" #include "memory_mapping.h" +#include "dump.h" /* some important defines: * @@ -551,6 +552,7 @@ int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, void *opaque); int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, void *opaque); +int cpu_get_dump_info(ArchDumpInfo *info); #else static inline int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, int cpuid, @@ -579,6 +581,11 @@ static inline int cpu_write_elf32_qemunote(write_core_dump_function f, { return -1; } + +static inline int cpu_get_dump_info(ArchDumpInfo *info) +{ + return -1; +} #endif #endif /* CPU_ALL_H */ -- cgit v1.2.1 From 0038ffb09692955b8f8f363958cbf58c205ae772 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 May 2012 12:09:36 +0800 Subject: target-i386: Add API to get note's size We should know where the note and memory is stored before writing them to vmcore. If we know this, we can avoid using lseek() when creating vmcore. Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino --- cpu-all.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cpu-all.h') diff --git a/cpu-all.h b/cpu-all.h index 7e07c91275..2b77f66b35 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -553,6 +553,7 @@ int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, void *opaque); int cpu_get_dump_info(ArchDumpInfo *info); +size_t cpu_get_note_size(int class, int machine, int nr_cpus); #else static inline int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, int cpuid, @@ -586,6 +587,11 @@ static inline int cpu_get_dump_info(ArchDumpInfo *info) { return -1; } + +static inline int cpu_get_note_size(int class, int machine, int nr_cpus) +{ + return -1; +} #endif #endif /* CPU_ALL_H */ -- cgit v1.2.1