Re: [PATCH v5 1/1] x86/test: Add a test for AMD SEV-ES #VC handling

From: Joerg Roedel
Date: Thu Mar 17 2022 - 09:21:15 EST


Hi Vasant,

thanks for submitting this.

On Tue, Feb 08, 2022 at 05:26:23PM +0100, Vasant Karasulli wrote:
> From: Varad Gautam <varad.gautam@xxxxxxxx>
>
> Add a KUnit based test to validate Linux's VC handling, and introduce
> a new CONFIG_X86_TESTS to cover such tests. The test:
> 1. installs a kretprobe on the #VC handler (sev_es_ghcb_hv_call, to
> access GHCB before/after the resulting VMGEXIT).
> 2. triggers 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@xxxxxxxx>
> Signed-off-by: Vasant Karasulli <vkarasulli@xxxxxxx>
> ---
> arch/x86/Kbuild | 2 +
> arch/x86/Kconfig.debug | 16 ++++
> arch/x86/kernel/Makefile | 7 ++
> arch/x86/tests/Makefile | 3 +
> arch/x86/tests/sev-test-vc.c | 154 +++++++++++++++++++++++++++++++++++
> 5 files changed, 182 insertions(+)
> create mode 100644 arch/x86/tests/Makefile
> create mode 100644 arch/x86/tests/sev-test-vc.c

Can we split this up a bit? Say into an initial patch which adds
arch/x86/tests/ and the Kconfig option and then three patches adding the
tests:

1. Infrastructure and instruction-based tests (cpuid, wbinvd)
2. Register access tests (MSR, DR7)
3. IO tests (mmio, ioio)

> +static void sev_es_nae_mmio(struct kunit *test)
> +{
> + unsigned long lapic_ver_pa = 0xfee00030; /* APIC_DEFAULT_PHYS_BASE + APIC_LVR */

Instead of the comment, please use the values directly to assign the
variable.

Regards,

--
Jörg Rödel
jroedel@xxxxxxx

SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany

(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev