Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2370626rdb; Mon, 12 Feb 2024 02:35:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWuGjzktpoSI6oVx8oGlsDxhr81tb1SHKgNTXAgqskIllRu17VamR28ZQNRsLdUWx6gnKUKRsVJ0PgjBlEoO+ZZzJflow//5RzBF5pqYg== X-Google-Smtp-Source: AGHT+IGCO2VOXMX5x+O2Rb5RTMz0pDWX+kmRWJp6rt5o0lpjKP77NvXxTNnhda3ncxmlIh1AuK4Z X-Received: by 2002:ac8:5cca:0:b0:42c:60ae:47bb with SMTP id s10-20020ac85cca000000b0042c60ae47bbmr9592891qta.45.1707734101442; Mon, 12 Feb 2024 02:35:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707734101; cv=pass; d=google.com; s=arc-20160816; b=r4c/06vdRsmlKHn/Umz2XYANnla5++o9vk0BmXJ9smsMLThqwGTmo/JL77lwrY8yNx tH1BdSKhAFVPsWKFDvKWsPLg3aZ0kypjNTjWgWTs0ezNZ2DWjs+PXzhctWiAPovhSc/u qEPlsyBHvxXW9S15dT5xjxNPH/3CI0uTBQsVYElIdWynJhNus3tKkNbCkWA73B7Zejyg VGk3wL2hIETRCWvXc6WsGD4wIZqUI2BJ2xseFWoJ2FmbTmFTHEV2nyx1XOuFxpRBZfzQ UdTCirbZg8EMNg5wM64KtFVPY7prMlOTU8zl9NWDBFsbkBKST41hKlHfV5w3R6/vUr3+ cQ4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=tgpAN4/fM2uvng00mD2oqsBNpUIMHVV2+w/F9N6+DNQ=; fh=T8CCoRwZv+OLvc4ppndj+AXmdaRHXlYlFfpBAvSoJrE=; b=ezSqqOe3veboH+hUmjVarr1MeZ9jHizIUljLfl8QDTnu6c3m5w7uAjW3GOmrf1fJOR l/oTkqycguwUSY6K6eBCIJWaI17JedWO1rXRoM68jPUvuIMtW2k8o3k2uC/G4ccfWRNA Ytj3/uyG8N77of5h5LM3DlthnRX6fVLLdp4wcJlDBL3a1gBB7SqCwdDhzlzt7W+stkNG QPZBTNEvBx8Mmhu6sZ+13RLEPw6RYOuTQLI06wTB/WaEo4KKY8Smma0+M7yhWJYUDkNr R9C00rv90MSu0uXQjDkKoP4IiY4ZbVQntFvT5yj/h79Prdn3TyJoqgs0Ju7VHVmGYGfK dfEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NwLY2a0d; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-61321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCX16UjnEmDmpwwV1hTHhUfH/Vc+hJTyswFRmBPy2J7phYUKek6ki08DYCp02Cn45CJqHVjChe5PnlUPDEKFvMWT+MCTvP7vnxqgWn/vwA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x8-20020a05622a000800b0042c7c5d8fb7si65520qtw.494.2024.02.12.02.35.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 02:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NwLY2a0d; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-61321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 166A31C20DE2 for ; Mon, 12 Feb 2024 10:35:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02DAD38F99; Mon, 12 Feb 2024 10:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NwLY2a0d" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0D1D383BF for ; Mon, 12 Feb 2024 10:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734089; cv=none; b=pgON9+sWTXkEKhCYz60D4NdO94xd6dv1bHcut0l3/Ua05A4VacQ4sjxQdreOaT+7l8RH4lrfpyCRYwHhFPCs+43y6+hnux5Y+2hhv6Ro3EUehWOckPmeKWy5j40RywyyzlV5Yj+XkZGo7Be7DQZm+4Hu/9ZvSKrMTtRQg4yKZwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734089; c=relaxed/simple; bh=EoFkIvo0jVT7iACpJyA0SYfSyvqCf8/ZdX+R+C/HGAU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XBGtsF0dPSeTmT8K1BoM0D5f6c/Yh9nykuQiKjoFyLqY8aUUGMvWHhC+Zs47Ty47lKR+xr4IGGOKgfCJKr2jRm+/5KuvNDQAadYutq8rT1dUcPEVBhYUFoeX9jOJuFrTuRryIKwCznPPdLtJUzHbHtP96tfScOKtZCpiDbd8nc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NwLY2a0d; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707734086; 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=tgpAN4/fM2uvng00mD2oqsBNpUIMHVV2+w/F9N6+DNQ=; b=NwLY2a0dbxPe24dtx9C+dRUCS+PbhIA9c5uUOUJkFLjNKFQgXpRwztyLLulFmGsQASW5Zx tsvxK38iSaxtmcIc4QtqgTjcv5CoIEDGBX3OEb5dydKAhsPw401tx6ctCF/Q6CX7GyDOfd gVusA3p6lGEYThIJUxWmDZ0W0Ki3EB8= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-BU4U0hmZMRu1-TqgKjBO3Q-1; Mon, 12 Feb 2024 05:34:45 -0500 X-MC-Unique: BU4U0hmZMRu1-TqgKjBO3Q-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-7d326aa3f86so1725208241.2 for ; Mon, 12 Feb 2024 02:34:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707734082; x=1708338882; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tgpAN4/fM2uvng00mD2oqsBNpUIMHVV2+w/F9N6+DNQ=; b=Gu6ZeyMIPmdJ/W/bngaE6cSZzhiSEwQ+3d17zXnrY2vPNxprkGPNhNqgrD9Z/QKJfl Kwm21jy+DowhtgzPUCjrhTIAjsU537FNTkjy+fdPlVbRD2NlbDgN/JuNgP8969nt/eb7 omqkxNzfXZh2Vt6DoHVn3Ng/bKtgtA5b46oK32qni9IF8T1JM2ZuGH6YuZlKKnMJeDsC U1qgMw3N4OkdccJ+EgZW9JeDb4txTTD9E24/meKZ/lFUGaXl4kMlMavnOmM7vygJURNC IWW6q66Qb4zCwrDcuI1C8jFRs0nZop+5eHeeLoDMkMdVWSlH90NZ8Dsvjo+e7BWOp7VU d0lw== X-Forwarded-Encrypted: i=1; AJvYcCVAxQTRdJyLRAkaDd4QF67PrqREhgAmrHgvjvtBsm1s12u8MJF4JdGmNeRb5srebwntUP2WpHYhi6U1K0JfbBHHdTP8yPba9cWCYrQk X-Gm-Message-State: AOJu0YxS/gf+6xsNdDAIquMa9tM36Xi/cfsSySYJ486Jip6i4xN1PT/k HkHpIlPdFoAwdzxWwY5RfF5X/xGmW/pXLmA6pGxTuGmG1tYBR3Y6ai7fByIJJYx2Ghc+Vullr6C PLpGP4aZ0iwbY1rGilC9hBci2HXX9j6u5QVPoIJKn6Ib3lbLQer4HnhvOGFf68i4ySZ7uJaW92O qqN3HXB5edCND+HxPeTLd7lqdq0jzt3wpnLkip X-Received: by 2002:a05:6102:116f:b0:46d:2d95:5c15 with SMTP id k15-20020a056102116f00b0046d2d955c15mr3800833vsg.13.1707734081984; Mon, 12 Feb 2024 02:34:41 -0800 (PST) X-Received: by 2002:a05:6102:116f:b0:46d:2d95:5c15 with SMTP id k15-20020a056102116f00b0046d2d955c15mr3800789vsg.13.1707734080219; Mon, 12 Feb 2024 02:34:40 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Paolo Bonzini Date: Mon, 12 Feb 2024 11:34:28 +0100 Message-ID: Subject: Re: [PATCH v18 041/121] KVM: x86/mmu: Allow per-VM override of the TDP max page level To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 23, 2024 at 12:55=E2=80=AFAM wrote: > > 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 maximu= m > page level support to support different maximum page sizes for TD guest a= nd > conventional VMX guest. > > Signed-off-by: Sean Christopherson > Signed-off-by: Isaku Yamahata > Acked-by: Kai Huang Please reimplement this on top of "KVM: x86: Add gmem hook for determining max NPT mapping level" from the SEV-SNP series. Paolo > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/mmu/mmu.c | 2 ++ > arch/x86/kvm/mmu/mmu_internal.h | 2 +- > 3 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_h= ost.h > index 430d7bd7c37c..313519edd79e 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1283,6 +1283,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 54d4c8f1ba68..e93bc16a5e9b 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -6307,6 +6307,8 @@ void kvm_mmu_init_vm(struct kvm *kvm) > > kvm->arch.split_desc_cache.kmem_cache =3D pte_list_desc_cache; > kvm->arch.split_desc_cache.gfp_zero =3D __GFP_ZERO; > + > + kvm->arch.tdp_max_page_level =3D KVM_MAX_HUGEPAGE_LEVEL; > } > > static void mmu_free_vm_memory_caches(struct kvm *kvm) > diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_inter= nal.h > index 0443bfcf5d9c..2b9377442927 100644 > --- a/arch/x86/kvm/mmu/mmu_internal.h > +++ b/arch/x86/kvm/mmu/mmu_internal.h > @@ -296,7 +296,7 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vc= pu *vcpu, gpa_t cr2_or_gpa, > .nx_huge_page_workaround_enabled =3D > is_nx_huge_page_enabled(vcpu->kvm), > > - .max_level =3D KVM_MAX_HUGEPAGE_LEVEL, > + .max_level =3D vcpu->kvm->arch.tdp_max_page_level, > .req_level =3D PG_LEVEL_4K, > .goal_level =3D PG_LEVEL_4K, > }; > -- > 2.25.1 >