Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F9E2C64ED8 for ; Mon, 27 Feb 2023 22:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbjB0WPR (ORCPT ); Mon, 27 Feb 2023 17:15:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbjB0WPM (ORCPT ); Mon, 27 Feb 2023 17:15:12 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C948C2917A; Mon, 27 Feb 2023 14:15:10 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id m20-20020a17090ab79400b00239d8e182efso823799pjr.5; Mon, 27 Feb 2023 14:15:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Yd/7Cq6SQonRclW5fSsjKrCDJc+mFVGxr8w4LVRPlHg=; b=iHDyQaCUPzs/wNxXh4G9VfFWF9JKM0sitaiNLTvyVwzcaHIMDHnGyBcANZbCeFRqCi aeLpCmmnq6AMjdinuEJ/zFauvypZ5PJfzI54euET3O7yU+3BIOg1oh8yuBAM8WuYYfo/ O/a2yUWca3w0HqWqiEmDJVBDyxwYdCRV4rLcbMvO/JWrxlG9k+UX7Wx+JtluwWyo5FG+ WVBfD4ZLC8IVq2UV2xRbrzzAjxoTwkGMGiOnznRBgXJwVA9fhxLcla8qtmJeRlcHBnkq xGDYQk1YsKSp4TlZtfCOxpajjWbpXbyCm97E9BPfFHBhAtiy1UxCdxZaXw/YLH+D8XQR pNbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yd/7Cq6SQonRclW5fSsjKrCDJc+mFVGxr8w4LVRPlHg=; b=5rCQClZhJKDaDas45HkvqxJx94hltBr6ZpbILEaeamdyRP1EBHF8Lns0EqDoGxYrsT cV9c9esTLPX6vu5rnrTXk56Ab9uvYCgWw752KICj/SZfRfxaMiS6FjCJYabx/o2ycG9N dujGd0ioLFnFmOOV102mVxEfFqOl50mF2WKFFSBwhNHlWenuKSS+P+WXuuss9DvmFpRI 1pzPS+6/HkIDt4Cpy3z73iEk8RISfj4TmCzQ9lbb6JD+DuC59SavznC46ZZ4ZTpZzREN hR8aiHLLSrHoMGU3qarGBhFYr1qAzfxlS+MYnDQNhsdwRn14ItCmD5Sm2SGSwHfvcY+w HB5g== X-Gm-Message-State: AO0yUKU9xc/qMKX+QU64SBTsogKvlb3qFJE/Uz2nlgUH5XljZVvEMD0l 3yzP2bmLl8CZkaC7SqPwMIk= X-Google-Smtp-Source: AK7set+AhMrSIziXntXX6bkcHMuEFmUPHZJDKgBFtjwuEzfLyDUsIe/uWea2VpEWhjUUp2CKTDcNsw== X-Received: by 2002:a05:6a20:918a:b0:cd:7d01:7671 with SMTP id v10-20020a056a20918a00b000cd7d017671mr873806pzd.22.1677536110258; Mon, 27 Feb 2023 14:15:10 -0800 (PST) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id j63-20020a638b42000000b005030113f46dsm4567577pge.37.2023.02.27.14.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 14:15:09 -0800 (PST) Date: Mon, 27 Feb 2023 14:15:08 -0800 From: Isaku Yamahata To: Yuan Yao Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack Subject: Re: [PATCH v11 058/113] KVM: TDX: MTRR: implement get_mt_mask() for TDX Message-ID: <20230227221508.GS4175971@ls.amr.corp.intel.com> References: <21e0d94ccf2fd3d766d6aa7b45441791c04e5e4f.1673539699.git.isaku.yamahata@intel.com> <20230203065545.piywnc3jnxqotehv@yy-desk-7060> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230203065545.piywnc3jnxqotehv@yy-desk-7060> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2023 at 02:55:45PM +0800, Yuan Yao wrote: > > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c > > index e68816999387..c4c5a8f786c1 100644 > > --- a/arch/x86/kvm/vmx/tdx.c > > +++ b/arch/x86/kvm/vmx/tdx.c > > @@ -309,6 +309,25 @@ int tdx_vm_init(struct kvm *kvm) > > return 0; > > } > > > > +u8 tdx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) > > +{ > > + /* TDX private GPA is always WB. */ > > + if (gfn & kvm_gfn_shared_mask(vcpu->kvm)) { > > + WARN_ON_ONCE(is_mmio); > > + return MTRR_TYPE_WRBACK << VMX_EPT_MT_EPTE_SHIFT; > > + } > > This looks not clear enough, the comment says things about private GPA > but the code returns WB for shared GPA, please align them. It should be !(gfn & shared mask). Thanks for the catch. -- Isaku Yamahata