Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4735107pxv; Tue, 6 Jul 2021 07:59:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9YLSOMYCiymSlvKJWLtTa3WEmdTASINwwuLL279bt3uCzSPJbT4B0XBqz1l2yuYLVZnzP X-Received: by 2002:a6b:5b11:: with SMTP id v17mr16399828ioh.19.1625583587454; Tue, 06 Jul 2021 07:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625583587; cv=none; d=google.com; s=arc-20160816; b=tooHBPTPB77FbHLgCtby1PIzPU26qyKjIKkBBusdUTF4RG8vs7Ec4M9EVSaUoUIW0T /0GZFHDmZ1OVJrPcWdwx33pueOvnIsPzslM0LcHv4jY2r9cE0hrk83ManbM+C/iTvnZi ytIutEeAgm0s9jcniXFSMrEOck5ckmATtj6fvU/BIOAGDIuxo37dpM4yAb6goTaVIczu 3dJIr0/DkpqhdWEgxSsQS08wyci7HYqoi9j1FllhHdNEVtWlyKsSI/ZdO4ZZT/QTC8bq SIUOe/thPA4HIjgC8pzUQWn2EDC5aOOqXIcjxh/GSoUaoBikxA0Bq0vIOP0ugyp/V/9c LHoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=HtdLqklHsoLBXRELRriccQVwitUFMwKVNw1+U6rtTks=; b=F1KD0RqcQKlYFCx/sLktDdXmLvt2fyyMN2VT2Dg1YmoE7HAMNN33nXf85JgILKAet2 2ZgTADZmbkMFTJaHn96u9gOjfN8VWV1Xq7PFU2GgHov7oscJqp9b69sA4dHSR/mTd6Hf P8lTG2uSh8dW3bEZQFu9eCXiqEvuNFQi9CMpIDsXrxAsRp96i3qNDr6solkGPLhN7p2D KeVGDwfpgLzej6NKZp85cyu8gi3uAEZI+IgSRNE7oFcKjP6QG4C14fUfNtDeC/H3nVXQ 01asNi1Ox9LuLuRqqnNeDgCuKKVEj+N/Lj5lkG76gXymoUob5MYJNQ2iOzsNILMoCK59 D+eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bzcXlcgh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si18942403jat.109.2021.07.06.07.59.35; Tue, 06 Jul 2021 07:59:47 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bzcXlcgh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231732AbhGFPBo (ORCPT + 99 others); Tue, 6 Jul 2021 11:01:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22143 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231544AbhGFPBm (ORCPT ); Tue, 6 Jul 2021 11:01:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625583543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtdLqklHsoLBXRELRriccQVwitUFMwKVNw1+U6rtTks=; b=bzcXlcghSjCwaIRaRMjiXVMMtgnt7/Wpixb39SIg2F2MV7/htXny0HhqFwG7Ek24MpSECn PlvpYLQroD9VC0IwhsxhsD9Iave47+acy//VYG70zx3LhfDQC9R+vnFjQm3o8xBAxqFwJd gcuLIYd/zTT1YZqGllzBTJXhoH5THxw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-n66gn4ZJPquMrphBCzvOJw-1; Tue, 06 Jul 2021 10:59:02 -0400 X-MC-Unique: n66gn4ZJPquMrphBCzvOJw-1 Received: by mail-wm1-f72.google.com with SMTP id j38-20020a05600c1c26b02901dbf7d18ff8so1195242wms.8 for ; Tue, 06 Jul 2021 07:59:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HtdLqklHsoLBXRELRriccQVwitUFMwKVNw1+U6rtTks=; b=jSCSqDeCj27cRFYI5WjQTRWTcJggVcMTKFZQAZuPue4rAMkav5At53ic7zOwc4wLU6 Nf9aubswpr3BZGRrXyiDAgCFGuwunXTH0AVLik75RBc0ga+9y4dpGU5JzXlIvDVWer/A k6vmSilz/ogg5Oq+FyYAiigGLA7ugn1a4gsNtRDPsuEJKELjGxn13fbpXijWMBW5R6v9 ymgyIBQToQ/GUczfAPZe3PPQ/9YY0B0AJQR+iYySkfHE6vZatuovE5j81xA97hfrE9w3 pN2OXpsm4YzAiARcAJMV8MgdbHLmp+KK4NUzxXHLKSt8QHoD8ZVAVcvoo3cgNlznTTc1 uBiA== X-Gm-Message-State: AOAM531b6zBPTQqofw8+TFcKFsxLaGvYCg19V/EnUVwLRYEk9ETAjMuJ wHdqSW7FvkODJjzKISfy0MtZHh/vgoL74L7ALeGs3zzNMIYWAxmoB49AzaguXZxixTImCXe9Edq AXE0LmqcHjoNH5LD8omThaJ8s X-Received: by 2002:adf:e8cc:: with SMTP id k12mr22195878wrn.163.1625583541110; Tue, 06 Jul 2021 07:59:01 -0700 (PDT) X-Received: by 2002:adf:e8cc:: with SMTP id k12mr22195862wrn.163.1625583540944; Tue, 06 Jul 2021 07:59:00 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id k14sm16117848wmr.29.2021.07.06.07.58.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 07:59:00 -0700 (PDT) Subject: Re: [RFC PATCH v2 51/69] KVM: x86/mmu: Allow per-VM override of the TDP max page level To: isaku.yamahata@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , 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@gmail.com, Sean Christopherson References: From: Paolo Bonzini Message-ID: <89d1ff17-dc48-0f39-257a-4cf11a98f435@redhat.com> Date: Tue, 6 Jul 2021 16:58:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/21 00:04, isaku.yamahata@intel.com wrote: > 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) > Seems good enough for now. Reviewed-by: Paolo Bonzini Paolo