ovmf miscompiles with gcc-12
Jiri Slaby <jirislaby@...>
Hi,
we discovered that qemu-ovmf-x86_64 doesn't start when compiled using gcc-12. Originally reported as: https://bugzilla.suse.com/show_bug.cgi?id=1199597 I run qemu as: qemu-kvm -drive file=/dev/null,format=raw -drive if=pflash,format=raw,unit=0,readonly=on,file=OVMF.fd -m 3000 The platform repeatedly resets after TemporaryRamMigration as can be seen in the debuglog: https://bugzilla.suse.com/attachment.cgi?id=858969 The reason is TemporaryRamMigration() overwrites rbp unconditionally -- it adds an offset to rbp even if rbp is NOT used as a frame pointer (-fomit-frame-pointer was always used for compilation here). So commenting out: //JumpBuffer.Rbp = JumpBuffer.Rbp + DebugAgentContext.StackMigrateOffset;makes it all work again. Also marking TemporaryRamMigration() as: __attribute__((optimize("-fno-omit-frame-pointer"))) works around the problem too. (But that doesn't guarantee anything.) The code is: if (SetJump (&JumpBuffer) == 0) {It was only coincidence this ever worked -- gcc-11 omits the frame pointer too, but apparently the caller (PeiCheckAndSwitchStack) does not use rbp. PeiCheckAndSwitchStack() (gcc-12): 79a6: 4c 29 fd sub %r15,%rbp <------ used rbpgcc-11 seems to copy rbp to r8 first and operates on r8 there instead. Now, what is the right way to fix this? Do the SetJump/LongJump in assembly and wrap it into push rbp/pop rbp? thanks, -- js suse labs |
|