Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 2ddacfb6b86cc6aafc5653336752715da7514f37
      
https://github.com/tianocore/edk2/commit/2ddacfb6b86cc6aafc5653336752715da7514f37
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    A OvmfPkg/Sec/AmdSev.c
    A OvmfPkg/Sec/AmdSev.h
    M OvmfPkg/Sec/SecMain.c
    M OvmfPkg/Sec/SecMain.inf

  Log Message:
  -----------
  OvmfPkg/SecMain: move SEV specific routines in AmdSev.c

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

Move all the SEV specific function in AmdSev.c.

No functional change intended.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: e2289d19d871d8016f5d1d07a0084583f7092333
      
https://github.com/tianocore/edk2/commit/e2289d19d871d8016f5d1d07a0084583f7092333
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    A UefiCpuPkg/Library/MpInitLib/AmdSev.c
    M UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
    M UefiCpuPkg/Library/MpInitLib/MpLib.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.h
    M UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
    A UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm
    M UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm

  Log Message:
  -----------
  UefiCpuPkg/MpInitLib: move SEV specific routines in AmdSev.c

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

Move all the SEV specific function in AmdSev.c.

No functional change intended.

Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Suggested-by: Jiewen Yao <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 2fe8edfe55ea28d9972ce3ba049783f0616007fa
      
https://github.com/tianocore/edk2/commit/2fe8edfe55ea28d9972ce3ba049783f0616007fa
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/ResetVector/Ia32/AmdSev.asm
    M OvmfPkg/Sec/AmdSev.c

  Log Message:
  -----------
  OvmfPkg/ResetVector: move clearing GHCB in SecMain

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

In preparation for SEV-SNP support move clearing of the GHCB memory from
the ResetVector/AmdSev.asm to SecMain/AmdSev.c. The GHCB page is not
accessed until SevEsProtocolCheck() switch to full GHCB. So, the move
does not make any changes in the code flow or logic. The move will
simplify the SEV-SNP support.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 3053183d417ae9e72fa05fd858ad6da15cbef7f9
      
https://github.com/tianocore/edk2/commit/3053183d417ae9e72fa05fd858ad6da15cbef7f9
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm
    M OvmfPkg/ResetVector/ResetVector.nasmb
    A OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm

  Log Message:
  -----------
  OvmfPkg/ResetVector: introduce SEV metadata descriptor for VMM use

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

The OvmfPkgX86 build reserves memory regions in MEMFD. The memory regions
get accessed in the SEC phase. AMD SEV-SNP require that the guest's
private memory be accepted or validated before access.

Introduce a Guided metadata structure that describes the reserved memory
regions. The VMM can locate the metadata structure by iterating through
the reset vector guid and process the areas based on the platform
specific requirements.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 707c71a01b9d00e0e40db500edb288e6cecdc032
      
https://github.com/tianocore/edk2/commit/707c71a01b9d00e0e40db500edb288e6cecdc032
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/OvmfPkg.dec
    M OvmfPkg/OvmfPkgX64.fdf
    M OvmfPkg/ResetVector/ResetVector.inf
    M OvmfPkg/ResetVector/ResetVector.nasmb
    M OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm

  Log Message:
  -----------
  OvmfPkg: reserve SNP secrets page

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

During the SNP guest launch sequence, a special secrets page needs to be
inserted by the VMM. The PSP will populate the page; it will contain the
VM Platform Communication Key (VMPCKs) used by the guest to send and
receive secure messages to the PSP.

The purpose of the secrets page in the SEV-SNP is different from the one
used in SEV guests. In SEV, the secrets page contains the guest owner's
private data after the remote attestation.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: cca9cd3dd6bfb95ed59c398b8e578d8ffd3437f1
      
https://github.com/tianocore/edk2/commit/cca9cd3dd6bfb95ed59c398b8e578d8ffd3437f1
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/OvmfPkg.dec
    M OvmfPkg/OvmfPkgX64.fdf
    M OvmfPkg/ResetVector/ResetVector.inf
    M OvmfPkg/ResetVector/ResetVector.nasmb
    M OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm

  Log Message:
  -----------
  OvmfPkg: reserve CPUID page

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

