All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests RFC 00/16] x86_64 UEFI and AMD SEV/SEV-ES support
@ 2021-08-18  0:08 Zixuan Wang
  2021-08-18  0:08 ` [kvm-unit-tests RFC 01/16] x86 UEFI: Copy code from GNU-EFI Zixuan Wang
                   ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Zixuan Wang @ 2021-08-18  0:08 UTC (permalink / raw)
  To: kvm, pbonzini, drjones
  Cc: marcorr, baekhw, tmroeder, erdemaktas, rientjes, seanjc,
	brijesh.singh, Thomas.Lendacky, varad.gautam, jroedel, bp,
	Zixuan Wang

Hello,

This patch series updates the x86_64 KVM-Unit-Tests to run under UEFI
and culminates in enabling AMD SEV/SEV-ES. We are sending it out for
early review as it provides basic support to run test cases in UEFI,
and also enables AMD SEV and SEV-ES features.

The patches are organized as two parts. The first part (patches 1-9)
enables the x86_64 test cases to run under UEFI. In particular, these
patches allow the x86_64 test cases to be built as EFI applications.
The efi_main() function sets up the KVM-Unit-Tests framework to run
under UEFI and then launches the test cases' main() function. To date,
we have 38/43 test cases running with UEFI using this approach.

The second part of the series (patches 10-16) focuses on SEV. In
particular, these patches introduce SEV/SEV-ES set up code into the EFI
set up process, including checking if SEV is supported, setting c-bits
for page table entries, and (notably) reusing the UEFI #VC handler so
that the set up process does not need to re-implement it (a test case
can always implement a new #VC handler and load it after set up is
finished). Using this approach, we are able to launch the x86_64 test
cases under SEV-ES and exercise KVM's VMGEXIT handler.

See the Part 1 and Part 2 summaries, below, for a high-level breakdown
of how the patches are organized.

Part 1 Summary:
Commits 1-3 introduce support to build test cases as EFI applications
(with the GNU-EFI library).

Commits 4-8 set up KVM-Unit-Tests to run under UEFI. In doing so, these
patches incrementally enable most existing x86_64 test cases to run
under UEFI.

Commit 9 fixes several test cases that fail to compile with GNU-EFI due
to UEFI's position independent code (PIC) requirement.

Part 2 Summary:
Commits 10-11 introduce support for SEV by adding new configuration
flags and set up code to set the SEV c-bit in page table entries.
SEV-related code is currently injected by configuration flags and C
macros, it is also possible to remove these flags and macros and
implement runtime SEV check and set up functions.

Commits 12-15 introduce support for SEV-ES by reusing the UEFI #VC
handler in KVM-Unit-Tests. They also fix GDT and IDT issues that occur
when reusing UEFI functions in KVM-Unit-Tests.

Commit 16 adds additional test cases for SEV-ES.

Regards,
Zixuan Wang

Zixuan Wang (16):
  x86 UEFI: Copy code from GNU-EFI
  x86 UEFI: Boot from UEFI
  x86 UEFI: Move setjmp.h out of desc.h
  x86 UEFI: Load KVM-Unit-Tests IDT after UEFI boot up
  x86 UEFI: Load GDT and TSS after UEFI boot up
  x86 UEFI: Set up memory allocator
  x86 UEFI: Set up RSDP after UEFI boot up
  x86 UEFI: Set up page tables
  x86 UEFI: Convert x86 test cases to PIC
  x86 AMD SEV: Initial support
  x86 AMD SEV: Page table with c-bit
  x86 AMD SEV-ES: Check SEV-ES status
  x86 AMD SEV-ES: Load GDT with UEFI segments
  x86 AMD SEV-ES: Copy UEFI #VC IDT entry
  x86 AMD SEV-ES: Set up GHCB page
  x86 AMD SEV-ES: Add test cases

 .gitignore                 |   3 +
 Makefile                   |  47 ++++++-
 README.md                  |   6 +
 configure                  |  29 +++++
 lib/efi.c                  |  60 +++++++++
 lib/string.c               |   3 +
 lib/x86/acpi.c             |  38 +++++-
 lib/x86/acpi.h             |   4 +
 lib/x86/amd_sev.c          | 147 +++++++++++++++++++++
 lib/x86/amd_sev.h          |  59 +++++++++
 lib/x86/asm/page.h         |  14 +-
 lib/x86/asm/setup.h        |  37 ++++++
 lib/x86/desc.c             |   4 +
 lib/x86/desc.h             |   5 -
 lib/x86/setup.c            | 259 +++++++++++++++++++++++++++++++++++++
 lib/x86/usermode.c         |   3 +-
 lib/x86/vm.c               |  18 ++-
 x86/Makefile.common        |  75 ++++++++---
 x86/Makefile.i386          |   5 +-
 x86/Makefile.x86_64        |  58 ++++++---
 x86/access.c               |   6 +-
 x86/amd_sev.c              |  97 ++++++++++++++
 x86/cet.c                  |   8 +-
 x86/efi/README.md          |  72 +++++++++++
 x86/efi/efistart64.S       | 141 ++++++++++++++++++++
 x86/efi/elf_x86_64_efi.lds |  81 ++++++++++++
 x86/efi/run                |  63 +++++++++
 x86/emulator.c             |   5 +-
 x86/eventinj.c             |   6 +-
 x86/run                    |  16 ++-
 x86/smap.c                 |   8 +-
 x86/umip.c                 |  10 +-
 x86/vmx.c                  |   1 +
 33 files changed, 1311 insertions(+), 77 deletions(-)
 create mode 100644 lib/efi.c
 create mode 100644 lib/x86/amd_sev.c
 create mode 100644 lib/x86/amd_sev.h
 create mode 100644 lib/x86/asm/setup.h
 create mode 100644 x86/amd_sev.c
 create mode 100644 x86/efi/README.md
 create mode 100644 x86/efi/efistart64.S
 create mode 100644 x86/efi/elf_x86_64_efi.lds
 create mode 100755 x86/efi/run

--
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-08-21  0:48 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18  0:08 [kvm-unit-tests RFC 00/16] x86_64 UEFI and AMD SEV/SEV-ES support Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 01/16] x86 UEFI: Copy code from GNU-EFI Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 02/16] x86 UEFI: Boot from UEFI Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 03/16] x86 UEFI: Move setjmp.h out of desc.h Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 04/16] x86 UEFI: Load KVM-Unit-Tests IDT after UEFI boot up Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 05/16] x86 UEFI: Load GDT and TSS " Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 06/16] x86 UEFI: Set up memory allocator Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 07/16] x86 UEFI: Set up RSDP after UEFI boot up Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 08/16] x86 UEFI: Set up page tables Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 09/16] x86 UEFI: Convert x86 test cases to PIC Zixuan Wang
2021-08-18  0:08 ` [kvm-unit-tests RFC 10/16] x86 AMD SEV: Initial support Zixuan Wang
2021-08-18  0:09 ` [kvm-unit-tests RFC 11/16] x86 AMD SEV: Page table with c-bit Zixuan Wang
2021-08-18  0:09 ` [kvm-unit-tests RFC 12/16] x86 AMD SEV-ES: Check SEV-ES status Zixuan Wang
2021-08-18  0:09 ` [kvm-unit-tests RFC 13/16] x86 AMD SEV-ES: Load GDT with UEFI segments Zixuan Wang
2021-08-18  0:09 ` [kvm-unit-tests RFC 14/16] x86 AMD SEV-ES: Copy UEFI #VC IDT entry Zixuan Wang
2021-08-20 23:50   ` Sean Christopherson
2021-08-21  0:37     ` Marc Orr
2021-08-21  0:47     ` Zixuan Wang
2021-08-18  0:09 ` [kvm-unit-tests RFC 15/16] x86 AMD SEV-ES: Set up GHCB page Zixuan Wang
2021-08-18  0:09 ` [kvm-unit-tests RFC 16/16] x86 AMD SEV-ES: Add test cases Zixuan Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.