Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp565090rwb; Thu, 12 Jan 2023 09:22:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXvBSjREb4aeNrn/6HqsgfNkeyUvmn8d1b+j3SYOsOIsGHTYJZ/9dTVy8W0pSMh+PWsK+xHp X-Received: by 2002:a17:907:6d97:b0:7c1:5ee1:4c56 with SMTP id sb23-20020a1709076d9700b007c15ee14c56mr84901527ejc.55.1673544157744; Thu, 12 Jan 2023 09:22:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673544157; cv=none; d=google.com; s=arc-20160816; b=KEKRVrOV9lv7obb5pBoEhFQUVDxLUg4r/SevWIQar+hTlL3Pc9yF818PM3uqNFqBkA r/rajP4OME48Rv4Ywy6xl96LZ5ShHPzb8i7FYEnA8zDjqBnPb2nQqJjfJiBQF1mT8Nmn 9FD5agyQf+t7sFg3gJupvfqIi+3099XKWH4cGCeZByP+A+GV04zvoI/tauK9WjxIN339 w+Vbx/yna3ZJa6CrnKrD6xAopUyqo9pJl9nIMp/Uc7uFyY55CPkc2tPyaHmlwzvLt+u3 l5rNT4fkl6G/wBrpXJ/HS/kTEs25ueGoNdw5sgyTFlhSToaLH64RrLCVb7HyaRuyYb1l 3U3w== 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=50nebRbbuR+9+HU7vKC2VTWhREPWdbBCQxtUBnAkCJA=; b=vhPlkoHkTs2BLv34zi4MRh8vBBFobW9L5HVsAPZra5Z/6bm4M8jBufkSbyz3YW15E/ XkMUNbpEMx7KuFMmuVbiTaKlbShvZcVj1+5BIAMZziPrKg3y90mpEp3yED+oO0mzKKk7 8cx/RipG6m9HPwlb9WLX4Rfle6ZiyJvUh2IoZT1DGrEUzVW7P9BUXAAY3QuxIHga8REN oSjaEa9mG9vGSLSdO/VJpDD8LDo6icYWa7UrB+rL/9spfop2il3iUj5PB95KZ4Z+uFpQ w8RYNuymkgakYTG8hy18puSMcNTR7rsakFstNrtf4vKdr89JnDytOFC1v8wD9kjdT8rh tlLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q4mjjgqK; 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 xf9-20020a17090731c900b0084d0b4b4fdbsi19391899ejb.555.2023.01.12.09.22.25; Thu, 12 Jan 2023 09:22:37 -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=Q4mjjgqK; 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 S238562AbjALRQX (ORCPT + 50 others); Thu, 12 Jan 2023 12:16:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239063AbjALRP0 (ORCPT ); Thu, 12 Jan 2023 12:15:26 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 017F680AD5; Thu, 12 Jan 2023 08:49:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542173; x=1705078173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OeLsEo50hbC8XkGy3XlTL2j0FeJ7MRnEC1GCFgbITOk=; b=Q4mjjgqKyldQygCYOOFzHFwDmJRoFW0S/TeU/tjDDMH1/m0p4fENp2hN NY7DLCzdlsvVBALlOC3FzFJtd+FGMuzGk2u8h+L0Kom6HKtoFx+OB4zgV bDDKXv15cpf4qfzkTBM/9xeEgCj+T/9JTkJJHB7d4IUFcw+9QvToxsAnP YIrynhekqauC0TzustQEWqL8WWby9vcYdUYm28FZS7N4WMmy5xenT3x8k RdjiItWm03zQeVyHT+lGYJODztQvVJASNpKU3cKvpFyTfUXMP6ODxQqu/ M885kFY6PReXOrckPl2/bv+AavdXSmqOBX2cqbAj2dVZtnWYhl5caZ6Vq g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="323816350" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="323816350" 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:19 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="986658370" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="986658370" 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:18 -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 16/16] KVM: TDX: Allow 2MB large page for TD GUEST Date: Thu, 12 Jan 2023 08:44:08 -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 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 fc8f457292b9..7091c45697ef 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1630,14 +1630,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 4ed76ef46b0d..3084fa846460 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -487,8 +487,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