Platform features and capabilities are traditionally discovered via the
CPUID instruction. Hypervisors typically trap and emulate the CPUID
instruction for a variety of reasons. There are some cases where incorrect
CPUID information can potentially lead to a security issue. The SEV-SNP
firmware provides a feature to filter the CPUID results through the PSP.
The filtered CPUID values are saved on a special page for the guest to
consume. Reserve a page in MEMFD that will contain the results of
filtered CPUID values.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: f2dc28f0b69717255d9c9e3c753f6efbd96c2fc7
      
https://github.com/tianocore/edk2/commit/f2dc28f0b69717255d9c9e3c753f6efbd96c2fc7
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/ResetVector/ResetVector.inf
    M OvmfPkg/ResetVector/ResetVector.nasmb
    M OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm

  Log Message:
  -----------
  OvmfPkg/ResetVector: pre-validate the data pages used in SEC phase

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

An SEV-SNP guest requires that private memory (aka pages mapped encrypted)
must be validated before being accessed.

The validation process consist of the following sequence:

1) Set the memory encryption attribute in the page table (aka C-bit).
   Note: If the processor is in non-PAE mode, then all the memory accesses
   are considered private.
2) Add the memory range as private in the RMP table. This can be performed
   using the Page State Change VMGEXIT defined in the GHCB specification.
3) Use the PVALIDATE instruction to set the Validated Bit in the RMP table.

During the guest creation time, the VMM encrypts the OVMF_CODE.fd using
the SEV-SNP firmware provided LAUNCH_UPDATE_DATA command. In addition to
encrypting the content, the command also validates the memory region.
This allows us to execute the code without going through the validation
sequence.

During execution, the reset vector need to access some data pages
(such as page tables, SevESWorkarea, Sec stack). The data pages are
accessed as private memory. The data pages are not part of the
OVMF_CODE.fd, so they were not validated during the guest creation.

There are two approaches we can take to validate the data pages before
the access:

a) Enhance the OVMF reset vector code to validate the pages as described
   above (go through step 2 - 3).
OR
b) Validate the pages during the guest creation time. The SEV firmware
   provides a command which can be used by the VMM to validate the pages
   without affecting the measurement of the launch.

Approach #b seems much simpler; it does not require any changes to the
OVMF reset vector code.

Update the OVMF metadata with the list of regions that must be
pre-validated by the VMM before the boot.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 34819f2caccb061a982e77fd8ba908632cb9dcaf
      
https://github.com/tianocore/edk2/commit/34819f2caccb061a982e77fd8ba908632cb9dcaf
  Author: Michael Roth <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/ResetVector/Ia32/AmdSev.asm

  Log Message:
  -----------
  OvmfPkg/ResetVector: use SEV-SNP-validated CPUID values

CPUID instructions are issued during early boot to do things like probe
for SEV support. Currently these are handled by a minimal #VC handler
that uses the MSR-based GHCB protocol to fetch the CPUID values from
the hypervisor. When SEV-SNP is enabled, use the firmware-validated
CPUID values from the CPUID page instead [1].

[1]: SEV SNP Firmware ABI Specification, Rev. 0.8, 8.13.2.6

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: d9822304ce0075b1075edf93cc6e2514685b5212
      
https://github.com/tianocore/edk2/commit/d9822304ce0075b1075edf93cc6e2514685b5212
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Include/Library/MemEncryptSevLib.h
    M OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLibInternal.c
    M OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLibInternal.c
    M OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLibInternal.c

  Log Message:
  -----------
  OvmfPkg/MemEncryptSevLib: add MemEncryptSevSnpEnabled()

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

Create a function that can be used to determine if VM is running as an
SEV-SNP guest.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 7c3b2892ea4a2acc6d108d226d64bea86be20e02
      
https://github.com/tianocore/edk2/commit/7c3b2892ea4a2acc6d108d226d64bea86be20e02
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Sec/AmdSev.c

  Log Message:
  -----------
  OvmfPkg/SecMain: register GHCB gpa for the SEV-SNP guest

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

The SEV-SNP guest requires that GHCB GPA must be registered before using.
See the GHCB specification section 2.3.2 for more details.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: d2b998fbdca463ddcd8dc1407039a6e82578039f
      
https://github.com/tianocore/edk2/commit/d2b998fbdca463ddcd8dc1407039a6e82578039f
  Author: Michael Roth <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf
    M OvmfPkg/Library/VmgExitLib/VmgExitLib.inf
    M OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c

  Log Message:
  -----------
  OvmfPkg/VmgExitLib: use SEV-SNP-validated CPUID values

