[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v5 37/52] hw/xen: Implement EVTCHNOP_bind_vcpu
From: |
David Woodhouse |
Subject: |
[RFC PATCH v5 37/52] hw/xen: Implement EVTCHNOP_bind_vcpu |
Date: |
Fri, 30 Dec 2022 12:12:20 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/i386/kvm/xen_evtchn.c | 40 +++++++++++++++++++++++++++++++++++++++
hw/i386/kvm/xen_evtchn.h | 2 ++
target/i386/kvm/xen-emu.c | 12 ++++++++++++
3 files changed, 54 insertions(+)
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index 9146e61c66..1623922dfc 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -784,6 +784,46 @@ int xen_evtchn_unmask_op(struct evtchn_unmask *unmask)
return ret;
}
+int xen_evtchn_bind_vcpu_op(struct evtchn_bind_vcpu *vcpu)
+{
+ XenEvtchnState *s = xen_evtchn_singleton;
+ XenEvtchnPort *p;
+ int ret = -EINVAL;
+
+ if (!s) {
+ return -ENOTSUP;
+ }
+
+ if (!valid_port(vcpu->port)) {
+ return -EINVAL;
+ }
+
+ if (!valid_vcpu(vcpu->vcpu)) {
+ return -ENOENT;
+ }
+
+ qemu_mutex_lock(&s->port_lock);
+
+ p = &s->port_table[vcpu->port];
+
+ if (p->type == EVTCHNSTAT_interdomain ||
+ p->type == EVTCHNSTAT_unbound ||
+ p->type == EVTCHNSTAT_pirq ||
+ (p->type == EVTCHNSTAT_virq && virq_is_global(p->type_val))) {
+ /*
+ * unmask_port() with do_unmask==false will just raise the event
+ * on the new vCPU if the port was already pending.
+ */
+ p->vcpu = vcpu->vcpu;
+ unmask_port(s, vcpu->port, false);
+ ret = 0;
+ }
+
+ qemu_mutex_unlock(&s->port_lock);
+
+ return ret;
+}
+
int xen_evtchn_bind_virq_op(struct evtchn_bind_virq *virq)
{
XenEvtchnState *s = xen_evtchn_singleton;
diff --git a/hw/i386/kvm/xen_evtchn.h b/hw/i386/kvm/xen_evtchn.h
index 1ebc7580eb..486b031c82 100644
--- a/hw/i386/kvm/xen_evtchn.h
+++ b/hw/i386/kvm/xen_evtchn.h
@@ -23,6 +23,7 @@ struct evtchn_bind_ipi;
struct evtchn_send;
struct evtchn_alloc_unbound;
struct evtchn_bind_interdomain;
+struct evtchn_bind_vcpu;
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);
@@ -31,5 +32,6 @@ 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);
int xen_evtchn_bind_interdomain_op(struct evtchn_bind_interdomain
*interdomain);
+int xen_evtchn_bind_vcpu_op(struct evtchn_bind_vcpu *vcpu);
#endif /* QEMU_XEN_EVTCHN_H */
diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index 8a2a8c6291..960999198a 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -934,6 +934,18 @@ static bool kvm_xen_hcall_evtchn_op(struct kvm_xen_exit
*exit, X86CPU *cpu,
}
break;
}
+ case EVTCHNOP_bind_vcpu: {
+ struct evtchn_bind_vcpu vcpu;
+
+ qemu_build_assert(sizeof(vcpu) == 8);
+ if (kvm_copy_from_gva(cs, arg, &vcpu, sizeof(vcpu))) {
+ err = -EFAULT;
+ break;
+ }
+
+ err = xen_evtchn_bind_vcpu_op(&vcpu);
+ break;
+ }
default:
return false;
}
--
2.35.3
- [RFC PATCH v5 00/52] Xen support under KVM, David Woodhouse, 2022/12/30
- [RFC PATCH v5 36/52] hw/xen: Implement EVTCHNOP_bind_interdomain, David Woodhouse, 2022/12/30
- [RFC PATCH v5 43/52] hw/xen: Add xen_gnttab device for grant table emulation, David Woodhouse, 2022/12/30
- [RFC PATCH v5 19/52] i386/xen: implement HYPERVISOR_hvm_op, David Woodhouse, 2022/12/30
- [RFC PATCH v5 46/52] hw/xen: Implement GNTTABOP_query_size, David Woodhouse, 2022/12/30
- [RFC PATCH v5 34/52] hw/xen: Implement EVTCHNOP_send, David Woodhouse, 2022/12/30
- [RFC PATCH v5 13/52] i386/xen: Implement SCHEDOP_poll and SCHEDOP_yield, David Woodhouse, 2022/12/30
- [RFC PATCH v5 08/52] xen-platform: allow its creation with XEN_EMULATE mode, David Woodhouse, 2022/12/30
- [RFC PATCH v5 37/52] hw/xen: Implement EVTCHNOP_bind_vcpu,
David Woodhouse <=
- [RFC PATCH v5 11/52] i386/xen: implement HYPERVISOR_xen_version, David Woodhouse, 2022/12/30
- [RFC PATCH v5 18/52] i386/xen: implement XENMEM_add_to_physmap_batch, David Woodhouse, 2022/12/30
- [RFC PATCH v5 51/52] hw/xen: Add xen_xenstore device for xenstore emulation, David Woodhouse, 2022/12/30
- [RFC PATCH v5 03/52] xen: Add XEN_DISABLED mode and make it default, David Woodhouse, 2022/12/30
- [RFC PATCH v5 38/52] hw/xen: Implement EVTCHNOP_reset, David Woodhouse, 2022/12/30
- [RFC PATCH v5 29/52] hw/xen: Implement EVTCHNOP_status, David Woodhouse, 2022/12/30
- [RFC PATCH v5 30/52] hw/xen: Implement EVTCHNOP_close, David Woodhouse, 2022/12/30
- [RFC PATCH v5 15/52] i386/xen: add pc_machine_kvm_type to initialize XEN_EMULATE mode, David Woodhouse, 2022/12/30
- [RFC PATCH v5 12/52] i386/xen: implement HYPERVISOR_sched_op, SCHEDOP_shutdown, David Woodhouse, 2022/12/30
- [RFC PATCH v5 20/52] i386/xen: implement HYPERVISOR_vcpu_op, David Woodhouse, 2022/12/30