Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp196601rdb; Thu, 16 Nov 2023 16:37:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcIEi8n/1/ciHdpRQ9t7e+APkvA+skFKYz+fZMs0AqzAv054oRSwXjP7xjSWDhRdb6SLId X-Received: by 2002:a17:90a:4a0c:b0:27c:fe72:6e9 with SMTP id e12-20020a17090a4a0c00b0027cfe7206e9mr18427612pjh.27.1700181432722; Thu, 16 Nov 2023 16:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700181432; cv=none; d=google.com; s=arc-20160816; b=y0E5qPyqL8bIclScd4Q0cnRhtH2URFl4qvO38lAjqb4YpTe9brEvZgBCUqqqZPdJ3R 3YCsXhqDMnc4neuZepyML/Z4bRZRLY3uYL4AyAeh3p9uOWVkcA0kmqLVtmfHGAfaK+xm d0gm4PcpIRG8fBdOkm+gSbeKE28QPe4ENbdmuKkMTEofUhx2GnrWcfEav+JjbnksTUK2 Rv6OJj+Cg+XqNMVN0G51HkcUf4AyuH3kwUQU4ezq2PIuC9fHtciRVb+OrJvqiiwvwAt6 U6xJui3S7WEYcl7N6KIZn3OQ4v/tUWKntxRZC3FnuB1JNs4RtjgTY0ueL8Je3WEDsJz4 RD7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MRb3xiFqBd5/seJXxWcbAcQ2zVfqwVkOVowsLImYld8=; fh=1Be8UynfIG+Duu9kbImSJDV1BXKOznS5Lf0DQgUMWfI=; b=H6lFfVWmR+cWplp/hvQg9p1ZP4HEuxmV1K2x4RhVX/Q5axMZ/jWGgFjIruP/UEFskA qwnF+KOFwc3IJr06WPtWfo4H2ZGPozNOCmonZF910OYfSfAHG47P4XbCVxxhLojqMbye D1Tmi847VVXFLuPsBroNEppT0vzGDM8oe3YyZLwyIWGukT4qOR9M8aMvMQ4hahzyemaj Avq7md8bZ83GJi12LyN+V7CuUQwT/Rla0V5YUMjM/IMR0mTOPDXsRpgVkOnfx7rs03u7 8YVHQnKH2wpXsJiIMJS6tlWsJz1AR2dgzZ09NjYozMXJ2YmaU/7aL1dzKgWsKnlu5WQ/ L4aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mXwyctlT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id qc9-20020a17090b288900b002774c17dd73si712950pjb.11.2023.11.16.16.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 16:37:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mXwyctlT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 5FB9E81B6D7E; Thu, 16 Nov 2023 16:37:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345553AbjKQAg4 (ORCPT + 99 others); Thu, 16 Nov 2023 19:36:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbjKQAgy (ORCPT ); Thu, 16 Nov 2023 19:36:54 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9ACE84; Thu, 16 Nov 2023 16:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700181411; x=1731717411; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=NyaWUSiuZWIT4oMhTPN14kt5/T3qigWrUT/3PxoD7Uk=; b=mXwyctlT197jUHAWmiey7MFuL3DlKUlRv5aCVd0YnaX9Ij1jPe8Dc04P j6VJZqfWme5dtY1EeLk54QUPcCLXfjkj2/Pd2/Wuf5fy2YRWqiLNCPGeQ +EurMgGygCZ77fcQbkFj/T3mGAsP8xi191BC6Tll/R5x8/isbxtlPhAlW kz+GWOu5HMfFwswivQxI5Qj/0jRVYd6sclFsPlvQbj7MZmnnaPKZwza9K K71M983f4dtgdi7wgpFVb09wj+863DA56x3aNV+j4EYOTE/OVWGJ/1rdC 3T8KpZd+399FRKSab53FuVTYcWpLf1suY5go0r70USsrtwlvKDCMr1J8U w==; X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="371388770" X-IronPort-AV: E=Sophos;i="6.04,205,1695711600"; d="scan'208";a="371388770" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 16:36:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,205,1695711600"; d="scan'208";a="6696756" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 16:36:50 -0800 Date: Thu, 16 Nov 2023 16:36:49 -0800 From: Isaku Yamahata To: Binbin Wu 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 , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v6 04/16] KVM: TDX: Pass size to tdx_measure_page() Message-ID: <20231117003649.GD1277973@ls.amr.corp.intel.com> References: <7b024367db5909ffc22e6762acd0569c3a82ccd3.1699368363.git.isaku.yamahata@intel.com> <00b167fa-6635-47a4-a219-1f4117fe6c97@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <00b167fa-6635-47a4-a219-1f4117fe6c97@linux.intel.com> 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 16 Nov 2023 16:37:08 -0800 (PST) On Thu, Nov 16, 2023 at 04:57:26PM +0800, Binbin Wu wrote: > > > 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? You're right. As tdx_mem_page_add() is the only caller of tdx_measure_page(), open-code it into tdx_mem_page_add() and drop this patch. -- Isaku Yamahata