From: "James Bottomley" <James.Bottomley@HansenPartnership.com>
To: devel@edk2.groups.io
Cc: Guo Dong <guo.dong@intel.com>, "Dong, Eric" <eric.dong@intel.com>,
"Ni, Ray" <ray.ni@intel.com>,
"Kumar, Rahul1" <rahul1.kumar@intel.com>,
LaszloErsek <lersek@redhat.com>
Subject: Re: [edk2-devel] BUG: OvmfPkgX64 is broken with cee5b0441af3 UefiCpuPkg/CpuDxe: Fix boot error
Date: Mon, 14 Dec 2020 19:47:54 -0800 [thread overview]
Message-ID: <9c5f7e74f7c4adca81acaa6a7527484f0387d927.camel@HansenPartnership.com> (raw)
In-Reply-To: <58408ffaedfd7f7a1c433ff539b69acb625890dc.camel@HansenPartnership.com>
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
;------------------------------------------------------------------------------
prev parent reply other threads:[~2020-12-15 3:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-14 23:51 BUG: OvmfPkgX64 is broken with cee5b0441af3 UefiCpuPkg/CpuDxe: Fix boot error James Bottomley
2020-12-15 3:47 ` James Bottomley [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c5f7e74f7c4adca81acaa6a7527484f0387d927.camel@HansenPartnership.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox