Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1886667pxv; Fri, 2 Jul 2021 15:10:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUstNwf1Jnd0fO67XGJ7w1sejV5+QqKz7gB5sd8UbXQUgvDqhjJp8/ZYhZAQfhlv7X1as2 X-Received: by 2002:aa7:c952:: with SMTP id h18mr130170edt.18.1625263849432; Fri, 02 Jul 2021 15:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263849; cv=none; d=google.com; s=arc-20160816; b=WMB11BSjQtyhREk+z3UN1DeT+rSg2BDuCQ3fU+Hl7QC0CeX5vsKjLqUBbeG3wwOzp4 TRbFu3TJfp93qgLYtOkT1tQu6AM1LMcaqPQfFHWg+Uq2fdXdBZP7rzKJXJMhhPQePQpn JDRjkkGUBZ6vJgv5vB2xKSRmL3z6ElIhRXF7qviw6xB3UwPfnYEU1tV/YWxSxdePvpgn 5bBC1LZIdyDb0ND+lOfF/mNRG7t0FtJJoAo4qyCIvd3SCbkbRbN87HpGJDxuBFymN+mv osja3ZnQPm9e06P1TWOOlD8Wny8wdRRVJ9VSfnGjeICkO0z8yPSrlRMgmhOt2PfFiuxQ 9P9g== 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; bh=POx22UgQNXEWcmp9rzCoJycYS+VUDNYe6K16wmelD7M=; b=lsYXbbRiXdWvGIJGGpMGTJBE7ZE/axGHjXIvLXB/PULA+d2/yTfcsJqCviUZmC/72o 9XLoSd4ByOKD7d5xw4hmvE+EXyCKCu0bb4kU2GouV9k/UR2jQnozMf3Smaei8bFl3XZy qFuX48y5TWXcVrDez8oZqaSe077XJKJFoWGbv+6oOZhtsEYF6ygW5V1Nud85gfVGm9bU tW3miLcXZMlZvEKz2RRbkwDGx972p0YpeLn4K54s4T7awVJOHZs+Gim0Q8fUVoP8y4f3 SPfJe2iMEu8EflewDc8g4k4DDODf35C5H6va+Nla3G0inLXWN58Q4zcud6VLKIbYxkcI 8Ssg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la12si3996701ejc.560.2021.07.02.15.10.26; Fri, 02 Jul 2021 15:10:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233114AbhGBWJY (ORCPT + 99 others); Fri, 2 Jul 2021 18:09:24 -0400 Received: from mga17.intel.com ([192.55.52.151]:15270 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233262AbhGBWIC (ORCPT ); Fri, 2 Jul 2021 18:08:02 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="189168376" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="189168376" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:29 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814849" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:29 -0700 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Sean Christopherson Subject: [RFC PATCH v2 51/69] KVM: x86/mmu: Allow per-VM override of the TDP max page level Date: Fri, 2 Jul 2021 15:04:57 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson TODO: This is tentative patch. Support large page and delete this patch. Allow TDX to effectively disable large pages, as SEPT will initially support only 4k pages. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu/mmu.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 9631b985ebdc..a47e17892258 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -989,6 +989,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 82db62753acb..4ee6d7803f18 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4084,7 +4084,7 @@ int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, kvm_pfn_t pfn; int max_level; - for (max_level = KVM_MAX_HUGEPAGE_LEVEL; + for (max_level = vcpu->kvm->arch.tdp_max_page_level; max_level > PG_LEVEL_4K; max_level--) { int page_num = KVM_PAGES_PER_HPAGE(max_level); @@ -5802,6 +5802,8 @@ void kvm_mmu_init_vm(struct kvm *kvm) node->track_write = kvm_mmu_pte_write; node->track_flush_slot = kvm_mmu_invalidate_zap_pages_in_memslot; kvm_page_track_register_notifier(kvm, node); + + kvm->arch.tdp_max_page_level = KVM_MAX_HUGEPAGE_LEVEL; } void kvm_mmu_uninit_vm(struct kvm *kvm) -- 2.25.1