lkml.org 
[lkml]   [2019]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC 29/39] KVM: x86/xen: evtchn unmask support
Date
From: Ankur Arora <ankur.a.arora@oracle.com>

Handle hypercall to unmasks event channel ports.

A subtlety here is that we deliver an upcall if an actual unmask
happened and the event channel was pending (and if the vcpu-wide
evtchn_pending_sel was not already marked pending.)

Co-developed-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
arch/x86/kvm/xen.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 420e3ebb66bc..1988ed3866bf 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -2102,6 +2102,29 @@ static int shim_hcall_evtchn_send(struct kvm_xen *dom0, struct evtchn_send *snd)
return 0;
}

+static int shim_hcall_evtchn_unmask(struct kvm_xen *dom0, int port)
+{
+ struct shared_info *s = HYPERVISOR_shared_info;
+ struct evtchnfd *evtchnfd;
+ struct vcpu_info *v;
+
+ evtchnfd = idr_find(&dom0->port_to_evt, port);
+ if (!evtchnfd)
+ return -ENOENT;
+
+ v = per_cpu(xen_vcpu, evtchnfd->vcpu);
+
+ if (test_and_clear_bit(port, (unsigned long *) s->evtchn_mask) &&
+ test_bit(port, (unsigned long *) s->evtchn_pending) &&
+ !test_and_set_bit(port / BITS_PER_EVTCHN_WORD,
+ (unsigned long *) &v->evtchn_pending_sel)) {
+ kvm_xen_evtchn_2l_vcpu_set_pending(v);
+ return kvm_xen_evtchn_call_function(evtchnfd);
+ }
+
+ return 0;
+}
+
static int shim_hcall_evtchn(int op, void *p)
{
int ret;
@@ -2151,6 +2174,13 @@ static int shim_hcall_evtchn(int op, void *p)
un->port = evt.port;
break;
}
+ case EVTCHNOP_unmask: {
+ struct evtchn_unmask *unmask;
+
+ unmask = (struct evtchn_unmask *) p;
+ ret = shim_hcall_evtchn_unmask(xen_shim, unmask->port);
+ break;
+ }
case EVTCHNOP_send: {
struct evtchn_send *send;

--
2.11.0
\
 
 \ /
  Last update: 2019-02-20 21:20    [W:0.533 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site