SEV-SNP firmware allows a special guest page to be populated with
guest CPUID values so that they can be validated against supported
host features before being loaded into encrypted guest memory to be
used instead of hypervisor-provided values [1].

Add handling for this in the CPUID #VC handler and use it whenever
SEV-SNP is enabled. To do so, existing CPUID handling via VmgExit is
moved to a helper, GetCpuidHyp(), and a new helper that uses the CPUID
page to do the lookup, GetCpuidFw(), is used instead when SNP is
enabled. For cases where SNP CPUID lookups still rely on fetching
specific CPUID fields from hypervisor, GetCpuidHyp() is used there as
well.

[1]: SEV SNP Firmware ABI Specification, Rev. 0.8, 8.13.2.6

Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: a19b648952c4730bf0876fa13d446fe80ebb5cc3
      
https://github.com/tianocore/edk2/commit/a19b648952c4730bf0876fa13d446fe80ebb5cc3
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/PlatformPei/AmdSev.c

  Log Message:
  -----------
  OvmfPkg/PlatformPei: register GHCB gpa for the SEV-SNP guest

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

The SEV-SNP guest requires that GHCB GPA must be registered before using.
See the GHCB specification section 2.3.2 for more details.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 19914edc5a0202cc7830f819ffac7e7b2368166a
      
https://github.com/tianocore/edk2/commit/19914edc5a0202cc7830f819ffac7e7b2368166a
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/AmdSev/AmdSevX64.dsc
    M OvmfPkg/Bhyve/BhyveX64.dsc
    M OvmfPkg/OvmfPkgIa32X64.dsc
    M OvmfPkg/OvmfPkgX64.dsc
    M OvmfPkg/OvmfXen.dsc

  Log Message:
  -----------
  OvmfPkg/AmdSevDxe: do not use extended PCI config space

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

Commit 85b8eac59b8c5bd9c7eb9afdb64357ce1aa2e803 added support to ensure
that MMIO is only performed against the un-encrypted memory. If MMIO
is performed against encrypted memory, a #GP is raised.

The AmdSevDxe uses the functions provided by the MemEncryptSevLib to
clear the memory encryption mask from the page table. If the
MemEncryptSevLib is extended to include VmgExitLib then depedency
chain will look like this:

OvmfPkg/AmdSevDxe/AmdSevDxe.inf
-----> MemEncryptSevLib                    class
-----> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf"   instance
-----> VmgExitLib                          class
-----> "OvmfPkg/VmgExitLib"    instance
-----> LocalApicLib                        class
-----> "UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf" instance
-----> TimerLib                            class
-----> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf"   instance
-----> PciLib                                           class
-----> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf"    instance
-----> PciExpressLib                                          class
-----> "MdePkg/BasePciExpressLib/BasePciExpressLib.inf"  instance

The LocalApicLib provides a constructor that gets called before the
AmdSevDxe can clear the memory encryption mask from the MMIO regions.

When running under the Q35 machine type, the call chain looks like this:

AcpiTimerLibConstructor ()  [AcpiTimerLib]
  PciRead32 ()              [DxePciLibI440FxQ35]
   PciExpressRead32 ()      [PciExpressLib]

The PciExpressRead32 () reads the MMIO region. The MMIO regions are not
yet mapped un-encrypted, so the check introduced in the commit
85b8eac59b8c5bd9c7eb9afdb64357ce1aa2e803 raises a #GP.

The AmdSevDxe driver does not require the access to the extended PCI
config space. Accessing a normal PCI config space, via IO port should be
sufficent. Use the module-scope override to make the AmdSevDxe use the
BasePciLib instead of BasePciExpressLib so that PciRead32 () uses the
IO ports instead of the extended config space.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Suggested-by: Laszlo Ersek <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: ade62c18f4742301bbef474ac10518bde5972fba
      
https://github.com/tianocore/edk2/commit/ade62c18f4742301bbef474ac10518bde5972fba
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Include/Library/MemEncryptSevLib.h
    M OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
    M OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
    M OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
    M OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf
    A OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c
    A OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c
    A OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSystemRamValidate.c
    A OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChange.h
    A OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
    M OvmfPkg/OvmfPkgIa32.dsc
    M OvmfPkg/OvmfPkgIa32X64.dsc

  Log Message:
  -----------
  OvmfPkg/MemEncryptSevLib: add support to validate system RAM

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

