From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io, Michael.Roth@amd.com
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Ard Biesheuvel <ardb@kernel.org>,
Erdem Aktas <erdemaktas@google.com>,
Jiewen Yao <jiewen.yao@intel.com>, Min Xu <min.m.xu@intel.com>,
Jianyong Wu <jianyong.wu@arm.com>,
Anatol Belski <anbelski@linux.microsoft.com>
Subject: Re: [edk2-devel] [PATCH v3] OvmfPkg: Don't make APIC MMIO accesses with encryption bit set
Date: Tue, 30 Apr 2024 12:25:09 +0200 [thread overview]
Message-ID: <r6aixd4bz3ffbpnxebni3gofiaa2gj2n6ydc37ncsixk5e2ruu@wgvg3jp25e6w> (raw)
In-Reply-To: <20240426195007.1964795-1-michael.roth@amd.com>
On Fri, Apr 26, 2024 at 02:50:07PM GMT, Roth, Michael via groups.io wrote:
> For the most part, OVMF will clear the encryption bit for MMIO regions,
> but there is currently one known exception during SEC when the APIC
> base address is accessed via MMIO with the encryption bit set for
> SEV-ES/SEV-SNP guests. In the case of SEV-SNP, this requires special
> handling on the hypervisor side which may not be available in the
> future[1], so make the necessary changes in the SEC-configured page
> table to clear the encryption bit for 4K region containing the APIC
> base address.
>
> Since CpuPageTableLib is used to handle the splitting, some additional
> care must be taken to clear the C-bit in all non-leaf PTEs since the
> library expects that to be the case. Add handling for that when setting
> up the SEC page table.
>
> While here, drop special handling for the APIC base address in the
> SEV-ES/SNP #VC handler.
Please split this into smaller patches (one for each commit message
paragraph).
> -0x011000|0x00F000
> +0x011000|0x001000
> +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecApicPageTableBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecApicPageTableSize
Hmm, I think we need to figure how we'll organize page table allocation
best. This becomes a bit messy, even more so once we enable 5-level
paging for sev because one page isn't enough then ...
Is it possible to move the GHCB page setup to SecCoreStartupWithStack()
too? If so it would be nice to setup both GHCB and APIC page in C code,
and it should also allow to cleanup the page table memory reservation
and simplify the reset vector.
Note: I'm fine with this as-is for the next stable tag, the comments are
more for the next patch series, when enabling 5-level paging for sev,
where this must be touched again.
> + ApicAddress = (UINT64)GetLocalApicBaseAddress ();
> + Buffer = (VOID *)(UINTN)FixedPcdGet32 (PcdOvmfSecApicPageTableBase);
> + Cr3 = AsmReadCr3 ();
> +
> + MapAttribute.Uint64 = ApicAddress;
> + MapAttribute.Bits.Present = 1;
> + MapAttribute.Bits.ReadWrite = 1;
> + MapMask.Uint64 = MAX_UINT64;
> + BufferSize = SIZE_4KB;
> +
> + Status = PageTableMap (
> + (UINTN *)&Cr3,
> + Paging4Level,
> + Buffer,
> + &BufferSize,
> + ApicAddress,
> + SIZE_4KB,
> + &MapAttribute,
> + &MapMask,
> + NULL
> + );
Very nice.
take care,
Gerd
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118436): https://edk2.groups.io/g/devel/message/118436
Mute This Topic: https://groups.io/mt/105757219/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~2024-04-30 10:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 19:50 [edk2-devel] [PATCH v3] OvmfPkg: Don't make APIC MMIO accesses with encryption bit set Roth, Michael via groups.io
2024-04-30 10:25 ` Gerd Hoffmann [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=r6aixd4bz3ffbpnxebni3gofiaa2gj2n6ydc37ncsixk5e2ruu@wgvg3jp25e6w \
--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