Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp563898rwb; Thu, 12 Jan 2023 09:21:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXtFk9C41h0+xWtLJuup/xwli8D5ZhGCRDbtFo0+Iw4CsQ8ZcXnTo0oOj9Fz7vFuNug7h3ZF X-Received: by 2002:a17:906:6dcb:b0:7c0:d60b:2887 with SMTP id j11-20020a1709066dcb00b007c0d60b2887mr66613473ejt.69.1673544107764; Thu, 12 Jan 2023 09:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673544107; cv=none; d=google.com; s=arc-20160816; b=hKxfEGgkoaGmUziKj4WgkskNutc379hW7+BPNM7Up4EVLsqyOtQ5/o2Ct4S1zgBLmB MkHG+eXJbOoCNCmkX3g5uvKF3XMW7v9MLYgsJGJkUo0CXWR7B2h3xHV9eDA4L4GnbUj0 A1Fg/t730Bz9ECjxmiMsSTe/fcRFAIwaCz8WiYqXzRMehRHf/SyhjP74SVnS3DFZJNJE TIk4qhFt6GKKdISlwY3Ly5MOxyjOQUhL+yJe0h523BiCF2M7/O+RPGqIQYGd3u+Z00V7 SEybENDON03Ew+nYsd/nIdsuG2xKMEZhmwHpMYPxkPCxowWMHgqjZcVtq+PaIYP7nqbT j9Ww== 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=oQuJX1/szJMqNDkyU27a2x51LLPxiIMkcEfQK73HPD4=; b=lvnA+eiGyKadNz1vsQNyThJ0DwxmIW6JXvQgvmeRXVNQgiPYzGTRc38cwmV+9blUGm WuyCO6zLarCmg/kL+/0DaRTyFFL/LIz7m/F4E2bsXpEz9t+/WIUT1nok0zs48ICJmAxz tTJ4gymVtJis1u1m6Sn4t/Yd25GmEtrMvyYmVO8A+a8hu3rOyfDIFCyc3zzy1k3zg9C2 MJGvdjRuMFZnKtBcvNuCRGwmigmxmqJ5gzSIm9HAcI9lL7VodfHFJjauR2n+sFv3Ph+z QVQKyXzA4Kg6ltp9EJurqsu2mr1cRB/Bajf+L4kPnZ1ig14YBD4PNaiqkU6gfUv9MbrV ePTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TyyZFtiF; 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 xd9-20020a170907078900b0078de51e1c3dsi16247715ejb.840.2023.01.12.09.21.35; Thu, 12 Jan 2023 09:21:47 -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=TyyZFtiF; 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 S240612AbjALRLf (ORCPT + 50 others); Thu, 12 Jan 2023 12:11:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240503AbjALRKy (ORCPT ); Thu, 12 Jan 2023 12:10:54 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52856132E; Thu, 12 Jan 2023 08:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542090; x=1705078090; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QFP3jIj8NsfV1mtc5OzoIWRWOKvWQx16E9fvvGq2lpo=; b=TyyZFtiFunn4NJfPTmbE9VfYg2WPqZ6K7MpN/+4DHOimeenrMuhRgMRz c9mMlPdO0CLbuP5EjahO/CPUei0uW/YaEp9XLrkEvFLpD1AnY5gicuPot jh9lT4YW1LSgLwbHSdj5LOcv6N2WQZN2ZAzzRZzzItuXnpWh1TtF1K/R4 3fT4TmTU1EV4YV12FIrAqhNuhtqEGKM006QelGPw/Uqx7bWfxMSoO5XHa 1JP/IK14FvlagI0NTndY5hVYJqw8SqRiQLIgbSwfcXm3gOvIYPWYCn6RG w0llpwM4kqkSKu1BCwyt2r48pVBln88Jtc5qUeT3DUd0gL6IAAqLXg3pZ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="323816292" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="323816292" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:44:16 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="986658331" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="986658331" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:44:16 -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 , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Xiaoyao Li Subject: [RFC PATCH v3 04/16] KVM: TDX: Pass size to tdx_measure_page() Date: Thu, 12 Jan 2023 08:43:56 -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 8959a019b87a..1bc07dfe765a 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1299,13 +1299,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); @@ -1400,7 +1402,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