Author: stepan Date: 2009-12-02 19:14:10 +0100 (Wed, 02 Dec 2009) New Revision: 84
Modified: trunk/SerialICE/scripts/serialice.lua trunk/qemu-0.11.0/serialice.c Log: CPUID filter update: * calling CPUID is harmless, so call it unconditionally before calling the LUA filter. This allows us to pass the CPUID results into the LUA filter so we can easier modify them (in a more portable way)
Memory update: * Make low FSEG bios copy read/write so it can be overwritten by the BIOS. This should fix some BIOS brands that copy their uncompressed code to the FSEG before jumping to it.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/SerialICE/scripts/serialice.lua =================================================================== --- trunk/SerialICE/scripts/serialice.lua 2009-12-02 16:44:14 UTC (rev 83) +++ trunk/SerialICE/scripts/serialice.lua 2009-12-02 18:14:10 UTC (rev 84) @@ -402,15 +402,17 @@ return false, hi, lo end
-function SerialICE_cpuid_filter(eax, ecx) - -- set all to 0 so they're defined but return false, so the - -- result is not filtered. - -- NOTE: If the result is filtered, all four registers are - -- overwritten. - eax = 0 - ebx = 0 - ecx = 0 - edx = 0 +function SerialICE_cpuid_filter(in_eax, in_ecx, eax, ebx, ecx, edx) + + -- Set number of cores to 1 on Core Duo and Atom to trick the + -- firmware into not trying to wake up non-BSP nodes. + if in_eax == 1 then + ebx = bit.band(0xff00ffff, ebx); + ebx = bit.bor(0x00010000, ebx); + return true, eax, ebx, ecx, edx + end + + -- return false, so the result is not filtered. return false, eax, ebx, ecx, edx end
Modified: trunk/qemu-0.11.0/serialice.c =================================================================== --- trunk/qemu-0.11.0/serialice.c 2009-12-02 16:44:14 UTC (rev 83) +++ trunk/qemu-0.11.0/serialice.c 2009-12-02 18:14:10 UTC (rev 84) @@ -286,8 +286,8 @@ result = lua_pcall(L, 3, 3, 0); if (result) { fprintf(stderr, - "Failed to run function SerialICE_msr_read_filter: %s\n", - lua_tostring(L, -1)); + "Failed to run function SerialICE_msr_%s_filter: %s\n", + (flags & FILTER_WRITE)?"write":"read", lua_tostring(L, -1)); exit(1); } ret = lua_toboolean(L, -3); @@ -300,18 +300,24 @@ return ret; }
-static int serialice_cpuid_filter(cpuid_regs_t * regs) +static int serialice_cpuid_filter(uint32_t eax, uint32_t ecx, + cpuid_regs_t * regs) { int ret, result;
lua_getfield(L, LUA_GLOBALSINDEX, "SerialICE_cpuid_filter");
- lua_pushinteger(L, regs->eax); // eax - lua_pushinteger(L, regs->ecx); // ecx - result = lua_pcall(L, 2, 5, 0); + lua_pushinteger(L, eax); // eax before calling + lua_pushinteger(L, ecx); // ecx before calling + // and the registers after calling cpuid + lua_pushinteger(L, regs->eax); // eax + lua_pushinteger(L, regs->ebx); // ebx + lua_pushinteger(L, regs->ecx); // ecx + lua_pushinteger(L, regs->edx); // edx + result = lua_pcall(L, 6, 5, 0); if (result) { fprintf(stderr, - "Failed to run function SerialICE_msr_read_filter: %s\n", + "Failed to run function SerialICE_cpuid_filter: %s\n", lua_tostring(L, -1)); exit(1); } @@ -780,22 +786,21 @@ ret.ecx = ecx; ret.edx = 0; // either set by filter or by target
- filtered = serialice_cpuid_filter(&ret); - if (!filtered) { - sprintf(s->command, "*ci%08x.%08x", eax, ecx); + sprintf(s->command, "*ci%08x.%08x", eax, ecx);
- // command read back: "\n000006f2.00000000.00001234.12340324" - // (36 characters) - serialice_command(s->command, 36); + // command read back: "\n000006f2.00000000.00001234.12340324" + // (36 characters) + serialice_command(s->command, 36); + + s->buffer[9] = 0; // . -> \0 + s->buffer[18] = 0; // . -> \0 + s->buffer[27] = 0; // . -> \0 + ret.eax = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); + ret.ebx = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16); + ret.ecx = (uint32_t) strtoul(s->buffer + 19, (char **)NULL, 16); + ret.edx = (uint32_t) strtoul(s->buffer + 28, (char **)NULL, 16);
- s->buffer[9] = 0; // . -> \0 - s->buffer[18] = 0; // . -> \0 - s->buffer[27] = 0; // . -> \0 - ret.eax = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); - ret.ebx = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16); - ret.ecx = (uint32_t) strtoul(s->buffer + 19, (char **)NULL, 16); - ret.edx = (uint32_t) strtoul(s->buffer + 28, (char **)NULL, 16); - } + filtered = serialice_cpuid_filter(eax, ecx, &ret);
serialice_cpuid_log(eax, ecx, ret, filtered);
@@ -1151,7 +1156,7 @@ cpu_register_physical_memory(0x100000 - isa_bios_size, isa_bios_size, (bios_offset + bios_size - - isa_bios_size) | IO_MEM_ROM); + isa_bios_size));
/* map all the bios at the top of memory */ cpu_register_physical_memory((uint32_t) (-bios_size), bios_size,