QOM CPUState patch queue 2013-01-08
Hello,
This is my current QOM CPU patch queue. Please pull.
It includes:
* CPU as a device,
* improvements for x86 -cpu host,
* cleanups and preparations for QOM realize.
Another pull is intended before the Soft Freeze.
Regards,
Andreas
The following changes since commit 560c30b1db1d40fe45c5104185367c4de43399d3:
Merge remote-tracking branch 'kraxel/usb.75' into staging (2013-01-08 10:36:20 -0600)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git qom-cpu
for you to fetch changes up to ebe8b9c6eb6e425d44805288b6b5dabd69368f46:
target-i386: Explicitly set vendor for each built-in cpudef (2013-01-08 21:03:44 +0100)
----------------------------------------------------------------
Andreas Färber (2):
qdev: Don't assume existence of parent bus on unparenting qemu-common.h: Make qemu_init_vcpu() stub static inline
Eduardo Habkost (12):
libqemustub: Add qemu_[un]register_reset() stubs
libqemustub: vmstate register/unregister stubs
libqemustub: sysbus_get_default() stub
qdev: Include qdev code into *-user, too
cpu: Change parent type to Device
target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features
target-i386: kvm: Enable all supported KVM features for -cpu host
target-i386: check/enforce: Fix CPUID leaf numbers on error messages
target-i386: check/enforce: Do not ignore "hypervisor" flag
target-i386: check/enforce: Check all CPUID.80000001H.EDX bits
target-i386: check/enforce: Check SVM flag support as well
target-i386: check/enforce: Eliminate check_feat field
Igor Mammedov (3):
target-i386: Filter out unsupported features at realize time
target-i386: Sanitize AMD's ext2_features at realize time
target-i386: Explicitly set vendor for each built-in cpudef
Makefile.objs | 8 +++ hw/Makefile.objs | 9 ++- hw/qdev.c | 8 ++- include/qemu-common.h | 4 +- include/qom/cpu.h | 6 +- qom/cpu.c | 6 +- stubs/Makefile.objs | 3 + stubs/reset.c | 13 +++++ stubs/sysbus.c | 6 ++ stubs/vmstate.c | 17 ++++++ target-alpha/cpu.c | 2 - target-i386/cpu.c | 153 ++++++++++++++++++++++++++++++++----------------- target-i386/cpu.h | 3 + 13 Dateien geändert, 171 Zeilen hinzugefügt(+), 67 Zeilen entfernt(-) create mode 100644 stubs/reset.c create mode 100644 stubs/sysbus.c create mode 100644 stubs/vmstate.c
PATCH 1/17 libqemustub: Add qemu_[un]register_reset() stubs
From: Eduardo Habkost <[email protected]>
This will be useful for code that don't call qemu_devices_reset() (e.g. *-user). If qemu_devices_reset() is never called, it means we don't need to keep track of the reset handler list.
--- stubs/Makefile.objs | 1 + stubs/reset.c | 13 +++++++++++++ 2 Dateien geändert, 14 Zeilen hinzugefügt(+) create mode 100644 stubs/reset.c
stubs/Makefile.objs +1 -0
@@ -5,4 +5,5 @@ stub-obj-y += fdset-get-fd.o stub-obj-y += fdset-remove-fd.o stub-obj-y += get-fd.o stub-obj-y += set-fd-handler.o +stub-obj-y += reset.o stub-obj-$(CONFIG_WIN32) += fd-register.o
stubs/reset.c new file +13 -0
@@ -0,0 +1,13 @@ +#include "hw/hw.h" + +/* Stub functions for binaries that never call qemu_devices_reset(), +* and don't need to keep track of the reset handler list. +*/ + +void qemu_register_reset (QEMUResetHandler *func,void *opaque) +{ +} + +void qemu_unregister_reset (QEMUResetHandler *func,void *opaque) +{ +}
Signature · 1 line
1.7.10.4
PATCH 2/17 libqemustub: vmstate register/unregister stubs
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
Add vmstate stub functions, so that qdev.o can be used without savevm.o when vmstate support is not necessary (i.e. by *-user).
--- stubs/Makefile.objs | 1 + stubs/vmstate.c | 17 +++++++++++++++++ 2 Dateien geändert, 18 Zeilen hinzugefügt(+) create mode 100644 stubs/vmstate.c
stubs/Makefile.objs +1 -0
@@ -6,4 +6,5 @@ stub-obj-y += fdset-remove-fd.o stub-obj-y += get-fd.o stub-obj-y += set-fd-handler.o stub-obj-y += reset.o +stub-obj-y += vmstate.o stub-obj-$(CONFIG_WIN32) += fd-register.o
stubs/vmstate.c new file +17 -0
@@ -0,0 +1,17 @@ +#include "qemu-common.h" +#include "migration/vmstate.h" + +int vmstate_register_with_alias_id (DeviceState *dev, +int instance_id, +const VMStateDescription *vmsd, +void *base,int alias_id, +int required_for_version) +{ +return 0 ; +} + +void vmstate_unregister (DeviceState *dev, +const VMStateDescription *vmsd, +void *opaque) +{ +}
Signature · 1 line
1.7.10.4
PATCH 3/17 libqemustub: sysbus_get_default() stub
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
The stub will be used on cases where sysbus.c is not compiled in (e.g. *-user).
Note that code that uses NULL as the bus with qdev{_try,}_create() implicitly uses sysbus_get_default() as the bus, and will still require sysbus.c to be compiled in.
--- stubs/Makefile.objs | 1 + stubs/sysbus.c | 6 ++++++ 2 Dateien geändert, 7 Zeilen hinzugefügt(+) create mode 100644 stubs/sysbus.c
stubs/Makefile.objs +1 -0
@@ -7,4 +7,5 @@ stub-obj-y += get-fd.o stub-obj-y += set-fd-handler.o stub-obj-y += reset.o stub-obj-y += vmstate.o +stub-obj-y += sysbus.o stub-obj-$(CONFIG_WIN32) += fd-register.o
stubs/sysbus.c new file +6 -0
@@ -0,0 +1,6 @@ +#include "hw/qdev-core.h" + +BusState *sysbus_get_default (void ) +{ +return NULL ; +}
Signature · 1 line
1.7.10.4
PATCH 4/17 qdev: Include qdev code into *-user, too
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
The code depends on some functions from qemu-option.o, so add qemu-option.o to universal-obj-y to make sure it's included.
--- Makefile.objs | 8 ++++++++ hw/Makefile.objs | 9 +++++++--
2 Dateien geändert, 15 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
Makefile.objs +8 -0
@@ -22,6 +22,13 @@ qom-obj-y = qom/ universal-obj-y += $(qom-obj-y) ####################################################################### +# Core hw code (qdev core) +hw-core-obj-y += hw/ +hw-core-obj-y += qemu-option.o + +universal-obj-y += $(hw-core-obj-y) + +####################################################################### # oslib-obj-y is code depending on the OS (win32 vs posix) oslib-obj-y = osdep.o cutils.o qemu-timer-common.o oslib-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o
@@ -182,6 +189,7 @@ nested-vars += \ user-obj-y \ common-obj-y \ universal-obj-y \ + hw-core-obj-y \ extra-obj-y \ trace-obj-y dummy := $(call unnest-vars)
hw/Makefile.objs +7 -2
@@ -1,3 +1,9 @@ +# core qdev-related obj files, also used by *-user: +hw-core-obj-y += qdev.o qdev-properties.o +# irq.o needed for qdev GPIO handling: +hw-core-obj-y += irq.o + + common-obj-y = usb/ ide/ pci/ common-obj-y += loader.o common-obj-$(CONFIG_VIRTIO) += virtio-console.o
@@ -154,7 +160,6 @@ common-obj-$(CONFIG_SOUND) += $(sound-obj-y) common-obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ common-obj-y += usb/ -common-obj-y += irq.o common-obj-$(CONFIG_PTIMER) += ptimer.o common-obj-$(CONFIG_MAX7310) += max7310.o common-obj-$(CONFIG_WM8750) += wm8750.o
@@ -180,7 +185,7 @@ common-obj-$(CONFIG_SD) += sd.o common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o common-obj-y += bt-hci-csr.o common-obj-y += msmouse.o ps2.o -common-obj-y += qdev.o qdev-properties.o qdev-monitor.o +common-obj-y += qdev-monitor.o common-obj-y += qdev-properties-system.o common-obj-$(CONFIG_BRLAPI) += baum.o
Signature · 1 line
1.7.10.4
PATCH 5/17 qdev: Don't assume existence of parent bus on unparenting
In reply to Andreas FärberCommit 667d22d1ae59da46b4c1fbd094ca61145f19b8c3 (qdev: move bus removal to object_unparent) made the assumption that at unparenting time parent_bus is not NULL. This assumption is unjustified since object_unparent() may well be called directly after object_initialize(), without any qdev_set_parent_bus().
This did not cause any issues yet because qdev_[try_]create() does call qdev_set_parent_bus(), falling back to SysBus if unsupplied.
While at it, ensure that this new function uses the device_ prefix and make the name more neutral in light of this semantic change.
--- hw/qdev.c | 8 +++++---
1 Datei geändert, 5 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
hw/qdev.c +5 -3
@@ -698,16 +698,18 @@ static void device_class_base_init(ObjectClass *class, void *data) klass->props =NULL ; } -static void qdev_remove_from_bus (Object *obj) +static void device_unparent (Object *obj) {DeviceState *dev =DEVICE (obj); -bus_remove_child (dev->parent_bus, dev); +if (dev->parent_bus !=NULL ) { +bus_remove_child (dev->parent_bus, dev); + } }static void device_class_init (ObjectClass *class,void *data) { - class->unparent = qdev_remove_from_bus; + class->unparent = device_unparent; }void device_reset (DeviceState *dev)
Signature · 1 line
1.7.10.4
PATCH 6/17 cpu: Change parent type to Device
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
This finally makes the CPU class a subclass of the Device class, allowing us to start using DeviceState properties on CPU subclasses.
It has no_user=1, as creating CPUs using -device doesn't work yet.
--- include/qom/cpu.h | 6 +++--- qom/cpu.c | 6 ++++--
2 Dateien geändert, 7 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)
include/qom/cpu.h +3 -3
@@ -20,7 +20,7 @@#ifndef QEMU_CPU_H #define QEMU_CPU_H -#include "qom/object.h" +#include "hw/qdev-core.h" #include "qemu/thread.h" /**
@@ -46,7 +46,7 @@ typedef struct CPUState CPUState;*/ typedef struct CPUClass { /*< private >*/ - ObjectClass parent_class; + DeviceClass parent_class; /*< public >*/ void (*reset)(CPUState *cpu);
@@ -66,7 +66,7 @@ struct kvm_run;*/ struct CPUState {/*< private >*/ -Object parent_obj; +DeviceState parent_obj;/*< public >*/ struct QemuThread *thread;
qom/cpu.c +4 -2
@@ -36,14 +36,16 @@ static void cpu_common_reset(CPUState *cpu)static void cpu_class_init (ObjectClass *klass,void *data) { +DeviceClass *dc =DEVICE_CLASS (klass);CPUClass *k =CPU_CLASS (klass); k->reset = cpu_common_reset; + dc->no_user =1 ; } -static TypeInfo cpu_type_info = { +static const TypeInfo cpu_type_info = { .name =TYPE_CPU , - .parent =TYPE_OBJECT , + .parent =TYPE_DEVICE , .instance_size =sizeof (CPUState), .abstract = true, .class_size =sizeof (CPUClass),
Signature · 1 line
1.7.10.4
PATCH 7/17 target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
The existing -cpu host code simply sets every bit inside svm_features (initializing it to -1), and that makes it impossible to make the enforce/check options work properly when the user asks for SVM features explicitly in the command-line.
So, instead of initializing svm_features to -1, use GET_SUPPORTED_CPUID to fill only the bits that are supported by the host (just like we do for all other CPUID feature words inside kvm_cpu_fill_host()).
This will keep the existing behavior (as filter_features_for_kvm() already uses GET_SUPPORTED_CPUID to filter svm_features), but will allow us to properly check for KVM features inside kvm_check_features_against_host() later.
For example, we will be able to make this:
$ qemu-system-x86_64 -cpu ...,+pfthreshold,enforce
refuse to start if the SVM "pfthreshold" feature is not supported by the host (after we fix kvm_check_features_against_host() to check SVM flags as well).
--- target-i386/cpu.c | 11 ++++-------
1 Datei geändert, 4 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
target-i386/cpu.c +4 -7
@@ -897,13 +897,10 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def) } } -/* -* Every SVM feature requires emulation support in KVM - so we can't just -* read the host features here. KVM might even support SVM features not -* available on the host hardware. Just set all bits and mask out the -* unsupported ones later. -*/ - x86_cpu_def->svm_features =-1 ; +/* Other KVM-specific feature fields: */ + x86_cpu_def->svm_features = +kvm_arch_get_supported_cpuid (s,0x8000000A ,0 ,R_EDX ); +#endif /* CONFIG_KVM */ }
Signature · 1 line
1.7.10.4
PATCH 8/17 target-i386: kvm: Enable all supported KVM features for -cpu host
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
When using -cpu host, we don't need to use the kvm_default_features variable, as the user is explicitly asking QEMU to enable all feature supported by the host.
This changes the kvm_cpu_fill_host() code to use GET_SUPPORTED_CPUID to initialize the kvm_features field, so we get all host KVM features enabled.
This will also allow us to properly check/enforce KVM features inside kvm_check_features_against_host() later. For example, we will be able to make this:
$ qemu-system-x86_64 -cpu ...,+kvm_pv_eoi,enforce
refuse to start if kvm_pv_eoi is not supported by the host (after we fix kvm_check_features_against_host() to check KVM flags as well).
--- target-i386/cpu.c | 2 ++
1 Datei geändert, 2 Zeilen hinzugefügt(+)
target-i386/cpu.c +2 -0
@@ -900,6 +900,8 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)/* Other KVM-specific feature fields: */ x86_cpu_def->svm_features =kvm_arch_get_supported_cpuid (s,0x8000000A ,0 ,R_EDX ); + x86_cpu_def->kvm_features = +kvm_arch_get_supported_cpuid (s,KVM_CPUID_FEATURES ,0 ,R_EAX );#endif /* CONFIG_KVM */ }
Signature · 1 line
1.7.10.4
PATCH 9/17 target-i386: check/enforce: Fix CPUID leaf numbers on error messages
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
The -cpu check/enforce warnings are printing incorrect information about the missing flags. There are no feature flags on CPUID leaves 0 and 0x80000000, but there were references to 0 and 0x80000000 in the table at kvm_check_features_against_host().
This changes the model_features_t struct to contain the register number as well, so the error messages print the correct CPUID leaf+register information, instead of wrong CPUID leaf numbers.
This also changes the format of the error messages, so they follow the "CPUID.<leaf>.<register>.<name> [bit <offset>]" convention used in Intel documentation. Example output:
$ qemu-system-x86_64 -machine pc-1.0,accel=kvm -cpu Opteron_G4,+ia64,enforce
warning: host doesn't support requested feature: CPUID.01H:EDX.ia64 [bit 30]
warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]
warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.misalignsse [bit 7]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.3dnowprefetch [bit 8]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.xop [bit 11]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.fma4 [bit 16]
Unable to find x86 CPU definition
$--- target-i386/cpu.c | 42 +++++++++++++++++++++++++++++++++--------- target-i386/cpu.h | 3 +++
2 Dateien geändert, 36 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)
target-i386/cpu.c +33 -9
@@ -124,6 +124,25 @@ static const char *cpuid_7_0_ebx_feature_name[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; +const char *get_register_name_32 (unsigned int reg) +{ +static const char *reg_names[CPU_NB_REGS32 ] = { + [R_EAX ] ="EAX" , + [R_ECX ] ="ECX" , + [R_EDX ] ="EDX" , + [R_EBX ] ="EBX" , + [R_ESP ] ="ESP" , + [R_EBP ] ="EBP" , + [R_ESI ] ="ESI" , + [R_EDI ] ="EDI" , + }; + +if (reg >CPU_NB_REGS32 ) { +return NULL ; + } +return reg_names[reg]; +} +/* collects per-function cpuid data */ typedef struct model_features_t {
@@ -132,7 +151,8 @@ typedef struct model_features_t {uint32_t check_feat;const char **flag_names;uint32_t cpuid; - } model_features_t; +int reg; +} model_features_t;int check_cpuid =0 ;int enforce_cpuid =0 ;
@@ -912,10 +932,13 @@ static int unavailable_host_feature(struct model_features_t *f, uint32_t mask)for (i =0 ; i <32 ; ++i)if (1 << i & mask) { -fprintf (stderr,"warning: host cpuid %04x_%04x lacks requested" -" flag '%s' [0x%08x]\n" , - f->cpuid >>16 , f->cpuid &0xffff , - f->flag_names[i] ? f->flag_names[i] :"[reserved]" , mask); +const char *reg =get_register_name_32 (f->reg); +assert (reg); +fprintf (stderr,"warning: host doesn't support requested feature: " +"CPUID.%02XH:%s%s%s [bit %d]\n" , + f->cpuid, reg, + f->flag_names[i] ?"." :"" , + f->flag_names[i] ? f->flag_names[i] :"" , i);break ; }return 0 ;
@@ -934,13 +957,14 @@ static int kvm_check_features_against_host(x86_def_t *guest_def)int rv, i;struct model_features_t ft[] = { {&guest_def->features, &host_def.features, - ~0 , feature_name,0x00000000 }, + ~0 , feature_name,0x00000001 ,R_EDX }, {&guest_def->ext_features, &host_def.ext_features, - ~CPUID_EXT_HYPERVISOR , ext_feature_name,0x00000001 }, + ~CPUID_EXT_HYPERVISOR , ext_feature_name,0x00000001 ,R_ECX }, {&guest_def->ext2_features, &host_def.ext2_features, - ~PPRO_FEATURES , ext2_feature_name,0x80000000 }, + ~PPRO_FEATURES , ext2_feature_name,0x80000001 ,R_EDX }, {&guest_def->ext3_features, &host_def.ext3_features, - ~CPUID_EXT3_SVM , ext3_feature_name,0x80000001 }}; + ~CPUID_EXT3_SVM , ext3_feature_name,0x80000001 ,R_ECX } + };assert (kvm_enabled ());
target-i386/cpu.h +3 -0
@@ -1220,4 +1220,7 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);void enable_kvm_pv_eoi (void ); +/* Return name of 32-bit register, from a R_* constant */ +const char *get_register_name_32 (unsigned int reg); +#endif /* CPU_I386_H */
Signature · 1 line
1.7.10.4
PATCH 10/17 target-i386: check/enforce: Do not ignore "hypervisor" flag
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
We don't need any hack to ignore CPUID_EXT_HYPERVISOR anymore, because kvm_arch_get_supported_cpuid() now sets CPUID_EXT_HYPERVISOR properly. So, this shouldn't introduce any behavior change, but it makes the code simpler.
--- target-i386/cpu.c | 2 +-
1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
target-i386/cpu.c +1 -1
@@ -959,7 +959,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {&guest_def->features, &host_def.features, ~0, feature_name, 0x00000001, R_EDX}, {&guest_def->ext_features, &host_def.ext_features, - ~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x00000001, R_ECX}, + ~0, ext_feature_name, 0x00000001, R_ECX}, {&guest_def->ext2_features, &host_def.ext2_features, ~PPRO_FEATURES, ext2_feature_name, 0x80000001, R_EDX}, {&guest_def->ext3_features, &host_def.ext3_features,
Signature · 1 line
1.7.10.4
PATCH 11/17 target-i386: check/enforce: Check all CPUID.80000001H.EDX bits
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
I have no idea why PPRO_FEATURES was being ignored on the check of the CPUID.80000001H.EDX bits. I believe it was a mistake, and it was supposed to be ~(PPRO_FEATURES & CPUID_EXT2_AMD_ALIASES) or just ~CPUID_EXT2_AMD_ALIASES, because some time ago kvm_cpu_fill_host() used the CPUID instruction directly (instead of kvm_arch_get_supported_cpuid()).
But now kvm_cpu_fill_host() uses kvm_arch_get_supported_cpuid(), and kvm_arch_get_supported_cpuid() returns all supported bits for CPUID.80000001H.EDX, even the AMD aliases (that are explicitly copied from CPUID.01H.EDX), so we can make the code check/enforce all the CPUID.80000001H.EDX bits.
--- target-i386/cpu.c | 2 +-
1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
target-i386/cpu.c +1 -1
@@ -961,7 +961,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {&guest_def->ext_features, &host_def.ext_features, ~0, ext_feature_name, 0x00000001, R_ECX}, {&guest_def->ext2_features, &host_def.ext2_features, - ~PPRO_FEATURES, ext2_feature_name, 0x80000001, R_EDX}, + ~0, ext2_feature_name, 0x80000001, R_EDX}, {&guest_def->ext3_features, &host_def.ext3_features, ~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001, R_ECX} };
Signature · 1 line
1.7.10.4
PATCH 12/17 target-i386: check/enforce: Check SVM flag support as well
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
When nested SVM is supported, the kernel returns the SVM flag on GET_SUPPORTED_CPUID[1], so we can check the SVM flag safely in kvm_check_features_against_host().
I don't know why the original code ignored the SVM flag. Maybe it was because kvm_cpu_fill_host() used the CPUID instruction directly instead of GET_SUPPORTED_CPUID
[1] Older kernels (before v2.6.37) returned the SVM flag even if nested SVM was _not_ supported. So the only cases where this patch should change behavior is when SVM is being requested by the user or the CPU model, but not supported by the host. And on these cases we really want QEMU to abort if the "enforce" option is set.
--- target-i386/cpu.c | 2 +-
1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
target-i386/cpu.c +1 -1
@@ -963,7 +963,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) {&guest_def->ext2_features, &host_def.ext2_features, ~0, ext2_feature_name, 0x80000001, R_EDX}, {&guest_def->ext3_features, &host_def.ext3_features, - ~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001, R_ECX} + ~0, ext3_feature_name, 0x80000001, R_ECX} };assert (kvm_enabled ());
Signature · 1 line
1.7.10.4
PATCH 13/17 target-i386: check/enforce: Eliminate check_feat field
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
Now that all entries have check_feat=~0 in kvm_check_features_against_host(), we can eliminate check_feat entirely and make the code check all bits.
This patch shouldn't introduce any behavior change, as check_feat is set to ~0 on all entries.
--- target-i386/cpu.c | 14 ++++++--------
1 Datei geändert, 6 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)
target-i386/cpu.c +6 -8
@@ -148,7 +148,6 @@ const char *get_register_name_32(unsigned int reg) typedef struct model_features_t { uint32_t *guest_feat; uint32_t *host_feat; - uint32_t check_feat; const char **flag_names; uint32_t cpuid; int reg;
@@ -945,8 +944,7 @@ static int unavailable_host_feature(struct model_features_t *f, uint32_t mask) }/* best effort attempt to inform user requested cpu flags aren't making -* their way to the guest. Note: ft[].check_feat ideally should be -* specified via a guest_def field to suppress report of extraneous flags. +* their way to the guest. * * This function may be called only if KVM is enabled. */
@@ -957,13 +955,13 @@ static int kvm_check_features_against_host(x86_def_t *guest_def)int rv, i;struct model_features_t ft[] = { {&guest_def->features, &host_def.features, - ~0 , feature_name,0x00000001 ,R_EDX }, + feature_name,0x00000001 ,R_EDX }, {&guest_def->ext_features, &host_def.ext_features, - ~0 , ext_feature_name,0x00000001 ,R_ECX }, + ext_feature_name,0x00000001 ,R_ECX }, {&guest_def->ext2_features, &host_def.ext2_features, - ~0 , ext2_feature_name,0x80000001 ,R_EDX }, + ext2_feature_name,0x80000001 ,R_EDX }, {&guest_def->ext3_features, &host_def.ext3_features, - ~0 , ext3_feature_name,0x80000001 ,R_ECX } + ext3_feature_name,0x80000001 ,R_ECX } };assert (kvm_enabled ());
@@ -971,7 +969,7 @@ static int kvm_check_features_against_host(x86_def_t *guest_def)kvm_cpu_fill_host (&host_def);for (rv =0 , i =0 ; i <ARRAY_SIZE (ft); ++i)for (mask =1 ; mask; mask <<=1 ) -if (ft[i].check_feat & mask && *ft[i].guest_feat & mask && +if (*ft[i].guest_feat & mask && !(*ft[i].host_feat & mask)) {unavailable_host_feature (&ft[i], mask); rv =1 ;
Signature · 1 line
1.7.10.4
PATCH 14/17 qemu-common.h: Make qemu_init_vcpu() stub static inline
In reply to Andreas FärberTurn the *-user macro into a no-op inline function to avoid unused-variable warnings and band-aiding #ifdef'ery.
This allows to drop an #ifdef for alpha and avoids more for unicore32 and other upcoming trivial realizefn implementations.
--- include/qemu-common.h | 4 +++- target-alpha/cpu.c | 2 --
2 Dateien geändert, 3 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
include/qemu-common.h +3 -1
@@ -288,7 +288,9 @@ struct qemu_work_item { };#ifdef CONFIG_USER_ONLY -#define qemu_init_vcpu (env) do { } while (0) +static inline void qemu_init_vcpu (void *env) +{ +}#else void qemu_init_vcpu (void *env);#endif
target-alpha/cpu.c +0 -2
@@ -26,11 +26,9 @@static void alpha_cpu_realize (Object *obj,Error **errp) { -#ifndef CONFIG_USER_ONLY AlphaCPU *cpu =ALPHA_CPU (obj);qemu_init_vcpu (&cpu->env); -#endif }/* Sort alphabetically by type name. */
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH 14/17] qemu-common.h: Make qemu_init_vcpu() stub static inline
Quoted 6 lines · Andreas Färber
Turn the *-user macro into a no-op inline function to avoid unused-variable warnings and band-aiding #ifdef'ery.
This allows to drop an #ifdef for alpha and avoids more for unicore32 and other upcoming trivial realizefn implementations.
Quoted 8 lines
Suggested-by Lluís Vilanova <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Andreas Färber <[email protected]>Reviewed-by Eduardo Habkost <[email protected]>--- include/qemu-common.h | 4 +++- target-alpha/cpu.c | 2 --2 Dateien geändert, 3 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
r~
PATCH 15/17 target-i386: Filter out unsupported features at realize time
In reply to Andreas FärberFrom: Igor Mammedov <[email protected]>
--- target-i386/cpu.c | 31 ++++++++++++++++---------------
1 Datei geändert, 16 Zeilen hinzugefügt(+), 15 Zeilen entfernt(-)
target-i386/cpu.c +16 -15
@@ -1571,21 +1571,6 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model) env->cpuid_ext2_features |= (def->features &CPUID_EXT2_AMD_ALIASES ); } -if (!kvm_enabled ()) { - env->cpuid_features &=TCG_FEATURES ; - env->cpuid_ext_features &=TCG_EXT_FEATURES ; - env->cpuid_ext2_features &= (TCG_EXT2_FEATURES -#ifdef TARGET_X86_64 - |CPUID_EXT2_SYSCALL |CPUID_EXT2_LM -#endif - ); - env->cpuid_ext3_features &=TCG_EXT3_FEATURES ; - env->cpuid_svm_features &=TCG_SVM_FEATURES ; - }else { -#ifdef CONFIG_KVM -filter_features_for_kvm (cpu); -#endif - }object_property_set_str (OBJECT (cpu), def->model_id,"model-id" , &error);if (error) {fprintf (stderr,"%s\n" ,error_get_pretty (error));
@@ -2106,6 +2091,22 @@ void x86_cpu_realize(Object *obj, Error **errp) env->cpuid_level =7 ; } +if (!kvm_enabled ()) { + env->cpuid_features &=TCG_FEATURES ; + env->cpuid_ext_features &=TCG_EXT_FEATURES ; + env->cpuid_ext2_features &= (TCG_EXT2_FEATURES +#ifdef TARGET_X86_64 + |CPUID_EXT2_SYSCALL |CPUID_EXT2_LM +#endif + ); + env->cpuid_ext3_features &=TCG_EXT3_FEATURES ; + env->cpuid_svm_features &=TCG_SVM_FEATURES ; + }else { +#ifdef CONFIG_KVM +filter_features_for_kvm (cpu); +#endif + } +#ifndef CONFIG_USER_ONLY qemu_register_reset (x86_cpu_machine_reset_cb, cpu);
Signature · 1 line
1.7.10.4
PATCH 16/17 target-i386: Sanitize AMD's ext2_features at realize time
In reply to Andreas FärberFrom: Igor Mammedov <[email protected]>
When CPU properties are implemented, ext2_features may change between object_new(CPU) and cpu_realize_fn(). Sanitizing ext2_features for AMD based CPU at realize() time will keep current behavior after CPU features are converted to properties.
--- target-i386/cpu.c | 21 +++++++++++----------
1 Datei geändert, 11 Zeilen hinzugefügt(+), 10 Zeilen entfernt(-)
target-i386/cpu.c +11 -10
@@ -1561,16 +1561,6 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)object_property_set_int (OBJECT (cpu), (int64_t )def->tsc_khz *1000 ,"tsc-frequency" , &error); -/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on -* CPUID[1].EDX. -*/ -if (env->cpuid_vendor1 ==CPUID_VENDOR_AMD_1 && - env->cpuid_vendor2 ==CPUID_VENDOR_AMD_2 && - env->cpuid_vendor3 ==CPUID_VENDOR_AMD_3 ) { - env->cpuid_ext2_features &= ~CPUID_EXT2_AMD_ALIASES ; - env->cpuid_ext2_features |= (def->features &CPUID_EXT2_AMD_ALIASES ); - } -object_property_set_str (OBJECT (cpu), def->model_id,"model-id" , &error);if (error) {fprintf (stderr,"%s\n" ,error_get_pretty (error));
@@ -2091,6 +2081,17 @@ void x86_cpu_realize(Object *obj, Error **errp) env->cpuid_level =7 ; } +/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on +* CPUID[1].EDX. +*/ +if (env->cpuid_vendor1 ==CPUID_VENDOR_AMD_1 && + env->cpuid_vendor2 ==CPUID_VENDOR_AMD_2 && + env->cpuid_vendor3 ==CPUID_VENDOR_AMD_3 ) { + env->cpuid_ext2_features &= ~CPUID_EXT2_AMD_ALIASES ; + env->cpuid_ext2_features |= (env->cpuid_features + &CPUID_EXT2_AMD_ALIASES ); + } +if (!kvm_enabled ()) { env->cpuid_features &=TCG_FEATURES ; env->cpuid_ext_features &=TCG_EXT_FEATURES ;
Signature · 1 line
1.7.10.4
PATCH 17/17 target-i386: Explicitly set vendor for each built-in cpudef
In reply to Andreas FärberFrom: Igor Mammedov <[email protected]>
Since cpudef config is not supported anymore and all remaining sources now always set x86_def_t.vendor[123] fields, remove setting default vendor to simplify future re-factoring.
--- target-i386/cpu.c | 40 +++++++++++++++++++++++++++++++---------
1 Datei geändert, 31 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)
target-i386/cpu.c +31 -9
@@ -407,6 +407,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "core2duo", .level = 10, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 6, .model = 15, .stepping = 11,
@@ -451,6 +454,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "qemu32", .level = 4, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 6, .model = 3, .stepping = 3,
@@ -461,6 +467,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "kvm32", .level = 5, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 15, .model = 6, .stepping = 1,
@@ -475,6 +484,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "coreduo", .level = 10, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 6, .model = 14, .stepping = 8,
@@ -490,6 +502,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "486", .level = 1, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 4, .model = 0, .stepping = 0,
@@ -499,6 +514,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "pentium", .level = 1, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 5, .model = 4, .stepping = 3,
@@ -508,6 +526,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "pentium2", .level = 2, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 6, .model = 5, .stepping = 2,
@@ -517,6 +538,9 @@ static x86_def_t builtin_x86_defs[] = { { .name = "pentium3", .level = 2, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 6, .model = 7, .stepping = 3,
@@ -542,6 +566,9 @@ static x86_def_t builtin_x86_defs[] = { .name = "n270",/* original is on level 10 */ .level = 5, + .vendor1 = CPUID_VENDOR_INTEL_1, + .vendor2 = CPUID_VENDOR_INTEL_2, + .vendor3 = CPUID_VENDOR_INTEL_3, .family = 6, .model = 28, .stepping = 2,
@@ -1534,15 +1561,10 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)if (cpu_x86_parse_featurestr (def, features) <0 ) { goto error; } -if (def->vendor1) { - env->cpuid_vendor1 = def->vendor1; - env->cpuid_vendor2 = def->vendor2; - env->cpuid_vendor3 = def->vendor3; - }else { - env->cpuid_vendor1 =CPUID_VENDOR_INTEL_1 ; - env->cpuid_vendor2 =CPUID_VENDOR_INTEL_2 ; - env->cpuid_vendor3 =CPUID_VENDOR_INTEL_3 ; - } +assert (def->vendor1); + env->cpuid_vendor1 = def->vendor1; + env->cpuid_vendor2 = def->vendor2; + env->cpuid_vendor3 = def->vendor3; env->cpuid_vendor_override = def->vendor_override;object_property_set_int (OBJECT (cpu), def->level,"level" , &error);object_property_set_int (OBJECT (cpu), def->family,"family" , &error);
Signature · 1 line
1.7.10.4
Am 08.01.2013 21:56, schrieb Andreas Färber:
Quoted 9 lines
Hello,
This is my current QOM CPU patch queue. Please pull.
It includes:
* CPU as a device,
* improvements for x86 -cpu host,
* cleanups and preparations for QOM realize.
Quoted 4 lines
Another pull is intended before the Soft Freeze.
Regards,
Andreas
Updated:
The following changes since commit 560c30b1db1d40fe45c5104185367c4de43399d3:
Merge remote-tracking branch 'kraxel/usb.75' into staging (2013-01-08
10:36:20 -0600)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git qom-cpu
for you to fetch changes up to aa9bae00da7b264131bc1de2a128bb0236851b40:
target-i386: Explicitly set vendor for each built-in cpudef
(2013-01-08 22:52:43 +0100)
Quoted 41 lines
----------------------------------------------------------------
Andreas Färber (2):
qdev: Don't assume existence of parent bus on unparentingqemu-common.h: Makeqemu_init_vcpu()stub static inlineEduardo Habkost (12):
libqemustub: Add qemu_[un]register_reset() stubs
libqemustub: vmstate register/unregister stubs
libqemustub:sysbus_get_default()stub
qdev: Include qdev code into *-user, too
cpu: Change parent type to Device
target-i386: kvm: -cpu host: UseGET_SUPPORTED_CPUIDfor SVM features
target-i386: kvm: Enable all supported KVM features for -cpu host
target-i386: check/enforce: Fix CPUID leaf numbers on error messages
target-i386: check/enforce: Do not ignore "hypervisor" flag
target-i386: check/enforce: Check all CPUID.80000001H.EDX bits
target-i386: check/enforce: Check SVM flag support as well
target-i386: check/enforce: Eliminatecheck_featfieldIgor Mammedov (3):
target-i386: Filter out unsupported features at realize time
target-i386: Sanitize AMD'sext2_featuresat realize time
target-i386: Explicitly set vendor for each built-in cpudefMakefile.objs | 8 +++ hw/Makefile.objs | 9 ++- hw/qdev.c | 8 ++- include/qemu-common.h | 4 +- include/qom/cpu.h | 6 +- qom/cpu.c | 6 +- stubs/Makefile.objs | 3 + stubs/reset.c | 13 +++++ stubs/sysbus.c | 6 ++ stubs/vmstate.c | 17 ++++++ target-alpha/cpu.c | 2 - target-i386/cpu.c | 153 ++++++++++++++++++++++++++++++++----------------- target-i386/cpu.h | 3 + 13 Dateien geändert, 171 Zeilen hinzugefügt(+), 67 Zeilen entfernt(-) create mode 100644 stubs/reset.c create mode 100644 stubs/sysbus.c create mode 100644 stubs/vmstate.c
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
Quoted 15 lines · Andreas Färber
Am 08.01.2013 21:56, schrieb Andreas Färber:
Quoted 9 lines
Hello,
This is my current QOM CPU patch queue. Please pull.
It includes:
* CPU as a device,
* improvements for x86 -cpu host,
* cleanups and preparations for QOM realize.Quoted 4 lines
Another pull is intended before the Soft Freeze.
Regards,
Andreas
Quoted 8 lines
Updated:
The following changes since commit
560c30b1db1d40fe45c5104185367c4de43399d3:Merge remote-tracking branch 'kraxel/usb.75' into staging (2013-01-08
10:36:20 -0600)are available in the git repository at:
I already processed the previous one. Please send a delta.
Really should avoid updating pull requests... Better to send another one.
Regards,
Anthony Liguori
Quoted 54 lines
git://github.com/afaerber/qemu-cpu.gitqom-cpufor you to fetch changes up to
aa9bae00da7b264131bc1de2a128bb0236851b40:target-i386: Explicitly set vendor for each built-in cpudef
(2013-01-08 22:52:43 +0100)Quoted 41 lines
----------------------------------------------------------------
Andreas Färber (2):
qdev: Don't assume existence of parent bus on unparentingqemu-common.h: Makeqemu_init_vcpu()stub static inlineEduardo Habkost (12):
libqemustub: Add qemu_[un]register_reset() stubs
libqemustub: vmstate register/unregister stubs
libqemustub:sysbus_get_default()stub
qdev: Include qdev code into *-user, too
cpu: Change parent type to Device
target-i386: kvm: -cpu host: UseGET_SUPPORTED_CPUIDfor SVM features
target-i386: kvm: Enable all supported KVM features for -cpu host
target-i386: check/enforce: Fix CPUID leaf numbers on error messages
target-i386: check/enforce: Do not ignore "hypervisor" flag
target-i386: check/enforce: Check all CPUID.80000001H.EDX bits
target-i386: check/enforce: Check SVM flag support as well
target-i386: check/enforce: Eliminatecheck_featfieldIgor Mammedov (3):
target-i386: Filter out unsupported features at realize time
target-i386: Sanitize AMD'sext2_featuresat realize time
target-i386: Explicitly set vendor for each built-in cpudefMakefile.objs | 8 +++ hw/Makefile.objs | 9 ++- hw/qdev.c | 8 ++- include/qemu-common.h | 4 +- include/qom/cpu.h | 6 +- qom/cpu.c | 6 +- stubs/Makefile.objs | 3 + stubs/reset.c | 13 +++++ stubs/sysbus.c | 6 ++ stubs/vmstate.c | 17 ++++++ target-alpha/cpu.c | 2 - target-i386/cpu.c | 153 ++++++++++++++++++++++++++++++++----------------- target-i386/cpu.h | 3 + 13 Dateien geändert, 171 Zeilen hinzugefügt(+), 67 Zeilen entfernt(-) create mode 100644 stubs/reset.c create mode 100644 stubs/sysbus.c create mode 100644 stubs/vmstate.cSignature · 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
Am 08.01.2013 23:34, schrieb Anthony Liguori:
Quoted 24 lines
Quoted 22 lines · Andreas Färber
Am 08.01.2013 21:56, schrieb Andreas Färber:
Quoted 9 lines
Hello,
This is my current QOM CPU patch queue. Please pull.
It includes:
* CPU as a device,
* improvements for x86 -cpu host,
* cleanups and preparations for QOM realize.Quoted 4 lines
Another pull is intended before the Soft Freeze.
Regards,
AndreasUpdated:
The following changes since commit
560c30b1db1d40fe45c5104185367c4de43399d3:Merge remote-tracking branch 'kraxel/usb.75' into staging (2013-01-08
10:36:20 -0600)
Quoted 6 lines
Quoted 1 line
are available in the git repository at:
I already processed the previous one. Please send a delta.
Really should avoid updating pull requests... Better to send another one.
There is no delta for another pull, just a filled-in Reviewed-by.
Thanks for processing so quickly,
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
Pulled, thanks.
Regards,
Anthony Liguori