On Wed, Aug 05, 2026, Xiaoyao Li wrote:
> On 7/31/2026 4:34 AM, Ackerley Tng wrote:
> > I think another way to phrase this is that if we don't make this change,
> > say, on the foo architecture where there's no CoCo and no private mem
> > support, kvm_supported_mem_attributes() would return true for the !kvm
> > case, which is over-reporting.
> 
> Under the condition that the foo architecture enables
> CONFIG_KVM_VM_MEMORY_ATTRIBUTES.
> 
> > How about this, replacing the entire changelog paragraph above:
> > 
> >    Explicitly guard reporting support for KVM_MEMORY_ATTRIBUTE_PRIVATE
> >    based on kvm_arch_has_private_mem being #defined. This improves
> >    reporting accuracy by not reporting support for
> >    KVM_MEMORY_ATTRIBUTE_PRIVATE when kvm_supported_mem_attributes() is
> >    called with kvm == NULL.
> 
> It doesn't help for the case where kvm == NULL, but help for the case where
> CONFIG_KVM_VM_MEMORY_ATTRIBUTES is defined but kvm_arch_has_private_mem not.
> 
> sorry for being picky. I think we can say
> 
> This improves the reporting accuracy by avoiding the case where
> KVM_MEMORY_ATTRIBUTE_PRIVATE is reported when kvm == null even without
> kvm_arch_has_private_mem being #defined.

How about this?

Explicitly guard reporting support for KVM_MEMORY_ATTRIBUTE_PRIVATE based
on kvm_arch_has_private_mem being #defined in anticipation of tracking
PRIVATE vs. SHARED state per-guest_memfd, not per-VM (to allow in-place
conversion).

guest_memfd support for memory attributes is expected to be unconditional
to avoid yet more macros (all architectures that support guest_memfd are
expected to use per-gmem attributes at some point), at which point
enumerating support KVM_MEMORY_ATTRIBUTE_PRIVATE based solely on memory
attributes being supported by KVM at-large would result in a system-scope
check (NULL @kvm) over-reporting support on arm64.

> 
> >    Give architectures full control over overriding the default definition
> >    of kvm_arch_has_private_mem() by removing the coupling with
> >    CONFIG_KVM_VM_MEMORY_ATTRIBUTES.
> > 
> >    In a later patch, kvm_arch_has_private_mem() will be defined based on
> >    whether architectural features are compiled in, and made orthogonal to
> >    CONFIG_KVM_VM_MEMORY_ATTRIBUTES.
> 

Reply via email to