From ffce9ebbb69363dfe7605585cdad58ea3847edf4 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 27 May 2013 17:23:54 -0300 Subject: target-i386: Update model values on Conroe/Penryn/Nehalem CPU models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CPUID model values on Conroe, Penryn, and Nehalem are too conservative and don't reflect the values found on real Conroe, Penryn, and Nehalem CPUs. This causes at least one known problems: Windows XP disables sysenter when (family == 6 && model <= 2), but Skype tries to use the sysenter instruction anyway because it is reported as available on CPUID, making it crash. This patch sets appropriate model values that correspond to real Conroe, Penryn, and Nehalem CPUs. Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Andreas Färber --- include/hw/i386/pc.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 6154058..f232d75 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -185,7 +185,23 @@ int pvpanic_init(ISABus *bus); int e820_add_entry(uint64_t, uint64_t, uint32_t); +#define PC_COMPAT_1_5 \ + {\ + .driver = "Conroe-" TYPE_X86_CPU,\ + .property = "model",\ + .value = stringify(2),\ + },{\ + .driver = "Penryn-" TYPE_X86_CPU,\ + .property = "model",\ + .value = stringify(2),\ + },{\ + .driver = "Nehalem-" TYPE_X86_CPU,\ + .property = "model",\ + .value = stringify(2),\ + } + #define PC_COMPAT_1_4 \ + PC_COMPAT_1_5, \ {\ .driver = "scsi-hd",\ .property = "discard_granularity",\ -- cgit v1.1 From 6b11322e0f724eb0649fdc324a44288b783023ad Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 27 May 2013 17:23:55 -0300 Subject: target-i386: Set level=4 on Conroe/Penryn/Nehalem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CPUID level value on Conroe, Penryn, and Nehalem are too low. This causes at least one known problem: the -smp "threads" option doesn't work as expect if level is < 4, because thread count information is provided to the guest on CPUID[EAX=4,ECX=2].EAX Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Andreas Färber --- include/hw/i386/pc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f232d75..fab9be5 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -191,13 +191,25 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); .property = "model",\ .value = stringify(2),\ },{\ + .driver = "Conroe-" TYPE_X86_CPU,\ + .property = "level",\ + .value = stringify(2),\ + },{\ .driver = "Penryn-" TYPE_X86_CPU,\ .property = "model",\ .value = stringify(2),\ },{\ + .driver = "Penryn-" TYPE_X86_CPU,\ + .property = "level",\ + .value = stringify(2),\ + },{\ .driver = "Nehalem-" TYPE_X86_CPU,\ .property = "model",\ .value = stringify(2),\ + },{\ + .driver = "Nehalem-" TYPE_X86_CPU,\ + .property = "level",\ + .value = stringify(2),\ } #define PC_COMPAT_1_4 \ -- cgit v1.1 From 444d55907871f88276a654fc7fdc8c7db95f4b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 28 May 2013 13:28:38 +0200 Subject: cpu: Turn cpu_paging_enabled() into a CPUState hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relocate assignment of x86 get_arch_id to have all hooks in one place. Reviewed-by: Jens Freimann Reviewed-by: Luiz Capitulino Signed-off-by: Andreas Färber --- include/qom/cpu.h | 10 ++++++++++ include/sysemu/memory_mapping.h | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 7cd9442..1f70240 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)(const 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(const 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 -- cgit v1.1 From 6d4d3ae77dbb756d454c2deb2ef844b0cc7bde7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 28 May 2013 14:20:15 +0200 Subject: memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will avoid issues with hwaddr and ram_addr_t when including sysemu/memory_mapping.h for CONFIG_USER_ONLY, e.g., from qom/cpu.h. Signed-off-by: Andreas Färber --- include/qemu/typedefs.h | 2 ++ include/sysemu/memory_mapping.h | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index afe4ec7..698fc03 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); -- cgit v1.1 From a23bbfda75118eb738acce84afd64965934828f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 28 May 2013 13:52:01 +0200 Subject: cpu: Turn cpu_get_memory_mapping() into a CPUState hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change error reporting from return value to Error argument. Reviewed-by: Jens Freimann Reviewed-by: Luiz Capitulino [AF: Fixed cpu_get_memory_mapping() documentation] Signed-off-by: Andreas Färber --- include/qom/cpu.h | 13 +++++++++++++ include/sysemu/memory_mapping.h | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 1f70240..a5bb515 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -23,6 +23,7 @@ #include #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,8 @@ typedef struct CPUClass { void (*do_interrupt)(CPUState *cpu); int64_t (*get_arch_id)(CPUState *cpu); bool (*get_paging_enabled)(const CPUState *cpu); + void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, + Error **errp); const struct VMStateDescription *vmsd; int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu, @@ -148,6 +152,15 @@ struct CPUState { bool cpu_paging_enabled(const CPUState *cpu); /** + * cpu_get_memory_mapping: + * @cpu: The CPU whose memory mappings are to be obtained. + * @list: Where to write the memory mappings to. + * @errp: Pointer for reporting an #Error. + */ +void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, + Error **errp); + +/** * 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, -- cgit v1.1 From 11ed09cf0753c1288a97f00138fc4534135442bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 29 May 2013 21:54:03 +0200 Subject: memory_mapping: Improve qemu_get_guest_memory_mapping() error reporting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass any Error out into dump_init() and have it actually stop on errors. Whether it is unsupported on a certain CPU can be checked by looking for a NULL CPUClass::get_memory_mapping field. Reviewed-by: Luiz Capitulino [AF: Reverted changes to CPU loops] Signed-off-by: Andreas Färber --- include/sysemu/memory_mapping.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'include') diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h index c47e6ee..6dfb68d 100644 --- a/include/sysemu/memory_mapping.h +++ b/include/sysemu/memory_mapping.h @@ -45,13 +45,7 @@ void memory_mapping_list_free(MemoryMappingList *list); void memory_mapping_list_init(MemoryMappingList *list); -/* - * Return value: - * 0: success - * -1: failed - * -2: unsupported - */ -int qemu_get_guest_memory_mapping(MemoryMappingList *list); +void qemu_get_guest_memory_mapping(MemoryMappingList *list, Error **errp); /* get guest's memory mapping without do paging(virtual address is 0). */ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); -- cgit v1.1