Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1026088pxb; Wed, 6 Apr 2022 07:02:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbC0AenusJJSgPqf4JvDkTzcd0ORrDEVQwilHLB6njEebq6qkKo+Pb+/UpBi3brVHtkwRg X-Received: by 2002:a5e:c00f:0:b0:64c:7199:468e with SMTP id u15-20020a5ec00f000000b0064c7199468emr4213396iol.161.1649253747072; Wed, 06 Apr 2022 07:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649253747; cv=none; d=google.com; s=arc-20160816; b=bxDLurABCAKY7hyLYYJD2W/EyGwUXu9KTs589WvJUohGgaWSVmLb03jbPYP0Aw7+3D HQH/GVpIIgVwfzTGT5ye42FnFDnpbD4Yuyqi/QHu1lqWgYx/xx/x+Y645rqMaGWfTTbr JeIZPHhy42FMIL3rdEypJepBTxwHJR7K9FHyDzcV92gEPt4K/C5FBQkh7dT77rFNCvp0 BGeWmNvVqmmHWU/keMF/eQK3h3OAYl/YbX/GxdjqTGIKtPR5QJ6PmF0zFptuU/OwuZtb BWDhSmkSgkNanpAQKac5YLZg8E+/ngyuGIr9EpRU1s+A+LL6RfToAaZgRS/8F8wgvci7 XpuA== 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; bh=het7xQEY6AiunexNVt3R9JrRc+WqABKqnLlFmve94Cc=; b=R9YeiUCuo0jvn1RVE2rAuxqmK3LVZwMmRK43y6lqQx1SRaWdAEd6VeQCZtnWYdsmrC WcY7+mIn5w3MWVkM97MidDGBZWmrlCt/dlonyyj7/e4LNPu2lH1QkH7glO2nIjZX0yXA TL+9uGic/rWFyL2B3CYz37tbi3obozTZkOmTmh65TtfuJ2XchvGT1JB0fMvFUr1OJe2Q OPkwUAtGZPbnZG6bHqXKBF6iLpSJaZ+CnvZaXt3PR/AOPBUOB8LT5nvVuynhdnOvRXpU rnjOjCouPmfg3WUZXSjkMR6kUhb+4q6+TUYz7UO3plM54zOLfyFG7I0iGNlO5aHndzbo eU+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=itRW2E0k; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z3-20020a056638318300b0031a6c04b7e9si4417688jak.119.2022.04.06.07.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:02:27 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=itRW2E0k; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76D631C9B5E; Wed, 6 Apr 2022 04:52:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242513AbiDFI0N (ORCPT + 99 others); Wed, 6 Apr 2022 04:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359202AbiDFIY0 (ORCPT ); Wed, 6 Apr 2022 04:24:26 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56EA21FAA2D for ; Tue, 5 Apr 2022 18:23:00 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id w21so887001pgm.7 for ; Tue, 05 Apr 2022 18:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=het7xQEY6AiunexNVt3R9JrRc+WqABKqnLlFmve94Cc=; b=itRW2E0kExcc0Xbaqr5Rh6BbC+cbZkZDFpK9xbhZMF0juee9my0sm58u9xyFrLsprz ot2kFFHJ1bTgUg/fkR0IR5ACSG3O2kY3wbGZKsfnHPRgqglv6F20nLcOqRJYT6abN+b/ XUJnGOA9Pkr8343tkubrNfuBP3p0OT+EyRVXTb43d3x+xb9/TdGS7afMW/Ax8Qo/pUJj /CkF2+7+R+QXIikz7cnO0nvZHX2zpv6hjyWAHgQSjiCrAqBOMM1nv1aRMn4TW+KAl1cm H1HVHdBs+dCQa9JdCslDgZkoOj6P5HsLWe+AkWTDb0ClwzJ5EsIyIwJvQzH8Gy+hoUBN 956Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=het7xQEY6AiunexNVt3R9JrRc+WqABKqnLlFmve94Cc=; b=43IMJqRNGyLGvyWgkMQ+Y1a9YGg+JbhfQv4cp+UnPKRBHC1B2Q39V9LCIuUvZxxnHg O1hVnC0BFC4p5NaQOMv30gNWzHrsM4RveU7d7yRgoHIhuAfxIQ7RKRB1+l5yZCRXW5Uc jtdFzgoDEjOY0QxKoyFJ/UMYZzVZEolDgO1apDIrABbd5Zn2ftizO/HsDEntGx4YdlX4 7Fs9NMBgW4LMLpFMhP2NBVkInWgPRaRfrbe9JEJ8MCYmfQbSin11pC847j7HJdMbguVw 113Cj3w6+EH7WKeccKrNSc/8gGlkG2zjJDurY/YNsknwXcc42K9puXkn/9ZbZNgBoS4u IblA== X-Gm-Message-State: AOAM5324QDFS07EkpUBX/hTqcWh0Bh5XT90jP0LC+tUOpLCB3cOSo4UD Z4J7GWfg3Two8WwSRefuotq+CQ== X-Received: by 2002:a05:6a02:28a:b0:385:f767:34f4 with SMTP id bk10-20020a056a02028a00b00385f76734f4mr5163616pgb.299.1649208179490; Tue, 05 Apr 2022 18:22:59 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id m21-20020a17090a7f9500b001c97c6bcaf4sm3663556pjl.39.2022.04.05.18.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 18:22:58 -0700 (PDT) Date: Wed, 6 Apr 2022 01:22:55 +0000 From: Sean Christopherson To: Vasant Karasulli Cc: linux-kernel@vger.kernel.org, jroedel@suse.de, kvm@vger.kernel.org, bp@alien8.de, x86@kernel.org, thomas.lendacky@amd.com, varad.gautam@suse.com Subject: Re: [PATCH v6 2/4] x86/tests: Add tests for AMD SEV-ES #VC handling Add KUnit based tests to validate Linux's VC handling for instructions cpuid and wbinvd. These tests: 1. install a kretprobe on the #VC handler (sev_es_ghcb_hv_call, to access GHCB before/after the resulting VMGEXIT). 2. trigger an NAE by executing either cpuid or wbinvd. 3. check that the kretprobe was hit with the right exit_code available in GHCB. Message-ID: References: <20220318094532.7023-1-vkarasulli@suse.de> <20220318094532.7023-3-vkarasulli@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220318094532.7023-3-vkarasulli@suse.de> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The shortlog and changelog are all messed up. Ditto for the other patches in this series. On Fri, Mar 18, 2022, Vasant Karasulli wrote: > Signed-off-by: Vasant Karasulli > --- > arch/x86/tests/Makefile | 2 + > arch/x86/tests/sev-test-vc.c | 114 +++++++++++++++++++++++++++++++++++ > 2 files changed, 116 insertions(+) > create mode 100644 arch/x86/tests/sev-test-vc.c ... > +int sev_es_test_vc_init(struct kunit *test) > +{ > + int ret; > + > + if (!cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) { > + kunit_info(test, "Not a SEV-ES guest. Skipping."); > + ret = -EINVAL; > + goto out; > + } > + > + memset(&hv_call_krp, 0, sizeof(hv_call_krp)); > + hv_call_krp.entry_handler = hv_call_krp_entry; > + hv_call_krp.handler = hv_call_krp_ret; > + hv_call_krp.maxactive = 100; > + hv_call_krp.data_size = sizeof(unsigned long); > + hv_call_krp.kp.symbol_name = "sev_es_ghcb_hv_call"; > + hv_call_krp.kp.addr = 0; > + > + ret = register_kretprobe(&hv_call_krp); > + if (ret) { > + kunit_info(test, "Could not register kretprobe. Skipping."); > + goto out; > + } > + > + test->priv = kunit_kzalloc(test, sizeof(u64), GFP_KERNEL); Allocating 8 bytes and storing the pointer an 8-byte field is rather pointless :-) > + if (!test->priv) { > + ret = -ENOMEM; > + kunit_info(test, "Could not allocate. Skipping."); > + goto out; > + } > + > +out: > + return ret; > +} > + > +void sev_es_test_vc_exit(struct kunit *test) > +{ > + if (test->priv) > + kunit_kfree(test, test->priv); > + > + if (hv_call_krp.kp.addr) > + unregister_kretprobe(&hv_call_krp); > +} > + > +#define check_op(kt, ec, op) \ > +do { \ > + struct kunit *t = (struct kunit *) kt; \ > + op; \ > + KUNIT_EXPECT_EQ(t, (typeof(ec)) ec, \ > + *((typeof(ec) *)(t->priv))); \ > +} while (0) > + > +static void sev_es_nae_cpuid(struct kunit *test) > +{ > + unsigned int cpuid_fn = 0x8000001f; > + > + check_op(test, SVM_EXIT_CPUID, native_cpuid_eax(cpuid_fn)); Are there plans to go beyond basic checks? Neat idea, but it seems like it will be prone to bitrot since it requires a somewhat esoteric setup and an opt-in config. And odds are very good that if the kernel can make it this far as an SEV-ES guest, it's gotten the basics right.