Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3140790rdb; Thu, 16 Nov 2023 00:57:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLDxAbSejUkOkOXk7oONz+0O8MXppRzgDmjQxXRCMIoLNpBQYk4IuqXH4WAlToj6VAWRU2 X-Received: by 2002:aa7:858d:0:b0:68f:c078:b0c9 with SMTP id w13-20020aa7858d000000b0068fc078b0c9mr1454515pfn.11.1700125074240; Thu, 16 Nov 2023 00:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700125074; cv=none; d=google.com; s=arc-20160816; b=uJXYd5+tEjbmp1oMvnXDFCe4Je5onb6jFssDL/RlR8bWWyUL6SdezjwUjvZzv+WYq8 hpNhz8lFcUatw+GTuND+lA9c/Q29a6r+ok3ty8axvPJvKPL19U9DcWGUVHHFeWaDriWy e4mK4yXjTD0O7OE4B/lgtfm3THbDTmYMQRnD/zQTz0OukMNedeuCnblKWkMVL2cyXJb+ pcUUbgT9eix9gKsgQGdyZel/sAjrVqX7KdC6Xunf7hnRgAzrr6qgC8HJMzY6jGT4OLn3 VxjGUFvqaRs/JIPfFk2NRzVXBwRqsaXKc4uNDwSVhtQqRq+d07EnTz5BusPf8sDAkaVp a/Ew== 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:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=f2wtnEG5tpnxcdGj9ttFa0soTDQi1396st3Emanlvgg=; fh=SSl64FBK0Lhy77ytVxLm3gRT6oITPT9jTW5tmAf+4Dk=; b=egA8iV0eWItiJ6x17GXygvuPiP9xqDxAlp5jOQYF+2/vek6pfuyqQcllkcvC0eUiMb ZFTTy+X5AjPs79TvCCunmXsPNWJM4XatZ+1eKGY7QD7BlGhvvd3clt0xn8UZUxbwEDe9 dPxkdxSNVmSHk5ADoPAbHF5/P22nruSfFolBQNGJ2aITaaA3j5RpVOZNwucCwusv8VT2 K36uiC361CkaLzrDhPWz3yARsr/jkBQxC+C9apz52F8vbcryDffMiiasdlvrEqFwceZ4 nOHgLFr1pfyDZ0OF1TOnqnH9kBYvieQ86ENVRcf/kuN97ahHEHB11lg2V5jLLWWcASDx dVuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HNe5gzl8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d11-20020a056a00198b00b0068e2b901138si11824467pfl.158.2023.11.16.00.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 00:57:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HNe5gzl8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6A2828116E5B; Thu, 16 Nov 2023 00:57:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbjKPI5h (ORCPT + 99 others); Thu, 16 Nov 2023 03:57:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjKPI5g (ORCPT ); Thu, 16 Nov 2023 03:57:36 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD4EA1; Thu, 16 Nov 2023 00:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700125054; x=1731661054; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=6hF/KOy4geEzMKDye/KnnEK2zzobLNIQdCZGvFvFx7o=; b=HNe5gzl8rRw3i7yMvw7P0d7YAv8/iO5RuqzW1q3r70wBr8No8yvrZJL8 WuGUilodLGmHGC7m5z9Ifpg0hiyxATSsjfsobYNNONri/1SHVeSrdR/Ar q9DUJMc7gd/8MSe8bJwObtLVstBWQxTqQMGbcUnOY9nibmMFAdowKCit7 tVJ3KJwWZKRfCrEYLj03TsUI97/HFuPZhhUfKXvfD6Y/TDTb4zRXaaaez TMLXQ58DBMbEEyLAflsSrPVM/vUy9uxbdVxkNYd1BUn4x8LnLI3dGhu2+ Ejsy/4Sl14DiRixdEryNMdrZuHUvgpk5hp2pWnaM/xRRunojDyUATEpry Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="9687822" X-IronPort-AV: E=Sophos;i="6.03,307,1694761200"; d="scan'208";a="9687822" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 00:57:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="794437255" X-IronPort-AV: E=Sophos;i="6.03,307,1694761200"; d="scan'208";a="794437255" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.10.126]) ([10.238.10.126]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 00:57:28 -0800 Message-ID: <00b167fa-6635-47a4-a219-1f4117fe6c97@linux.intel.com> Date: Thu, 16 Nov 2023 16:57:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 04/16] KVM: TDX: Pass size to tdx_measure_page() To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li References: <7b024367db5909ffc22e6762acd0569c3a82ccd3.1699368363.git.isaku.yamahata@intel.com> From: Binbin Wu In-Reply-To: <7b024367db5909ffc22e6762acd0569c3a82ccd3.1699368363.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 16 Nov 2023 00:57:51 -0800 (PST) On 11/7/2023 11:00 PM, isaku.yamahata@intel.com wrote: > From: Xiaoyao Li > > Extend tdx_measure_page() to pass size info so that it can measure > large page as well. > > Signed-off-by: Xiaoyao Li > Signed-off-by: Isaku Yamahata > --- > arch/x86/kvm/vmx/tdx.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c > index 2d5c86e06c5f..a728175c4a6d 100644 > --- a/arch/x86/kvm/vmx/tdx.c > +++ b/arch/x86/kvm/vmx/tdx.c > @@ -1434,13 +1434,15 @@ void tdx_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa, int pgd_level) > td_vmcs_write64(to_tdx(vcpu), SHARED_EPT_POINTER, root_hpa & PAGE_MASK); > } > > -static void tdx_measure_page(struct kvm_tdx *kvm_tdx, hpa_t gpa) > +static void tdx_measure_page(struct kvm_tdx *kvm_tdx, hpa_t gpa, int size) IMHO, it's better to pass kvm page level instead of size here to align with other APIs. > { > struct tdx_module_args out; > u64 err; > int i; > > - for (i = 0; i < PAGE_SIZE; i += TDX_EXTENDMR_CHUNKSIZE) { > + WARN_ON_ONCE(size % TDX_EXTENDMR_CHUNKSIZE); If passed level instead of size, then no need to check KVM_HPAGE_SIZE(level) against TDX_EXTENDMR_CHUNKSIZE But same qeustion, tdx_measure_page() is only for tdh_mem_page_add(), is this change necessary? > + > + for (i = 0; i < size; i += TDX_EXTENDMR_CHUNKSIZE) { > err = tdh_mr_extend(kvm_tdx->tdr_pa, gpa + i, &out); > if (KVM_BUG_ON(err, &kvm_tdx->kvm)) { > pr_tdx_error(TDH_MR_EXTEND, err, &out); > @@ -1544,7 +1546,7 @@ static int tdx_sept_page_add(struct kvm *kvm, gfn_t gfn, > tdx_unpin(kvm, pfn); > return -EIO; > } else if (measure) > - tdx_measure_page(kvm_tdx, gpa); > + tdx_measure_page(kvm_tdx, gpa, KVM_HPAGE_SIZE(level)); > > return 0; >