QOM CPUState patch queue 2014-09-05
Hello Peter,
This is my (corrected) QOM CPU patch queue. Please pull.
Regards,
Andreas
The following changes since commit fd884c07658d02a96a882b8457d6d7a5cd71a407:
Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging (2014-09-04 19:41:15 +0100)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git tags/qom-cpu-for-peter
for you to fetch changes up to c00c94abbdb82c39c22b6dd72875aa1ae0f4b2c0:
target-i386: Reject invalid CPU feature names on the command-line (2014-09-05 16:37:07 +0200)
----------------------------------------------------------------
QOM CPUState and X86CPU
* Include exception state in CPU VMState
* Fix -cpu *,migratable=foo
* Error out on unknown -cpu *,+foo,-bar
----------------------------------------------------------------
Eduardo Habkost (2):
target-i386: Support migratable=no properly
target-i386: Reject invalid CPU feature names on the command-line
Pavel Dovgaluk (1):
exec: Save CPUState::exception_index field
exec.c | 35 +++++++++++++++++++++++++++++++++++ target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 32 ++++++++++++++++++++------------ 3 files changed, 56 insertions(+), 12 deletions(-)
[Qemu-devel] [PULL v3 1/3] exec: Save CPUState::exception_index field
From: Pavel Dovgaluk <[email protected]>
This patch adds a subsection with exception_index field to the VMState for correct saving the CPU state.
Without this patch, simulator could miss the pending exception in the saved virtual machine state.
--- exec.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
exec.c +35 -0
@@ -430,15 +430,50 @@ static int cpu_common_post_load(void *opaque, int version_id)return 0 ; } +static int cpu_common_pre_load (void *opaque) +{ +CPUState *cpu = opaque; + + cpu->exception_index =0 ; + +return 0 ; +} + +static bool cpu_common_exception_index_needed (void *opaque) +{ +CPUState *cpu = opaque; + +return cpu->exception_index !=0 ; +} + +static const VMStateDescription vmstate_cpu_common_exception_index = { + .name ="cpu_common/exception_index" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_INT32 (exception_index, CPUState), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_cpu_common = { .name ="cpu_common" , .version_id =1 , .minimum_version_id =1 , + .pre_load = cpu_common_pre_load, .post_load = cpu_common_post_load, .fields = (VMStateField []) {VMSTATE_UINT32 (halted, CPUState),VMSTATE_UINT32 (interrupt_request, CPUState),VMSTATE_END_OF_LIST () + }, + .subsections = (VMStateSubsection []) { + { + .vmsd = &vmstate_cpu_common_exception_index, + .needed = cpu_common_exception_index_needed, + } , { +/* empty */ + } } };
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL v3 2/3] target-i386: Support migratable=no properly
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
When the "migratable" property was implemented, the behavior was tested by changing the default on the code, but actually using the option on the command-line (e.g. "-cpu host,migratable=false") doesn't work as expected. This is a regression for a common use case of "-cpu host", which is to enable features that are supported by the host CPU + kernel before feature-specific code is added to QEMU.
Fix this by initializing the feature words for "-cpu host" on x86_cpu_parse_featurestr(), right after parsing the CPU options.
--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-)
target-i386/cpu-qom.h +1 -0
@@ -92,6 +92,7 @@ typedef struct X86CPU {bool enforce_cpuid;bool expose_kvm;bool migratable; +bool host_features;/* if true the CPUID code directly forward host cache leaves to the guest */ bool cache_info_passthrough;
target-i386/cpu.c +15 -8
@@ -1254,6 +1254,9 @@ void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w, } } +static uint32_t x86_cpu_get_supported_feature_word (FeatureWord w, +bool migratable_only); +#ifdef CONFIG_KVM static int cpu_x86_fill_model_id (char *str)
@@ -1310,26 +1313,23 @@ static void host_x86_cpu_class_init(ObjectClass *oc, void *data) dc->props = host_x86_cpu_properties; } -static uint32_t x86_cpu_get_supported_feature_word (FeatureWord w, -bool migratable_only); -static void host_x86_cpu_initfn (Object *obj) {X86CPU *cpu =X86_CPU (obj);CPUX86State *env = &cpu->env;KVMState *s = kvm_state; -FeatureWord w;assert (kvm_enabled ()); +/* We can't fill the features array here because we don't know yet if +* "migratable" is true or false. +*/ + cpu->host_features = true; + env->cpuid_level =kvm_arch_get_supported_cpuid (s,0x0 ,0 ,R_EAX ); env->cpuid_xlevel =kvm_arch_get_supported_cpuid (s,0x80000000 ,0 ,R_EAX ); env->cpuid_xlevel2 =kvm_arch_get_supported_cpuid (s,0xC0000000 ,0 ,R_EAX ); -for (w =0 ; w <FEATURE_WORDS ; w++) { - env->features[w] = -x86_cpu_get_supported_feature_word (w, cpu->migratable); - }object_property_set_bool (OBJECT (cpu), true,"pmu" , &error_abort); }
@@ -1828,6 +1828,13 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, featurestr =strtok (NULL ,"," ); } +if (cpu->host_features) { +for (w =0 ; w <FEATURE_WORDS ; w++) { + env->features[w] = +x86_cpu_get_supported_feature_word (w, cpu->migratable); + } + } +for (w =0 ; w <FEATURE_WORDS ; w++) { env->features[w] |= plus_features[w]; env->features[w] &= ~minus_features[w];
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL v3 3/3] target-i386: Reject invalid CPU feature names on the command-line
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
Instead of simply printing a warning, report an error when invalid CPU options are provided on the CPU model string.
--- target-i386/cpu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
target-i386/cpu.c +5 -4
@@ -592,7 +592,8 @@ static bool lookup_feature(uint32_t *pval, const char *s, const char *e, }static void add_flagname_to_bitmaps (const char *flagname, -FeatureWordArray words) +FeatureWordArray words, +Error **errp) {FeatureWord w;for (w =0 ; w <FEATURE_WORDS ; w++) {
@@ -603,7 +604,7 @@ static void add_flagname_to_bitmaps(const char *flagname, } }if (w ==FEATURE_WORDS ) { -fprintf (stderr,"CPU feature %s not found\n" , flagname); +error_setg (errp,"CPU feature %s not found" , flagname); } }
@@ -1761,9 +1762,9 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features,while (featurestr) {char *val;if (featurestr[0 ] =='+' ) { -add_flagname_to_bitmaps (featurestr +1 , plus_features); +add_flagname_to_bitmaps (featurestr +1 , plus_features, &local_err); }else if (featurestr[0 ] =='-' ) { -add_flagname_to_bitmaps (featurestr +1 , minus_features); +add_flagname_to_bitmaps (featurestr +1 , minus_features, &local_err); }else if ((val =strchr (featurestr,'=' ))) { *val =0 ; val++;feat2prop (featurestr);
Signature · 1 line
1.8.4.5
Peter Maydell
AppliedQuoted 36 lines · Andreas Färber
Hello Peter,
This is my (corrected) QOM CPU patch queue. Please pull.
Regards,
AndreasCc Peter Maydell <[email protected]>Cc Eduardo Habkost <[email protected]>The following changes since commit
fd884c07658d02a96a882b8457d6d7a5cd71a407:Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging (2014-09-04 19:41:15 +0100)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.gittags/qom-cpu-for-peterfor you to fetch changes up to
c00c94abbdb82c39c22b6dd72875aa1ae0f4b2c0:target-i386: Reject invalid CPU feature names on the command-line (2014-09-05 16:37:07 +0200)
----------------------------------------------------------------
QOM CPUState and X86CPU* Include exception state in CPU VMState
* Fix -cpu *,migratable=foo
* Error out on unknown -cpu *,+foo,-bar----------------------------------------------------------------
Eduardo Habkost (2):
target-i386: Support migratable=no properly
target-i386: Reject invalid CPU feature names on the command-line
Quoted 7 lines
Pavel Dovgaluk (1):
exec: SaveCPUState::exception_indexfieldexec.c | 35 +++++++++++++++++++++++++++++++++++ target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 32 ++++++++++++++++++++------------ 3 files changed, 56 insertions(+), 12 deletions(-)
Applied, thanks.
-- PMM