On 7/16/2025 4:11 PM, Fuad Tabba wrote:
On Wed, 16 Jul 2025 at 05:09, Xiaoyao Li<xiaoyao.li@xxxxxxxxx> wrote:
On 7/15/2025 5:33 PM, Fuad Tabba wrote:
The original name was vague regarding its functionality. This Kconfig
option specifically enables and gates the kvm_gmem_populate() function,
which is responsible for populating a GPA range with guest data.
Well, I disagree.
The config KVM_GENERIC_PRIVATE_MEM was introduced by commit 89ea60c2c7b5
("KVM: x86: Add support for "protected VMs" that can utilize private
memory"), which is a convenient config for vm types that requires
private memory support, e.g., SNP, TDX, and KVM_X86_SW_PROTECTED_VM.
It was commit e4ee54479273 ("KVM: guest_memfd: let kvm_gmem_populate()
operate only on private gfns") that started to use
CONFIG_KVM_GENERIC_PRIVATE_MEM gates kvm_gmem_populate() function. But
CONFIG_KVM_GENERIC_PRIVATE_MEM is not for kvm_gmem_populate() only.
If using CONFIG_KVM_GENERIC_PRIVATE_MEM to gate kvm_gmem_populate() is
vague and confusing, we can introduce KVM_GENERIC_GMEM_POPULATE to gate
kvm_gmem_populate() and select KVM_GENERIC_GMEM_POPULATE under
CONFIG_KVM_GENERIC_PRIVATE_MEM.
Directly replace CONFIG_KVM_GENERIC_PRIVATE_MEM with
KVM_GENERIC_GMEM_POPULATE doesn't look correct to me.
I'll quote David's reply to an earlier version of this patch [*]:
It's not related to my concern.
My point is that CONFIG_KVM_GENERIC_PRIVATE_MEM is used for selecting
the private memory support. Rename it to KVM_GENERIC_GMEM_POPULATE is
not correct.
Current code uses CONFIG_KVM_GENERIC_PRIVATE_MEM to gate
kvm_gmem_populate() because kvm_gmem_populate() requires both gmem and
memory attributes support and CONFIG_KVM_GENERIC_PRIVATE_MEM can ensure
it. But CONFIG_KVM_GENERIC_PRIVATE_MEM was not only for gating
kvm_gmem_populate().
I'm curious what generic means in this name?
That an architecture wants to use the generic version and not provide
it's own alternative implementation.
We frequently use that term in this context, see GENERIC_IOREMAP as one
example.
[*]https://lore.kernel.org/all/b6355951-5f9d-4ca9-850f-79e767d8caa2@xxxxxxxxxx/
Thanks,
/fuad