Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4124236rwb; Sun, 7 Aug 2022 15:45:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/W1DLGmKT2Z/3HzraCwu2jTbb8ZW6lqOYgB4TQtCKIJpLvgLHyfCPLBU+yuYDEkA6NGgt X-Received: by 2002:a63:9142:0:b0:41b:f217:8b83 with SMTP id l63-20020a639142000000b0041bf2178b83mr13682597pge.478.1659912320405; Sun, 07 Aug 2022 15:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659912320; cv=none; d=google.com; s=arc-20160816; b=wirlnETVdg685gHDHXz0adZWeVd1Yx5ELzUPGqj+MrJBoNkp6JKFy+IYQfTEyUxD5p VjN/2ButSMIpqhL84RypzAaHaQOM+lTQUUmF8+2EFtDlnDDX8/i1y3+fG56LsDN97wZW 6Qa3PF5Ntf1pMxCfc6yOjXxl7Rxmm8QNVvGmKDqD47Q+Oa8fxi9U9CNn4m1KcVgk1IIZ VJpagADqi+WRtlRwQpzB5b3C5MEenHpM+icW7k/zTferABknHno3LUjvviAekgHJpNmS N56XffWN1ox3aNXlC53bobqv3TlJt2qBK08GC5mtIqhfGtI/0ecDrlhznckYWO9Zg6SP moXA== 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=vMesKWCXvqWK/Hq7UFtoAYqnBVmWhgeVKmwLVW49jdY=; b=jdp3nG6Zr3S1rtYZUreet7tM1ehFC++WZscbrTOufgxlksed8G/MUXOsO4TjciLHAr jp8yqmtZ35vx13h4sYbCk3KEJVWlFBHpqHWX9pBlNvMnwnOMhjYPgtA7Ek+09s7ZpvDx rG4hXbJoxsucVf8fD469hxhmWTa8W67KAu3nAXJBLG8o/UD1L/KV/SAQqcEHQs/0Epz+ NWmOOeNOUPN8+DpW1ZqP9XQogfdWOxY92HHN7uOvntIeEhw/gq7KbbLShNws1b4r0Cip b9GhZv8elRYqRQEcYESKtyDUpZqfCl7Q2v7Ui7w2VtKdysHT5BXgtarWkaq8dhbTXakk rPLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=THSepzMT; 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 g184-20020a636bc1000000b0041c227d3793si8610435pgc.732.2022.08.07.15.45.06; Sun, 07 Aug 2022 15:45:20 -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=THSepzMT; 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 S242378AbiHGWcQ (ORCPT + 99 others); Sun, 7 Aug 2022 18:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242188AbiHGWbi (ORCPT ); Sun, 7 Aug 2022 18:31:38 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E398818360; Sun, 7 Aug 2022 15:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659910730; x=1691446730; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n1VhPYbloRyaQpOluo7vN8itgxhqrMUvvsfBcoYG0Y8=; b=THSepzMTwTBrSkHRqbLQIou3jEpn9IPUNdHiM1mLCC6WMnBaY9T/7b/L swcxQdzV85oX5ZA3J/7MUmfunYefWy97Z6pVybD4XXE+PFYQE9mG391gm zxTmtGc4GPhVr8yOGroDu2g2lAGsqRNyiFeWckrqX6DQK0qvNX6jrH/3z +J6lAMuhaAGA3ac5tJ/5l4o8kJj9qUfSR7JpIU1o6GOZDE/Q0zgkw2atl w151bQnIb+FdEd4fkzXlW4ugNB+CUklsSK/op92gKeWOdNG7kSOxr2tlg 8+N/ckW2sBO6OPT58tadTUUMSzkEqfOAshBTNTp3v+yt4h8eBeFqinZqd Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="270852833" X-IronPort-AV: E=Sophos;i="5.93,221,1654585200"; d="scan'208";a="270852833" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:18:49 -0700 X-IronPort-AV: E=Sophos;i="5.93,221,1654585200"; d="scan'208";a="632642313" 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; 07 Aug 2022 15:18:49 -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 Subject: [RFC PATCH 05/13] KVM: TDX: Pass size to tdx_measure_page() Date: Sun, 7 Aug 2022 15:18:38 -0700 Message-Id: <824f3a80ea74d1065ec5e2f8c123aa64e527f7f0.1659854957.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=-5.0 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 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 b717d50ee4d3..b7a75c0adbfa 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1417,13 +1417,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); @@ -1497,7 +1499,7 @@ static void __tdx_sept_set_private_spte(struct kvm *kvm, gfn_t gfn, pr_tdx_error(TDH_MEM_PAGE_ADD, err, &out); tdx_unpin_pfn(kvm, pfn); } else if ((kvm_tdx->source_pa & KVM_TDX_MEASURE_MEMORY_REGION)) - tdx_measure_page(kvm_tdx, gpa); /* TODO: handle page size > 4KB */ + tdx_measure_page(kvm_tdx, gpa, KVM_HPAGE_SIZE(level)); kvm_tdx->source_pa = INVALID_PAGE; } -- 2.25.1