Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1598410pxb; Wed, 20 Oct 2021 08:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpWleJGb1ThAinyTjKV6+LkDyint8RbyESApSVbCKO73KGSKw/U5mM+zul1pBUfdcqo+Ik X-Received: by 2002:a05:6402:274c:: with SMTP id z12mr22119edd.57.1634742721635; Wed, 20 Oct 2021 08:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634742721; cv=none; d=google.com; s=arc-20160816; b=m9Bdc2j+gWqNxIatB64aLNM38VGWdP8mj41esnDdYCgw1MZ4PiFKIxk33kqpiVSgqD Iq1at5F+vBlxdD545RXLEct9Ht0qdy1zMtWkyxyNQjT1xCoCZ9S0NesrKFti5heWDowr Na/hxf/u8m0HFLZJaNfQRH+nCV1zwPO3pbD8K9z9v9TS5h9aLi74mBHsZZecUkOjNxwY o1QJ95MQVMBaaQkwpgRT1SLPxj7LRLVyhwamXmUUWj6ZjqvQ97CSWWMDCqnnjU3Jk9NA FQyOcEHATWFdXEAzEWbZ8rLkRwtbsqAra/ENR3yarypizyYRDCGaeTGTfUwstYIYNrQe Ni/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4uNWaRHMlXqdsk57g9klMRY2UiTW10bRdpFkdpi3veM=; b=e4y4eoAko4vNym9efq4125sIXbi8Qe+EZcsauV0/y6MOcpZd+KbYz3qQKJggvxL5+0 7upT+kwbxC3GFqqylcSd+J5k2s0Ftmb6FSjWA/6SakgJob008rHs8rLlerbWK9FFVYoo mfLj11tJSNrXd9yQbryc+kgqd9zWxFkJ9agmHUzFvztPop+C/Ow9WEMNWka6zdS+YP0v 7AtnsiPUOalld7XTkMzkEqfr7/riXa4+9EpeCMslu/LZ186C8Wls1jJ+/AeG+n4xdp4I AOpYkTRWuLyCvA4QhWgo3zEek0EdQh9uK3oIt3aBVB7GHqyMQp/M4BOzccHGCallMkXT kqDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cukLpuMo; 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 x12si3172547edr.120.2021.10.20.08.11.35; Wed, 20 Oct 2021 08:12:01 -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=20210112 header.b=cukLpuMo; 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 S230387AbhJTPLa (ORCPT + 99 others); Wed, 20 Oct 2021 11:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbhJTPL3 (ORCPT ); Wed, 20 Oct 2021 11:11:29 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66909C06161C; Wed, 20 Oct 2021 08:09:15 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id f21so16361756plb.3; Wed, 20 Oct 2021 08:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=4uNWaRHMlXqdsk57g9klMRY2UiTW10bRdpFkdpi3veM=; b=cukLpuMoyHVybbDBE/wFKzKYtBZovXI9IN2vPTTq8tXwOPJQ9hv0EJY2P0R4J/4ntC PQwrbCvTFvGnPngpRUk9z5upZGGHXa9IhLi20i7R4vweKFQ/hfgC02+wNk8PxKKZpo9H ji8f7YqN69ON1KH7uJxiyBAR4iwTtT+8Z1ylJwMhz7WHESu1btDvFkNl3Iqrni7bbxmr kds1M3lwsloxN2bs3cABQCPQLlHrDvbCB8+ZUQb46m+LtSq3t1RpINTdyNdz+d0GqLo3 iRymbGAMMgcnuNd8keU8nIt2RiK8UiiFiawJ4FmL3+zx8Iy4y/bcbljSM9w7rmQpZbfo saAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=4uNWaRHMlXqdsk57g9klMRY2UiTW10bRdpFkdpi3veM=; b=RpUJ9eZB0jCnCQqXA+H78DlNFzEjIdXFqw2+Vv8MKnvF5tXHtvDXkMHL5DY3x85Eg6 XjI8m2TBsPxMqTPaRmVe4Gq0P82+4PyoVaKL7+QqzYM0kKdRG3eYt49pYGV5PuV8JXY9 2OVJwh+dpWwL/XjP4N33gcEimgtnjK3DH4qpz4SMeZ0ERMu6eRsW+lNnkxsuiwCUsG77 Qr/dZblSivCQvLeBBZgn63DS2jckqrRdjESiNggWQMWvkZ99zgTUjN2V6TRBgDv0vjY9 z9bWPMJJbN7aVeeVleU01BQFl8TWy9uOlC0MuxjyqBkpnaIrVXx3EwBcN54GJurjG27A w3sw== X-Gm-Message-State: AOAM533qFTikoUg30tbYyKBmqlQxoYMS3GF8czvbvAH5wkkyASRHBsVS AdisD3IfUGvXmP+LrsqK8pU= X-Received: by 2002:a17:90b:33c7:: with SMTP id lk7mr533731pjb.172.1634742554921; Wed, 20 Oct 2021 08:09:14 -0700 (PDT) Received: from ?IPV6:2404:f801:0:6:8000::a31c? ([2404:f801:9000:18:efed::a31c]) by smtp.gmail.com with ESMTPSA id o72sm2759176pjo.50.2021.10.20.08.09.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Oct 2021 08:09:14 -0700 (PDT) Message-ID: <7bab8b73-e276-c23c-7a0a-2a6280e8a7d9@gmail.com> Date: Wed, 20 Oct 2021 23:09:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] x86/sev-es: Expose __sev_es_ghcb_hv_call() to call ghcb hv call out of sev code Content-Language: en-US To: Borislav Petkov Cc: Tom Lendacky , Tianyu Lan , kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, davem@davemloft.net, kuba@kernel.org, gregkh@linuxfoundation.org, arnd@arndb.de, jroedel@suse.de, brijesh.singh@amd.com, pgonda@google.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, rppt@kernel.org, tj@kernel.org, aneesh.kumar@linux.ibm.com, saravanand@fb.com, hannes@cmpxchg.org, rientjes@google.com, michael.h.kelley@microsoft.com, linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, konrad.wilk@oracle.com, hch@lst.de, robin.murphy@arm.com, joro@8bytes.org, parri.andrea@gmail.com, dave.hansen@intel.com References: <2772390d-09c1-80c1-082f-225f32eae4aa@gmail.com> <20211020062321.3581158-1-ltykernel@gmail.com> <62ffaeb4-1940-4934-2c39-b8283d402924@amd.com> <32336f13-fa66-670d-0ea3-7822bd5b829b@gmail.com> From: Tianyu Lan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/20/2021 10:39 PM, Borislav Petkov wrote: > On Wed, Oct 20, 2021 at 10:23:06PM +0800, Tianyu Lan wrote: >> This follows Joreg's previous comment and I implemented similar version in >> the V! patchset([PATCH 05/13] HV: Add Write/Read MSR registers via ghcb page >> https://lkml.org/lkml/2021/7/28/668). >> "Instead, factor out a helper function which contains what Hyper-V needs and >> use that in sev_es_ghcb_hv_call() and Hyper-V code." >> >> https://lkml.org/lkml/2021/8/2/375 > > If you wanna point to mails on a mailing list, you simply do > > https://lore.kernel.org/r/ > > No need to use some random, unreliable web pages. OK. Thanks for suggestion. > > As to Joerg's suggestion, in the version I'm seeing, you're checking the > *context* - and the one you sent today, avoids the __pa(ghcb) MSR write. > > So which is it? > > Because your current version will look at the context too, see > > return verify_exception_info(ghcb, ctxt); > > at the end of the function. Both old and new patches are to avoid setting GHCB page address via MSR. Paravisor is in charge of doing that and un-enlightened guest should not change it. The old one was in the patchset v1 "x86/Hyper-V: Add Hyper-V Isolation VM support". The patch I sent today is based on your clean up patch and for review first. It should be in patchset "x86/Hyper-V: Add Hyper-V Isolation VM support." > > So is the issue what Tom said that "the paravisor uses the same GHCB MSR > and GHCB protocol, it just can't use __pa() to get the address of the > GHCB."? Yes, hyper-V enables vTOM in the CVM and GHCB page PA reported by paravisor contains vTOM bit. We need to use memremap() to map ghcb page before accessing GHCB page. __pa() doesn't work for PA with vTOM bit. Otherwise, guest should not set GHCB page address and avoid conflict with paravisor. > > If that is the case and the only thing you want is to avoid the GHCB PA > write, then, in the future, we might drop that MSR write altogether on > the enlightened Linux guests too and then the same function will be used > by your paravisor and the Linux guest. Yes, this is the target of the patch. Can we put the change in the Hyper-V patchset? Other patch has been fully reviewed. Thanks.