[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-2.9 10/17] target-i386: Allow short strings to b
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH for-2.9 10/17] target-i386: Allow short strings to be used as vendor ID |
Date: |
Fri, 2 Dec 2016 19:18:09 -0200 |
If a short string is specified, it will be padded with zeroes.
Without this, "query-cpu-model-expansion model=base" would return
an expansion that would never work in the command-line.
Signed-off-by: Eduardo Habkost <address@hidden>
---
target-i386/cpu.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 98e1063..a584c3e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1789,19 +1789,22 @@ static void x86_cpuid_set_vendor(Object *obj, const
char *value,
X86CPU *cpu = X86_CPU(obj);
CPUX86State *env = &cpu->env;
int i;
+ char buf[CPUID_VENDOR_SZ] = { 0 };
- if (strlen(value) != CPUID_VENDOR_SZ) {
+ if (strlen(value) > CPUID_VENDOR_SZ) {
error_setg(errp, QERR_PROPERTY_VALUE_BAD, "", "vendor", value);
return;
}
+ strncpy(buf, value, sizeof(buf));
+
env->cpuid_vendor1 = 0;
env->cpuid_vendor2 = 0;
env->cpuid_vendor3 = 0;
for (i = 0; i < 4; i++) {
- env->cpuid_vendor1 |= ((uint8_t)value[i ]) << (8 * i);
- env->cpuid_vendor2 |= ((uint8_t)value[i + 4]) << (8 * i);
- env->cpuid_vendor3 |= ((uint8_t)value[i + 8]) << (8 * i);
+ env->cpuid_vendor1 |= ((uint8_t)buf[i]) << (8 * i);
+ env->cpuid_vendor2 |= ((uint8_t)buf[i + 4]) << (8 * i);
+ env->cpuid_vendor3 |= ((uint8_t)buf[i + 8]) << (8 * i);
}
}
--
2.7.4
- [Qemu-devel] [PATCH for-2.9 00/17] target-i386: Implement query-cpu-model-expansion, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 01/17] qmp: Report QOM type name on query-cpu-definitions, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 02/17] qemu.py: Make logging optional, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 03/17] qtest.py: Support QTEST_LOG environment variable, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 04/17] qtest.py: make logging optional, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 05/17] qtest.py: Make 'binary' parameter optional, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 06/17] tests: Add rules to non-gtester qtest test cases, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 07/17] target-i386: Reorganize and document CPUID initialization steps, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 08/17] target-i386: Support "-cpu host" on TCG too, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 09/17] target-i386: Move "host" properties to base class, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 10/17] target-i386: Allow short strings to be used as vendor ID,
Eduardo Habkost <=
- [Qemu-devel] [PATCH for-2.9 12/17] target-i386: Return migration-safe field on query-cpu-definitions, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 13/17] cpu: Support comma escaping when parsing -cpu, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 11/17] target-i386: Remove AMD feature flag aliases from Opteron models, Eduardo Habkost, 2016/12/02
- [Qemu-devel] [PATCH for-2.9 15/17] target-i386: Define static "base" CPU model, Eduardo Habkost, 2016/12/02