Page 1 of 1

[SOLVED] ACPICA Corrupted Tables on Qemu

Posted: Fri Dec 07, 2012 1:00 am
by thepowersgang
I've decided to add ACPICA to my OS, but despite having what seems to be correct implimetations of all the OS shim functions (linked below), the ACPI tables on qemu appear partially corrupted (despite the pointer being correct)

Code: Select all

00000000000000 AcpiOsGetRootPointer[0]: val=FD8C0
ACPI: RSDP *0xFD8C0 00014 (v0 BOCHS )
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFE550+1 pg) to *0xFE000550
ACPI: RSDT *0x7FFE550 00038 (v1 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000550
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFE550+1 pg) to *0xFE000550
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000550
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFFF80+1 pg) to *0xFE000F80
ACPI: _HID *0x7FFFF80 3D0410C (v3  ?_STA ????)_CR 54080053 MP_? 47150A18)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000F80
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFFE40+1 pg) to *0xFE000E40
ACPI: ?[?? *0x7FFFE40 4D545048 (v19 END PR D_ ?6_ST 56700041 END` 44525070)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000E40
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFFD50+1 pg) to *0xFE000D50
ACPI: LNKA *0x7FFFD50 40E1200 (v12     ??      NKB 0B015453      5010815B)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000D50
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFFD10+1 pg) to *0xFE000D10
ACPI:  ??? *0x7FFFD10 4E4C020A (v75              ?? 0D120041 ???? 4C00001F)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000D10
00000000000000 AcpiOsMapMemory[0]: Map (0x7FFF6C0+1 pg) to *0xFE0006C0
ACPI:   KD *0x7FFF6C0 FF0C040E (v25               A 4C000003  NKC 0C040D12)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE0006C0
ACPI Exception: AE_NO_ACPI_TABLES, While loading namespace from ACPI tables (20121114/tbxfload-161)
00000000000000e [ACPI    ] 0 - AcpiLoadTables: 2
The shim code is avaliable at https://github.com/thepowersgang/acess2 ... 6/acpica.c

(Edit: On Bochs / VirtualBox the tables are sane, and I hit a page fault in the ACPICA code - somewhere around the AML VM from memory - I'm pretty sure that's my fault somehow)

Re: ACPICA Corrupted Tables on Qemu

Posted: Fri Dec 07, 2012 9:34 am
by Cognition
I'm not 100% certain but it looks like a problem in the mapping. ACPICA appears to be trying to locate additional tables but ends up pulling out what looks like AML code values. So either something is wrong with your mapping function or there's some other memory corruption that's disrupting the values read in from the RSDT (which appears valid).

Re: ACPICA Corrupted Tables on Qemu

Posted: Fri Dec 07, 2012 6:48 pm
by thepowersgang
I would blame the mapping code too, if that code wasn't known stable (the function used is integral to my MM code, and has been tested thoroughly) and works in the same situation on two other VMs.

I'll check if that memory is writable, then work on validating if it's being corrupted (I gave a brief check of my page allocator, but didn't find anything)

Here is the bochs output for comparison (from bochs 2.6, the qemu dump was from 1.2.0)

Code: Select all

00000000000000 AcpiOsGetRootPointer[0]: val=FA680
ACPI: RSDP *0xFA680 00014 (v0 BOCHS )
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0000+1 pg) to *0xFE000000
ACPI: RSDT *0x1FF0000 00030 (v1 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000000
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0000+1 pg) to *0xFE000000
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000000
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0030+1 pg) to *0xFE000030
ACPI: FACP *0x1FF0030 00074 (v1 BOCHS  BXPCFACP 00000001 BXPC 00000001)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000030
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0030+1 pg) to *0xFE000030
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000030
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0100+1 pg) to *0xFE000100
ACPI: DSDT *0x1FF0100 0080D (v1   BXPC   BXDSDT 00000001 INTL 20090320)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000100
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF00C0+1 pg) to *0xFE0000C0
ACPI: FACS *0x1FF00C0 00040
00000000000000 AcpiOsUnmapMemory[0]: *0xFE0000C0
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0958+1 pg) to *0xFE000958
ACPI: APIC *0x1FF0958 00052 (v1 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE000958
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF090D+1 pg) to *0xFE00090D
ACPI: SSDT *0x1FF090D 00044 (v1 BOCHS  BXPCSSDT 00000001 BXPC 00000001)
00000000000000 AcpiOsUnmapMemory[0]: *0xFE00090D
00000000000000 AcpiOsMapMemory[0]: Map (0x1FF0100+1 pg) to *0xFE000100

Re: ACPICA Corrupted Tables on Qemu

Posted: Fri Dec 07, 2012 8:09 pm
by Cognition
It's very possible that it's just a small amount of memory being overwritten, maybe a single byte or word given that the pointer is still in the right ballpark. Another thing worth trying might be configuring ACPICA to use it's internal cache implementation to see if it runs into similar errors, that might narrow it down to your own caching implementation (though it looks fine). One thing I'll note that can really screw things up is simply updating your ACPICA revision incorrectly. I was chasing a phantom bug in my code for months once due to a botched update. ACPICA can dump a ton of debug info if it's configured for it too, you can probably narrow things down fairly quickly at this point as only the tables are being parsed so there's a lot less info to go through. At any rate if the mapping code is solid the next most likely candidate is the object cache implementation and probably the heap after that.

Re: ACPICA Corrupted Tables on Qemu

Posted: Fri Dec 07, 2012 9:12 pm
by thepowersgang
Actually, I've just found out why it broke, and it's because this is the first time this MM function has been used in this way (repeated map/unmap)... TLB. Running a page dump after each mapping caused tables to parse correctly, hence it was most probably the TLB not being flushed. Adding an invlpg after the unmap fixed the problem.

Now to figure out why the AML VM segfaults.