On Tue, 2013-02-05 at 23:14 -0500, Kevin O'Connor wrote:
I think the reloc_init() change that I wrote (patch 1) may have been a mistake because of the VISIBLE32INIT proliferation that it causes. I put together an alternate approach which requires csm_return().
Hm, there is strangeness here.
I disabled CONFIG_RELOCATE_INIT, and I made the Lock call in OVMF's LegacyRegion code a no-op so it's never actually locking it; just to eliminate certain classes of problem.
I also fixed your code as follows:
commit debcd72c34a6b8eba91c9157b15422d418fe8868 Author: David Woodhouse David.Woodhouse@intel.com Date: Wed Feb 6 13:25:34 2013 +0000
Fix handle_csm invocation to compensate for BUILD_BIOS_ADDR
Signed-off-by: David Woodhouse David.Woodhouse@intel.com
diff --git a/src/csm.c b/src/csm.c index 473d322..91a1a57 100644 --- a/src/csm.c +++ b/src/csm.c @@ -49,7 +49,8 @@ csm_maininit(struct bregs *regs) regs->ax = 0;
// Return directly to UEFI instead of unwinding stack. - csm_return(regs); + if (CONFIG_RELOCATE_INIT) + csm_return(regs); }
/* Legacy16InitializeYourself */ diff --git a/src/romlayout.S b/src/romlayout.S index 07d1645..cbe6b1c 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -385,7 +385,6 @@ entry_elf: .code16gcc
EXPORTFUNC entry_csm - .global csm_return entry_csm: // Backup register state pushfw @@ -405,15 +404,16 @@ entry_csm: movw %ax, %ss movl $BUILD_STACK_ADDR, %esp
- // Jump to 32bit mode and call handle_csm32(bregs) + // Jump to 32bit mode and call handle_csm(bregs) movl $(1f + BUILD_BIOS_ADDR), %edx jmp transition32 .code32 1: movl %ebx, %eax - calll _cfunc32flat_handle_csm + calll _cfunc32flat_handle_csm - BUILD_BIOS_ADDR movl $2f, %edx jmp transition16big
+ .global csm_return csm_return: movl %eax, %ebx movl $2f, %edx
It kind of works. Sometimes. But other times it just locks up in OVMF code at...
handle_csm16 regs 0x0004ffd4 AX=0001 Legacy16UpdateBbs table 480a:0008 MajorVersion 0000 MinorVersion 0000 AcpiTable 00000000 SmbiosTable 00000000 SmbiosTableLength 00000000 DevicePathType 0000 PciIrqMask 0000 NumberE820Entries 0000000c NumberBbsEntries 00000100 BBsTable 0004a1ea SmmTable 00000000 OsMemoryAbove1Mb 07a15000 UnconventionalDeviceTable 00000000 handle_csm16 returning AX=0000 enter handle_15: a=00002401 b=00000008 c=00000000 d=00000003 ds=0000 es=480a ss=4000 si=00000000 di=00000000 bp=00000000 sp=0000ffc6 cs=4f00 ip=0030 f=3002 Buffer: EFI DVD/CDROM Select Item: 0x19
This is most easily reproduced by pressing a key to enter the boot menu. And if I add '-d in_asm' or '-enable-kvm' to the qemu command line it's a lot *less* likely to trigger. I don't think I've *ever* seen it with KVM enabled in fact... but remember, the whole region should be *unlocked* so I don't know why.
If I then revert romlayout.S to the version I had in my tree (which obviously won't work with CONFIG_RELOCATE_INIT but as I said, I turned that off), everything works fine.
I'm using qemu-system-x86_64 v1.3.0 (the Fedora package).