Hi guys,
I'm using the hack below to do some quick kernel testing by setting
arbitrary feature bits and then make it execute the code for that
feature.
For example, boot with:
-cpu EPYC,cpuid-leaf=0x80000007,ebx=0xf
to set some RAS feature bits and test newer RAS code.
Would something like that be of interest to a wider audience?
It is rough and ugly but if deemed useful, I could try to clean it up.
Thx.
---
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 045d66191f28..249fb23be696 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -2732,6 +2732,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
uint32_t limit;
uint32_t signature[3];
+ /*
+ * Pull up max xlevel in case the one we've specified on the cmdline is
+ * higher.
+ */
+ if (cpu->cpuid_leaf && env->cpuid_xlevel < cpu->cpuid_leaf)
+ env->cpuid_xlevel = cpu->cpuid_leaf;
+
/* Calculate & apply limits for different index ranges */
if (index >= 0xC0000000) {
limit = env->cpuid_xlevel2;
@@ -3140,6 +3147,22 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
*edx = 0;
break;
}
+
+ /* Do CPUID overrides: */
+ if (cpu->cpuid_leaf && cpu->cpuid_leaf == index) {
+
+ if (cpu->eax)
+ *eax = cpu->eax;
+
+ if (cpu->ebx)
+ *ebx = cpu->ebx;
+
+ if (cpu->ecx)
+ *ecx = cpu->ecx;
+
+ if (cpu->edx)
+ *edx = cpu->edx;
+ }
}
/* CPUClass::reset() */
@@ -4173,6 +4196,11 @@ static Property x86_cpu_properties[] = {
* to the specific Windows version being used."
*/
DEFINE_PROP_INT32("x-hv-max-vps", X86CPU, hv_max_vps, -1),
+ DEFINE_PROP_UINT32("cpuid-leaf", X86CPU, cpuid_leaf, UINT32_MAX),
+ DEFINE_PROP_UINT32("eax", X86CPU, eax, UINT32_MAX),
+ DEFINE_PROP_UINT32("ebx", X86CPU, ebx, UINT32_MAX),
+ DEFINE_PROP_UINT32("ecx", X86CPU, ecx, UINT32_MAX),
+ DEFINE_PROP_UINT32("edx", X86CPU, edx, UINT32_MAX),
DEFINE_PROP_END_OF_LIST()
};
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index b086b1528b89..b336b0849456 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1284,6 +1284,13 @@ struct X86CPU {
int32_t thread_id;
int32_t hv_max_vps;
+
+ /*
+ * CPUID overrides:
+ */
+ uint32_t cpuid_leaf;
+ uint32_t eax, ebx, ecx, edx;
+
};
static inline X86CPU *x86_env_get_cpu(CPUX86State *env)
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
Hi, This series seems to have some coding style problems. See output below for more information: Subject: [Qemu-devel] qemu x86 CPUID leafs override Type: series Message-id: 20171123131331.5jyqwlbgthijqgl7@pd.tnic === TEST SCRIPT BEGIN === #!/bin/bash BASE=base n=1 total=$(git log --oneline $BASE.. | wc -l) failed=0 git config --local diff.renamelimit 0 git config --local diff.renames True commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..." if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then failed=1 echo fi n=$((n+1)) done exit $failed === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu t [tag update] patchew/1511388334-16347-1-git-send-email-pmorel@linux.vnet.ibm.com -> patchew/1511388334-16347-1-git-send-email-pmorel@linux.vnet.ibm.com * [new tag] patchew/20171123131331.5jyqwlbgthijqgl7@pd.tnic -> patchew/20171123131331.5jyqwlbgthijqgl7@pd.tnic Switched to a new branch 'test' e148d5c86c qemu x86 CPUID leafs override === OUTPUT BEGIN === Checking PATCH 1/1: qemu x86 CPUID leafs override... ERROR: code indent should never use tabs #39: FILE: target/i386/cpu.c:2740: +^I env->cpuid_xlevel = cpu->cpuid_leaf;$ ERROR: code indent should never use tabs #52: FILE: target/i386/cpu.c:3154: +^I if (cpu->eax)$ ERROR: braces {} are necessary for all arms of this statement #52: FILE: target/i386/cpu.c:3154: + if (cpu->eax) [...] ERROR: code indent should never use tabs #53: FILE: target/i386/cpu.c:3155: +^I^I *eax = cpu->eax;$ ERROR: code indent should never use tabs #55: FILE: target/i386/cpu.c:3157: +^I if (cpu->ebx)$ ERROR: braces {} are necessary for all arms of this statement #55: FILE: target/i386/cpu.c:3157: + if (cpu->ebx) [...] ERROR: code indent should never use tabs #56: FILE: target/i386/cpu.c:3158: +^I^I *ebx = cpu->ebx;$ ERROR: code indent should never use tabs #58: FILE: target/i386/cpu.c:3160: +^I if (cpu->ecx)$ ERROR: braces {} are necessary for all arms of this statement #58: FILE: target/i386/cpu.c:3160: + if (cpu->ecx) [...] ERROR: code indent should never use tabs #59: FILE: target/i386/cpu.c:3161: +^I^I *ecx = cpu->ecx;$ ERROR: code indent should never use tabs #61: FILE: target/i386/cpu.c:3163: +^I if (cpu->edx)$ ERROR: braces {} are necessary for all arms of this statement #61: FILE: target/i386/cpu.c:3163: + if (cpu->edx) [...] ERROR: code indent should never use tabs #62: FILE: target/i386/cpu.c:3164: +^I^I *edx = cpu->edx;$ ERROR: Missing Signed-off-by: line(s) total: 14 errors, 0 warnings, 59 lines checked Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. === OUTPUT END === Test command exited with code: 1 --- Email generated automatically by Patchew [http://patchew.org/]. Please send your feedback to patchew-devel@freelists.org
© 2016 - 2024 Red Hat, Inc.