Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1016399pxb; Wed, 6 Apr 2022 06:48:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUDUUSsRUfltp4BTTdbclWfyEUCJ7hSuwQh5XzCOgKxic/odKczk3lHQAX/DjxQO22ZlU+ X-Received: by 2002:a17:902:7296:b0:14b:4bc6:e81 with SMTP id d22-20020a170902729600b0014b4bc60e81mr8594156pll.132.1649252892535; Wed, 06 Apr 2022 06:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252892; cv=none; d=google.com; s=arc-20160816; b=gXTGkepNqnH9h8DW4iUN3MA4r1u/a5FIpLpxRbHTTouk/YpfbpoOEYLq83XEoXpdAz fejY1jdALtydFkaMLaZ1lLsxYKnPEsPDUuVDCE28LY5S1Pst1CLBkBv66+faCTMKqHlu icmdC2PtXwVGcbeXze2YPbeMbwX7msW9/Ycj0lm5MZBle0XV1yZwWG7SfgoEb5X4nIys AtrZh6qZdg7iBIEF5XVfO895qUwOW09twaJlprl/uP57ejeYDGQvXCpa0rgfk3jeEuh3 lG3X+m/8yq/oqgG5inRu7azLPxJyUM88sn0qH0Xuc8NCHMapwq34JORfwMiKhfeh+XA3 Sz4Q== 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=nJYEigw7gcZXWEyFZUr/9QDtSTka9JkbzhfWwkRGDd4=; b=ONT+Po0OeSs5V9WYDJazaF4CZQHbV1Ciw3WBcs1DdToCWKjk/fAEYI2qI4UFIohzRa uN5ROZZ0nY+Kx0HlmT+gbUtz9Gir6WO5hAvj2fUjr2rV84yvAIIANgLVUp1WbmD+0q7T yQEObEFM5+xlmNRuHsq0qGOQwjU0B4Ch738JwpBOaU43c5dsT3FjmwxQPRUPRCxfI+6r VXw2mSV4wBenFP8g3gz4jvULPuBCmYSDktkoJsNL4eqT54/4nH6QPTkK7BDl+CX0LWUI 1BfoGJ0SMKe8aj/JMmk3JnX8ONB3gEeroSEwB2OGnJcp/fCtYZJjxiaOQxHS5IJJ8Z+p p2cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hOpDRQgh; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b16-20020a056a000a9000b004fade889fd0si16520638pfl.15.2022.04.06.06.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:48:12 -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=@redhat.com header.s=mimecast20190719 header.b=hOpDRQgh; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6470932C23C; Wed, 6 Apr 2022 04:43:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1844695AbiDFBvY (ORCPT + 99 others); Tue, 5 Apr 2022 21:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443904AbiDEPk0 (ORCPT ); Tue, 5 Apr 2022 11:40:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4E2114DFCB for ; Tue, 5 Apr 2022 07:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649167327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nJYEigw7gcZXWEyFZUr/9QDtSTka9JkbzhfWwkRGDd4=; b=hOpDRQghpVeyVJnRZi6pPt5LDyWPt0GDS3xutIDt4N22Am4v5LGHULtyJg9ReKGcHhTXdj BxDQbbS86WQ4lvpDhX1WLxIkAY3OPHTzhD8U/k9VYJGCEH1yiUzGOatmZ3rlP61n5zExsP nh8zicYOWdZVJ7uynezC/dUP+Dui5Ak= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-LIj8ySS4M2OktSYiYq33WA-1; Tue, 05 Apr 2022 10:02:06 -0400 X-MC-Unique: LIj8ySS4M2OktSYiYq33WA-1 Received: by mail-wr1-f71.google.com with SMTP id r16-20020adfbb10000000b002060d469943so1482412wrg.4 for ; Tue, 05 Apr 2022 07:02:05 -0700 (PDT) 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=nJYEigw7gcZXWEyFZUr/9QDtSTka9JkbzhfWwkRGDd4=; b=gT3s0McmaL0z+p5Zy5dH2Xe+Oq4s+0dtgR6ouETVQuq9+A2sgAHF5kX33s7DfoQidV M4wYc55s6jftP/XATnLw8RkYLR9ZbTU0xjpFYOElB0hjsRD8wkcSRk3PO4ZkVSO9oSNz 6YVNsDlj061E6uz29CW50jxOB2LIM/uHTdx7BFbEJz/rwRcz5icQ32p4RHJ0470VPhLZ /gdyb84+3JFGvrlX6yc0TLPlA6fLbriTa4/l83UAs9nuwb6esmBf4cer/xjZY+i9eVmJ fWlxSRfihMLlC7Lhpg6fE5V5yJdrwlZhbDLYIXPYM6zpcjmxWdpuKkron2JW3sdhAlrv hXRw== X-Gm-Message-State: AOAM5335VkCTq3PI016qRohwVCiCAEJtB3+P35eTXx4Lh23KVnCzgikU sN38WQ8KPoYZZ4/Omj9/ebhDqx8GEKa2OT7dIifVSA3z8dfHPOstWeuloJcTUt2uVfGkhziG4gx +MDXfPP9W3G0Qf2yr1t55dAch X-Received: by 2002:a1c:f415:0:b0:37f:ab4d:1df2 with SMTP id z21-20020a1cf415000000b0037fab4d1df2mr3179624wma.75.1649167324789; Tue, 05 Apr 2022 07:02:04 -0700 (PDT) X-Received: by 2002:a1c:f415:0:b0:37f:ab4d:1df2 with SMTP id z21-20020a1cf415000000b0037fab4d1df2mr3179606wma.75.1649167324553; Tue, 05 Apr 2022 07:02:04 -0700 (PDT) Received: from [10.32.181.87] (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.googlemail.com with ESMTPSA id j2-20020a5d6182000000b00206134c3225sm5083632wru.67.2022.04.05.07.02.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 07:02:03 -0700 (PDT) Message-ID: <240599a4-47f0-fe7e-1270-5ec7fbc0da0b@redhat.com> Date: Tue, 5 Apr 2022 16:02:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH v5 033/104] KVM: x86: Add infrastructure for stolen GPA bits Content-Language: en-US To: Isaku Yamahata , Kai Huang Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , Chao Peng References: <2b8038c17b85658a054191b362840240bd66e46b.camel@intel.com> <20220401023426.GF2084469@ls.amr.corp.intel.com> From: Paolo Bonzini In-Reply-To: <20220401023426.GF2084469@ls.amr.corp.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 4/1/22 04:34, Isaku Yamahata wrote: > Sure, this patch heavily changed from the original patch Now. One suggestion > is that private/shared is characteristic to kvm page fault, not gpa/gfn. > It's TDX specific. > > - Add a helper function to check if KVM MMU is TD or VM. Right now > kvm_gfn_stolen_mask() is used. Probably kvm_mmu_has_private_bit(). > (any better name?) I think use of kvm_gfn_stolen_mask() should be minimized anyway. I would rename it to to kvm_{gfn,gpa}_private_mask and not return bool. > - Let's keep address conversion functions: address => unalias/shared/private unalias is the same as private. It doesn't seem to have a lot of uses. I would just inline "x & ~gfn_private_mask", or "x & ~kvm_gfn_private_mask(kvm)"; or the same with gpa of course. The shared and private conversion functions should remain. > - Add struct kvm_page_fault.is_private > see how kvm_is_private_{gpa, gfn}() can be removed (or reduced). Agreed. Paolo