[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v3 31/38] hw/xen: Implement EVTCHNOP_alloc_unbound
From: |
David Woodhouse |
Subject: |
[RFC PATCH v3 31/38] hw/xen: Implement EVTCHNOP_alloc_unbound |
Date: |
Fri, 16 Dec 2022 00:41:10 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/i386/kvm/xen_evtchn.c | 32 ++++++++++++++++++++++++++++++++
hw/i386/kvm/xen_evtchn.h | 2 ++
target/i386/kvm/xen-emu.c | 15 +++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index d90a92a25a..4272b63853 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -732,6 +732,38 @@ int xen_evtchn_bind_ipi_op(struct evtchn_bind_ipi *ipi)
return ret;
}
+int xen_evtchn_alloc_unbound_op(struct evtchn_alloc_unbound *alloc)
+{
+ XenEvtchnState *s = xen_evtchn_singleton;
+ uint16_t type_val;
+ int ret;
+
+ if (!s) {
+ return -ENOTSUP;
+ }
+
+ if (alloc->dom != DOMID_SELF && alloc->dom != xen_domid) {
+ return -ESRCH;
+ }
+
+ if (alloc->remote_dom == DOMID_QEMU) {
+ type_val = PORT_INFO_TYPEVAL_REMOTE_QEMU;
+ } else if (alloc->remote_dom == DOMID_SELF ||
+ alloc->remote_dom == xen_domid) {
+ type_val = 0;
+ } else {
+ return -EPERM;
+ }
+
+ qemu_mutex_lock(&s->port_lock);
+
+ ret = allocate_port(s, 0, EVTCHNSTAT_unbound, type_val, &alloc->port);
+
+ qemu_mutex_unlock(&s->port_lock);
+
+ return ret;
+}
+
int xen_evtchn_send_op(struct evtchn_send *send)
{
XenEvtchnState *s = xen_evtchn_singleton;
diff --git a/hw/i386/kvm/xen_evtchn.h b/hw/i386/kvm/xen_evtchn.h
index c27b9e8096..5dc68a188d 100644
--- a/hw/i386/kvm/xen_evtchn.h
+++ b/hw/i386/kvm/xen_evtchn.h
@@ -19,9 +19,11 @@ struct evtchn_unmask;
struct evtchn_bind_virq;
struct evtchn_bind_ipi;
struct evtchn_send;
+struct evtchn_alloc_unbound;
int xen_evtchn_status_op(struct evtchn_status *status);
int xen_evtchn_close_op(struct evtchn_close *close);
int xen_evtchn_unmask_op(struct evtchn_unmask *unmask);
int xen_evtchn_bind_virq_op(struct evtchn_bind_virq *virq);
int xen_evtchn_bind_ipi_op(struct evtchn_bind_ipi *ipi);
int xen_evtchn_send_op(struct evtchn_send *send);
+int xen_evtchn_alloc_unbound_op(struct evtchn_alloc_unbound *alloc);
diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index 300b0d75bc..6f393c4149 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -812,6 +812,21 @@ static bool kvm_xen_hcall_evtchn_op(struct kvm_xen_exit
*exit, X86CPU *cpu,
err = xen_evtchn_send_op(&send);
break;
}
+ case EVTCHNOP_alloc_unbound: {
+ struct evtchn_alloc_unbound alloc;
+
+ qemu_build_assert(sizeof(alloc) == 8);
+ if (kvm_copy_from_gva(cs, arg, &alloc, sizeof(alloc))) {
+ err = -EFAULT;
+ break;
+ }
+
+ err = xen_evtchn_alloc_unbound_op(&alloc);
+ if (!err && kvm_copy_to_gva(cs, arg, &alloc, sizeof(alloc))) {
+ err = -EFAULT;
+ }
+ break;
+ }
default:
return false;
}
--
2.35.3
- [RFC PATCH v3 22/38] i386/xen: HVMOP_set_param / HVM_PARAM_CALLBACK_IRQ, (continued)
- [RFC PATCH v3 22/38] i386/xen: HVMOP_set_param / HVM_PARAM_CALLBACK_IRQ, David Woodhouse, 2022/12/15
- [RFC PATCH v3 29/38] hw/xen: Implement EVTCHNOP_bind_ipi, David Woodhouse, 2022/12/15
- [RFC PATCH v3 02/38] xen: add CONFIG_XENFV_MACHINE and CONFIG_XEN_EMU options for Xen emulation, David Woodhouse, 2022/12/15
- [RFC PATCH v3 32/38] hw/xen: Implement EVTCHNOP_bind_interdomain, David Woodhouse, 2022/12/15
- [RFC PATCH v3 25/38] hw/xen: Implement EVTCHNOP_status, David Woodhouse, 2022/12/15
- [RFC PATCH v3 08/38] hw/xen_backend: refactor xen_be_init(), David Woodhouse, 2022/12/15
- [RFC PATCH v3 15/38] i386/xen: implement XENMEM_add_to_physmap_batch, David Woodhouse, 2022/12/15
- [RFC PATCH v3 23/38] i386/xen: implement HYPERVISOR_event_channel_op, David Woodhouse, 2022/12/15
- [RFC PATCH v3 31/38] hw/xen: Implement EVTCHNOP_alloc_unbound,
David Woodhouse <=
- [RFC PATCH v3 36/38] i386/xen: Implement SCHEDOP_poll, David Woodhouse, 2022/12/15
- [RFC PATCH v3 11/38] hw/xen: Add xen_overlay device for emulating shared xenheap pages, David Woodhouse, 2022/12/15
- [RFC PATCH v3 19/38] i386/xen: handle VCPUOP_register_vcpu_time_info, David Woodhouse, 2022/12/15
- [RFC PATCH v3 28/38] hw/xen: Implement EVTCHNOP_bind_virq, David Woodhouse, 2022/12/15
- [RFC PATCH v3 21/38] i386/xen: implement HVMOP_set_evtchn_upcall_vector, David Woodhouse, 2022/12/15
- [RFC PATCH v3 33/38] hw/xen: Implement EVTCHNOP_bind_vcpu, David Woodhouse, 2022/12/15
- [RFC PATCH v3 04/38] i386/kvm: Add xen-version machine property and init KVM Xen support, David Woodhouse, 2022/12/15
- [RFC PATCH v3 14/38] i386/xen: implement HYPERVISOR_memory_op, David Woodhouse, 2022/12/15
- [RFC PATCH v3 09/38] i386/xen: handle guest hypercalls, David Woodhouse, 2022/12/15