qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v10 32/59] hw/xen: Implement EVTCHNOP_bind_virq


From: Paul Durrant
Subject: Re: [PATCH v10 32/59] hw/xen: Implement EVTCHNOP_bind_virq
Date: Fri, 10 Feb 2023 13:48:36 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1

On 01/02/2023 14:31, David Woodhouse wrote:
From: David Woodhouse <dwmw@amazon.co.uk>

Add the array of virq ports to each vCPU so that we can deliver timers,
debug ports, etc. Global virqs are allocated against vCPU 0 initially,
but can be migrated to other vCPUs (when we implement that).

The kernel needs to know about VIRQ_TIMER in order to accelerate timers,
so tell it via KVM_XEN_VCPU_ATTR_TYPE_TIMER. Also save/restore the value
of the singleshot timer across migration, as the kernel will handle the
hypercalls automatically now.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
  hw/i386/kvm/xen_evtchn.c  | 85 ++++++++++++++++++++++++++++++++++++
  hw/i386/kvm/xen_evtchn.h  |  2 +
  include/sysemu/kvm_xen.h  |  1 +
  target/i386/cpu.h         |  4 ++
  target/i386/kvm/xen-emu.c | 91 +++++++++++++++++++++++++++++++++++++++
  target/i386/machine.c     |  2 +
  6 files changed, 185 insertions(+)


Reviewed-by: Paul Durrant <paul@xen.org>

... with one suggestion...

diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index deea7de027..da2f5711dd 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -244,6 +244,11 @@ static bool valid_port(evtchn_port_t port)
      }
  }
+static bool valid_vcpu(uint32_t vcpu)
+{
+    return !!qemu_get_cpu(vcpu);
+}
+
  int xen_evtchn_status_op(struct evtchn_status *status)
  {
      XenEvtchnState *s = xen_evtchn_singleton;
@@ -494,6 +499,43 @@ static void free_port(XenEvtchnState *s, evtchn_port_t 
port)
      clear_port_pending(s, port);
  }
+static int allocate_port(XenEvtchnState *s, uint32_t vcpu, uint16_t type,
+                         uint16_t val, evtchn_port_t *port)
+{
+    evtchn_port_t p = 1;
+
+    for (p = 1; valid_port(p); p++) {
+        if (s->port_table[p].type == EVTCHNSTAT_closed) {
+            s->port_table[p].vcpu = vcpu;
+            s->port_table[p].type = type;
+            s->port_table[p].type_val = val;

It'd be neater to use a structured initializer to create a port_table entry on stack and then do a single assignment.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]