On 11/30/20 7:04 PM, David Woodhouse wrote: > On Mon, 2020-11-30 at 18:41 +0000, Joao Martins wrote: >> int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) >> { >> ... >> if (kvm_hv_hypercall_enabled(vcpu->kvm)) >> return kvm_hv_hypercall(...); >> >> if (kvm_xen_hypercall_enabled(vcpu->kvm)) >> return kvm_xen_hypercall(...); >> ... >> } >> >> And on kvm_xen_hypercall() for the cases VMM offloads to demarshal what the registers mean >> e.g. for event channel send 64-bit guest: RAX for opcode and RDI/RSI for cmd and port. > > Right, although it's a little more abstract than that: "RDI/RSI for > arg#0, arg#1 respectively". > > And those are RDI/RSI for 64-bit Xen, EBX/ECX for 32-bit Xen, and > RBX/RDI for Hyper-V. (And Hyper-V seems to use only the two, while Xen > theoretically has up to 6). > Indeed, almost reminds my other patch for xen hypercalls -- it was handling 32-bit and 64-bit that way: https://lore.kernel.org/kvm/20190220201609.28290-3-joao.m.martins@xxxxxxxxxx/ >> The kernel logic wouldn't be much different at the core, so thought of tihs consolidation. >> But the added complexity would have come from having to deal with two userspace exit types >> -- indeed probably not worth the trouble as you pointed out. > > Yeah, I think I'm just going to move the 'kvm_userspace_hypercall()' > from my patch to be 'kvm_xen_hypercall()' in a new xen.c but still > using KVM_EXIT_HYPERCALL. Then I can rebase your other patches on top > of that, with the evtchn bypass. > Yeap, makes sense. Joao