Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1814620rwb; Thu, 8 Dec 2022 15:58:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GphwwGxg8lfDNW5ptTtGQHVafNDG9Z3a4BOsBEEPoRS7qQos2ar+ciyocx5prKYS64/Iw X-Received: by 2002:a05:6a20:6f89:b0:a3:f233:c35 with SMTP id gv9-20020a056a206f8900b000a3f2330c35mr5273076pzb.52.1670543933439; Thu, 08 Dec 2022 15:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670543933; cv=none; d=google.com; s=arc-20160816; b=apccJQsVrshUSQMIrcZGyFojzvia+6Bt2pfNd6lc767IIxWQY9s4r6/OirZbMwS9ee XEvTuH5cnb6AWKF+yWJ0rT1VHHZVPKgHrXXwRxcsnSzqR7sS5+jGiSVeOQtQnHOCLg9C HZx0AJ5/QiF0Hn2WzbrLMNXsEj1o2/T3GsVmWxSXz2EACpQ7WtTGcVyjAKV/zFMo6cFC 8YJlyY2mirLnWdIpSQmDQ4EGTnfLf2Nd+RymPU8fvYgFWGEfkisEOYWxtE80rSqHx7An K6uNuK0y+E1Q0NQ3FId9L+zwjJA4BVN970iKn749rdrsM8pOJvYJX/+0ldwkhcy40WY3 IP0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WGw0gaR3Xfodtg1lqoa4vKIluh2TLF9iR3UwW08y3y0=; b=tMNAQsBBCHswh+m6q36mFkKy5t3pVAt7PELstns28FzfObUIsCyAfLuasHD3HybiPa 4n252SYVoNuOE4lXYx6+DJ4OKreRtIKEXQoghMpEPRtoPlUNcI/oZtzusfpRvA6RsXkp /QGdJf8rVcfHaqQGbb+lpymOwu0GX9swRV93+2q4UCTb2U5XeX/0Q2JGZKHPwSOj4v6W zIhgyJU5TGMhSUS5ODMps4NL5RwgkYUiym7ZruQHVo3W4JOhmGeGU3ne/uDq5kCU+zx1 +PsR405fMhw07DatnE1Q5HIZR31ule61ioPChZWUS0GsqfUoImCnLSf5MLfLV83U1PEf LrOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RLwThGfJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s25-20020a632159000000b004785a1141cbsi25088738pgm.485.2022.12.08.15.58.43; Thu, 08 Dec 2022 15:58:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RLwThGfJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbiLHXgM (ORCPT + 73 others); Thu, 8 Dec 2022 18:36:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiLHXfz (ORCPT ); Thu, 8 Dec 2022 18:35:55 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9096BCA7; Thu, 8 Dec 2022 15:35:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670542554; x=1702078554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+sQP4o0OJhYPC5qL5BglaZeRAlQ+9kwaddW+ppgbLVk=; b=RLwThGfJGe21vbvqdstR1tedwwtkM7smjuq/XxWH5B0sXvDZPgy454kl eTyvXQxTKbMGwlcGQjIMF3o96vUZodte6mEzkFdDWZoYPglms9S7WbW7f ubLyPpGrkB4chNXeVkKlgC/LZjGtfLTyN9oKA1tXR9lyyZmBo+3T5B5vL jj8Zc0nF+iQ6IHEw5C/tUKuKWoZHUCtGujWFQ77CRR4NuNLPPiAYMaEjr tBsmiWo+0Y3nfcviqIwDOiNIqq/WbwOHXtMPO0HX+WIH1hABjtC4cQMU6 D1lwJQ+HzOMqq+lh1rkN5TLbN/gAgmAj4m51Cp8L4MYacUi0FHTJHe9QG Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="403586493" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="403586493" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 15:35:53 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="677950904" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="677950904" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 15:35:53 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , Sean Christopherson , David Matlack Subject: [RFC PATCH v2 04/15] KVM: TDX: Pass size to tdx_measure_page() Date: Thu, 8 Dec 2022 15:35:39 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 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 4f8479c20553..5b392d9baa25 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1273,13 +1273,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) { struct tdx_module_output out; u64 err; int i; - for (i = 0; i < PAGE_SIZE; i += TDX_EXTENDMR_CHUNKSIZE) { + WARN_ON_ONCE(size % TDX_EXTENDMR_CHUNKSIZE); + + 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); @@ -1371,7 +1373,7 @@ static int tdx_sept_set_private_spte(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; } -- 2.25.1