Re: [PATCH v3] x86: Add a test for AMD SEV-ES guest #VC handling
From: Joerg Roedel <hidden>
Date: 2021-06-09 14:50:40
Also in:
lkml
On Wed, Jun 02, 2021 at 04:14:47PM +0200, Varad Gautam wrote:
From: Varad Gautam <redacted> Some vmexits on a SEV-ES guest need special handling within the guest before exiting to the hypervisor. This must happen within the guest's \#VC exception handler, triggered on every non automatic exit. Add a KUnit based test to validate Linux's VC handling. The test: 1. installs a kretprobe on the #VC handler (sev_es_ghcb_hv_call, to access GHCB before/after the resulting VMGEXIT). 2. tiggers an NAE. 3. checks that the kretprobe was hit with the right exit_code available in GHCB. Since relying on kprobes, the test does not cover NMI contexts. Signed-off-by: Varad Gautam <redacted> --- arch/x86/Kconfig | 9 ++ arch/x86/kernel/Makefile | 8 ++ arch/x86/kernel/sev-es-test-vc.c | 155 +++++++++++++++++++++++++++++++
This looks good to me except for the small comment below, thanks Varad. I ran it in an SEV-ES guest and I am seeing the test results in dmesg. Only thing I am missing is a 'rep movs' test for MMIO, but that can be added later, so Tested-by: Joerg Roedel <redacted> Btw, should we create a separate directory for such tests like /arch/x86/tests/ or something along those lines?
quoted hunk ↗ jump to hunk
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 0045e1b441902..85b8ac450ba56 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig@@ -1543,6 +1543,15 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT If set to N, then the encryption of system memory can be activated with the mem_encrypt=on command line option. +config AMD_SEV_ES_TEST_VC + bool "Test for AMD SEV-ES VC exception handling." + depends on AMD_MEM_ENCRYPT + select FUNCTION_TRACER + select KPROBES + select KUNIT + help + Enable KUnit-based testing for AMD SEV-ES #VC exception handling. +
I think this should be in arch/x86/Kconfig.debug.