Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp311939rwb; Tue, 25 Jul 2023 16:30:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHOT6hlOnZhihUjSWXOAK83QWG6Ml81N7BKjk8iOOJcTqqzqskt7queQhVvLYeG6FSMK47C X-Received: by 2002:a05:6870:b48d:b0:1a2:cfd7:bfd0 with SMTP id y13-20020a056870b48d00b001a2cfd7bfd0mr604633oap.9.1690327849452; Tue, 25 Jul 2023 16:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690327849; cv=none; d=google.com; s=arc-20160816; b=zAdradSnL3HLI0ufeuK1T7I9IdV2GYPAanpw9D60Af9TcZaKDlKKRPYnIefHg1WSWs nWym0d4TE7V99BNnBHoRB0+48/H0Btfq7H2cr8XG1bJq1Qmw+WCx/XcYArHFKS/L/qnf pKAKKfRZe118EhaBZB5GfErIbehd6GaUMwpdwLGP4I1lIRWgX6ltJMG9B9jW7r2dxd8s BZVc2DTrsHooA+fKWyab04J7P2CA2rlf0wmrh5wT5aka82t07zkPTA31TvguHS22Ee+S AO6kPW0//QETi+Yhxmhdj6kvdWyn776h+aCc87hhaID7m7iqnAM+ZE+l8lN5PXuK47Xt WC0Q== 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=QocrthbJLHPowCDy159XkFjyf5bENdfKk6uLVRIYSQk=; fh=E1bxw31VVcEBr76WIqXfdV5vG/YqvWMYjFMgvHDq2Zc=; b=GAj+LGg28KLMRInrdC1wP+Po34ROn2j0u5KqemehToEpMO2y2uOXK/Q2EDrk2SbNOf 9vTCR7gWvzDUW8HkeUOTYkJZlaxG3fJfEXDyFnyJ5k2FRmDe0oJpafHp7BeG0uvHjQH8 u+Rd3YsqPL6LW0XUlDCpFYAJoLVlplBA6hXh7AUFSIB0KFwq9TLblpLku6kLwFHvU6Z1 qpADIZ3DQCPnIqbUgElY6a/9+i6CJG8dJB+mJ7oW1fTkZeE7/jDnTP0c8U6NouLYkY7R h/trJv8rt0BygB1EfVzQOwwDHfjQiRm7am9d5G5NkASK4Ow3H5PwuIxidytJL9j0srf9 ZYtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CkfIZEbK; 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 r10-20020a63440a000000b0055ff89f224bsi12119033pga.689.2023.07.25.16.30.36; Tue, 25 Jul 2023 16:30:49 -0700 (PDT) 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=CkfIZEbK; 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 S231270AbjGYWgN (ORCPT + 99 others); Tue, 25 Jul 2023 18:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232255AbjGYWfv (ORCPT ); Tue, 25 Jul 2023 18:35:51 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06F6D30C6; Tue, 25 Jul 2023 15:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690324157; x=1721860157; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M4lsElPqrb+BsCyYm4xXsf8VDc7nGWLgLNAovuenxyo=; b=CkfIZEbKbqLZC1MBk2q4hr54yiB2BkzdlW52x46+PkBoFVbgtj+ICDcS 62RU44AXqpkyA5bti84r2+zjKk6vV1xhddiMgL+9t65SNfd+1mvKbe0bg 234hvit9FFq1GwY08UY0B8Xt9ajLGS3cGzbSTA9sA68PRYo6h848E4VUB wEeSq8sj+/87k6BvUaFIsUWSo4pjCTXSMFB5X/L4fevajOIXDUttGjypv gCVki34KIYb7/OkAyi9SHVDX4yoZ836no3m7zGO+CycwI6Ttd/sOYAQm8 LsWQSnXl+6X+JjFsafzzGR6HF2skGIbCOn4uTOzHjtLNwJmAkJa3+G5Uf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="371467111" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="371467111" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:24:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="972855796" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="972855796" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:24:09 -0700 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 , 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 Subject: [RFC PATCH v4 04/16] KVM: TDX: Pass size to tdx_measure_page() Date: Tue, 25 Jul 2023 15:23:50 -0700 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 f3a8ae3e81bd..3522ee232eda 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1340,13 +1340,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); @@ -1441,7 +1443,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