[edk2-devel] BUG: OvmfPkgX64 is broken with cee5b0441af3 UefiCpuPkg/CpuDxe: Fix boot error
James Bottomley
James.Bottomley at HansenPartnership.com
Tue Dec 15 03:47:54 UTC 2020
On Mon, 2020-12-14 at 15:51 -0800, James Bottomley wrote:
> I found this trying to test out the upstream SEV secret injection on
> an
> AMD rome system. However, I rebuilt the OvmfPkgX64 (still on a rome
> system) just to check. I get a boot loop here if I leave this commit
> unreverted:
>
> InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF
> 7F1AD918
> ProtectUefiImageCommon - 0x7F1AD2C0
> - 0x000000007F068000 - 0x000000000000FCC0
> Paging: added 512 pages to page table pool
> CurrentPagingContext:
> MachineType - 0x8664
> PageTableBase - 0x7F801000
> Attributes - 0xC0000006
> SecCoreStartupWithStack(0xFFFCC000, 0x820000)
>
> If I revert this commit, it will boot up normally.
>
> The memory specification for qemu-kvm I'm using is
>
> -m 4096M,slots=5,maxmem=30G
>
> but reducing it to under 4GB doesn't help
I think I found the source of the problem: nasm is generating this
assembly sequence (disassembled by objdump):
14: 48 ff 2c 24 rex.W ljmp *(%rsp)
However, on AMD the rex.W prefix to a ljmp can be ineffective and the
recommended way to do this is with lretq (or retfq in nasm speak). If
I apply the patch below, I can get the long word version to work for me
on SEV.
James
---
diff --git a/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm b/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm
index 6ad32b49f4ef..a2490073cef6 100644
--- a/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm
+++ b/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm
@@ -20,13 +20,11 @@
;------------------------------------------------------------------------------
global ASM_PFX(SetCodeSelector)
ASM_PFX(SetCodeSelector):
- sub rsp, 0x10
lea rax, [setCodeSelectorLongJump]
- mov [rsp], rax
- mov [rsp+8], cx
- jmp qword far [rsp]
+ push rcx
+ push rax
+ retfq
setCodeSelectorLongJump:
- add rsp, 0x10
ret
;------------------------------------------------------------------------------
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68832): https://edk2.groups.io/g/devel/message/68832
Mute This Topic: https://groups.io/mt/78965392/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list