[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <77e09c12-0971-e5dc-7002-c88e30e9455e@suse.com>
Date: Wed, 16 Jun 2021 11:16:59 +0200
From: Varad Gautam <varad.gautam@...e.com>
To: Joerg Roedel <jroedel@...e.de>
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 6/9/21 4:50 PM, Joerg Roedel wrote:
> 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?
>
Thanks, I've sent out a v4 with the test moved to arch/x86/tests. This is
now hidden behind a CONFIG_X86_TESTS, where more stuff can be plugged in.
>> 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.
>
Ack, also moved in v4.
Varad
--
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany
HRB 36809, AG Nürnberg
Geschäftsführer: Felix Imendörffer
Powered by blists - more mailing lists