RE: [PATCH v2 18/23] kvm: x86: Get/set expanded xstate buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday, December 21, 2021 4:45 PM, Paolo Bonzini wrote:
> On 12/21/21 03:45, Wang, Wei W wrote:
> >> KVM_GET_XSAVE2 and KVM_SET_XSAVE respectively write and read as
> many
> >> bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2),
> when
> >> invoked on the vm file descriptor.  Currently,
> >> KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will only return a value that is
> >> greater than 4096 bytes if any dynamic features have been enabled
> >> with ``arch_prctl()``; this however may change in the future.
> > Would this make people think that
> KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)
> > doesn’t return the value (i.e. return 0) if it is smaller than 4096?
> > (i.e. KVM_GET_XSAVE2 doesn't work with size < 4096, which isn’t true)
> >
> > I plan to just reword a bit:
> > Currently, KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will only return a
> size
> > value, and the value is greater than 4096 bytes if any dynamic
> > features have been enabled with ``arch_prctl()``. More types of values could
> be returned in the future.
> 
> Next refinement:
> 
> The size value returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will
> always be at least 4096.  Currently, it is only greater than 4096 if a dynamic
> feature has been enabled with ``arch_prctl()``, but this may change in the
> future.

> (I'm not sure if the first sentence is true in the code, but if not it is a bug that
> has to be fixed :)).

For the implementation, KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) always return kvm->vcpus[0]->arch.guest_fpu.uabi_size.
Do you want to change it to below?

If (kvm->vcpus[0]->arch.guest_fpu.uabi_size < 4096)
	return 0;
else
	return kvm->vcpus[0]->arch.guest_fpu.uabi_size;

If the size is less than 4096 (e.g. no dynamic xfeatures enabled),
userspace should use the old KVM_GET_XSAVE (instead of KVM_GET_XSAVE2)?
(KVM_GET_XSAVE2 supports to work with size less than 4096, so I think this isn't necessary)

Thanks,
Wei




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux