[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bdda79b5-79e4-22fd-9af8-ec6e87a412ab@redhat.com>
Date: Mon, 13 Dec 2021 10:24:08 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: "Wang, Wei W" <wei.w.wang@...el.com>,
"Zhong, Yang" <yang.zhong@...el.com>,
"x86@...nel.org" <x86@...nel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>
Cc: "seanjc@...gle.com" <seanjc@...gle.com>,
"Nakajima, Jun" <jun.nakajima@...el.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
"jing2.liu@...ux.intel.com" <jing2.liu@...ux.intel.com>,
"Liu, Jing2" <jing2.liu@...el.com>,
"Zeng, Guang" <guang.zeng@...el.com>
Subject: Re: [PATCH 16/19] kvm: x86: Introduce KVM_{G|S}ET_XSAVE2 ioctl
On 12/13/21 09:23, Wang, Wei W wrote:
> On Saturday, December 11, 2021 6:13 AM, Paolo Bonzini wrote:
>>
>> By the way, I think KVM_SET_XSAVE2 is not needed. Instead:
>>
>> - KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) should return the size of the
>> buffer that is passed to KVM_GET_XSAVE2
>>
>> - KVM_GET_XSAVE2 should fill in the buffer expecting that its size is
>> whatever KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) passes
>>
>> - KVM_SET_XSAVE can just expect a buffer that is bigger than 4k if the
>> save states recorded in the header point to offsets larger than 4k.
>
> I think one issue is that KVM_SET_XSAVE works with "struct kvm_xsave" (hardcoded 4KB buffer),
> including kvm_vcpu_ioctl_x86_set_xsave. The states obtained via KVM_GET_XSAVE2 will be made
> using "struct kvm_xsave2".
>
> Did you mean that we could add a new code path under KVM_SET_XSAVE to make it work with
> the new "struct kvm_xsave2"?
There is no need for struct kvm_xsave2, because there is no need for a
"size" argument.
- KVM_GET_XSAVE2 *is* needed, and it can expect a buffer as big as the
return value of KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)
- but KVM_SET_XSAVE2 is not needed, because KVM_SET_XSAVE can use
copy_from_user to read the XSTATE_BV, use it to deduce the size of the
buffer, and use copy_from_user to read the full size of the buffer.
For this to work you can redefine struct kvm_xsave to
struct kvm_xsave {
__u32 region[1024];
/*
* KVM_GET_XSAVE only uses 4096 bytes and only returns
* user save states up to save state 17 (TILECFG).
*
* For KVM_GET_XSAVE2, the total size of region + extra
* must be the size that is communicated by
* KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2).
*
* KVM_SET_XSAVE uses the extra field if the struct was
* returned by KVM_GET_XSAVE2.
*/
__u32 extra[];
}
Paolo
Powered by blists - more mailing lists