Many of the integrity guarantees of SEV-SNP are enforced through the
Reverse Map Table (RMP). Each RMP entry contains the GPA at which a
particular page of DRAM should be mapped. The guest can request the
hypervisor to add pages in the RMP table via the Page State Change VMGEXIT
defined in the GHCB specification section 2.5.1 and 4.1.6. Inside each RMP
entry is a Validated flag; this flag is automatically cleared to 0 by the
CPU hardware when a new RMP entry is created for a guest. Each VM page
can be either validated or invalidated, as indicated by the Validated
flag in the RMP entry. Memory access to a private page that is not
validated generates a #VC. A VM can use the PVALIDATE instruction to
validate the private page before using it.

During the guest creation, the boot ROM memory is pre-validated by the
AMD-SEV firmware. The MemEncryptSevSnpValidateSystemRam() can be called
during the SEC and PEI phase to validate the detected system RAM.

One of the fields in the Page State Change NAE is the RMP page size. The
page size input parameter indicates that either a 4KB or 2MB page should
be used while adding the RMP entry. During the validation, when possible,
the MemEncryptSevSnpValidateSystemRam() will use the 2MB entry. A
hypervisor backing the memory may choose to use the different page size
in the RMP entry. In those cases, the PVALIDATE instruction should return
SIZEMISMATCH. If a SIZEMISMATCH is detected, then validate all 512-pages
constituting a 2MB region.

Upon completion, the PVALIDATE instruction sets the rFLAGS.CF to 0 if
instruction changed the RMP entry and to 1 if the instruction did not
change the RMP entry. The rFlags.CF will be 1 only when a memory region
is already validated. We should not double validate a memory
as it could lead to a security compromise. If double validation is
detected, terminate the boot.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: d706f8fec256585de76280d2a1e1aa9550cefe12
      
https://github.com/tianocore/edk2/commit/d706f8fec256585de76280d2a1e1aa9550cefe12
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSystemRamValidate.c
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChange.h
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c

  Log Message:
  -----------
  OvmfPkg/MemEncryptSevLib: add function to check the VMPL0

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

Virtual Machine Privilege Level (VMPL) feature in the SEV-SNP
architecture allows a guest VM to divide its address space into four
levels. The level can be used to provide the hardware isolated
abstraction layers with a VM. The VMPL0 is the highest privilege, and
VMPL3 is the least privilege. Certain operations must be done by the
VMPL0 software, such as:

* Validate or invalidate memory range (PVALIDATE instruction)
* Allocate VMSA page (RMPADJUST instruction when VMSA=1)

The initial SEV-SNP support assumes that the guest is running on VMPL0.
Let's add function in the MemEncryptSevLib that can be used for checking
whether guest is booted under the VMPL0.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 11b15336f0ced4879529708f734a83adf69faf47
      
https://github.com/tianocore/edk2/commit/11b15336f0ced4879529708f734a83adf69faf47
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c

  Log Message:
  -----------
  OvmfPkg/BaseMemEncryptSevLib: skip the pre-validated system RAM

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

The MemEncryptSevSnpPreValidateSystemRam() is used for pre-validating the
system RAM. As the boot progress, each phase validates a fixed region of
the RAM. In the PEI phase, the PlatformPei detects all the available RAM
and calls to pre-validate the detected system RAM.

While validating the system RAM in PEI phase, we must skip previously
validated system RAM to avoid the double validation.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: d39f8d88ecb31df46e2f95bcc5c20100d1f14681
      
https://github.com/tianocore/edk2/commit/d39f8d88ecb31df46e2f95bcc5c20100d1f14681
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h

  Log Message:
  -----------
  OvmfPkg/MemEncryptSevLib: add support to validate > 4GB memory in PEI phase

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

The initial page built during the SEC phase is used by the
MemEncryptSevSnpValidateSystemRam() for the system RAM validation. The
page validation process requires using the PVALIDATE instruction;  the
instruction accepts a virtual address of the memory region that needs
to be validated. If hardware encounters a page table walk failure (due
to page-not-present) then it raises #GP.

The initial page table built in SEC phase address up to 4GB. Add an
internal function to extend the page table to cover > 4GB. The function
builds 1GB entries in the page table for access > 4GB. This will provide
the support to call PVALIDATE instruction for the virtual address >
4GB in PEI phase.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 202fb22be6e9100c2ce6329f1b09f885dfdb514a
      
