[edk2-devel] [PATCH 00/12] SEV-ES security mitigations

Lendacky, Thomas posted 12 patches 3 years, 4 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
OvmfPkg/OvmfPkg.dec                           |   2 +
OvmfPkg/AmdSev/AmdSevX64.dsc                  |   6 +-
OvmfPkg/Bhyve/BhyveX64.dsc                    |   4 +-
OvmfPkg/OvmfPkgIa32.dsc                       |   4 +-
OvmfPkg/OvmfPkgIa32X64.dsc                    |   4 +-
OvmfPkg/OvmfPkgX64.dsc                        |   6 +-
OvmfPkg/OvmfXen.dsc                           |   3 +-
OvmfPkg/AmdSev/AmdSevX64.fdf                  |   3 +
OvmfPkg/OvmfPkgX64.fdf                        |   3 +
OvmfPkg/AmdSevDxe/AmdSevDxe.inf               |   8 +-
...SevLib.inf => DxeBaseMemEncryptSevLib.inf} |  14 +-
.../PeiBaseMemEncryptSevLib.inf               |  57 ++
.../SecBaseMemEncryptSevLib.inf               |  55 +
OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf  |  44 +
OvmfPkg/Library/VmgExitLib/VmgExitLib.inf     |   6 +-
OvmfPkg/PlatformPei/PlatformPei.inf           |   2 +
OvmfPkg/Include/Library/MemEncryptSevLib.h    |  90 +-
.../BaseMemEncryptSevLib/X64/VirtualMemory.h  |  35 +-
OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.h |  53 +
OvmfPkg/AmdSevDxe/AmdSevDxe.c                 |  20 +-
OvmfPkg/Bhyve/PlatformPei/AmdSev.c            |  12 +-
.../DxeMemEncryptSevLibInternal.c             | 145 +++
.../Ia32/MemEncryptSevLib.c                   |  31 +-
.../MemEncryptSevLibInternal.c                |  91 +-
.../PeiMemEncryptSevLibInternal.c             | 159 +++
.../SecMemEncryptSevLibInternal.c             | 130 +++
.../X64/MemEncryptSevLib.c                    |  32 +-
.../X64/PeiDxeVirtualMemory.c                 | 893 ++++++++++++++++
.../X64/SecVirtualMemory.c                    | 100 ++
.../BaseMemEncryptSevLib/X64/VirtualMemory.c  | 954 +++---------------
.../VmgExitLib/PeiDxeVmgExitVcHandler.c       | 103 ++
.../Library/VmgExitLib/SecVmgExitVcHandler.c  | 109 ++
OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 130 ++-
OvmfPkg/PlatformPei/AmdSev.c                  |  50 +-
OvmfPkg/PlatformPei/MemDetect.c               |   5 +
OvmfPkg/Sec/SecMain.c                         |   6 +-
OvmfPkg/XenPlatformPei/AmdSev.c               |  12 +-
OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm   | 116 +++
OvmfPkg/ResetVector/Ia32/PageTables64.asm     | 108 +-
OvmfPkg/ResetVector/ResetVector.nasmb         |   5 +-
40 files changed, 2590 insertions(+), 1020 deletions(-)
rename OvmfPkg/Library/BaseMemEncryptSevLib/{BaseMemEncryptSevLib.inf => DxeBaseMemEncryptSevLib.inf} (66%)
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/PeiBaseMemEncryptSevLib.inf
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SecBaseMemEncryptSevLib.inf
create mode 100644 OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf
create mode 100644 OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.h
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
create mode 100644 OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c
create mode 100644 OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c
create mode 100644 OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
[edk2-devel] [PATCH 00/12] SEV-ES security mitigations
Posted by Lendacky, Thomas 3 years, 4 months ago
From: Tom Lendacky <thomas.lendacky@amd.com>

This patch series provides security mitigations for SEV-ES to protect
against some attacks identified in the paper titled "Exploiting Interfaces
of Secure Encrypted Virtual Machines" at:
  https://arxiv.org/pdf/2010.07094.pdf

The mitigations include:

- Validating the encryption bit position provided by the hypervisor.
  Additionally, once validated use the validated value throughout the
  code.

