diff options
author | Andreas Färber <afaerber@suse.de> | 2012-02-17 17:46:01 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-24 09:06:58 -0600 |
commit | ed5e1ec3fc00911a2231de8e4c7717aa63a116ab (patch) | |
tree | 0d1a05044c7bf8549e44150184aea4ec3d422bcc /target-i386/cpuid.c | |
parent | 8811e1e174f885a87d4ada0290e7e40fd21fff89 (diff) |
target-i386: Introduce x86_cpuid_version_set_family()
Move the logic for setting the family and extended family into a
helper function.
To make the helper self-contained and in preparation of future
unordered/multiple uses, mask out any previous family values first.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'target-i386/cpuid.c')
-rw-r--r-- | target-i386/cpuid.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index ace2a6779c..47e2881103 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -597,6 +597,16 @@ static int check_features_against_host(x86_def_t *guest_def) return rv; } +static void x86_cpuid_version_set_family(CPUX86State *env, int family) +{ + env->cpuid_version &= ~0xff00f00; + if (family > 0x0f) { + env->cpuid_version |= 0xf00 | ((family - 0x0f) << 20); + } else { + env->cpuid_version |= family << 8; + } +} + static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) { unsigned int i; @@ -883,10 +893,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model) } env->cpuid_vendor_override = def->vendor_override; env->cpuid_level = def->level; - if (def->family > 0x0f) - env->cpuid_version = 0xf00 | ((def->family - 0x0f) << 20); - else - env->cpuid_version = def->family << 8; + x86_cpuid_version_set_family(env, def->family); env->cpuid_version |= ((def->model & 0xf) << 4) | ((def->model >> 4) << 16); env->cpuid_version |= def->stepping; env->cpuid_features = def->features; |