https://github.com/tianocore/edk2/commit/202fb22be6e9100c2ce6329f1b09f885dfdb514a
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/FvmainCompactScratchEnd.fdf.inc
    M OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c
    M OvmfPkg/OvmfPkg.dec
    M OvmfPkg/Sec/AmdSev.c
    M OvmfPkg/Sec/AmdSev.h
    M OvmfPkg/Sec/SecMain.c
    M OvmfPkg/Sec/SecMain.inf

  Log Message:
  -----------
  OvmfPkg/SecMain: validate the memory used for decompressing Fv

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

The VMM launch sequence should have pre-validated all the data pages used
in the Reset vector. The range does not cover the data pages used during
the SEC phase (mainly PEI and DXE firmware volume decompression memory).

When SEV-SNP is active, the memory must be pre-validated before the access.
Add support to pre-validate the memory range from SnpSecPreValidatedStart
to SnpSecPreValidatedEnd. This should be sufficent to enter into the PEI
phase.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 8eb79b5f4fed31667f27b7ac97b568724fe12496
      
https://github.com/tianocore/edk2/commit/8eb79b5f4fed31667f27b7ac97b568724fe12496
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/PlatformPei/AmdSev.c

  Log Message:
  -----------
  OvmfPkg/PlatformPei: validate the system RAM when SNP is active

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

When SEV-SNP is active, a memory region mapped encrypted in the page
table must be validated before access. There are two approaches that
can be taken to validate the system RAM detected during the PEI phase:

1) Validate on-demand
OR
2) Validate before access

On-demand
=========
If memory is not validated before access, it will cause a #VC
exception with the page-not-validated error code. The VC exception
handler can perform the validation steps.

The pages that have been validated will need to be tracked to avoid
the double validation scenarios. The range of memory that has not
been validated will need to be communicated to the OS through the
recently introduced unaccepted memory type
https://github.com/microsoft/mu_basecore/pull/66, so that OS can
validate those ranges before using them.

Validate before access
======================
Since the PEI phase detects all the available system RAM, use the
MemEncryptSevSnpValidateSystemRam() function to pre-validate the
system RAM in the PEI phase.

For now, choose option 2 due to the dependency and the complexity
of the on-demand validation.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 26210f9436d82174fa03d1c43b58a63c2fa2c176
      
https://github.com/tianocore/edk2/commit/26210f9436d82174fa03d1c43b58a63c2fa2c176
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    A MdePkg/Include/ConfidentialComputingGuestAttr.h
    M MdePkg/MdePkg.dec

  Log Message:
  -----------
  MdePkg: Define ConfidentialComputingGuestAttr

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

While initializing APs, the MpInitLib may need to know whether the
guest is running with active AMD SEV or Intel TDX memory encryption.

Add a new ConfidentialComputingGuestAttr PCD that can be used to query
the memory encryption attribute.

Cc: Michael D Kinney <[email protected]>
Cc: Liming Gao <[email protected]>
Cc: Zhiguang Liu <[email protected]>
Cc: Michael Roth <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Suggested-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 504ae26b80b589eb48a17d42b8fb6ac48c4ebf7b
      
https://github.com/tianocore/edk2/commit/504ae26b80b589eb48a17d42b8fb6ac48c4ebf7b
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/AmdSev/AmdSevX64.dsc
    M OvmfPkg/OvmfPkgIa32.dsc
    M OvmfPkg/OvmfPkgIa32X64.dsc
    M OvmfPkg/OvmfPkgX64.dsc
    M OvmfPkg/PlatformPei/AmdSev.c
    M OvmfPkg/PlatformPei/PlatformPei.inf

  Log Message:
  -----------
  OvmfPkg/PlatformPei: set PcdConfidentialComputingAttr when SEV is active

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

The MpInitLib uses the ConfidentialComputingAttr PCD to determine whether
AMD SEV is active so that it can use the VMGEXITs defined in the GHCB
specification to create APs.

Cc: Michael Roth <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Suggested-by: Jiewen Yao <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: b95908e04317a2b1e3641845ba36f673d5aebada
      
https://github.com/tianocore/edk2/commit/b95908e04317a2b1e3641845ba36f673d5aebada
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
    M UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.h
    M UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
    M UefiCpuPkg/Library/MpInitLib/PeiMpLib.c

  Log Message:
  -----------
  UefiCpuPkg/MpInitLib: use PcdConfidentialComputingAttr to check SEV status

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

