On Tue, May 12, 2020 at 05:40:10PM +0200, Vitaly Kuznetsov wrote: > Vivek Goyal <vgoyal@xxxxxxxxxx> writes: > > > On Mon, May 11, 2020 at 06:47:46PM +0200, Vitaly Kuznetsov wrote: > >> Currently, APF mechanism relies on the #PF abuse where the token is being > >> passed through CR2. If we switch to using interrupts to deliver page-ready > >> notifications we need a different way to pass the data. Extent the existing > >> 'struct kvm_vcpu_pv_apf_data' with token information for page-ready > >> notifications. > >> > >> The newly introduced apf_put_user_ready() temporary puts both reason > >> and token information, this will be changed to put token only when we > >> switch to interrupt based notifications. > >> > >> Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> > >> --- > >> arch/x86/include/uapi/asm/kvm_para.h | 3 ++- > >> arch/x86/kvm/x86.c | 17 +++++++++++++---- > >> 2 files changed, 15 insertions(+), 5 deletions(-) > >> > >> diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h > >> index 2a8e0b6b9805..e3602a1de136 100644 > >> --- a/arch/x86/include/uapi/asm/kvm_para.h > >> +++ b/arch/x86/include/uapi/asm/kvm_para.h > >> @@ -113,7 +113,8 @@ struct kvm_mmu_op_release_pt { > >> > >> struct kvm_vcpu_pv_apf_data { > >> __u32 reason; > >> - __u8 pad[60]; > >> + __u32 pageready_token; > > > > How about naming this just "token". That will allow me to deliver error > > as well. pageready_token name seems to imply that this will always be > > successful with page being ready. > > > > And reason will tell whether page could successfully be ready or > > it was an error. And token will help us identify the task which > > is waiting for the event. > > I added 'pageready_' prefix to make it clear this is not used for 'page > not present' notifications where we pass token through CR2. (BTW > 'reason' also becomes a misnomer because we can only see > 'KVM_PV_REASON_PAGE_NOT_PRESENT' there.) Sure. I am just trying to keep names in such a way so that we could deliver more events and not keep it too tightly coupled with only two events (page not present, page ready). > > I have no strong opinion, can definitely rename this to 'token' and add > a line to the documentation to re-state that this is not used for type 1 > events. I don't even know why are we calling "type 1" and "type 2" event. Calling it KVM_PV_REASON_PAGE_NOT_PRESENT and KVM_PV_REASON_PAGE_READY event is much more intuitive. If somebody is confused about how event will be delivered, that could be part of documentation. And "type1" and "type2" does not say anything about delivery method anyway. Also, type of event should not necessarily be tied to delivery method. For example if we end up introducing say, "KVM_PV_REASON_PAGE_ERROR", then I would think that event can be injected both using exception (#PF or #VE) as well as interrupt (depending on state of system). Thanks Vivek