public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Roth, Michael via groups.io" <Michael.Roth=amd.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	"Tom Lendacky" <thomas.lendacky@amd.com>
Subject: [edk2-devel] [PATCH v4 0/3] OvmfPkg: Don't make APIC MMIO accesses with encryption bit set
Date: Wed, 1 May 2024 14:03:37 -0500	[thread overview]
Message-ID: <20240501190340.2238565-1-michael.roth@amd.com> (raw)

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.34mvemnzrwwsaesw@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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



             reply	other threads:[~2024-05-01 19:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 19:03 Roth, Michael via groups.io [this message]
2024-05-01 19:03 ` [edk2-devel] [PATCH v4 1/3] OvmfPkg/ResetVector: Clear SEV encryption bit for non-leaf PTEs Roth, Michael via groups.io
2024-05-01 19:03 ` [edk2-devel] [PATCH v4 2/3] OvmfPkg: Don't make APIC MMIO accesses with encryption bit set Roth, Michael via groups.io
2024-05-01 19:03 ` [edk2-devel] [PATCH v4 3/3] OvmfPkg/CcExitLib: Drop special handling for Encrypted MMIO to APIC Roth, Michael via groups.io
2024-05-02  9:06 ` [edk2-devel] [PATCH v4 0/3] OvmfPkg: Don't make APIC MMIO accesses with encryption bit set Gerd Hoffmann
2024-05-02 11:50   ` Ard Biesheuvel

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=20240501190340.2238565-1-michael.roth@amd.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