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.

[1] https://lore.kernel.org/lkml/20240208002420.34mvemnzrwwsa...@amd.com/#t

Thanks!

-Mike

v4:
  - split original patch out into 3 patches for each functional change (Gerd)
v3:
  - also clear C-bit for non-leaf PTEs containing GHCB range
  - add missing Cc's to commit log
v2:
  - use CpuPageTableLib to handle splitting (Gerd, Tom)


----------------------------------------------------------------
Michael Roth (3):
      OvmfPkg/ResetVector: Clear SEV encryption bit for non-leaf PTEs
      OvmfPkg: Don't make APIC MMIO accesses with encryption bit set
      OvmfPkg/CcExitLib: Drop special handling for Encrypted MMIO to APIC

 OvmfPkg/AmdSev/AmdSevX64.fdf                |  5 ++-
 OvmfPkg/Bhyve/BhyveX64.dsc                  |  1 +
 OvmfPkg/CloudHv/CloudHvX64.fdf              |  5 ++-
 OvmfPkg/Library/CcExitLib/CcExitVcHandler.c | 12 +-----
 OvmfPkg/Microvm/MicrovmX64.fdf              |  3 ++
 OvmfPkg/OvmfPkg.dec                         |  5 +++
 OvmfPkg/OvmfPkgX64.fdf                      |  5 ++-
 OvmfPkg/ResetVector/Ia32/AmdSev.asm         |  5 ++-
 OvmfPkg/ResetVector/Ia32/PageTables64.asm   | 20 +++++-----
 OvmfPkg/Sec/AmdSev.c                        | 58 +++++++++++++++++++++++++++++
 OvmfPkg/Sec/AmdSev.h                        | 14 +++++++
 OvmfPkg/Sec/SecMain.c                       |  1 +
 OvmfPkg/Sec/SecMain.inf                     |  3 ++
 13 files changed, 112 insertions(+), 25 deletions(-)




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118470): https://edk2.groups.io/g/devel/message/118470
Mute This Topic: https://groups.io/mt/105849106/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to