Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2624100rdg; Mon, 16 Oct 2023 09:42:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh4S4fWarv4U3Vm+TVFf08F0WCUQMR223FdMGnvn/bxSvekVvIqeywroEPslcOHkX/e+eH X-Received: by 2002:a05:6830:208:b0:6b8:82ed:ea2e with SMTP id em8-20020a056830020800b006b882edea2emr38038387otb.4.1697474522138; Mon, 16 Oct 2023 09:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474522; cv=none; d=google.com; s=arc-20160816; b=aoc8tfkiSHg3LiXb1V0Oh7jSqCjkmzEGjk1S76cSBJtr2fyfP1vNjWZcMuanqSc1eY EDVYPz49BDz+lMtPSuXPWWlIhocidW1bXyOWbiCST1jvWq7pF/evDle2G/wmla7Huwts JYDBMI+bU1Fvh/OeBoDJ1UTxUL7pSl0I1hNXQOrWtHpf9XIdxOuqpHwEfj8GxPLzhmom iaPl/K4YohNO0MCrG2wOd3KLUcC8EifWD3mehRiHFQybudW+SeLSR0UHOSpa5lO88joA D3mOg/MmQ7MdGcX3w2ghbCn7bc/b2kxKX9quJCeGR+e4b1g8ySEDDIvx4FORwR1kbZFW GB6w== 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=argNGVGTKzk2574Q81JR58XHSe6NvzxJtPx1n6ktYco=; fh=PgPONM/W1VtmLglMgmd5Kb29Va4E/NEsDAvR3ZLGW2Y=; b=dennpTuZioUjGa9jfXcPrxPnN5XOfM6x8igOTXyrAMHNZmY2s35XswzH5LiqlKpIRb 9ZoX2ODgGg4kQv/QNrwxX4OEb6IDe2Rgdnc8+fYyC/FXddvcJdLJ9NhCmhjnYhBgZ8p5 9fuas0KHvOKtCMkk8Q8J1AsC+/wa+qQlnZGaEpYECBK1SPsoid5Ncqq3NzKDTzBaeqR0 8iwCxFDdFbTZopUNkm9Ga3VYFcBt7ntAX7fj3pMu5Y9UTekUEHm24Eu3ZAmj6hKZQnSt uOoYoduZZ6ETP2cKn4xdqNQHKBhTMXhxoxMJcpkGHpzzCUXeQCHqtng8rauy0r1hm6P7 ROPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ncosRVKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u15-20020a056a00158f00b0068bf645ac9bsi176356pfk.238.2023.10.16.09.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ncosRVKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 5B0908040C52; Mon, 16 Oct 2023 09:40:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343524AbjJPQkY (ORCPT + 99 others); Mon, 16 Oct 2023 12:40:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343569AbjJPQjO (ORCPT ); Mon, 16 Oct 2023 12:39:14 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB9948255; Mon, 16 Oct 2023 09:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473396; x=1729009396; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yRWbSVt3B/Gex4+EgIb9aWYiPKxKJtDXPk/HN1H82fE=; b=ncosRVKfHbHSV9DFV5dX/q5qGdowDuYe/dQQzRcOuCO/IEcOnHtlzWeB /VNszo3DLaNC+KPG7em0Koe1EnP/gzgKP+jpnMudWPgKDCEM6GuVzxbib fVBb4PJDWGIQ07GBXWqzia+V7u+6IBeK/0k/brhBbfaAWyxs9da8gp0cM deinIIqRGER21hVfR7uZT7hPMCIUwKk5UFEMZVQU7KAYbtDZAy91i6r+L FRyA/ewmjwVDXi3A+cN0KIP6pEXWJsxe+p2TeBqgUCY2Yh2X+jQlTIznQ JyyFAvL7S/XTTkLkMkS4YCXOKJruEq7zE3wFGzB8aD9o8aFor9485/Ulf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="471793127" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="471793127" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:21:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="899569223" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="899569223" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:19:12 -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 v5 04/16] KVM: TDX: Pass size to tdx_measure_page() Date: Mon, 16 Oct 2023 09:20:55 -0700 Message-Id: <8c0aa0968cb1f995cbd4552e1f2cf79ac443475b.1697473009.git.isaku.yamahata@intel.com> 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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:40:47 -0700 (PDT) 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 471128946e63..bda2c8fa895c 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1415,13 +1415,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_args 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); @@ -1543,7 +1545,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; -- 2.25.1