public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v7 00/11] Add #VC exception handling for AMD SEV-ES
@ 2024-04-19 16:16 vsntk18
  2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 01/11] x86: AMD SEV-ES: Setup #VC exception handler " vsntk18
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: vsntk18 @ 2024-04-19 16:16 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini, seanjc, jroedel, papaluri, andrew.jones,
	Vasant Karasulli

From: Vasant Karasulli <vkarasulli@suse.de>

For AMD SEV-ES, kvm-unit-tests currently rely on UEFI to set up a
#VC exception handler. This leads to the following problems:

1) The test's page table needs to map the firmware and the shared
   GHCB used by the firmware.
2) The firmware needs to keep its #VC handler in the current IDT
   so that kvm-unit-tests can copy the #VC entry into its own IDT.
3) The firmware #VC handler might use state which is not available
   anymore after ExitBootServices.
4) After ExitBootServices, the firmware needs to get the GHCB address
   from the GHCB MSR if it needs to use the kvm-unit-test GHCB. This
   requires keeping an identity mapping, and the GHCB address must be
   in the MSR at all times where a #VC could happen.

Problems 1) and 2) were temporarily mitigated via commits b114aa57ab
("x86 AMD SEV-ES: Set up GHCB page") and 706ede1833 ("x86 AMD SEV-ES:
Copy UEFI #VC IDT entry") respectively.

However, to make kvm-unit-tests reliable against 3) and 4), the tests
must supply their own #VC handler [1][2].

This series adds #VC exception processing from Linux into kvm-unit-tests,
and makes it the default way of handling #VC exceptions.

If --amdsev-efi-vc is passed during ./configure, the tests will continue
using the UEFI #VC handler.

[1] https://lore.kernel.org/all/Yf0GO8EydyQSdZvu@suse.de/
[2] https://lore.kernel.org/all/YSA%2FsYhGgMU72tn+@google.com/

v7:
- Rebased the patches on top of the current state of the test suite.
- Addressed review comment by Andrew Jones:
  - moved macros unlikely()/likely to linux/compiler.h

v6:
- Rebased the patches on top of the current state of the test suite.
- Rebased the insn decoder on linux kernel e8c39d0f57f.
- Add a line about configuration option --amdsev-efi-vc in the
  x86/efi/README.md file.

Vasant Karasulli (11):
  x86: AMD SEV-ES: Setup #VC exception handler for AMD SEV-ES
  x86: Move svm.h to lib/x86/
  lib: Define unlikely()/likely() macros in compiler.h
  lib: x86: Import insn decoder from Linux
  x86: AMD SEV-ES: Pull related GHCB definitions and helpers from Linux
  x86: AMD SEV-ES: Prepare for #VC processing
  lib/x86: Move xsave helpers to lib/
  x86: AMD SEV-ES: Handle CPUID #VC
  x86: AMD SEV-ES: Handle MSR #VC
  x86: AMD SEV-ES: Handle IOIO #VC
  x86: AMD SEV-ES: Handle string IO for IOIO #VC

 .gitignore                         |    2 +
 Makefile                           |    3 +
 configure                          |   21 +
 lib/linux/compiler.h               |    3 +
 lib/x86/amd_sev.c                  |   13 +-
 lib/x86/amd_sev.h                  |  140 ++++
 lib/x86/amd_sev_vc.c               |  500 ++++++++++++
 lib/x86/desc.c                     |   17 +
 lib/x86/desc.h                     |    1 +
 lib/x86/insn/README                |   23 +
 lib/x86/insn/gen-insn-attr-x86.awk |  443 +++++++++++
 lib/x86/insn/inat.c                |   86 ++
 lib/x86/insn/inat.h                |  233 ++++++
 lib/x86/insn/inat_types.h          |   18 +
 lib/x86/insn/insn.c                |  735 +++++++++++++++++
 lib/x86/insn/insn.h                |  279 +++++++
 lib/x86/insn/insn_glue.h           |   32 +
 lib/x86/insn/x86-opcode-map.txt    | 1191 ++++++++++++++++++++++++++++
 lib/x86/msr.h                      |    1 +
 lib/x86/processor.h                |   25 +-
 lib/x86/setup.c                    |    8 +
 {x86 => lib/x86}/svm.h             |   19 +-
 lib/x86/xsave.c                    |   26 +
 lib/x86/xsave.h                    |   15 +
 x86/Makefile.common                |   16 +-
 x86/Makefile.x86_64                |    1 +
 x86/efi/README.md                  |    4 +
 x86/kvmclock.c                     |    4 -
 x86/svm.c                          |    2 +-
 x86/svm_tests.c                    |    2 +-
 x86/xsave.c                        |   17 +-
 31 files changed, 3832 insertions(+), 48 deletions(-)
 create mode 100644 lib/x86/amd_sev_vc.c
 create mode 100644 lib/x86/insn/README
 create mode 100644 lib/x86/insn/gen-insn-attr-x86.awk
 create mode 100644 lib/x86/insn/inat.c
 create mode 100644 lib/x86/insn/inat.h
 create mode 100644 lib/x86/insn/inat_types.h
 create mode 100644 lib/x86/insn/insn.c
 create mode 100644 lib/x86/insn/insn.h
 create mode 100644 lib/x86/insn/insn_glue.h
 create mode 100644 lib/x86/insn/x86-opcode-map.txt
 rename {x86 => lib/x86}/svm.h (97%)
 create mode 100644 lib/x86/xsave.c
 create mode 100644 lib/x86/xsave.h


base-commit: 69ee03b0598ee49f75ebab5cd0fe39bf18c1146e
--
2.34.1


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

end of thread, other threads:[~2024-06-06 23:49 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19 16:16 [kvm-unit-tests PATCH v7 00/11] Add #VC exception handling for AMD SEV-ES vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 01/11] x86: AMD SEV-ES: Setup #VC exception handler " vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 02/11] x86: Move svm.h to lib/x86/ vsntk18
2024-06-05 16:05   ` Sean Christopherson
2024-06-06 18:57     ` Vasant Karasulli
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 03/11] lib: Define unlikely()/likely() macros in compiler.h vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 04/11] lib: x86: Import insn decoder from Linux vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 05/11] x86: AMD SEV-ES: Pull related GHCB definitions and helpers " vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 06/11] x86: AMD SEV-ES: Prepare for #VC processing vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 07/11] lib/x86: Move xsave helpers to lib/ vsntk18
2024-06-05 16:04   ` Sean Christopherson
2024-06-06 18:58     ` Vasant Karasulli
2024-06-06 23:49       ` Sean Christopherson
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 08/11] x86: AMD SEV-ES: Handle CPUID #VC vsntk18
2024-06-05 16:07   ` Sean Christopherson
2024-06-06 18:59     ` Vasant Karasulli
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 09/11] x86: AMD SEV-ES: Handle MSR #VC vsntk18
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 10/11] x86: AMD SEV-ES: Handle IOIO #VC vsntk18
2024-06-05 16:08   ` Sean Christopherson
2024-06-06 19:01     ` Vasant Karasulli
2024-04-19 16:16 ` [kvm-unit-tests PATCH v7 11/11] x86: AMD SEV-ES: Handle string IO for " vsntk18

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox