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 850243659F4 for ; Tue, 3 Feb 2026 20:12:46 +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=1770149568; cv=none; b=jWJtlN5PJxEVt4awXwn4cFqAHlr2V3WW7heEwI9kbOTW1RdQBitONXEP00TWD9IfzmIEMtkgBJvfe8nTwOFob/zFiiMNAyY8wQl7fdaC1RMTS5lB8UvPkEn2oYYARONim1a6Gev0kzDvcZBtKwl0jXkkKU1gMph5xm9xylH01sk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770149568; c=relaxed/simple; bh=FIof7DYQ8YAnpUNQ255+qFKJqv7JLf9E6vtY6I2uHL0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gKbLQn3CBPQ+LIe9jQpmcCbZQ7bQnzk0ESf73IIUKSwElEUZFJQ7vap0aY/OiIGb/568wWlzqwydMyPNWXroCV6m0o+1oj2vemHbYS/lRe5uGG4CxAW5xh/LG7cqcO4IMdWKiiPoj+VUoTWbtWLmwBz40LDmUmp9gvATw/R3qN0= 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=OnzGRLty; 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="OnzGRLty" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2a0bb1192cbso177165ad.1 for ; Tue, 03 Feb 2026 12:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770149566; x=1770754366; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=f6/I6jJ9cFq/C0EPaMkedZtBiJ7Dv2IDfYAyyp9jzoo=; b=OnzGRLtyPMODUdj57mQXQ6g74M4fsKXhLyZ6Yvqf6KOJlqG79iBpMyDMw7A25c+yTJ 6RrqyDPxPFeE/ckLOxo38NIVUW8Kwn/FHzvU4wC3b/7EwWyzy641WvJgH+qSCHZVs/rB MfRMFIjQw18epIPjH/rHZrpOMxfM4S7XElPy+XtvNwFrwHwPr7KGYDWKHbb3MfD2h0E8 IXQtLRd1jJfE8cOq32RwqJLhBvg9hi+9rRnwCE8cNhUnQzY06ProVyMlQWmuA2HmW6mU H7i0Pr7nHJUvx3xQXetQlITq21Ef3uAT4j58sBrB3hBCjDoOb75EaljnbZy2Q5qKRhND jPtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770149566; x=1770754366; h=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=f6/I6jJ9cFq/C0EPaMkedZtBiJ7Dv2IDfYAyyp9jzoo=; b=DvfiKCRrh14LjR8/LHa7XzUxMFwf0iBemXmiN+YRamnYfaEGAtR6/8OEWQYVT6uS71 JZeIuGVRHeje53b6vwkWcJW4bj+pz2evJypyxbr0hgpWigXo+CtEk3FyXt2VUURGKldp cY4Q917L31nFPGIniZmaurIJUOMZH0LVHX86wcX4u77nXmFSrJ0YMyTck4QOCsaWb78b ErnyxYUNEJpj/H+JhQhXfJQ0hnb3ye1YXOctmZcX+pWwe0vtfKqTD15rNTgD4fr+d/eo q0dXIaf0rXSHyXUz9e+fLLcnUe5+THxI2GEO520H4dfLIY9ykRC3LwQnlsu98ecNfdnX zLDQ== X-Forwarded-Encrypted: i=1; AJvYcCV40L4kHucC3oqGDsHlFYqbYYydBt6bzX3J8iHbshAV1AAAAfsqialvcXOcmeAidMQVKpo=@vger.kernel.org X-Gm-Message-State: AOJu0YzZZiV015Zw76yTLH4UzpujLqLAilY0OnEzSzxF1YAff0Zqui2f bgKzU7izrfD95DKYGpmb8n0FQBINielnwowyYLZysmXRegM3mrTYndHzwL8pmNKW3Fjssh+wZwt oCPVo9g== X-Received: from ploe16.prod.google.com ([2002:a17:903:2410:b0:2a3:1bf9:d25]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:194:b0:393:372c:dedf with SMTP id adf61e73a8af0-39372498a63mr518728637.68.1770149565819; Tue, 03 Feb 2026 12:12:45 -0800 (PST) Date: Tue, 3 Feb 2026 12:12:44 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260129011517.3545883-1-seanjc@google.com> <20260129011517.3545883-20-seanjc@google.com> Message-ID: Subject: Re: [RFC PATCH v5 19/45] KVM: Allow owner of kvm_mmu_memory_cache to provide a custom page allocator From: Sean Christopherson To: Kai Huang Cc: "x86@kernel.org" , "dave.hansen@linux.intel.com" , "kas@kernel.org" , "bp@alien8.de" , "mingo@redhat.com" , "pbonzini@redhat.com" , "tglx@kernel.org" , Rick P Edgecombe , "ackerleytng@google.com" , "sagis@google.com" , Vishal Annapurve , "linux-kernel@vger.kernel.org" , Yan Y Zhao , Xiaoyao Li , "kvm@vger.kernel.org" , "linux-coco@lists.linux.dev" , Isaku Yamahata , "binbin.wu@linux.intel.com" Content-Type: text/plain; charset="us-ascii" On Tue, Feb 03, 2026, Kai Huang wrote: > On Wed, 2026-01-28 at 17:14 -0800, Sean Christopherson wrote: > > Extend "struct kvm_mmu_memory_cache" to support a custom page allocator > > so that x86's TDX can update per-page metadata on allocation and free(). > > > > Name the allocator page_get() to align with __get_free_page(), e.g. to > > communicate that it returns an "unsigned long", not a "struct page", and > > to avoid collisions with macros, e.g. with alloc_page. > > > > Suggested-by: Kai Huang > > Signed-off-by: Sean Christopherson > > I thought it could be more generic for allocating an object, but not just a > page. > > E.g., I thought we might be able to use it to allocate a structure which has > "pair of DPAMT pages" so it could be assigned to 'struct kvm_mmu_page'. But > it seems you abandoned this idea. May I ask why? Just want to understand > the reasoning here. Because that requires more complexity and there's no known use case, and I don't see an obvious way for a use case to come along. All of the motiviations for a custom allocation scheme that I can think of apply only to full pages, or fit nicely in a kmem_cache. Specifically, the "cache" logic is already bifurcated between "kmem_cache' and "page" usage. Further splitting the "page" case doesn't require modifications to the "kmem_cache" case, whereas providing a fully generic solution would require additional changes, e.g. to handle this code: page = (void *)__get_free_page(gfp_flags); if (page && mc->init_value) memset64(page, mc->init_value, PAGE_SIZE / sizeof(u64)); It certainly wouldn't be much complexity, but this code is already a bit awkward, so I don't think it makes sense to add support for something that will probably never be used.