kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zixuan Wang <zixuanwang@google.com>
To: kvm@vger.kernel.org, pbonzini@redhat.com, drjones@redhat.com
Cc: marcorr@google.com, baekhw@google.com, tmroeder@google.com,
	erdemaktas@google.com, rientjes@google.com, seanjc@google.com,
	brijesh.singh@amd.com, Thomas.Lendacky@amd.com,
	varad.gautam@suse.com, jroedel@suse.de, bp@suse.de,
	Zixuan Wang <zixuanwang@google.com>
Subject: [kvm-unit-tests RFC 00/16] x86_64 UEFI and AMD SEV/SEV-ES support
Date: Wed, 18 Aug 2021 00:08:49 +0000	[thread overview]
Message-ID: <20210818000905.1111226-1-zixuanwang@google.com> (raw)

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


             reply	other threads:[~2021-08-18  0:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  0:08 Zixuan Wang [this message]
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

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-all 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=20210818000905.1111226-1-zixuanwang@google.com \
    --to=zixuanwang@google.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=baekhw@google.com \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=drjones@redhat.com \
    --cc=erdemaktas@google.com \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    --cc=tmroeder@google.com \
    --cc=varad.gautam@suse.com \
    --subject='Re: [kvm-unit-tests RFC 00/16] x86_64 UEFI and AMD SEV/SEV-ES support' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).