Previous commit introduced a generic confidential computing PCD that can
determine whether AMD SEV-ES is enabled. Update the MpInitLib to drop the
PcdSevEsIsEnabled in favor of PcdConfidentialComputingAttr.

Cc: Michael Roth <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Suggested-by: Jiewen Yao <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: f4e3ce5f532860bbcf3a78d38f699dfbff0e1e75
      
https://github.com/tianocore/edk2/commit/f4e3ce5f532860bbcf3a78d38f699dfbff0e1e75
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M UefiCpuPkg/UefiCpuPkg.dec

  Log Message:
  -----------
  UefiCpuPkg: add PcdGhcbHypervisorFeatures

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

Version 2 of the GHCB specification added a new VMGEXIT that the guest
could use for querying the hypervisor features. One of the immediate
users for it will be an AP creation code. When SEV-SNP is enabled, the
guest can use the newly added AP_CREATE VMGEXIT to create the APs.

The MpInitLib will check the hypervisor feature, and if AP_CREATE is
available, it will use it.

See GHCB spec version 2 for more details on the VMGEXIT.

Cc: Michael Roth <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: f5a6e1bab5d4d9d7bd0d543777290269e6c1a065
      
https://github.com/tianocore/edk2/commit/f5a6e1bab5d4d9d7bd0d543777290269e6c1a065
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/PlatformPei/AmdSev.c
    M OvmfPkg/PlatformPei/PlatformPei.inf

  Log Message:
  -----------
  OvmfPkg/PlatformPei: set the Hypervisor Features PCD

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

Version 2 of the GHCB specification added the support to query the
hypervisor feature bitmap. The feature bitmap provide information
such as whether to use the AP create VmgExit or use the AP jump table
approach to create the APs. The MpInitLib will use the
PcdGhcbHypervisorFeatures to determine which method to use for creating
the AP.

Query the hypervisor feature and set the PCD accordingly.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 2c354252be0ef156a80540555d7293800a200ecd
      
https://github.com/tianocore/edk2/commit/2c354252be0ef156a80540555d7293800a200ecd
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M MdePkg/Include/Register/Amd/Ghcb.h

  Log Message:
  -----------
  MdePkg/GHCB: increase the GHCB protocol max version

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

Now that OvmfPkg supports version 2 of the GHCB specification, bump the
protocol version.

Cc: Michael Roth <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 9c703bc0f1d6972ef44d55d9a5243f8558c564e4
      
https://github.com/tianocore/edk2/commit/9c703bc0f1d6972ef44d55d9a5243f8558c564e4
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M UefiCpuPkg/Library/MpInitLib/MpEqu.inc
    M UefiCpuPkg/Library/MpInitLib/MpLib.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.h
    M UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm

  Log Message:
  -----------
  UefiCpuPkg/MpLib: add support to register GHCB GPA when SEV-SNP is enabled

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

An SEV-SNP guest requires that the physical address of the GHCB must
be registered with the hypervisor before using it. See the GHCB
specification section 2.3.2 for more details.

Cc: Michael Roth <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: d4d7c9ad5fe531bbb69422ce833c67ef87d19087
      
https://github.com/tianocore/edk2/commit/d4d7c9ad5fe531bbb69422ce833c67ef87d19087
  Author: Michael Roth <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M UefiCpuPkg/Library/MpInitLib/AmdSev.c
    M UefiCpuPkg/Library/MpInitLib/MpEqu.inc
    M UefiCpuPkg/Library/MpInitLib/MpLib.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.h
    M UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm

  Log Message:
  -----------
  UefiCpuPkg/MpInitLib: use BSP to do extended topology check

During AP bringup, just after switching to long mode, APs will do some
cpuid calls to verify that the extended topology leaf (0xB) is available
so they can fetch their x2 APIC IDs from it. In the case of SEV-ES,
these cpuid instructions must be handled by direct use of the GHCB MSR
protocol to fetch the values from the hypervisor, since a #VC handler
is not yet available due to the AP's stack not being set up yet.

For SEV-SNP, rather than relying on the GHCB MSR protocol, it is
expected that these values would be obtained from the SEV-SNP CPUID
table instead. The actual x2 APIC ID (and 8-bit APIC IDs) would still
be fetched from hypervisor using the GHCB MSR protocol however, so
introducing support for the SEV-SNP CPUID table in that part of the AP
bring-up code would only be to handle the checks/validation of the
extended topology leaf.

