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

[[UNIKRAFT PATCH] v4 4/4] plat/xen: Made xen event handler interrupt-context-safe



From: Cristian Vijelie <cristianvijelie@xxxxxxxxx>

I have moved 'do_event' function into a separate source file, 'isr.c' 
along with another function, which is called by 'do_event',
'clear_eventchn'. I also added a header file 'internal/isr.h', which
contains definitions needed in both events.c and the newlycreated
source file.

Signed-off-by: Cristian Vijelie <cristianvijelie@xxxxxxxxx>
---
 plat/xen/Makefile.uk    |  1 +
 plat/xen/events.c       | 49 ++------------------------------
 plat/xen/internal/isr.h | 51 +++++++++++++++++++++++++++++++++
 plat/xen/isr.c          | 63 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 117 insertions(+), 47 deletions(-)
 create mode 100644 plat/xen/internal/isr.h
 create mode 100644 plat/xen/isr.c

diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk
index 2a8cdbf..c6e5a05 100644
--- a/plat/xen/Makefile.uk
+++ b/plat/xen/Makefile.uk
@@ -94,6 +94,7 @@ LIBXENPLAT_SRCS-y              += 
$(LIBXENPLAT_BASE)/emg_console.c
 endif
 LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/shutdown.c
 LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/events.c
+LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/isr.c|isr
 
 ifeq ($(CONFIG_XEN_GNTTAB),y)
 LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/gnttab.c
diff --git a/plat/xen/events.c b/plat/xen/events.c
index 3a1d155..bf9707d 100644
--- a/plat/xen/events.c
+++ b/plat/xen/events.c
@@ -32,24 +32,10 @@
  * Deals with events received on event channels
  * Ported from Mini-OS
  */
-#include <stdlib.h>
-#include <stdint.h>
-#include <common/hypervisor.h>
-#include <common/events.h>
+#include "internal/isr.h"
 #include <xen/xen.h>
-#include <uk/print.h>
-#include <uk/bitops.h>
 
-#define NR_EVS 1024
-
-/* this represents a event handler. Chaining or sharing is not allowed */
-typedef struct _ev_action_t {
-       evtchn_handler_t handler;
-       void *data;
-       uint32_t count;
-} ev_action_t;
-
-static ev_action_t ev_actions[NR_EVS];
+ev_action_t ev_actions[NR_EVS];
 static void default_handler(evtchn_port_t port, struct __regs *regs,
                            void *data);
 
@@ -78,30 +64,6 @@ void unbind_all_ports(void)
        vcpu_info->evtchn_pending_sel = 0;
 }
 
-/*
- * Demux events to different handlers.
- */
-int do_event(evtchn_port_t port, struct __regs *regs)
-{
-       ev_action_t *action;
-
-       clear_evtchn(port);
-
-       if (port >= NR_EVS) {
-               uk_pr_err("%s: Port number too large: %d\n", __func__, port);
-               return 1;
-       }
-
-       action = &ev_actions[port];
-       action->count++;
-
-       /* call the handler */
-       action->handler(port, regs, action->data);
-
-       return 1;
-
-}
-
 evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler,
                          void *data)
 {
@@ -321,13 +283,6 @@ inline void unmask_evtchn(evtchn_port_t port)
        }
 }
 
-inline void clear_evtchn(evtchn_port_t port)
-{
-       shared_info_t *s = HYPERVISOR_shared_info;
-
-       uk_clear_bit(port, &s->evtchn_pending[0]);
-}
-
 struct uk_alloc;
 
 int ukplat_irq_init(struct uk_alloc *a __unused)
diff --git a/plat/xen/internal/isr.h b/plat/xen/internal/isr.h
new file mode 100644
index 0000000..9a23d69
--- /dev/null
+++ b/plat/xen/internal/isr.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Authors: Rolf Neugebauer <neugebar@xxxxxxxxxxxxx>
+ *          Grzegorz Milos <gm281@xxxxxxxxx>
+ *          Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * Copyright (c) 2003-2005, Intel Research Cambridge
+ * Copyright (c) 2017, NEC Europe Ltd., NEC Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef XEN_ISR_H
+#define XEN_ISR_H
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <common/events.h>
+#include <uk/print.h>
+#include <common/hypervisor.h>
+#include <uk/bitops.h>
+
+#define NR_EVS 1024
+
+/* this represents a event handler. Chaining or sharing is not allowed */
+typedef struct _ev_action_t {
+       evtchn_handler_t handler;
+       void *data;
+       uint32_t count;
+} ev_action_t;
+
+#endif /* XEN_ISR_H */
diff --git a/plat/xen/isr.c b/plat/xen/isr.c
new file mode 100644
index 0000000..9aad3ac
--- /dev/null
+++ b/plat/xen/isr.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Authors: Rolf Neugebauer <neugebar@xxxxxxxxxxxxx>
+ *          Grzegorz Milos <gm281@xxxxxxxxx>
+ *          Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * Copyright (c) 2003-2005, Intel Research Cambridge
+ * Copyright (c) 2017, NEC Europe Ltd., NEC Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "internal/isr.h"
+
+extern ev_action_t *ev_actions;
+
+inline void clear_evtchn(evtchn_port_t port)
+{
+       shared_info_t *s = HYPERVISOR_shared_info;
+
+       uk_clear_bit(port, &s->evtchn_pending[0]);
+}
+
+/*
+ * Demux events to different handlers.
+ */
+int do_event(evtchn_port_t port, struct __regs *regs)
+{
+       ev_action_t *action;
+
+       clear_evtchn(port);
+
+       if (port >= NR_EVS) {
+               uk_pr_err("%s: Port number too large: %d\n", __func__, port);
+               return 1;
+       }
+
+       action = &ev_actions[port];
+       action->count++;
+
+       /* call the handler */
+       action->handler(port, regs, action->data);
+
+       return 1;
+}
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.