Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp312289rwb; Tue, 25 Jul 2023 16:31:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGkx2nzliPqPf1UwNh6VDRku8orx6qqqX4y4M65oBzow1gMcErLaoMLi6wA0hPdhX35Mtwn X-Received: by 2002:a05:6a20:96cb:b0:13a:25dd:a0 with SMTP id hq11-20020a056a2096cb00b0013a25dd00a0mr346401pzc.31.1690327868216; Tue, 25 Jul 2023 16:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690327868; cv=none; d=google.com; s=arc-20160816; b=UxV3H+QY+844v4K7R30TPTxtly60tGxrBXqtcnjwz++DtLWSH+tSy8TMdw6S5DKrHR wsjo+17aRi2M0zgc+swdGJKeEFfESyfjFjOzk0dQoWglJxoagbSbKsh22ZIeyQdF6lda +sFNrRJ1FEIPDkYU5SGAo9n1V4gkagNFz8cLH3Kfe9RqrMkzaHm/MPjwx7QhH6nwu3gx ARFz4zGz6WHV1wdiYMPEkupImSRlEXj4sKZitu1Fg6lmIOsIq6jxul4KnoadLmEJzF3u Fg8SAnHeQoxYu2T5JSV+jLYrA+wXT3l9niTojFMRiYfC0g3XTT5aaHDHsS4161lSON/k lzlQ== 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=3kLc7nJx3QzuWwo4KpmXGjYrz9laZ/7f/NGqv2eabAw=; fh=E1bxw31VVcEBr76WIqXfdV5vG/YqvWMYjFMgvHDq2Zc=; b=CEDDzrLjy7eU2CYvIeMEID7N7rNk7b2pcu81SDX9FOkCLTaQH+AM1IG5F3d/HVUORs f7C3X8W85yVUwnrTxZRpuHgNiwNqyRx3Z4mSImczXd1WuLL8kmDlrXlCuR6me3+fllqH EfVZNRfBV1K/wIBTZkTeVdNqxYrt2rDuHruP58nd/5FM0pZ+fKRNVGlBfEjSh80tyvcC zUHMDiewOCrvhGjh6aFLziZRuMI/tV26IJ8XSJkSNzBEYkKw9fno/NiACu1N885dLRPp xTL+iBagTxNH6fGYP5UiZvCqRqt0jsT8CLHZK5L10UuKl/Foy4mnCuTy4PX9WJvOpHRi Rzhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="OnywFQ/b"; 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 u2-20020a17090341c200b001b8698149fbsi13099770ple.477.2023.07.25.16.30.55; Tue, 25 Jul 2023 16:31:08 -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="OnywFQ/b"; 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 S231776AbjGYWg6 (ORCPT + 99 others); Tue, 25 Jul 2023 18:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjGYWgC (ORCPT ); Tue, 25 Jul 2023 18:36:02 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03D7883F8; Tue, 25 Jul 2023 15:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690324171; x=1721860171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M4x6pjQZoqyTbl/Z5Xt7XYBZU1uoEaJ6mWVH2yXohzs=; b=OnywFQ/bmoViI18+GMXWbTBE63KZdw6M09zyFOv/tc3smo9CKA9/k7nz s58YMaHYSg+HCR6hMUxd/REBWb5YOYgOv4hhZDeZ8WrjhNUqQc62/orUp B7PAE2kotHCJw4+BF1OxhHFrlLuS5eqnag3LNJx60DIzS5NqeaHLaqYBS QmCEmtBRAy/eTPNphTsXYqOgT46FeBsWOD3da/1/sevqg1pcoQ+X5k1er WBsleDH6fcZh2/9XIhXWb8x+KpVlljGv3IwVW1fHa04RO77ffMYhUBfFw +XKlABLgeeMCtQWap5UD9GVP4Mn7+5vnQ6EfyAbw3aXikVBw2F+XA73rq A==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="371467173" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="371467173" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:24:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="972855847" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="972855847" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:24:14 -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 v4 16/16] KVM: TDX: Allow 2MB large page for TD GUEST Date: Tue, 25 Jul 2023 15:24:02 -0700 Message-Id: <625bac22e29a0b359100420bbd07865d18e497c8.1690323516.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=-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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 6f22e38e3973..d78174a6c69b 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1562,14 +1562,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 2f375e0e45aa..0625c172cbb9 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -526,8 +526,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