Rather than introducing all the added complexity needed to handle these
checks via the CPUID table, instead let the BSP do the check in advance,
since it can make use of the #VC handler to avoid the need to scan the
SNP CPUID table directly, and add a flag in ExchangeInfo to communicate
the result of this check to APs.

Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Suggested-by: Brijesh Singh <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: b928eb44d5bfcf93895a3e488f15696e59ca127d
      
https://github.com/tianocore/edk2/commit/b928eb44d5bfcf93895a3e488f15696e59ca127d
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c

  Log Message:
  -----------
  OvmfPkg/MemEncryptSevLib: change the page state in the RMP table

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

The MemEncryptSev{Set,Clear}PageEncMask() functions are used to set or
clear the memory encryption attribute in the page table. When SEV-SNP
is active, we also need to change the page state in the RMP table so that
it is in sync with the memory encryption attribute change.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: b7b88720312be7daa5a7d955f7b5816a41e87485
      
https://github.com/tianocore/edk2/commit/b7b88720312be7daa5a7d955f7b5816a41e87485
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c

  Log Message:
  -----------
  OvmfPkg/MemEncryptSevLib: skip page state change for Mmio address

The SetMemoryEncDec() is used by the higher level routines to set or clear
the page encryption mask for system RAM and Mmio address. When SEV-SNP is
active, in addition to set/clear page mask it also updates the RMP table.
The RMP table updates are required for the system RAM address and not
the Mmio address.

Add a new parameter in SetMemoryEncDec() to tell whether the specified
address is Mmio. If its Mmio then skip the page state change in the RMP
table.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: ea3a12d9706dd405d5eb96901be31de28c3134af
      
https://github.com/tianocore/edk2/commit/ea3a12d9706dd405d5eb96901be31de28c3134af
  Author: Brijesh Singh via groups.io <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/PlatformPei/AmdSev.c
    M OvmfPkg/PlatformPei/MemDetect.c
    M OvmfPkg/PlatformPei/Platform.h
    M OvmfPkg/PlatformPei/PlatformPei.inf

  Log Message:
  -----------
  OvmfPkg/PlatformPei: mark cpuid and secrets memory reserved in EFI map

When SEV-SNP is active, the CPUID and Secrets memory range contains the
information that is used during the VM boot. The content need to be persist
across the kexec boot. Mark the memory range as Reserved in the EFI map
so that guest OS or firmware does not use the range as a system RAM.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 67484aed694e7d9dff4ae91df0afeff28898c68a
      
https://github.com/tianocore/edk2/commit/67484aed694e7d9dff4ae91df0afeff28898c68a
  Author: Brijesh Singh <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M OvmfPkg/AmdSevDxe/AmdSevDxe.c
    M OvmfPkg/AmdSevDxe/AmdSevDxe.inf
    A OvmfPkg/Include/Guid/ConfidentialComputingSevSnpBlob.h
    M OvmfPkg/OvmfPkg.dec

  Log Message:
  -----------
  OvmfPkg/AmdSev: expose the SNP reserved pages through configuration table

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

Now that both the secrets and cpuid pages are reserved in the HOB,
extract the location details through fixed PCD and make it available
to the guest OS through the configuration table.

Cc: Michael Roth <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


  Commit: 06544455d0d460ed18c8582121247bf53292d7e4
      
https://github.com/tianocore/edk2/commit/06544455d0d460ed18c8582121247bf53292d7e4
  Author: Tom Lendacky <[email protected]>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
    M UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
    A UefiCpuPkg/Library/MpInitLib/Ia32/AmdSev.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.c
    M UefiCpuPkg/Library/MpInitLib/MpLib.h
    M UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
    A UefiCpuPkg/Library/MpInitLib/X64/AmdSev.c

  Log Message:
  -----------
  UefiCpuPkg/MpInitLib: Use SEV-SNP AP Creation NAE event to launch APs

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

Use the SEV-SNP AP Creation NAE event to create and launch APs under
SEV-SNP. This capability will be advertised in the SEV Hypervisor
Feature Support PCD (PcdSevEsHypervisorFeatures).

Cc: Michael Roth <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Min Xu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Erdem Aktas <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Acked-by: Ray Ni <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Tom Lendacky <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>


Compare: https://github.com/tianocore/edk2/compare/c82ab4d8c148...06544455d0d4


_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to