Files
qemu-spoof/patches/0021-smbios-identity.patch
T

82 lines
3.9 KiB
Diff

qemu-spoof: SMBIOS type3/4/11/17 identity
Wire the remaining SMBIOS getters (module already derives them):
- type3 chassis type (Desktop/Notebook, from the persona machine class)
- type4 processor socket designation + processor manufacturer (CPU-vendor anchored)
- type11 OEM strings: QEMU emits no type 11 at all (a tell); emit the spoofed
OEM string when config provided none
- type17 memory manufacturer / serial / part (brand-correct, per-unit)
All inert unless a spoof-seed is set (getters return the stock value when off).
The type0 "VM" bit is handled by 0015; the spoof.h include is added there.
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 7d71418..0d8e569 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -656,7 +656,7 @@ static void smbios_build_type_3_table(void)
SMBIOS_BUILD_TABLE_PRE(3, T3_BASE, true); /* required */
SMBIOS_TABLE_SET_STR(3, manufacturer_str, type3.manufacturer);
- t->type = 0x01; /* Other */
+ t->type = spoof_smbios_chassis_type(0x01); /* Other (3=Desktop, 10=Notebook) */
SMBIOS_TABLE_SET_STR(3, version_str, type3.version);
SMBIOS_TABLE_SET_STR(3, serial_number_str, type3.serial);
SMBIOS_TABLE_SET_STR(3, asset_tag_number_str, type3.asset);
@@ -690,11 +690,13 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance,
SMBIOS_BUILD_TABLE_PRE_SIZE(4, T4_BASE + instance,
true, tbl_len); /* required */
- snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
+ snprintf(sock_str, sizeof(sock_str), "%s%2x",
+ spoof_smbios_cpu_socket(type4.sock_pfx), instance);
SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
t->processor_type = 0x03; /* CPU */
t->processor_family = 0xfe; /* use Processor Family 2 field */
- SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
+ SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str,
+ spoof_smbios_cpu_manufacturer(type4.manufacturer));
if (type4.processor_id == 0) {
t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
t->processor_id[1] = cpu_to_le32(smbios_cpuid_features);
@@ -825,13 +827,23 @@ static void smbios_build_type_11_table(void)
{
char count_str[128];
size_t i;
+ /* qemu-spoof: real machines expose OEM strings here; QEMU emits no type 11 at
+ * all, which is itself a tell. If config gave none, emit the spoofed one. */
+ const char *spoof_oem = spoof_smbios_oem_string(NULL);
- if (type11.nvalues == 0) {
+ if (type11.nvalues == 0 && !spoof_oem) {
return;
}
SMBIOS_BUILD_TABLE_PRE(11, T11_BASE, true); /* required */
+ if (type11.nvalues == 0) {
+ t->count = 1;
+ SMBIOS_TABLE_SET_STR_LIST(11, spoof_oem);
+ SMBIOS_BUILD_TABLE_POST;
+ return;
+ }
+
snprintf(count_str, sizeof(count_str), "%zu", type11.nvalues);
t->count = type11.nvalues;
@@ -900,10 +912,13 @@ static void smbios_build_type_17_table(unsigned instance, uint64_t size)
t->memory_type = 0x07; /* RAM */
t->type_detail = cpu_to_le16(0x02); /* Other */
t->speed = cpu_to_le16(type17.speed);
- SMBIOS_TABLE_SET_STR(17, manufacturer_str, type17.manufacturer);
- SMBIOS_TABLE_SET_STR(17, serial_number_str, type17.serial);
+ SMBIOS_TABLE_SET_STR(17, manufacturer_str,
+ spoof_smbios_mem_manufacturer(type17.manufacturer));
+ SMBIOS_TABLE_SET_STR(17, serial_number_str,
+ spoof_smbios_mem_serial(type17.serial));
SMBIOS_TABLE_SET_STR(17, asset_tag_number_str, type17.asset);
- SMBIOS_TABLE_SET_STR(17, part_number_str, type17.part);
+ SMBIOS_TABLE_SET_STR(17, part_number_str,
+ spoof_smbios_mem_part(type17.part));
t->attributes = 0; /* Unknown */
t->configured_clock_speed = t->speed; /* reuse value for max speed */
t->minimum_voltage = cpu_to_le16(0); /* Unknown */