- Validating that SEV-ES has been advertised to the guest if a #VC has
  been taken to prevent the hypervisor from pretending that SEV-ES is
  not enabled.

- Validate that MMIO is performed to/from unencrypted memory addresses
  to prevent the hypervisor try to inject data or expose secrets within
  the guest.

And a change separate from the above paper:

- When checking #VC related per-vCPU values, make checks for explicit
  values vs non-zero values so that a hypervisor can't write random data
  to the location to alter guest processing behavior.

Also, as part of creating these mitigations:
- MemEncryptSevLib is updated to now be available during SEC
- #VC now supports a single nested invocation

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3108

---

These patches are based on commit:
5c3cdebf95bf ("MdePkg/include: Add DMAR SATC Table Definition")

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Julien Grall <julien@xen.org>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>

Tom Lendacky (12):
  Ovmf/ResetVector: Simplify and consolidate the SEV features checks
  OvmfPkg/Sec: Move SEV-ES SEC workarea definition to common header file
  OvmfPkg/ResetVector: Validate the encryption bit position for
    SEV/SEV-ES
  OvmfPkg/ResetVector: Perform a simple SEV-ES sanity check
  OvmfPkg/MemEncryptSevLib: Add an interface to retrieve the encryption
    mask
  OvmfPkg/AmdSevDxe: Clear encryption bit on PCIe MMCONFIG range
  OvmfPkg/VmgExitLib: Check for an explicit DR7 cached value
  OvmfPkg/MemEncryptSevLib: Make the MemEncryptSevLib available for SEC
  OvmfPkg/MemEncryptSevLib: Address range encryption state interface
  OvmfPkg/VmgExitLib: Support nested #VCs
  OvmfPkg/PlatformPei: Reserve GHCB backup pages if S3 is supported
  OvfmPkg/VmgExitLib: Validate #VC MMIO is to un-encrypted memory

 OvmfPkg/OvmfPkg.dec                           |   2 +
 OvmfPkg/AmdSev/AmdSevX64.dsc                  |   6 +-
 OvmfPkg/Bhyve/BhyveX64.dsc                    |   4 +-
 OvmfPkg/OvmfPkgIa32.dsc                       |   4 +-
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   4 +-
 OvmfPkg/OvmfPkgX64.dsc                        |   6 +-
 OvmfPkg/OvmfXen.dsc                           |   3 +-
 OvmfPkg/AmdSev/AmdSevX64.fdf                  |   3 +
 OvmfPkg/OvmfPkgX64.fdf                        |   3 +
 OvmfPkg/AmdSevDxe/AmdSevDxe.inf               |   8 +-
 ...SevLib.inf => DxeBaseMemEncryptSevLib.inf} |  14 +-
 .../PeiBaseMemEncryptSevLib.inf               |  57 ++
 .../SecBaseMemEncryptSevLib.inf               |  55 +
 OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf  |  44 +
 OvmfPkg/Library/VmgExitLib/VmgExitLib.inf     |   6 +-
 OvmfPkg/PlatformPei/PlatformPei.inf           |   2 +
 OvmfPkg/Include/Library/MemEncryptSevLib.h    |  90 +-
 .../BaseMemEncryptSevLib/X64/VirtualMemory.h  |  35 +-
 OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.h |  53 +
 OvmfPkg/AmdSevDxe/AmdSevDxe.c                 |  20 +-
 OvmfPkg/Bhyve/PlatformPei/AmdSev.c            |  12 +-
 .../DxeMemEncryptSevLibInternal.c             | 145 +++
 .../Ia32/MemEncryptSevLib.c                   |  31 +-
 .../MemEncryptSevLibInternal.c                |  91 +-
 .../PeiMemEncryptSevLibInternal.c             | 159 +++
 .../SecMemEncryptSevLibInternal.c             | 130 +++
 .../X64/MemEncryptSevLib.c                    |  32 +-
 .../X64/PeiDxeVirtualMemory.c                 | 893 ++++++++++++++++
 .../X64/SecVirtualMemory.c                    | 100 ++
 .../BaseMemEncryptSevLib/X64/VirtualMemory.c  | 954 +++---------------
 .../VmgExitLib/PeiDxeVmgExitVcHandler.c       | 103 ++
 .../Library/VmgExitLib/SecVmgExitVcHandler.c  | 109 ++
 OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 130 ++-
 OvmfPkg/PlatformPei/AmdSev.c                  |  50 +-
 OvmfPkg/PlatformPei/MemDetect.c               |   5 +
 OvmfPkg/Sec/SecMain.c                         |   6 +-
 OvmfPkg/XenPlatformPei/AmdSev.c               |  12 +-
 OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm   | 116 +++
 OvmfPkg/ResetVector/Ia32/PageTables64.asm     | 108 +-
 OvmfPkg/ResetVector/ResetVector.nasmb         |   5 +-
 40 files changed, 2590 insertions(+), 1020 deletions(-)
 rename OvmfPkg/Library/BaseMemEncryptSevLib/{BaseMemEncryptSevLib.inf => DxeBaseMemEncryptSevLib.inf} (66%)
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/PeiBaseMemEncryptSevLib.inf
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SecBaseMemEncryptSevLib.inf
 create mode 100644 OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf
 create mode 100644 OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.h
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
 create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
 create mode 100644 OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c
 create mode 100644 OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c
 create mode 100644 OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm

