|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v2 06/13] fastabi: Introduce event_channel_op
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
Cc: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
Cc: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
.../guest-guide/fastabi/abi/event_channel.yml | 130 ++++++++++++
xen/common/event_channel.c | 198 ++++++++++++++++++
xen/common/fastabi.c | 4 +
xen/include/xen/fastabi.h | 2 +
4 files changed, 334 insertions(+)
create mode 100644 docs/guest-guide/fastabi/abi/event_channel.yml
diff --git a/docs/guest-guide/fastabi/abi/event_channel.yml
b/docs/guest-guide/fastabi/abi/event_channel.yml
new file mode 100644
index 0000000000..ee9d92a4cf
--- /dev/null
+++ b/docs/guest-guide/fastabi/abi/event_channel.yml
@@ -0,0 +1,130 @@
+name: event_channel
+hypercall_index: 32
+
+subops:
+ alloc_unbound:
+ index: 6
+ input:
+ dom: 2
+ remote_dom: 3
+ output:
+ port: 4
+ c_lang:
+ struct: evtchn_alloc_unbound
+
+ bind_interdomain:
+ index: 0
+ input:
+ remote_dom: 2
+ remote_port: 3
+ output:
+ local_port: 4
+ c_lang:
+ struct: evtchn_bind_interdomain
+
+ bind_virq:
+ index: 1
+ input:
+ virq: 2
+ vcpu: 3
+ output:
+ port: 4
+ c_lang:
+ struct: evtchn_bind_virq
+
+ bind_ipi:
+ index: 7
+ input:
+ vcpu: 2
+ output:
+ port: 4
+ c_lang:
+ struct: evtchn_bind_ipi
+
+ bind_pirq:
+ index: 2
+ input:
+ pirq: 2
+ flags: 3
+ output:
+ port: 4
+ c_lang:
+ struct: evtchn_bind_pirq
+
+ close:
+ index: 3
+ input:
+ port: 2
+ c_lang:
+ struct: evtchn_close
+
+ send:
+ index: 4
+ input:
+ port: 2
+ c_lang:
+ struct: evtchn_send
+
+ status:
+ index: 5
+ input:
+ dom: 2
+ port: 3
+ output:
+ status: 4
+ vcpu: 5
+ output1: 6
+ output2: 7
+ c_lang:
+ struct: evtchn_status
+ mapping:
+ output1: u.raw._output1
+ output2: u.raw._output2
+
+ bind_vcpu:
+ index: 8
+ input:
+ vcpu: 2
+ port: 3
+ c_lang:
+ struct: evtchn_bind_vcpu
+
+ unmask:
+ index: 9
+ input:
+ port: 2
+ c_lang:
+ struct: evtchn_unmask
+
+ reset:
+ index: 10
+ input:
+ dom: 2
+ c_lang:
+ struct: evtchn_reset
+
+ init_control:
+ index: 11
+ input:
+ control_gfn: 2
+ offset: 3
+ vcpu: 4
+ output:
+ link_bits: 5
+ c_lang:
+ struct: evtchn_init_control
+
+ expand_array:
+ index: 12
+ input:
+ array_gfn: 2
+ c_lang:
+ struct: evtchn_expand_array
+
+ set_priority:
+ index: 13
+ input:
+ port: 2
+ priority: 3
+ c_lang:
+ struct: evtchn_set_priority
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 97104bea15..01cc68be30 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -19,6 +19,7 @@
#include <xen/init.h>
#include <xen/lib.h>
#include <xen/errno.h>
+#include <xen/fastabi.h>
#include <xen/sched.h>
#include <xen/irq.h>
#include <xen/iocap.h>
@@ -1564,6 +1565,203 @@ long do_event_channel_op(int cmd,
XEN_GUEST_HANDLE_PARAM(void) arg)
return rc;
}
+#ifdef CONFIG_FASTABI
+void do_event_channel_fast_op(struct cpu_user_regs *regs)
+{
+ long rc;
+ uint64_t cmd = fastabi_value_n(regs, 1);
+
+ switch ( cmd )
+ {
+ case EVTCHNOP_alloc_unbound: {
+ struct evtchn_alloc_unbound alloc_unbound = {
+ .dom = fastabi_value_n(regs, 2),
+ .remote_dom = fastabi_value_n(regs, 3),
+ .port = 0,
+ };
+ rc = evtchn_alloc_unbound(&alloc_unbound, 0);
+
+ if ( !rc )
+ fastabi_value_n(regs, 4) = alloc_unbound.port;
+ break;
+ }
+
+ case EVTCHNOP_bind_interdomain: {
+ struct evtchn_bind_interdomain bind_interdomain = {
+ .remote_dom = fastabi_value_n(regs, 2),
+ .remote_port = fastabi_value_n(regs, 3),
+ .local_port = 0,
+ };
+ rc = evtchn_bind_interdomain(&bind_interdomain, current->domain, 0);
+
+ if ( !rc )
+ fastabi_value_n(regs, 4) = bind_interdomain.local_port;
+ break;
+ }
+
+ case EVTCHNOP_bind_virq: {
+ struct evtchn_bind_virq bind_virq = {
+ .virq = fastabi_value_n(regs, 2),
+ .vcpu = fastabi_value_n(regs, 3),
+ .port = 0,
+ };
+ rc = evtchn_bind_virq(&bind_virq, 0);
+
+ if ( !rc )
+ fastabi_value_n(regs, 4) = bind_virq.port;
+ break;
+ }
+
+ case EVTCHNOP_bind_ipi: {
+ struct evtchn_bind_ipi bind_ipi = {
+ .vcpu = fastabi_value_n(regs, 2),
+ .port = 0,
+ };
+ rc = evtchn_bind_ipi(&bind_ipi);
+
+ if ( !rc )
+ fastabi_value_n(regs, 4) = bind_ipi.port;
+ break;
+ }
+
+ case EVTCHNOP_bind_pirq: {
+ struct evtchn_bind_pirq bind_pirq = {
+ .pirq = fastabi_value_n(regs, 2),
+ .flags = fastabi_value_n(regs, 3),
+ };
+ rc = evtchn_bind_pirq(&bind_pirq);
+
+ if ( !rc )
+ fastabi_value_n(regs, 4) = bind_pirq.port;
+ break;
+ }
+
+ case EVTCHNOP_close: {
+ struct evtchn_close close = { .port = fastabi_value_n(regs, 2) };
+ rc = evtchn_close(current->domain, close.port, 1);
+ break;
+ }
+
+ case EVTCHNOP_send: {
+ struct evtchn_send send = { .port = fastabi_value_n(regs, 2) };
+ rc = evtchn_send(current->domain, send.port);
+ break;
+ }
+
+ case EVTCHNOP_status: {
+ struct evtchn_status status = {
+ .dom = fastabi_value_n(regs, 2),
+ .port = fastabi_value_n(regs, 3),
+ };
+ rc = evtchn_status(&status);
+
+ if ( !rc )
+ {
+ fastabi_value_n(regs, 4) = status.status;
+ fastabi_value_n(regs, 5) = status.vcpu;
+
+ switch (status.status)
+ {
+ case EVTCHNSTAT_unbound:
+ fastabi_value_n(regs, 6) = status.u.unbound.dom;
+ break;
+ case EVTCHNSTAT_interdomain:
+ fastabi_value_n(regs, 6) = status.u.interdomain.dom;
+ fastabi_value_n(regs, 7) = status.u.interdomain.port;
+ break;
+ case EVTCHNSTAT_pirq:
+ fastabi_value_n(regs, 6) = status.u.pirq;
+ break;
+ case EVTCHNSTAT_virq:
+ fastabi_value_n(regs, 6) = status.u.virq;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+
+ case EVTCHNOP_bind_vcpu: {
+ struct evtchn_bind_vcpu bind_vcpu = {
+ .vcpu = fastabi_value_n(regs, 2),
+ .port = fastabi_value_n(regs, 3)
+ };
+ rc = evtchn_bind_vcpu(bind_vcpu.port, bind_vcpu.vcpu);
+ break;
+ }
+
+ case EVTCHNOP_unmask: {
+ struct evtchn_unmask unmask = { .port = fastabi_value_n(regs, 2) };
+ rc = evtchn_unmask(unmask.port);
+ break;
+ }
+
+ case EVTCHNOP_reset:
+ case EVTCHNOP_reset_cont: {
+ struct evtchn_reset reset = { .dom = fastabi_value_n(regs, 2) };
+ struct domain *d;
+
+ d = rcu_lock_domain_by_any_id(reset.dom);
+ if ( d == NULL )
+ {
+ rc = -ESRCH;
+ break;
+ }
+
+ rc = xsm_evtchn_reset(XSM_TARGET, current->domain, d);
+ if ( !rc )
+ rc = evtchn_reset(d, cmd == EVTCHNOP_reset_cont);
+
+ rcu_unlock_domain(d);
+
+ if ( rc == -ERESTART )
+ {
+ fastabi_value_n(regs, 1) = EVTCHNOP_reset_cont;
+ fastabi_make_continuation();
+ return;
+ }
+ break;
+ }
+
+ case EVTCHNOP_init_control: {
+ struct evtchn_init_control init_control = {
+ .control_gfn = fastabi_value_n(regs, 2),
+ .offset = fastabi_value_n(regs, 3),
+ .vcpu = fastabi_value_n(regs, 4)
+ };
+ rc = evtchn_fifo_init_control(&init_control);
+
+ if ( !rc )
+ fastabi_value_n(regs, 5) = init_control.link_bits;
+ break;
+ }
+
+ case EVTCHNOP_expand_array: {
+ struct evtchn_expand_array expand_array = {
+ .array_gfn = fastabi_value_n(regs, 2)
+ };
+ rc = evtchn_fifo_expand_array(&expand_array);
+ break;
+ }
+
+ case EVTCHNOP_set_priority: {
+ struct evtchn_set_priority set_priority = {
+ .port = fastabi_value_n(regs, 2),
+ .priority = fastabi_value_n(regs, 3),
+ };
+ rc = evtchn_set_priority(&set_priority);
+ break;
+ }
+
+ default:
+ rc = -ENOSYS;
+ break;
+ }
+
+ fastabi_value_n(regs, 0) = rc;
+}
+#endif
int alloc_unbound_xen_event_channel(
struct domain *ld, unsigned int lvcpu, domid_t remote_domid,
diff --git a/xen/common/fastabi.c b/xen/common/fastabi.c
index efaaaaf96b..223082ea9a 100644
--- a/xen/common/fastabi.c
+++ b/xen/common/fastabi.c
@@ -23,6 +23,10 @@ void fastabi_dispatch(unsigned long index, struct
cpu_user_regs *regs)
do_sched_fast_op(regs);
break;
+ case __HYPERVISOR_event_channel_op:
+ do_event_channel_fast_op(regs);
+ break;
+
default:
fastabi_value_n(regs, 0) = -ENOSYS;
break;
diff --git a/xen/include/xen/fastabi.h b/xen/include/xen/fastabi.h
index 9364a85fc5..85244ea811 100644
--- a/xen/include/xen/fastabi.h
+++ b/xen/include/xen/fastabi.h
@@ -8,6 +8,8 @@
void fastabi_dispatch(unsigned long index, struct cpu_user_regs *regs);
void fastabi_make_continuation(void);
+void do_event_channel_fast_op(struct cpu_user_regs *regs);
+
void do_sched_fast_op(struct cpu_user_regs *regs);
void do_xen_version_fast_op(struct cpu_user_regs *regs);
#endif /* XEN_FASTABI_H */
--
2.56.1
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |