Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp553890pxj; Thu, 10 Jun 2021 07:16:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc+0yPbCYKXbtzisgMpSEj2WnQEF1yrdLLrXblM6gIeG71doide40W9Ys5d02gwxH7sJpF X-Received: by 2002:a17:907:779a:: with SMTP id ky26mr4685100ejc.293.1623334581464; Thu, 10 Jun 2021 07:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623334581; cv=none; d=google.com; s=arc-20160816; b=UTHuXoAG4ywe36UGtg2VAyA79W56+208Hs5g36US0kKdX9kmiieGzDLTI8XG9vQZ04 h4vlbl/Z88dIAmmO5cm9NKQaua+PIE2Y6vZf9h8rGJCSchqXCJDwnwbC6ZP8Je+N/s0G 6Ic7ZK+bTCfhAj8r3r0dlmPT17jWFo4aGyW2n3mUBInMY6DKZoT9DlHPz9F+NPjhbIwY gpA/bNe7HHZp6OGJ3ujJ1crr5fdR/Mossm5YTO7dfN2NJrdHyvBI23aZZzHQkgveXqrp ccK4xFORTiUfOaS5ey32W36cCo8JRtA0Wle+uX79XLLEaeWdA4KISCM6bKskD2Ou1HM6 5ojQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=uVvPHfIwriaeCqaGS4SWF2JfjGEeCNMTseqgcHKL0PY=; b=q81YDGc5aFUpbSrD/CPMTuY4hMu63aUzBKhXk2KN6Is6AhvIv38WxIJjeZ1c/HK6LL ToEN+Na1arlF1KK1XSNJm2+4dYvydidVHe0bf32VTcj8lwVER7mJH6z1XG28c7VpY428 o6ZKpB9bBvOs+L3VDRFtxYEc0tGd/170kkgM1S5Eu785v/CUDx/NstXOzTB2CJH/JVbY G3TWogZ72edDG7DqjzQylfxBFOeA6CGo3+fXmaxVr+UFcQiaZ5Y2Gdnqk3NLI8nJM/le hmrkGy1cb9rlCJzckc+BfnEapjXiK1XVOMqiMcGfq8EcpYgSW7NvtQYXrbhoX7kOmh6y MpVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ot0iffXK; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si2342044ejb.54.2021.06.10.07.15.56; Thu, 10 Jun 2021 07:16:21 -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=@gmail.com header.s=20161025 header.b=ot0iffXK; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbhFJOP5 (ORCPT + 99 others); Thu, 10 Jun 2021 10:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbhFJOP4 (ORCPT ); Thu, 10 Jun 2021 10:15:56 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8AE7C061574; Thu, 10 Jun 2021 07:13:47 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id u18so1715544pfk.11; Thu, 10 Jun 2021 07:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=uVvPHfIwriaeCqaGS4SWF2JfjGEeCNMTseqgcHKL0PY=; b=ot0iffXK2/znAlvDWUx0DvEHPs9Hu42jQhvk3aHGx+T2NhWFpnwKA1vIkYGIy+cgYb LxEbfgCrbULtFd7nVuJsfQAH+IMqZIL2R35dwiAl9sJZz1GKTswJr7viHRHzd8ec6z9L cpBdHTN6hAjfnZCW/MdapYStRdZ2pSAmS2zSYAlKj+wqby1v1sKfa0Z3IJGU1Q2S8YcP HqfC/opPsY22Z36tiTPSUNG8yLuAg9Bq77HzKuJDM2mT1cANyfp9SOlXy6wpSwett2B6 yucBibCk75zJ2NzA/8lMhfuq11vR41IllnpzmIyKLTH/P3wGLWQCIUfWmxQ4zGD/3HTx tacA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uVvPHfIwriaeCqaGS4SWF2JfjGEeCNMTseqgcHKL0PY=; b=Ob5AjVJlmewWgR91C2iGfH32rqVp9W5EnF11+BLWmpEgtRimFpEQMaBysOyo7RcTVj kvxM2SaGFg8t5sfZ0L6oqoxpQjkqb7ySAyb9AFHodVAL9+Q8Z5jiZKjH9JAeNUFNeeKq oYwL/EVQzB5PZX307pQc+Z1dcVZr09VYTuAbSCmARcFaDgDyZwFTv/oUze7mKDo27IId zdrUSWdvZ6rQZ+a0M5xP8L82dq/cSAqGONkxuMCVmtwV/exS+dccGbDtkwIXsz+8T8Om lyrwZspUfEnEq4X191QY4ap5ptVgz2zhFRZnhbEP0NbU0nTigIrw9MXypsXQAf8jnKP1 MC/w== X-Gm-Message-State: AOAM530It9T+D/oLpTv3sg30GnJpQoKABxSxMfca/I5TP5FZrDaRkoBG bk4gPaWYunVAN/RQi3+Ix3s= X-Received: by 2002:a05:6a00:2353:b029:2f2:987a:5da2 with SMTP id j19-20020a056a002353b02902f2987a5da2mr3220673pfj.58.1623334427380; Thu, 10 Jun 2021 07:13:47 -0700 (PDT) Received: from ?IPv6:2404:f801:0:5:8000::4b1? ([2404:f801:9000:1a:efea::4b1]) by smtp.gmail.com with ESMTPSA id h12sm3035510pgn.54.2021.06.10.07.13.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 07:13:46 -0700 (PDT) Subject: Re: [RFC PATCH V3 01/11] x86/HV: Initialize GHCB page in Isolation VM To: Joerg Roedel 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 References: <20210530150628.2063957-1-ltykernel@gmail.com> <20210530150628.2063957-2-ltykernel@gmail.com> From: Tianyu Lan Message-ID: Date: Thu, 10 Jun 2021 22:13:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg: Thanks for your review. On 6/9/2021 8:38 PM, Joerg Roedel wrote: > On Sun, May 30, 2021 at 11:06:18AM -0400, Tianyu Lan wrote: >> From: Tianyu Lan >> >> Hyper-V exposes GHCB page via SEV ES GHCB MSR for SNP guest >> to communicate with hypervisor. Map GHCB page for all >> cpus to read/write MSR register and submit hvcall request >> via GHCB. >> >> Signed-off-by: Tianyu Lan >> --- >> arch/x86/hyperv/hv_init.c | 60 ++++++++++++++++++++++++++++++--- >> arch/x86/include/asm/mshyperv.h | 2 ++ >> include/asm-generic/mshyperv.h | 2 ++ >> 3 files changed, 60 insertions(+), 4 deletions(-) >> >> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c >> index bb0ae4b5c00f..dc74d01cb859 100644 >> --- a/arch/x86/hyperv/hv_init.c >> +++ b/arch/x86/hyperv/hv_init.c >> @@ -60,6 +60,9 @@ static int hv_cpu_init(unsigned int cpu) >> struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()]; >> void **input_arg; >> struct page *pg; >> + u64 ghcb_gpa; >> + void *ghcb_va; >> + void **ghcb_base; > > Any reason you can't reuse the SEV-ES support code in the Linux kernel? > It already has code to setup GHCBs for all vCPUs. > > I see that you don't need #VC handling in your SNP VMs because of the > paravisor running underneath it, but just re-using the GHCB setup code > shouldn't be too hard. > Thanks for your suggestion. I will have a try to use SEV-ES code.