Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4120055rwb; Sun, 7 Aug 2022 15:37:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR7748YRHFdUsZ0l0dYAElJHxMciwpnp63gnMgUf7NDKyNdW1leYACCKq1alzvCg8uZWv8KC X-Received: by 2002:a17:90b:1d02:b0:1f5:8526:303 with SMTP id on2-20020a17090b1d0200b001f585260303mr14627767pjb.79.1659911845503; Sun, 07 Aug 2022 15:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659911845; cv=none; d=google.com; s=arc-20160816; b=ChlyBhOpwn8NHhwPF5kO4QBiMiWkch5XVUYe4hwPRDLXIs0a0wjP5ElkjvWpZZIZ6/ CKxl05GlUBqOErFCNl3zLEQZSfgZ2+nResR2oXK/Byo8PaYwik15PdnWVYeY/W1xTU0u 23wu0Pa+6paWQ3uXOh/UNtnAnjoAjM5nzsov95+JzWSc52xKTwH/FhAEY3UarV7uTXrR VnO0qUVVD5e+U1uVLY82Cq/NOuMa1bsaTx+pH7KodCPybbLxDv51yWtKss+DVgHmcjEN aSUNLmG5LPuoj3HplaIhsBsx9lJs1GwWyHAM9Db/RBjN8NQFAL6W7KZXlFH1YGW/z8X7 WiqA== 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=KFNV3ev2z+BmuIE73QRoQ/fxMcL3t5zIpGGHCRDWMm8=; b=TdKVAvBASF0Bg4CYwwYvD+j4QdyDXt2WA0P/tlIrTgIZL9jQd6AzfD2Ih9656h2eZa jVRPh7i14KF2+glGFhn75IFXFICxEe9FrH8Ato0c5Gs5Sry4ZS1j/muvvfSVd/njlva4 vQsVH7OSbiakJIYjX83M32hLisb24NMuM+JJhkz8lhs9Ow/AZOhLx0hJPwHsPqgN7cpm IrDxw4HpaSFUnM/D1T81QKJoSaNKzFC7IEAiZSuPtluGpE/etoS2pfdhlfqj13jTzvvC vdbdpM5pPghsIT8j+A2zxUeumTvdmU8axZwBN48nPxnKq12zgAuz5K7cSKnv/h3SEWe8 Otng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IaR6VFh0; 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 d18-20020a637352000000b004119e27a4d2si8325622pgn.507.2022.08.07.15.37.11; Sun, 07 Aug 2022 15:37:25 -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=IaR6VFh0; 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 S241664AbiHGWIV (ORCPT + 99 others); Sun, 7 Aug 2022 18:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235929AbiHGWDd (ORCPT ); Sun, 7 Aug 2022 18:03:33 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2EAB1F2; Sun, 7 Aug 2022 15:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659909769; x=1691445769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xSgPSoDmIlmEh6BZbSNc729hGT8Gqev9J1l5dGaRsWQ=; b=IaR6VFh08e9VeZrA1399LLlAyyYvCsOqfeDHvXg7R7ZdF2GKNbgp0lbD Eb/9UB1nD1FdZXed0K5vdMYccFeEBF/GSL9qsjHH2zPhyAzHskdHU2WSt rhUzJ4V4U9jwVK650lT3lnWHM5QezAOMDgqmhKNMq+Iym0kaGQKTMrUEu PxnrJTOzJ0OkMsJfY9abfi6ckPwuYuU1eUlH0Y3+Ks+zspj7GOJkNatb3 cLvR4T0mNTvNJAlv0AKOqyEWVFT/QANSEeG5tygcifmeHVbQrGa4N+Xxd 6bFYC3FXuW2Lh0NuOF5qDEZrDs5JqwDKLNle67lSZKlZy/PIT9PJZ2y8m w==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="289224116" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="289224116" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:34 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682548" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:34 -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: [PATCH v8 035/103] KVM: x86/mmu: Allow per-VM override of the TDP max page level Date: Sun, 7 Aug 2022 15:01:20 -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=-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: Sean Christopherson TDX requires special handling to support large private page. For simplicity, only support 4K page for TD guest for now. Add per-VM maximum page level support to support different maximum page sizes for TD guest and conventional VMX guest. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu/mmu.c | 1 + arch/x86/kvm/mmu/mmu_internal.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3c4051d4512b..e07294fc2219 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1142,6 +1142,7 @@ struct kvm_arch { unsigned long n_requested_mmu_pages; unsigned long n_max_mmu_pages; unsigned int indirect_shadow_pages; + int tdp_max_page_level; u8 mmu_valid_gen; struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; struct list_head active_mmu_pages; diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 1f7f61e04b94..0e5a6dcc4966 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -6063,6 +6063,7 @@ int kvm_mmu_init_vm(struct kvm *kvm) kvm->arch.split_desc_cache.kmem_cache = pte_list_desc_cache; kvm->arch.split_desc_cache.gfp_zero = __GFP_ZERO; + kvm->arch.tdp_max_page_level = KVM_MAX_HUGEPAGE_LEVEL; return 0; } diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index 582def531d4d..e1b2e84c16b5 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -272,7 +272,7 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, .nx_huge_page_workaround_enabled = is_nx_huge_page_enabled(vcpu->kvm), - .max_level = KVM_MAX_HUGEPAGE_LEVEL, + .max_level = vcpu->kvm->arch.tdp_max_page_level, .req_level = PG_LEVEL_4K, .goal_level = PG_LEVEL_4K, }; -- 2.25.1