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 84FA47261C 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=1770149567; cv=none; b=E5N/awFw2esZhGqhfUgjArvUPAx2Q4XHZgqqAJzHVKGDCQGNzwY6ckhTa5q874+UQDL0TqNlOuPAc94TX6meBdz+MzEf4e7sYDiSLdZImkvD9RamJGhhFvb0bF6UliZmEw0/lL/VEt5K6vs/2gwvoW4WovbF/kWZ8kXB1vc4LnI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770149567; c=relaxed/simple; bh=FIof7DYQ8YAnpUNQ255+qFKJqv7JLf9E6vtY6I2uHL0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=a3JvWsNua8h++0qZm0X+7CN2wS55Duxo/uRp7p/7ZMoGp7z77xkcnfTy9hlqYkCRHdxQP87KWxqt2tXFNQH+AvdXRURf7G3l5rE46KExMHF4xj3s8b8PUgvXhGgRdBMXNvoDruHUAwwjWqFxEKXkCmY4jFbG+bgB882j7juChew= 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-2a07fa318fdso299565ad.0 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=pS42LhusH/KrLtHmgAWyQFIs3KDgAIwBabv/5Sq8Wd0FgPC1Dac7iXNjv12d09Gbdl TmbGPSQb9gHfgIVLF6LZbSsowUxRllW+S2FE9F4DhDznJKu58NCF3jsaVlMVnjErD7Tu 5eJew6VOuEylOfEYsPWOcdQoDE3ZOiVdw6HrWUWOqjJ5+UUilFyi+7LTSft+5YI79Lk/ 725FuFm4mE0fyGK4hFK4YEE8mFpK8wAKLDNxpIvcFpPlTGrWwkOT5rG6XC6lXXSXaGp+ PVN41aSpGhwZSNx/T+ZH0c+VXkVEHRsMZPKLoqoKogYg9dfRM8xnnjuRUpJNo8j/Heq/ 7JaQ== X-Forwarded-Encrypted: i=1; AJvYcCWjfP8yFJ2430N9kbQX5vnIf5nmGAYqYzZEzWsbyX2U7Gby0VjAv1tJcPJ9eLNZtlScSTtZidT/UwEDmAA=@vger.kernel.org X-Gm-Message-State: AOJu0YzMq+ZwsCmmJKpS/3iojWY3/SGKl1uv4F6U/mK0K7ZjR4cNbwJK PAVv4B/HcyLiv23b98itmJDTPxHo3AlqhIqlO83QgK+IyKUC4/SUKbld22egSCugnK5q9cSosov /wScXSQ== 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: linux-kernel@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.