[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YMDVNHh9KHsha4a+@suse.de>
Date: Wed, 9 Jun 2021 16:50:28 +0200
From: Joerg Roedel <jroedel@...e.de>
To: Varad Gautam <varadgautam@...il.com>
Cc: linux-kernel@...r.kernel.org, Varad Gautam <varad.gautam@...e.com>,
kvm@...r.kernel.org, x86@...nel.org,
Borislav Petkov <bp@...en8.de>,
Tom Lendacky <thomas.lendacky@....com>
Subject: Re: [PATCH v3] x86: Add a test for AMD SEV-ES guest #VC handling
On Wed, Jun 02, 2021 at 04:14:47PM +0200, Varad Gautam wrote:
> From: Varad Gautam <varad.gautam@...e.com>
>
> 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 <varad.gautam@...e.com>
> ---
> 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 <jroedel@...e.de>
Btw, should we create a separate directory for such tests like
/arch/x86/tests/ or something along those lines?
> 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.
Powered by blists - more mailing lists