Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2622391rdg; Mon, 16 Oct 2023 09:39:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRB6QUTXm9c/oPZGSuoHat18xqdK6KcR8olDlFvRVOg8NSx/dokCAtdOwHh7DIGwf4MmvC X-Received: by 2002:a05:6a00:1691:b0:693:3cbc:3d8e with SMTP id k17-20020a056a00169100b006933cbc3d8emr40450019pfc.0.1697474339611; Mon, 16 Oct 2023 09:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474339; cv=none; d=google.com; s=arc-20160816; b=a7zNL0o7sh8eX47Okp6tfoY3pLhSS3iU+epr9eaeN5AqEBFXX54tW/OD97cNABB7LW 9vyvvZFJVZ5HcZKanztrwvezoVP4Wcx4lE3m8JGXoY6p4NaRoHhsE5pXVqB3/ybTqggQ nUQCvhT/Td+LzAT9Hprag945Ri1zcpfzvXuM6TuXvUCGx+lNU9GWG9mp61a25+JQa4Ab Cmn3hrKkOhvElICAUkx12oY0Bzmg8g4FKpSrqxU7gfBjn2+6od699TH4UjQ3uoA8KqPf XNedK6PR35N0BRb8CdoDOY8HUXoXLm1u7rTWXw1AOJ9JApPal42Kl6sDkMPfr4dLhXFF tiuA== 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=KmUH/V8fChKhC5Xae22BJkkH3R2a6ZRE5ou81RVbOBI=; fh=PgPONM/W1VtmLglMgmd5Kb29Va4E/NEsDAvR3ZLGW2Y=; b=L5EmQ7TUgMHA6jTCt0ZqJKAc6/7nMdpTUQ4IC/C3G2Uy6XQAa9+NU8pOH4mXM9c1rI 5PDsmyCH/In12TOzhYe7PllLudUdiDf2mrhAftkYLQlIAfQBFC9K9bEb9+oOr8K/jTSa 7KZOsx6GR74K/k17LFDNKEKY5nScHnRO9ZjG/GtY0oD3C5Q+m2SCYAqoVKxhFuoML48n Hnmoa5A56FLEU3xEXIIDTHPwxdGvIJasaLkO5WeBZcP5ANcUysF1/QfmLegbBuGFaprW j5k0zCrMnf9XhVLWGrzDvk4oqPfC3mCztVT+03TwzYrh+uPtU/h7sJphWzhZDkW2IYcR 2neQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ChweWF40; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l184-20020a6391c1000000b005ab74d58e01si7841618pge.439.2023.10.16.09.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ChweWF40; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 101D8809E8B4; Mon, 16 Oct 2023 09:38:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234123AbjJPQiJ (ORCPT + 99 others); Mon, 16 Oct 2023 12:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234456AbjJPQhg (ORCPT ); Mon, 16 Oct 2023 12:37:36 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D1A83C0; Mon, 16 Oct 2023 09:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473398; x=1729009398; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B72YDEO70rKyCktJVODQJPRxRRKceKPZ5dkJZRqrFkA=; b=ChweWF400kKXogUbCsz/6iO2/3nfrcalzm3xrKzrfkdj9R4aM8sNJ7HC 0nOiTdoou5aFqcO4MIKVF+C6Msy/ooumSWx2q5ly4elB1xmH/3iSI5Fjz mMVo2qlgrsYeBqHxMzj8jyd5QvY1tg+klifW0JgR5bu5AvIlo2tb4w2Xw dQ7nzqiBYYlaShDXg/XxnO+9AQ1trhkSkEwcgmazxzFUPHmXAN1qfFeYz Qxm1TbyKg/q02BfYvDAHo0nQybqJjTv/mvnMyBwwVBhrXhVXoFx/L/uas 3vp6a8RjJ8yVOapqvBTAaJui1gqOm5hPM2mAxueiKMZPo9qLj7jXSOw0X g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="471793226" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="471793226" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:21:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="899569280" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="899569280" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:19:18 -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 v5 16/16] KVM: TDX: Allow 2MB large page for TD GUEST Date: Mon, 16 Oct 2023 09:21:07 -0700 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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:38:47 -0700 (PDT) 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 cac48881c5f1..4158ca4612fa 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1687,14 +1687,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 2627dcf240cc..648bd2636ff3 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -565,8 +565,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