Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5059170pxj; Wed, 9 Jun 2021 08:15:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqsWYZUEsmSO0vpPLY2B5jqYqQuFzPGPov4s09DcKkSA5RcjFEODf85+nbnoXD/XHU4nRB X-Received: by 2002:a17:906:6d14:: with SMTP id m20mr364289ejr.504.1623251703708; Wed, 09 Jun 2021 08:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623251703; cv=none; d=google.com; s=arc-20160816; b=GUgrn4z75ucTnpGoVf6kdqk+zClnF8aBq9nyIrAqbSDqxeP56p4Fpja5CY41RPd0e8 w3sAO1Y44L3Uyp1Ohk/DvTqQrdhvoR/loigrcT2zxQ/iQgWfDYZFkhdJ9pM6Rr4DWTdm frmmDCA902bYtoWcmDWFX5dtMCPEjVvVYKydngNiCQ3rjByjF8PFBUKv1A/wm0BeedBy lrs39+7IXJKHFdXA54Ed52NCu05W+077Som7MbF02VuneSNco7deLNJka2D5azU4gtOQ U1EdVh1jcBMo16k18cMmNwwrA0UBYtNvDkUldHP60WgmbfBmwgiZdC5R+UCx3b73951E wY7Q== 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; bh=H/RFnqMeizQqVlDVRe4q0MUCMJfopv7BsNRBk4mgn4w=; b=wws/VnqxOhEBmEBaWNyw31Y02Uvd1ce2bIi4srxQgn5jyBTUPnqhbzUReB5rIhMr1B /zoSizjFFKf2ga8BcjC61juIOPzG5pN5EA1thdUcErHt7tsWPPwkwwhxUsiBIyZWX5rc 8/yQs6hsQn7kRgPnYnbQxVslkhPD18f3fOanmriGVnf7M+VKQ93Ep2XbOrPhma0R8PzB b8wPOv5zMnEC4Q06/7DRUJVDo3wH0umPHVjfUBMcd3AtatQiz83dCDGZSRmoIvhKAkpt S+pLToJjZnDaF0Xi++JCUiRQ9iT2/3pDuq7F1wQACEmkhuxO7Oc/EHe2uYdR1Ya7KGEJ UU+w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si81389ejl.587.2021.06.09.08.14.39; Wed, 09 Jun 2021 08:15:03 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbhFIMvU (ORCPT + 99 others); Wed, 9 Jun 2021 08:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231405AbhFIMvR (ORCPT ); Wed, 9 Jun 2021 08:51:17 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BAE7C061574; Wed, 9 Jun 2021 05:49:22 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id B439236A; Wed, 9 Jun 2021 14:49:20 +0200 (CEST) Date: Wed, 9 Jun 2021 14:49:19 +0200 From: Joerg Roedel To: Tianyu Lan Cc: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, rppt@kernel.org, hannes@cmpxchg.org, cai@lca.pw, krish.sadhukhan@oracle.com, saravanand@fb.com, Tianyu.Lan@microsoft.com, konrad.wilk@oracle.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, will@kernel.org, xen-devel@lists.xenproject.org, davem@davemloft.net, kuba@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, sunilmut@microsoft.com Subject: Re: [RFC PATCH V3 05/11] HV: Add ghcb hvcall support for SNP VM Message-ID: References: <20210530150628.2063957-1-ltykernel@gmail.com> <20210530150628.2063957-6-ltykernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210530150628.2063957-6-ltykernel@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 30, 2021 at 11:06:22AM -0400, Tianyu Lan wrote: > +u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size) > +{ > + union hv_ghcb *hv_ghcb; > + void **ghcb_base; > + unsigned long flags; > + > + if (!ms_hyperv.ghcb_base) > + return -EFAULT; > + > + local_irq_save(flags); > + ghcb_base = (void **)this_cpu_ptr(ms_hyperv.ghcb_base); > + hv_ghcb = (union hv_ghcb *)*ghcb_base; > + if (!hv_ghcb) { > + local_irq_restore(flags); > + return -EFAULT; > + } > + > + memset(hv_ghcb, 0x00, HV_HYP_PAGE_SIZE); > + hv_ghcb->ghcb.protocol_version = 1; > + hv_ghcb->ghcb.ghcb_usage = 1; > + > + hv_ghcb->hypercall.outputgpa = (u64)output; > + hv_ghcb->hypercall.hypercallinput.asuint64 = 0; > + hv_ghcb->hypercall.hypercallinput.callcode = control; > + > + if (input_size) > + memcpy(hv_ghcb->hypercall.hypercalldata, input, input_size); > + > + VMGEXIT(); Also not NMI-safe. When you re-use the existing GHCB setup code from from SEV-ES code, you can also use sev_es_get/put_ghcb() which takes care of re-using a GHCB already in use. Regards, Joerg