[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 58/62] kvm/i386: Add xen-evtchn-max-pirq property
From: |
Paolo Bonzini |
Subject: |
[PULL 58/62] kvm/i386: Add xen-evtchn-max-pirq property |
Date: |
Thu, 2 Mar 2023 13:30:25 +0100 |
From: David Woodhouse <dwmw@amazon.co.uk>
The default number of PIRQs is set to 256 to avoid issues with 32-bit MSI
devices. Allow it to be increased if the user desires.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
---
accel/kvm/kvm-all.c | 1 +
hw/i386/kvm/xen_evtchn.c | 21 +++++++++++----------
include/sysemu/kvm_int.h | 1 +
include/sysemu/kvm_xen.h | 1 +
target/i386/kvm/kvm.c | 34 ++++++++++++++++++++++++++++++++++
target/i386/kvm/xen-emu.c | 6 ++++++
6 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 3d8e400bbf86..f2a6ea6a68a2 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3705,6 +3705,7 @@ static void kvm_accel_instance_init(Object *obj)
s->notify_window = 0;
s->xen_version = 0;
s->xen_gnttab_max_frames = 64;
+ s->xen_evtchn_max_pirq = 256;
}
/**
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index 69c0204d4f0c..886fbf6b3bed 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -302,17 +302,18 @@ void xen_evtchn_create(void)
}
/*
- * We could parameterise the number of PIRQs available if needed,
- * but for now limit it to 256. The Xen scheme for encoding PIRQ#
- * into an MSI message is not compatible with 32-bit MSI, as it
- * puts the high bits of the PIRQ# into the high bits of the MSI
- * message address, instead of using the Extended Destination ID
- * in address bits 4-11 which perhaps would have been a better
- * choice. So to keep life simple, just stick with 256 as the
- * default, which conveniently doesn't need to set anything
- * outside the low 32 bits of the address.
+ * The Xen scheme for encoding PIRQ# into an MSI message is not
+ * compatible with 32-bit MSI, as it puts the high bits of the
+ * PIRQ# into the high bits of the MSI message address, instead of
+ * using the Extended Destination ID in address bits 4-11 which
+ * perhaps would have been a better choice.
+ *
+ * To keep life simple, kvm_accel_instance_init() initialises the
+ * default to 256. which conveniently doesn't need to set anything
+ * outside the low 32 bits of the address. It can be increased by
+ * setting the xen-evtchn-max-pirq property.
*/
- s->nr_pirqs = 256;
+ s->nr_pirqs = kvm_xen_get_evtchn_max_pirq();
s->nr_pirq_inuse_words = DIV_ROUND_UP(s->nr_pirqs, 64);
s->pirq_inuse_bitmap = g_new0(uint64_t, s->nr_pirq_inuse_words);
diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
index 39ce4d36f684..a641c974ea54 100644
--- a/include/sysemu/kvm_int.h
+++ b/include/sysemu/kvm_int.h
@@ -121,6 +121,7 @@ struct KVMState
uint32_t xen_version;
uint32_t xen_caps;
uint16_t xen_gnttab_max_frames;
+ uint16_t xen_evtchn_max_pirq;
};
void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
diff --git a/include/sysemu/kvm_xen.h b/include/sysemu/kvm_xen.h
index b2aafaf7abdd..595abfbe402f 100644
--- a/include/sysemu/kvm_xen.h
+++ b/include/sysemu/kvm_xen.h
@@ -26,6 +26,7 @@ void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id,
int type);
void kvm_xen_set_callback_asserted(void);
int kvm_xen_set_vcpu_virq(uint32_t vcpu_id, uint16_t virq, uint16_t port);
uint16_t kvm_xen_get_gnttab_max_frames(void);
+uint16_t kvm_xen_get_evtchn_max_pirq(void);
#define kvm_xen_has_cap(cap) (!!(kvm_xen_get_caps() & \
KVM_XEN_HVM_CONFIG_ ## cap))
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d390137f02be..1aef54f87e64 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -5922,6 +5922,33 @@ static void kvm_arch_set_xen_gnttab_max_frames(Object
*obj, Visitor *v,
s->xen_gnttab_max_frames = value;
}
+static void kvm_arch_get_xen_evtchn_max_pirq(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ KVMState *s = KVM_STATE(obj);
+ uint16_t value = s->xen_evtchn_max_pirq;
+
+ visit_type_uint16(v, name, &value, errp);
+}
+
+static void kvm_arch_set_xen_evtchn_max_pirq(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ KVMState *s = KVM_STATE(obj);
+ Error *error = NULL;
+ uint16_t value;
+
+ visit_type_uint16(v, name, &value, &error);
+ if (error) {
+ error_propagate(errp, error);
+ return;
+ }
+
+ s->xen_evtchn_max_pirq = value;
+}
+
void kvm_arch_accel_class_init(ObjectClass *oc)
{
object_class_property_add_enum(oc, "notify-vmexit", "NotifyVMexitOption",
@@ -5954,6 +5981,13 @@ void kvm_arch_accel_class_init(ObjectClass *oc)
NULL, NULL);
object_class_property_set_description(oc, "xen-gnttab-max-frames",
"Maximum number of grant table
frames");
+
+ object_class_property_add(oc, "xen-evtchn-max-pirq", "uint16",
+ kvm_arch_get_xen_evtchn_max_pirq,
+ kvm_arch_set_xen_evtchn_max_pirq,
+ NULL, NULL);
+ object_class_property_set_description(oc, "xen-evtchn-max-pirq",
+ "Maximum number of Xen PIRQs");
}
void kvm_set_max_apic_id(uint32_t max_apic_id)
diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index 96a90821969d..bad3131d08e1 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -1765,6 +1765,12 @@ uint16_t kvm_xen_get_gnttab_max_frames(void)
return s->xen_gnttab_max_frames;
}
+uint16_t kvm_xen_get_evtchn_max_pirq(void)
+{
+ KVMState *s = KVM_STATE(current_accel());
+ return s->xen_evtchn_max_pirq;
+}
+
int kvm_put_xen_state(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);
--
2.39.1
- [PULL 18/62] i386/xen: implement XENMEM_add_to_physmap_batch, (continued)
- [PULL 18/62] i386/xen: implement XENMEM_add_to_physmap_batch, Paolo Bonzini, 2023/03/02
- [PULL 20/62] i386/xen: implement HYPERVISOR_vcpu_op, Paolo Bonzini, 2023/03/02
- [PULL 17/62] i386/xen: implement HYPERVISOR_memory_op, Paolo Bonzini, 2023/03/02
- [PULL 36/62] hw/xen: Implement EVTCHNOP_bind_interdomain, Paolo Bonzini, 2023/03/02
- [PULL 32/62] hw/xen: Implement EVTCHNOP_bind_virq, Paolo Bonzini, 2023/03/02
- [PULL 27/62] hw/xen: Add xen_evtchn device for event channel emulation, Paolo Bonzini, 2023/03/02
- [PULL 28/62] i386/xen: Add support for Xen event channel delivery to vCPU, Paolo Bonzini, 2023/03/02
- [PULL 31/62] hw/xen: Implement EVTCHNOP_unmask, Paolo Bonzini, 2023/03/02
- [PULL 38/62] hw/xen: Implement EVTCHNOP_reset, Paolo Bonzini, 2023/03/02
- [PULL 39/62] i386/xen: add monitor commands to test event injection, Paolo Bonzini, 2023/03/02
- [PULL 58/62] kvm/i386: Add xen-evtchn-max-pirq property,
Paolo Bonzini <=
- [PULL 29/62] hw/xen: Implement EVTCHNOP_status, Paolo Bonzini, 2023/03/02
- [PULL 41/62] hw/xen: Support HVM_PARAM_CALLBACK_TYPE_PCI_INTX callback, Paolo Bonzini, 2023/03/02
- [PULL 22/62] i386/xen: handle VCPUOP_register_vcpu_time_info, Paolo Bonzini, 2023/03/02
- [PULL 42/62] kvm/i386: Add xen-gnttab-max-frames property, Paolo Bonzini, 2023/03/02
- [PULL 45/62] i386/xen: Implement HYPERVISOR_grant_table_op and GNTTABOP_[gs]et_verson, Paolo Bonzini, 2023/03/02
- [PULL 49/62] i386/xen: handle HVMOP_get_param, Paolo Bonzini, 2023/03/02
- [PULL 62/62] Makefile: qemu-bundle is a directory, Paolo Bonzini, 2023/03/02
- [PULL 23/62] i386/xen: handle VCPUOP_register_runstate_memory_area, Paolo Bonzini, 2023/03/02
- [PULL 24/62] i386/xen: implement HYPERVISOR_event_channel_op, Paolo Bonzini, 2023/03/02
- [PULL 33/62] hw/xen: Implement EVTCHNOP_bind_ipi, Paolo Bonzini, 2023/03/02