-- 
2.28.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68900): https://edk2.groups.io/g/devel/message/68900
Mute This Topic: https://groups.io/mt/78986133/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 00/12] SEV-ES security mitigations
Posted by Laszlo Ersek 3 years, 4 months ago
Hi Tom,

On 12/15/20 21:50, Tom Lendacky wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> This patch series provides security mitigations for SEV-ES to protect
> against some attacks identified in the paper titled "Exploiting Interfaces
> of Secure Encrypted Virtual Machines" at:
>   https://arxiv.org/pdf/2010.07094.pdf
> 
> The mitigations include:
> 
> - Validating the encryption bit position provided by the hypervisor.
>   Additionally, once validated use the validated value throughout the
>   code.
> 
> - Validating that SEV-ES has been advertised to the guest if a #VC has
>   been taken to prevent the hypervisor from pretending that SEV-ES is
>   not enabled.
> 
> - Validate that MMIO is performed to/from unencrypted memory addresses
>   to prevent the hypervisor try to inject data or expose secrets within
>   the guest.
> 
> And a change separate from the above paper:
> 
> - When checking #VC related per-vCPU values, make checks for explicit
>   values vs non-zero values so that a hypervisor can't write random data
>   to the location to alter guest processing behavior.
> 
> Also, as part of creating these mitigations:
> - MemEncryptSevLib is updated to now be available during SEC
> - #VC now supports a single nested invocation
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3108
> 
> ---
> 
> These patches are based on commit:
> 5c3cdebf95bf ("MdePkg/include: Add DMAR SATC Table Definition")

