Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5085894pxj; Wed, 9 Jun 2021 08:50:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIanRv6K0/FuOKIYevp/Bo2ll+D2Kin0puVhfHaf/A2BZzm4vud9Zy8L3ktny7zLTrer4E X-Received: by 2002:a05:6402:8d4:: with SMTP id d20mr86268edz.117.1623253812367; Wed, 09 Jun 2021 08:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623253812; cv=none; d=google.com; s=arc-20160816; b=RxiqtbvrKykfuR0vytbL4FfgFM2fx8rTW1+GXOFiv885KfY7pLJs2XX96izoJCHm6W MPbiBj8cJbXa6cCcBxZ4g87Rne7w+uROIDZhSHTKHjmikoIbumWtlSAtoQ7PuOjlSWdt ETzBDBSc2BkuXZ+cCLf9dq1o3MCHDbHPuwbO2PNndsFXBmQ1Ooxe5gUrYXMHFNnpWzHJ dzBhjqu0J9XrZxRVv1oI4AAVB7DpFo8y99AwmJ/yRh68wiqVUWVMqf/KcjlHiJlTeTJi uRhIogy3gSqIsRll/rY0Uh07NuD2j9vifX99Bd+vZip5BwN+WysT7lxJPFlKwZAlLbqB /KuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=bfjFCPehMo1dyNPOnDLbyFFsGSL83cnl+X5eXtIrdMo=; b=Z2WYd47hFWERk4/KDC7bHxHrliHJ9XlOTjhLDpU8Nth/EdW+9rHF3IBoiyeHck3pIC 93v9wSNe+7kMsTOJ6WADTarpKDs1fsH5D3UK6OHWrbeTDfUpBV8uC3Z3mYvg6XCb9C87 DlTBv4vBLNiHqt1q4fL/4jcPqT/CTe/5ZNm1Pug5Y6tEM53h5JfJXnM0GqX4XC659HsH ervk7FoljBqMUONTG/4N9kWBrAV8JE4DtXXcoEUbMySUuhz9ZAE4Z7BbKyXX8rRZ67z1 Zw+2fHkc2RJ9cI0uy5SkOmFNSvck6CQEHhv3W6kzHsvJBgu1CEBltHKfa6PHBZjsBslT EKDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BmwR7ybJ; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BmwR7ybJ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=DZbZ5Blb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm15si24044edb.472.2021.06.09.08.49.48; Wed, 09 Jun 2021 08:50:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BmwR7ybJ; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BmwR7ybJ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=DZbZ5Blb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238250AbhFIOwb (ORCPT + 99 others); Wed, 9 Jun 2021 10:52:31 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:42626 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238229AbhFIOw0 (ORCPT ); Wed, 9 Jun 2021 10:52:26 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7475D1FD5F; Wed, 9 Jun 2021 14:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623250230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bfjFCPehMo1dyNPOnDLbyFFsGSL83cnl+X5eXtIrdMo=; b=BmwR7ybJEQTIkO2dHxeC8RucevhwFNqF5glMJdWb8NS5t4xsTPaoMlrYtvQQQvLgiosSzU vKY81XNPyQpFno1hE62xVlkHiGpCSmopP5c3wioB9niwn6i0djX/lZHy7+HWwBkld7I6DT ZZoO5rVE/JZDsZe3zs8etR7QSDhQ1Yk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623250230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bfjFCPehMo1dyNPOnDLbyFFsGSL83cnl+X5eXtIrdMo=; b=DZbZ5Blb/fF29l+3M+5ErblsWt+rGhhgXR/PRrYnbG6Q5YGQCEXoNrOaBbyWA90Cas+Fs1 miO/AthFhYrHk1Aw== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 34138118DD; Wed, 9 Jun 2021 14:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623250230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bfjFCPehMo1dyNPOnDLbyFFsGSL83cnl+X5eXtIrdMo=; b=BmwR7ybJEQTIkO2dHxeC8RucevhwFNqF5glMJdWb8NS5t4xsTPaoMlrYtvQQQvLgiosSzU vKY81XNPyQpFno1hE62xVlkHiGpCSmopP5c3wioB9niwn6i0djX/lZHy7+HWwBkld7I6DT ZZoO5rVE/JZDsZe3zs8etR7QSDhQ1Yk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623250230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bfjFCPehMo1dyNPOnDLbyFFsGSL83cnl+X5eXtIrdMo=; b=DZbZ5Blb/fF29l+3M+5ErblsWt+rGhhgXR/PRrYnbG6Q5YGQCEXoNrOaBbyWA90Cas+Fs1 miO/AthFhYrHk1Aw== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id yJIXCzbVwGBcXAAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 14:50:30 +0000 Date: Wed, 9 Jun 2021 16:50:28 +0200 From: Joerg Roedel To: Varad Gautam Cc: linux-kernel@vger.kernel.org, Varad Gautam , kvm@vger.kernel.org, x86@kernel.org, Borislav Petkov , Tom Lendacky Subject: Re: [PATCH v3] x86: Add a test for AMD SEV-ES guest #VC handling Message-ID: References: <20210531125035.21105-1-varad.gautam@suse.com> <20210602141447.18629-1-varadgautam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210602141447.18629-1-varadgautam@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 02, 2021 at 04:14:47PM +0200, Varad Gautam wrote: > From: Varad Gautam > > 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 > --- > 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 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.