From: Jiri Denemark Date: Wed, 15 Mar 2017 13:29:30 +0000 (+0100) Subject: cputest: Add cpuidLeaf helper to cpu-cpuid.py X-Git-Tag: v3.2.0-rc1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74f0b0c552f854292f971e3a61d5ef06c19fd937;p=thirdparty%2Flibvirt.git cputest: Add cpuidLeaf helper to cpu-cpuid.py Signed-off-by: Jiri Denemark --- diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 9ea858d98f..f4cf6d4408 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -189,6 +189,18 @@ def cpuidIsSet(cpuid, feature): (edx > 0 and leaf["edx"] & edx > 0)) +def cpuidLeaf(cpuid, in_eax, in_ecx): + if in_eax not in cpuid: + cpuid[in_eax] = {} + leaf = cpuid[in_eax] + + if in_ecx not in leaf: + leaf[in_ecx] = {"eax": 0, "ebx": 0, "ecx": 0, "edx": 0} + leaf = leaf[in_ecx] + + return leaf + + def parseFeatureWords(path): features = None @@ -222,14 +234,7 @@ def parseFeatureWords(path): if "cpuid-input-ecx" in feat: in_ecx = feat["cpuid-input-ecx"] - if in_eax not in cpuid: - cpuid[in_eax] = {} - leaf = cpuid[in_eax] - - if in_ecx not in leaf: - leaf[in_ecx] = {"eax": 0, "ebx": 0, "ecx": 0, "edx": 0} - leaf = leaf[in_ecx] - + leaf = cpuidLeaf(cpuid, in_eax, in_ecx) leaf[feat["cpuid-register"].lower()] = feat["features"] return props, cpuid