I plan to review this series next year (and then after the VCPU
hot-unplug stuff that's already been in my review queue for a bit...)

Thanks,
Laszlo

> 
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Rebecca Cran <rebecca@bsdio.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Julien Grall <julien@xen.org>
> Cc: Peter Grehan <grehan@freebsd.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> 
> Tom Lendacky (12):
>   Ovmf/ResetVector: Simplify and consolidate the SEV features checks
>   OvmfPkg/Sec: Move SEV-ES SEC workarea definition to common header file
>   OvmfPkg/ResetVector: Validate the encryption bit position for
>     SEV/SEV-ES
>   OvmfPkg/ResetVector: Perform a simple SEV-ES sanity check
>   OvmfPkg/MemEncryptSevLib: Add an interface to retrieve the encryption
>     mask
>   OvmfPkg/AmdSevDxe: Clear encryption bit on PCIe MMCONFIG range
>   OvmfPkg/VmgExitLib: Check for an explicit DR7 cached value
>   OvmfPkg/MemEncryptSevLib: Make the MemEncryptSevLib available for SEC
>   OvmfPkg/MemEncryptSevLib: Address range encryption state interface
>   OvmfPkg/VmgExitLib: Support nested #VCs
>   OvmfPkg/PlatformPei: Reserve GHCB backup pages if S3 is supported
>   OvfmPkg/VmgExitLib: Validate #VC MMIO is to un-encrypted memory
> 
>  OvmfPkg/OvmfPkg.dec                           |   2 +
>  OvmfPkg/AmdSev/AmdSevX64.dsc                  |   6 +-
>  OvmfPkg/Bhyve/BhyveX64.dsc                    |   4 +-
>  OvmfPkg/OvmfPkgIa32.dsc                       |   4 +-
>  OvmfPkg/OvmfPkgIa32X64.dsc                    |   4 +-
>  OvmfPkg/OvmfPkgX64.dsc                        |   6 +-
>  OvmfPkg/OvmfXen.dsc                           |   3 +-
>  OvmfPkg/AmdSev/AmdSevX64.fdf                  |   3 +
>  OvmfPkg/OvmfPkgX64.fdf                        |   3 +
>  OvmfPkg/AmdSevDxe/AmdSevDxe.inf               |   8 +-
>  ...SevLib.inf => DxeBaseMemEncryptSevLib.inf} |  14 +-
>  .../PeiBaseMemEncryptSevLib.inf               |  57 ++
>  .../SecBaseMemEncryptSevLib.inf               |  55 +
>  OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf  |  44 +
>  OvmfPkg/Library/VmgExitLib/VmgExitLib.inf     |   6 +-
>  OvmfPkg/PlatformPei/PlatformPei.inf           |   2 +
>  OvmfPkg/Include/Library/MemEncryptSevLib.h    |  90 +-
>  .../BaseMemEncryptSevLib/X64/VirtualMemory.h  |  35 +-
>  OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.h |  53 +
>  OvmfPkg/AmdSevDxe/AmdSevDxe.c                 |  20 +-
>  OvmfPkg/Bhyve/PlatformPei/AmdSev.c            |  12 +-
>  .../DxeMemEncryptSevLibInternal.c             | 145 +++
>  .../Ia32/MemEncryptSevLib.c                   |  31 +-
>  .../MemEncryptSevLibInternal.c                |  91 +-
>  .../PeiMemEncryptSevLibInternal.c             | 159 +++
>  .../SecMemEncryptSevLibInternal.c             | 130 +++
>  .../X64/MemEncryptSevLib.c                    |  32 +-
>  .../X64/PeiDxeVirtualMemory.c                 | 893 ++++++++++++++++
>  .../X64/SecVirtualMemory.c                    | 100 ++
>  .../BaseMemEncryptSevLib/X64/VirtualMemory.c  | 954 +++---------------
>  .../VmgExitLib/PeiDxeVmgExitVcHandler.c       | 103 ++
>  .../Library/VmgExitLib/SecVmgExitVcHandler.c  | 109 ++
>  OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 130 ++-
>  OvmfPkg/PlatformPei/AmdSev.c                  |  50 +-
>  OvmfPkg/PlatformPei/MemDetect.c               |   5 +
>  OvmfPkg/Sec/SecMain.c                         |   6 +-
>  OvmfPkg/XenPlatformPei/AmdSev.c               |  12 +-
>  OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm   | 116 +++
>  OvmfPkg/ResetVector/Ia32/PageTables64.asm     | 108 +-
>  OvmfPkg/ResetVector/ResetVector.nasmb         |   5 +-
>  40 files changed, 2590 insertions(+), 1020 deletions(-)
>  rename OvmfPkg/Library/BaseMemEncryptSevLib/{BaseMemEncryptSevLib.inf => DxeBaseMemEncryptSevLib.inf} (66%)
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/PeiBaseMemEncryptSevLib.inf
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SecBaseMemEncryptSevLib.inf
>  create mode 100644 OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf
>  create mode 100644 OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.h
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
>  create mode 100644 OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
>  create mode 100644 OvmfPkg/Library/VmgExitLib/PeiDxeVmgExitVcHandler.c
>  create mode 100644 OvmfPkg/Library/VmgExitLib/SecVmgExitVcHandler.c
>  create mode 100644 OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69134): https://edk2.groups.io/g/devel/message/69134
Mute This Topic: https://groups.io/mt/78986133/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 00/12] SEV-ES security mitigations
Posted by Laszlo Ersek 3 years, 4 months ago
On 12/15/20 21:50, Lendacky, Thomas wrote:

> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3108

I've listed this BZ under
<https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning#edk2-stable202102-tag-planning>.

Thanks
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69331): https://edk2.groups.io/g/devel/message/69331
Mute This Topic: https://groups.io/mt/78986133/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-