From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE4D1441047 for ; Wed, 21 Jan 2026 22:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769033539; cv=none; b=IXDE463aAndIE63Lxj8JqweM/wzgpOIQjaVnjyBy10q2tT+70gcgmRsj/tzIPrOq3RdXrhiGpaD+XOoHzL2lgkeUfoJwCj/wq6xKwmlYWgsREgs53Lxs35ItHUlUeqsS16ztS5DkouEEOTfko4nLz0zISuODgDJ+RheVuQ7nl+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769033539; c=relaxed/simple; bh=tWIojze7Uj2EM7vNRu2AjQDw+wemuXBR7n+CBdw4tjY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FzXyAehG9Yas3FeawyRxhSu7UuaCcu5osFY0+k9RaOkgFrhhKm7IcxFYoUKGxD1NX4mYZz3hsRFUmYQS0cchpwfv47urygjU8Ilh3gUhiF7yiZm7GmyAzqS5I6yw+MVr7GaeWpXWGbap1dY2lSB3821dmXOR94tLMN0UYtrtnEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kCTbJJ1F; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kCTbJJ1F" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2a0f0c7a06eso2124475ad.2 for ; Wed, 21 Jan 2026 14:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769033527; x=1769638327; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=C6X4IkRQuNjfo8L0KHGq4+kOsjjdeSYBGnFI9g0tePg=; b=kCTbJJ1FCYTKxQGXh8Bq+ttAkMCMNGcpB0f9ZhxT/KBQEqZ47cpn/kz+2FPqX7zEV+ xRvBaPhvAmCYbJyAzcOYi356Z3xS7B6ORyTcui5L5K3xkjCNIY2MseF1lWldwAMQnDZI TyVYr/S1UnKzbQ5huatI3x04H3Wqs+AmNlAx+NXXQ0jjTJf0Hk+AM76mQYiVK8kG/0/I EoOYpGL1rebs86RlNzmQwgl4doQdSZkCZXn7qpsv6MXbwwKfR/QIr4f2KM3bfuGPJ14L 4MxaWn7RvAP1UBYoI3z6C6ZidkoeISKcT5xu0g9IDsEmYAYtxK1GngUKxwv2E/sE9K81 yKOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769033527; x=1769638327; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=C6X4IkRQuNjfo8L0KHGq4+kOsjjdeSYBGnFI9g0tePg=; b=fmwW9hHExhqd5xIKvNR5B8WKRdCfagMs6i1kxLxeIE3NHIQUE2q2Nt+R2ZAOrZtOQU eoJZnzPt/SO2ixG3lJxgZC9hKG7w11cCR+M08+/1WAL+suUbdDUB5dSF8Pupzxi8Eh21 ZYVciPzagdBUMzFJKu/hr2v+TS7EIqbB4Jdm8YM01EnitL1KbaNZx7fje6SpkonNa7O0 11BiupXPuqULczK5c2P6tGJ9UE9DbELW2lRagZMaID1QCLE+ChOjy9sloH6/Hmxh+zkD hFlq15QWC40lHHOst77KooNDkV5eGUR0hw7DaJ+FKsWTmMLP0o4NSpdvgjBn4p9jHKHa pIRA== X-Forwarded-Encrypted: i=1; AJvYcCUSgQlrjfMW9/oY7BjUvaWydKWFfT+CePbEF+xY9Ii8rXQVBVgp8qWVDN1U1qLtp8hh3br2xnxekRA85Fw=@vger.kernel.org X-Gm-Message-State: AOJu0YzHiK53M4SVq56ik7EP26VCK9G3GMBVxk+D/gve1bNOo2FL1TGH bIC67AOtNMTFH8MCBrBnerMcvG6AWJiJm0rsFkcu/SOeHG6TMJdFtQQQ20QsUa1QA4o80zUlhge J2sxngQ== X-Received: from plch11.prod.google.com ([2002:a17:902:f2cb:b0:2a7:61b8:be8d]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:9ce:b0:295:fc0:5a32 with SMTP id d9443c01a7336-2a717518e27mr198109225ad.3.1769033526812; Wed, 21 Jan 2026 14:12:06 -0800 (PST) Date: Wed, 21 Jan 2026 14:12:05 -0800 In-Reply-To: <24665176b1e6b169441c9f6db9b5d02d073377a4.camel@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251121005125.417831-1-rick.p.edgecombe@intel.com> <20251121005125.417831-12-rick.p.edgecombe@intel.com> <24665176b1e6b169441c9f6db9b5d02d073377a4.camel@intel.com> Message-ID: Subject: Re: [PATCH v4 11/16] KVM: TDX: Add x86 ops for external spt cache From: Sean Christopherson To: Rick P Edgecombe Cc: "kvm@vger.kernel.org" , "linux-coco@lists.linux.dev" , Kai Huang , Xiaoyao Li , Dave Hansen , Yan Y Zhao , Binbin Wu , "kas@kernel.org" , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "pbonzini@redhat.com" , "tglx@linutronix.de" , Isaku Yamahata , Vishal Annapurve , Chao Gao , "bp@alien8.de" , "x86@kernel.org" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 20, 2026, Rick P Edgecombe wrote: > Sean, really appreciate you taking a look despite being overbooked. >=20 > On Fri, 2026-01-16 at 16:53 -0800, Sean Christopherson wrote: > > NAK.=C2=A0 I kinda sorta get why you did this?=C2=A0 But the pages KVM = uses for page tables > > are KVM's, not to be mixed with PAMT pages. > >=20 > > Eww.=C2=A0 Definitely a hard "no".=C2=A0 In tdp_mmu_alloc_sp_for_split(= ), the allocation > > comes from KVM: > >=20 > > if (mirror) { > > sp->external_spt =3D (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT); > > if (!sp->external_spt) { > > free_page((unsigned long)sp->spt); > > kmem_cache_free(mmu_page_header_cache, sp); > > return NULL; > > } > > } >=20 > Ah, this is from the TDX huge pages series. There is a bit of fallout fro= m TDX=20 > /coco's eternal nemesis: stacks of code all being co-designed at once. >=20 > Dave has been directing us recently to focus on only the needs of the cur= rent > series. Now that we can test at each incremental step we don't have the s= ame > problems as before. But of course there is still desire for updated TDX h= uge > pages, etc to help with development of all the other WIP stuff. >=20 > For this design aspect of how the topup caches work for DPAMT, he asked > specifically for the DPAMT patches to *not* consider how TDX huge pages w= ill use > them. >=20 > Now the TDX huge pages coverletter asked you to look at some aspects of t= hat, > and traditionally KVM side has preferred to=C2=A0look at how the code is = all going to > work together. The presentation of this was a bit rushed and confused, bu= t > looking forward, how do you want to do this? >=20 > After the 130 patches ordeal, I'm a bit amenable to Dave's view. What do = you > think? IMO, it's largely irrelevant for this discussion. Bluntly, the code propos= ed here is simply bad. S-EPT hugepage support just makes it worse. The core issue is that the ownership of the pre-allocation cache is split a= cross KVM and the TDX subsystem (and within KVM, between tdx.c and the MMU), whic= h makes it extremely difficult to understand who is responsible for what, which in = turn leads to brittle code, and sets the hugepage series up to fail, e.g. by unn= ecessarily mixing S-EPT page allocation with PAMT maintenance.q That aside, I generally agree with Dave. The only caveat I'll throw in is = that I do think we need to _at least_ consider how things will likely play out w= hen all is said and done, otherwise we'll probably paint ourselves into a corne= r. E.g. we don't need to know exactly how S-EPT hugepage support will interact= with DPAMT, but IMO we do need to be aware that KVM will need to demote pages ou= tside of vCPU context, and thus will need to pre-allocate pages for PAMT without = having a loaded/running vCPU. That knowledge doesn't require active support in th= e DPAMT series, but it most definitely influences design decisions.