QOM CPUState and X86CPU

* Include exception state in CPU VMState
 * Fix -cpu *,migratable=foo
 * Error out on unknown -cpu *,+foo,-bar
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJUCcrWAAoJEPou0S0+fgE/Xe0QAL35pT77bnQF4xnIED9z24gG
 VU/sVSIK+iJLIbAYoBPyefsUANzg2Nz2Dw/aqXtS4DunOTPKanPik0alFNDjq51r
 Q+xsEJF417QYrn9WZAgnMCZmiU4UV9IWiC2LWAeC4xGgxoz8Td4LONTAq6+S2vau
 JSYVSHp2zbclItSikl/vOyIlAs/PAhkJoBIPDsze56zfR/6y7Rdt1XkCBF9H16lt
 diEiNiPpsv+tkgeMsTKgGwR+xRH5MJ78BaHS1ZLVa3W5vmdSF1r0lk5dS6qoxgR7
 3rmvSCdh7u6eJOra86n+Lvb4AaY4dWMG4IWzLf8lfWGOKnreuUkf22I8F7amE4rZ
 WL0tkW1Cv4EYUvmxAyVkrzQJxfEcs6FwT98miKRGHe2v79pKvCI+c8mZ5I7g6yo3
 wehcZo5jyb2XJMzOJF+MBnefijQvGlM5YrSJpXaoa3nxyVMDrqpSd7LP5WqVHssI
 +BxsDgYo+dxYBO6pL12iyuxBIiN51Gh/Bc5TtyiFaDW+hZY4eio95943pQeVk5f5
 tSe1LqywFsHR0cWb/0s3AOO4Ojg6zIjF141XVM/8rYc7bmWVsiiJ97wk9WzjSJOv
 L4U3lCbBpTYAxgIqtdRuRo4OatHuFkcg+H2ZddeQgIzVQBp9Jexku3AB8n5pt1/N
 4Bn7uLurxASuFuWpz7ZE
 =Ankt
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/afaerber/tags/qom-cpu-for-peter' into staging

QOM CPUState and X86CPU

* Include exception state in CPU VMState
* Fix -cpu *,migratable=foo
* Error out on unknown -cpu *,+foo,-bar

# gpg: Signature made Fri 05 Sep 2014 15:38:14 BST using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/qom-cpu-for-peter:
  target-i386: Reject invalid CPU feature names on the command-line
  target-i386: Support migratable=no properly
  exec: Save CPUState::exception_index field

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2014-09-05 16:03:56 +01:00
commit f102f22455
3 changed files with 56 additions and 12 deletions

35
exec.c
View File

@ -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 */
}
}
};

View File

@ -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;

View File

@ -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);
}
}
@ -1254,6 +1255,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 +1314,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);
}
@ -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);
@ -1828,6 +1829,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];