Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp198746rdb; Mon, 22 Jan 2024 17:28:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhm2Bbx9XCRBctZRII3CmKpo7QaNkxHhcG5m+DWxB/PQcP9v3LlH9BhVYGq0EiDVHd6Vo5 X-Received: by 2002:a05:6871:827:b0:210:9bd3:ad86 with SMTP id q39-20020a056871082700b002109bd3ad86mr871103oap.41.1705973307940; Mon, 22 Jan 2024 17:28:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705973307; cv=pass; d=google.com; s=arc-20160816; b=zHo3VINyAe/Rk/QW0jiM5QTKtFXZcewfKj6Mxm+5lY6g88gYx6+2AFhwb8/6Bu4w5l LffLvXU5G2cIYz5d+vp++ol5t0AXiY4pa/i7VpdfDGYdX4mtoEegVVzENIXM78m+jZIr PE5SUn4uFcgh/lwcheKXg4Jw007mDzmtgJUsKVUbolEsfQ7p7smO6omlfQUd/jNdJse7 RDxiqQaIYY4BlGbrsUel1zZemhlzk3eTkxEHY9rJZp1kO+PAvza5ucnVmovhSJjzGH+n ZAm74yAvC/s+j4/NTs8uEJn4ST4KZszXVlN+khbAVgNRoKpZaPHYPruWC6l9vd8L4Df8 IlMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NNBKzA/C8Bc8XKfvO3GKzRsK1j0P/q7tuiYs/5HSH/M=; fh=sMdP/xP2j0mAr7mmqXKi/DmIqVqVXObmf3aqGFg9BJU=; b=oDANubnrCPbRlgYxklOCnExT5H0PN0+gdopmp+bUzfP7z2LF1DftCTzLA0cUleyeC4 5ytReBmDeLXH+okL0lLmVrMWbbJODUNnOK2YAkCyNRi3EUa0UJCTJorfQv1pRVER58/j mDzS2nKWqOLd68//sZ6Axn9X2tdHOK0k+RlLCodpA/YjeSZ7R4055Y38eFBSJ+OQDWux siIhUo1ZYtevQBu4mxfdKjr5SXfr/fYyw8ep9QnKIthReIO+BZA4gOu/Z+ZaE9enLrDk xXh5vFaPJ6K9QeN7sEZ4a0nW9AOz7AcwFUTvAa/scWBlr3NXIO7DKHoITXnaVbZFnGF8 yKjA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fHIGO4Wx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n1-20020a6563c1000000b005cec86b7a50si8766712pgv.570.2024.01.22.17.28.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 17:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fHIGO4Wx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 23CE9B20BB5 for ; Tue, 23 Jan 2024 01:06:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1ADB15350B; Tue, 23 Jan 2024 00:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fHIGO4Wx" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905E2151CE4; Tue, 23 Jan 2024 00:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705969369; cv=none; b=jRtLXcROeJ06l69BwO6rMAgOZv8y/9ShAyztO9Cea27bM03OgoyRPASr5yB7KGhSiwMllnnQE314jBmIUOoaEtiYyeSLnky+f41zIw97cDKGeKszwwGJ1ME712IZnewpLl/B6M2LASaLGsKRVHrHxD4SapHWePVay5BkE+XU9co= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705969369; c=relaxed/simple; bh=oOdtFrbtkdulJhQpZoj4hAR/TTunbrVEH9i/DDy2uWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Wc41dBcMI1AwKDOc7VGNGx5SFKjNdCcw5Vy/g/ZbWffLfNcQtnJ1rnjWIUMJr9t4ia/ozux+fixGpSUB1sIK2T7NvmmHM8/g9leg/TTSFcpcKkXatkoPZjrZHGULbgsP4UeMuyVM/JkrVtPWtO0H1u62D62L5xfLPCZuzDzX0bw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fHIGO4Wx; arc=none smtp.client-ip=134.134.136.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705969367; x=1737505367; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oOdtFrbtkdulJhQpZoj4hAR/TTunbrVEH9i/DDy2uWA=; b=fHIGO4Wx0fautjWxbPgo54EvTc/SRVTBgOY3rD/50y+oJSrqv+NLDqy2 NOfkhWIcSTvxivm8RqEtJR+izOfaP01EPgfni01QrI3A712hkiEksmMPf SFUseUgykEwmQcsMpoerlO69fOD6ERy24JOEccLhSo7ZCgUDcCv7/fi3t rHlhb0tRkVgjaiR2OHiu5MGcEvc54aho3W4IAYIxLoO+esKGYaewDGhE3 gFk4BmOSD6Hiy5BJAD+vRRZX9ntlfQwOU6WOgPPs92/326inTv+qmiHVY WB5iIJESj8z4O+jyx0tHVqzmvZFw8KvsHNij4W1DI/DtMDZwvRse6BTdr A==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="405125706" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="405125706" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 16:22:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27825672" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 16:22:41 -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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li Subject: [PATCH v7 13/13] KVM: TDX: Allow 2MB large page for TD GUEST Date: Mon, 22 Jan 2024 16:22:28 -0800 Message-Id: <1f8f8f8a9450cd83e2a38abec26b0725b6d1ded4.1705965958.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Xiaoyao Li Now that everything is there to support 2MB page for TD guest. Because TDX module TDH.MEM.PAGE.AUG supports 4KB page and 2MB page, set struct kvm_arch.tdp_max_page_level to 2MB page level. Signed-off-by: Xiaoyao Li Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/tdp_mmu.c | 9 ++------- arch/x86/kvm/vmx/tdx.c | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index 42c8cf1abdf8..feb499dc381e 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1544,14 +1544,9 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) sp->nx_huge_page_disallowed = fault->huge_page_disallowed; - if (is_shadow_present_pte(iter.old_spte)) { - /* - * TODO: large page support. - * Doesn't support large page for TDX now - */ - KVM_BUG_ON(is_private_sptep(iter.sptep), vcpu->kvm); + if (is_shadow_present_pte(iter.old_spte)) r = tdp_mmu_split_huge_page(kvm, &iter, sp, true); - } else + else r = tdp_mmu_link_sp(kvm, &iter, sp, true); /* diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index f26caa496d1b..7ef1d3536f0e 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -636,8 +636,8 @@ int tdx_vm_init(struct kvm *kvm) */ kvm_mmu_set_mmio_spte_value(kvm, 0); - /* TODO: Enable 2mb and 1gb large page support. */ - kvm->arch.tdp_max_page_level = PG_LEVEL_4K; + /* TDH.MEM.PAGE.AUG supports up to 2MB page. */ + kvm->arch.tdp_max_page_level = PG_LEVEL_2M; /* * This function initializes only KVM software construct. It doesn't -- 2.25.1