[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 37/58] hw/xen: Implement EVTCHNOP_reset
From: |
David Woodhouse |
Subject: |
[PATCH v8 37/58] hw/xen: Implement EVTCHNOP_reset |
Date: |
Fri, 20 Jan 2023 13:13:22 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/i386/kvm/xen_evtchn.c | 29 +++++++++++++++++++++++++++++
hw/i386/kvm/xen_evtchn.h | 3 +++
target/i386/kvm/xen-emu.c | 17 +++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index e4535e14e8..bf4e3c61a8 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -745,6 +745,35 @@ static int close_port(XenEvtchnState *s, evtchn_port_t
port)
return 0;
}
+int xen_evtchn_soft_reset(void)
+{
+ XenEvtchnState *s = xen_evtchn_singleton;
+ int i;
+
+ if (!s) {
+ return -ENOTSUP;
+ }
+
+ assert(qemu_mutex_iothread_locked());
+
+ QEMU_LOCK_GUARD(&s->port_lock);
+
+ for (i = 0; i < s->nr_ports; i++) {
+ close_port(s, i);
+ }
+
+ return 0;
+}
+
+int xen_evtchn_reset_op(struct evtchn_reset *reset)
+{
+ if (reset->dom != DOMID_SELF && reset->dom != xen_domid) {
+ return -ESRCH;
+ }
+
+ return xen_evtchn_soft_reset();
+}
+
int xen_evtchn_close_op(struct evtchn_close *close)
{
XenEvtchnState *s = xen_evtchn_singleton;
diff --git a/hw/i386/kvm/xen_evtchn.h b/hw/i386/kvm/xen_evtchn.h
index 486b031c82..5d3e03553f 100644
--- a/hw/i386/kvm/xen_evtchn.h
+++ b/hw/i386/kvm/xen_evtchn.h
@@ -13,6 +13,7 @@
#define QEMU_XEN_EVTCHN_H
void xen_evtchn_create(void);
+int xen_evtchn_soft_reset(void);
int xen_evtchn_set_callback_param(uint64_t param);
struct evtchn_status;
@@ -24,6 +25,7 @@ struct evtchn_send;
struct evtchn_alloc_unbound;
struct evtchn_bind_interdomain;
struct evtchn_bind_vcpu;
+struct evtchn_reset;
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);
@@ -33,5 +35,6 @@ 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);
+int xen_evtchn_reset_op(struct evtchn_reset *reset);
#endif /* QEMU_XEN_EVTCHN_H */
diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index ed8ede6e3f..4283663fd4 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -961,6 +961,18 @@ static bool kvm_xen_hcall_evtchn_op(struct kvm_xen_exit
*exit, X86CPU *cpu,
err = xen_evtchn_bind_vcpu_op(&vcpu);
break;
}
+ case EVTCHNOP_reset: {
+ struct evtchn_reset reset;
+
+ qemu_build_assert(sizeof(reset) == 2);
+ if (kvm_copy_from_gva(cs, arg, &reset, sizeof(reset))) {
+ err = -EFAULT;
+ break;
+ }
+
+ err = xen_evtchn_reset_op(&reset);
+ break;
+ }
default:
return false;
}
@@ -978,6 +990,11 @@ int kvm_xen_soft_reset(void)
trace_kvm_xen_soft_reset();
+ err = xen_evtchn_soft_reset();
+ if (err) {
+ return err;
+ }
+
/*
* Zero is the reset/startup state for HVM_PARAM_CALLBACK_IRQ. Strictly,
* it maps to HVM_PARAM_CALLBACK_TYPE_GSI with GSI#0, but Xen refuses to
--
2.39.0
- [PATCH v8 18/58] i386/xen: implement HYPERVISOR_hvm_op, (continued)
- [PATCH v8 18/58] i386/xen: implement HYPERVISOR_hvm_op, David Woodhouse, 2023/01/20
- [PATCH v8 28/58] hw/xen: Implement EVTCHNOP_status, David Woodhouse, 2023/01/20
- [PATCH v8 12/58] i386/xen: Implement SCHEDOP_poll and SCHEDOP_yield, David Woodhouse, 2023/01/20
- [PATCH v8 14/58] i386/xen: add pc_machine_kvm_type to initialize XEN_EMULATE mode, David Woodhouse, 2023/01/20
- [PATCH v8 57/58] hw/xen: Support MSI mapping to PIRQ, David Woodhouse, 2023/01/20
- [PATCH v8 06/58] i386/hvm: Set Xen vCPU ID in KVM, David Woodhouse, 2023/01/20
- [PATCH v8 33/58] hw/xen: Implement EVTCHNOP_send, David Woodhouse, 2023/01/20
- [PATCH v8 19/58] i386/xen: implement HYPERVISOR_vcpu_op, David Woodhouse, 2023/01/20
- [PATCH v8 03/58] xen: Add XEN_DISABLED mode and make it default, David Woodhouse, 2023/01/20
- [PATCH v8 37/58] hw/xen: Implement EVTCHNOP_reset,
David Woodhouse <=
- [PATCH v8 47/58] i386/xen: Reserve Xen special pages for console, xenstore rings, David Woodhouse, 2023/01/20
- [PATCH v8 32/58] hw/xen: Implement EVTCHNOP_bind_ipi, David Woodhouse, 2023/01/20
- [PATCH v8 43/58] hw/xen: Support mapping grant frames, David Woodhouse, 2023/01/20
- [PATCH v8 55/58] hw/xen: Implement emulated PIRQ hypercall support, David Woodhouse, 2023/01/20
- [PATCH v8 42/58] hw/xen: Add xen_gnttab device for grant table emulation, David Woodhouse, 2023/01/20
- [PATCH v8 11/58] i386/xen: implement HYPERVISOR_sched_op, SCHEDOP_shutdown, David Woodhouse, 2023/01/20
- [PATCH v8 41/58] kvm/i386: Add xen-gnttab-max-frames property, David Woodhouse, 2023/01/20
- [PATCH v8 51/58] hw/xen: Add basic ring handling to xenstore, David Woodhouse, 2023/01/20
- [PATCH v8 26/58] hw/xen: Add xen_evtchn device for event channel emulation, David Woodhouse, 2023/01/20