Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp979296pxb; Wed, 6 Apr 2022 05:55:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn73Jm861WR6Tk5tS4VLXAY7boJHPmmGDVLO5R5D0VYI2jXixgbUTiYz2kBea+xNfw1FcU X-Received: by 2002:a63:6d4c:0:b0:398:7c40:c160 with SMTP id i73-20020a636d4c000000b003987c40c160mr7013052pgc.109.1649249730842; Wed, 06 Apr 2022 05:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649249730; cv=none; d=google.com; s=arc-20160816; b=nYHicxV7S9zP23t+gCmpZNV13I4BBrlKy1aBDvkk5ulf2zNwYj/Gek+wOwfSsDIxdk vCWf/87kgBKJOLYZJ/35XFItLRq8KVmwM1ZOCtAs+qdXPLGlhA6DXPj98JGGSUXodOhY /pNKdBF1SASDXyrJmHwYzqZF63Q/6J6ddlmcp7rlqznLZAJvwZUrCDFgmcnktuhO3F5l yjUecsLeV+mHkIad9pSKBklxBWwv2016OSNm8F4XmO0h4ZmiKl4F2jxmvt5+FERmSWWD NBE37B10ocyvT50Aeayljviy0Yz7wRhydgS/RzFK/T/6MT0yIaiQ/T2d6zdOaObPfqoh jthQ== 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=oZgGqWh+Dkow1AMA8Z2UXJK/TsgkZFgRMuBDpkGFT0viaCTBfQkuMSMhWT9kPLJz0g os3QCQdGZmeYMCL9PclYCJCauiHfkaU7Z1ciwi/xO5zJLnEug7wDkSHVuznpAlv0U/ou lrXpS+gXRXQuEwJ4jKj9EJXfAAS98KKNyxj9Btce0/m5Pe31zbzQlfxlADVoofLtxa9b 84U9pNDEngSL6J7qCv1kFr3XJydiRHroysaVFfFtlILUL6lR2IMX+psX3yEnimq3LjIT qgRoU+ojGGndTkN8zmrMjmYp59hKGOBoTft0VT3CLmhyae/hrVzRuFTI+u1Q2KETfWy5 1AYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=icU7AB6Y; 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 q14-20020a17090311ce00b00153b2d1664bsi17532028plh.595.2022.04.06.05.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:55:30 -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=icU7AB6Y; 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CC7ABB938; Wed, 6 Apr 2022 03:02:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1842841AbiDFBfF (ORCPT + 99 others); Tue, 5 Apr 2022 21:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443911AbiDEPk1 (ORCPT ); Tue, 5 Apr 2022 11:40:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 344C414DFDA for ; Tue, 5 Apr 2022 07:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649167333; 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=icU7AB6YYKUnvftN2X8qG4stY5ePjwlHLdPkODSV/UPwWm0DOkeaPxIUp1HmTmylXjt3rX 81tY0owgw4gM/oVB/C9N6Ym0krpDvyyDi2tr0h2SODjGZcFiDMmVSEZQ6wCs1sSRK6Ct+g 2+RJsYGWuuGlIjhp/6IxsTR/Rgs9Cgs= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-XspWuqyBNMSuMfuyvcVjLg-1; Tue, 05 Apr 2022 10:02:12 -0400 X-MC-Unique: XspWuqyBNMSuMfuyvcVjLg-1 Received: by mail-wr1-f69.google.com with SMTP id j67-20020adf9149000000b00203e6b7d151so2494439wrj.13 for ; Tue, 05 Apr 2022 07:02:11 -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=3feWaPW86kUCi7p0B7iKhQs19aJg+asqCntOO/NehW+vlptH9EBZbsLlkWB1cZUY3a uVcyMnoSUTeH0j28jw+csLdyGjX61Lr2JSpz9Eg3lt+5XsOmWQ7LGCS0hd6PvJ43gM4Q Wv9mnjH9CYxdQYQhxg2bOG4ro4EcgP2WAsmFlntCTRCSXisIaxFK+ttFY2OUr4wv8Ak9 bTzPNMlMwCDCmW4jMRCxW68Wc2ZBWfdLkTCxOT9+hlcELlGqEhBrex8eFjozAnICo0He /p8MGt1KT2iGvPV0e/7P8PDgLmw6Q/5ZUULaGW3YBtUAiUbNIVKV5U4cRFasEZPYmkHQ J3zQ== X-Gm-Message-State: AOAM533W1zl0VoUe5LzlHrt/6hQi3dmvML2b9yzOLdGCKx+nFSxtDcZl R9Cg0ldK5wcmdEG6otIPjzMy7/7z7J4fZjUWbnh9IxhawPoBPYipLAz4DfN33/ZofhB1kbWGIrS LMeBUOm+ATvmcfPtpX5R1QsFn X-Received: by 2002:a05:600c:4e8a:b0:380:e340:bfba with SMTP id f10-20020a05600c4e8a00b00380e340bfbamr3263452wmq.80.1649167330585; Tue, 05 Apr 2022 07:02:10 -0700 (PDT) X-Received: by 2002:a05:600c:4e8a:b0:380:e340:bfba with SMTP id f10-20020a05600c4e8a00b00380e340bfbamr3263429wmq.80.1649167330381; Tue, 05 Apr 2022 07:02:10 -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 t9-20020adfa2c9000000b002061561d4a7sm5011314wra.96.2022.04.05.07.02.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 07:02:09 -0700 (PDT) Message-ID: <0d18e8aa-93ac-ea3e-37ee-d104d681459d@redhat.com> Date: Tue, 5 Apr 2022 16:02:08 +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