On Thu, Oct 23, 2025, Ackerley Tng wrote: > Sean Christopherson <[email protected]> writes: > > > On Wed, Oct 22, 2025, Ackerley Tng wrote: > >> Ackerley Tng <[email protected]> writes: > >> > >> Found another issue with KVM_CAP_MEMORY_ATTRIBUTES2. > >> > >> KVM_CAP_MEMORY_ATTRIBUTES2 was defined to do the same thing as > >> KVM_CAP_MEMORY_ATTRIBUTES, but that's wrong since > >> KVM_CAP_MEMORY_ATTRIBUTES2 should indicate the presence of > >> KVM_SET_MEMORY_ATTRIBUTES2 and struct kvm_memory_attributes2. > > > > No? If no attributes are supported, whether or not > > KVM_SET_MEMORY_ATTRIBUTES2 > > exists is largely irrelevant. > > That's true. > > > We can even provide the same -ENOTTY errno by > > checking that _any_ attributes are supported, i.e. so that doing > > KVM_SET_MEMORY_ATTRIBUTES2 on KVM without any support whatsoever fails in > > the > > same way that KVM with code support but no attributes fails. > > IIUC KVM_SET_MEMORY_ATTRIBUTES doesn't fail with -ENOTTY now when there > are no valid attributes. > > Even if there's no valid attributes (as in > kvm_supported_mem_attributes() returns 0), it's possible to call > KVM_SET_MEMORY_ATTRIBUTES with .attributes set to 0, which will be a > no-op, but will return 0. > > I think this is kind of correct behavior since .attributes = 0 is > actually a valid expression for "I want this range to be shared", and > for a VM that doesn't support private memory, it's a valid expression. > > > The other way that there are "no attributes" would be if there are no > /VM/ attributes, in which case KVM_SET_MEMORY_ATTRIBUTES, sent to as a > vm ioctl, will return -ENOTTY.
Ya, this is what I was trying to say with "_any_ attributes are supported". I.e. by "any" I meant "any attributes in KVM for VMs vs. gmems", not "any attributes for this specific VM/gmem instance". > > In other words, I don't see why it can't do both. Even if we can't massage > > the > > right errno, I would much rather KVM_SET_MEMORY_ATTRIBUTES2 enumerate the > > set of > > Did you mean KVM_CAP_MEMORY_ATTRIBUTES2 in the line above? Doh, yes.
