Mon Apr 20 19:46:44 2020 UTC ()
Misc fixes after merge


(bouyer)
diff -r1.28.2.2 -r1.28.2.3 src/sys/arch/xen/include/evtchn.h
diff -r1.35.6.5 -r1.35.6.6 src/sys/arch/xen/x86/xen_ipi.c
diff -r1.88.2.10 -r1.88.2.11 src/sys/arch/xen/xen/evtchn.c

cvs diff -r1.28.2.2 -r1.28.2.3 src/sys/arch/xen/include/evtchn.h (expand / switch to unified diff)

--- src/sys/arch/xen/include/evtchn.h 2020/04/20 11:29:00 1.28.2.2
+++ src/sys/arch/xen/include/evtchn.h 2020/04/20 19:46:44 1.28.2.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: evtchn.h,v 1.28.2.2 2020/04/20 11:29:00 bouyer Exp $ */ 1/* $NetBSD: evtchn.h,v 1.28.2.3 2020/04/20 19:46:44 bouyer Exp $ */
2 2
3/* 3/*
4 * 4 *
5 * Copyright (c) 2004 Christian Limpach. 5 * Copyright (c) 2004 Christian Limpach.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -31,28 +31,28 @@ @@ -31,28 +31,28 @@
31 31
32#define NR_PIRQS 256 32#define NR_PIRQS 256
33 33
34extern struct evtsource *evtsource[]; 34extern struct evtsource *evtsource[];
35 35
36void events_default_setup(void); 36void events_default_setup(void);
37void events_init(void); 37void events_init(void);
38bool events_suspend(void); 38bool events_suspend(void);
39bool events_resume(void); 39bool events_resume(void);
40 40
41unsigned int evtchn_do_event(int, struct intrframe *); 41unsigned int evtchn_do_event(int, struct intrframe *);
42void call_evtchn_do_event(int, struct intrframe *); 42void call_evtchn_do_event(int, struct intrframe *);
43void call_xenevt_event(int); 43void call_xenevt_event(int);
44int event_set_handler(int, int (*func)(void *), void *, int, const char *, 44struct intrhand *event_set_handler(int, int (*func)(void *), void *,
45 const char *, bool, bool); 45 int, const char *, const char *, bool, bool);
46int event_remove_handler(int, int (*func)(void *), void *); 46int event_remove_handler(int, int (*func)(void *), void *);
47 47
48struct cpu_info; 48struct cpu_info;
49struct intrhand; 49struct intrhand;
50void event_set_iplhandler(struct cpu_info *, struct intrhand *, int); 50void event_set_iplhandler(struct cpu_info *, struct intrhand *, int);
51 51
52extern int debug_port; 52extern int debug_port;
53extern int xen_debug_handler(void *); 53extern int xen_debug_handler(void *);
54 54
55int bind_virq_to_evtch(int); 55int bind_virq_to_evtch(int);
56int bind_pirq_to_evtch(int); 56int bind_pirq_to_evtch(int);
57int get_pirq_to_evtch(int); 57int get_pirq_to_evtch(int);
58int unbind_pirq_from_evtch(int); 58int unbind_pirq_from_evtch(int);

cvs diff -r1.35.6.5 -r1.35.6.6 src/sys/arch/xen/x86/xen_ipi.c (expand / switch to unified diff)

--- src/sys/arch/xen/x86/xen_ipi.c 2020/04/20 11:29:01 1.35.6.5
+++ src/sys/arch/xen/x86/xen_ipi.c 2020/04/20 19:46:44 1.35.6.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xen_ipi.c,v 1.35.6.5 2020/04/20 11:29:01 bouyer Exp $ */ 1/* $NetBSD: xen_ipi.c,v 1.35.6.6 2020/04/20 19:46:44 bouyer Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Cherry G. Mathew <cherry@zyx.in> 8 * by Cherry G. Mathew <cherry@zyx.in>
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> /* RCS ID macro */ 32#include <sys/cdefs.h> /* RCS ID macro */
33 33
34/*  34/*
35 * Based on: x86/ipi.c 35 * Based on: x86/ipi.c
36 */ 36 */
37 37
38__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.5 2020/04/20 11:29:01 bouyer Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.6 2020/04/20 19:46:44 bouyer Exp $");
39 39
40#include "opt_ddb.h" 40#include "opt_ddb.h"
41 41
42#include <sys/types.h> 42#include <sys/types.h>
43 43
44#include <sys/atomic.h> 44#include <sys/atomic.h>
45#include <sys/cpu.h> 45#include <sys/cpu.h>
46#include <sys/mutex.h> 46#include <sys/mutex.h>
47#include <sys/device.h> 47#include <sys/device.h>
48#include <sys/xcall.h> 48#include <sys/xcall.h>
49#include <sys/ipi.h> 49#include <sys/ipi.h>
50#include <sys/errno.h> 50#include <sys/errno.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
@@ -133,27 +133,27 @@ xen_ipi_init(void) @@ -133,27 +133,27 @@ xen_ipi_init(void)
133 133
134 vcpu = ci->ci_vcpuid; 134 vcpu = ci->ci_vcpuid;
135 KASSERT(vcpu < XEN_LEGACY_MAX_VCPUS); 135 KASSERT(vcpu < XEN_LEGACY_MAX_VCPUS);
136 136
137 evtchn = bind_vcpu_to_evtch(vcpu); 137 evtchn = bind_vcpu_to_evtch(vcpu);
138 ci->ci_ipi_evtchn = evtchn; 138 ci->ci_ipi_evtchn = evtchn;
139 139
140 KASSERT(evtchn != -1 && evtchn < NR_EVENT_CHANNELS); 140 KASSERT(evtchn != -1 && evtchn < NR_EVENT_CHANNELS);
141 141
142 snprintf(intr_xname, sizeof(intr_xname), "%s ipi", 142 snprintf(intr_xname, sizeof(intr_xname), "%s ipi",
143 device_xname(ci->ci_dev)); 143 device_xname(ci->ci_dev));
144 144
145 if (event_set_handler(evtchn, xen_ipi_handler, ci, IPL_HIGH, NULL, 145 if (event_set_handler(evtchn, xen_ipi_handler, ci, IPL_HIGH, NULL,
146 intr_xname, true, false) != 0) { 146 intr_xname, true, false) == NULL) {
147 panic("%s: unable to register ipi handler\n", __func__); 147 panic("%s: unable to register ipi handler\n", __func__);
148 /* NOTREACHED */ 148 /* NOTREACHED */
149 } 149 }
150 150
151 hypervisor_unmask_event(evtchn); 151 hypervisor_unmask_event(evtchn);
152} 152}
153 153
154#ifdef DIAGNOSTIC 154#ifdef DIAGNOSTIC
155static inline bool /* helper */ 155static inline bool /* helper */
156valid_ipimask(uint32_t ipimask) 156valid_ipimask(uint32_t ipimask)
157{ 157{
158 uint32_t masks = XEN_IPI_GENERIC | XEN_IPI_HVCB | XEN_IPI_XCALL | 158 uint32_t masks = XEN_IPI_GENERIC | XEN_IPI_HVCB | XEN_IPI_XCALL |
159 XEN_IPI_DDB | XEN_IPI_SYNCH_FPU | 159 XEN_IPI_DDB | XEN_IPI_SYNCH_FPU |

cvs diff -r1.88.2.10 -r1.88.2.11 src/sys/arch/xen/xen/evtchn.c (expand / switch to unified diff)

--- src/sys/arch/xen/xen/evtchn.c 2020/04/20 11:29:01 1.88.2.10
+++ src/sys/arch/xen/xen/evtchn.c 2020/04/20 19:46:44 1.88.2.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: evtchn.c,v 1.88.2.10 2020/04/20 11:29:01 bouyer Exp $ */ 1/* $NetBSD: evtchn.c,v 1.88.2.11 2020/04/20 19:46:44 bouyer Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Manuel Bouyer. 4 * Copyright (c) 2006 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -44,27 +44,27 @@ @@ -44,27 +44,27 @@
44 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 44 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
46 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 46 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
47 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 47 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 */ 53 */
54 54
55 55
56#include <sys/cdefs.h> 56#include <sys/cdefs.h>
57__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.10 2020/04/20 11:29:01 bouyer Exp $"); 57__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.11 2020/04/20 19:46:44 bouyer Exp $");
58 58
59#include "opt_xen.h" 59#include "opt_xen.h"
60#include "isa.h" 60#include "isa.h"
61#include "pci.h" 61#include "pci.h"
62 62
63#include <sys/param.h> 63#include <sys/param.h>
64#include <sys/cpu.h> 64#include <sys/cpu.h>
65#include <sys/kernel.h> 65#include <sys/kernel.h>
66#include <sys/systm.h> 66#include <sys/systm.h>
67#include <sys/device.h> 67#include <sys/device.h>
68#include <sys/proc.h> 68#include <sys/proc.h>
69#include <sys/kmem.h> 69#include <sys/kmem.h>
70#include <sys/reboot.h> 70#include <sys/reboot.h>
@@ -875,30 +875,31 @@ event_set_handler(int evtch, int (*func) @@ -875,30 +875,31 @@ event_set_handler(int evtch, int (*func)
875 * api needs to be reshuffled so that this assumption 875 * api needs to be reshuffled so that this assumption
876 * is more explicitly implemented. 876 * is more explicitly implemented.
877 */ 877 */
878 evts->ev_cpu = ci; 878 evts->ev_cpu = ci;
879 mutex_init(&evtlock[evtch], MUTEX_DEFAULT, IPL_HIGH); 879 mutex_init(&evtlock[evtch], MUTEX_DEFAULT, IPL_HIGH);
880 evtsource[evtch] = evts; 880 evtsource[evtch] = evts;
881 strlcpy(evts->ev_intrname, intrname, sizeof(evts->ev_intrname)); 881 strlcpy(evts->ev_intrname, intrname, sizeof(evts->ev_intrname));
882 882
883 evcnt_attach_dynamic(&evts->ev_evcnt, EVCNT_TYPE_INTR, NULL, 883 evcnt_attach_dynamic(&evts->ev_evcnt, EVCNT_TYPE_INTR, NULL,
884 device_xname(ci->ci_dev), evts->ev_intrname); 884 device_xname(ci->ci_dev), evts->ev_intrname);
885 if (bind) { 885 if (bind) {
886 op.cmd = EVTCHNOP_bind_vcpu; 886 op.cmd = EVTCHNOP_bind_vcpu;
887 op.u.bind_vcpu.port = evtch; 887 op.u.bind_vcpu.port = evtch;
888 op.u.bind_vcpu.vcpu = ci->ci_cpuid; 888 op.u.bind_vcpu.vcpu = ci->ci_vcpuid;
889 if (HYPERVISOR_event_channel_op(&op) != 0) { 889 if (HYPERVISOR_event_channel_op(&op) != 0) {
890 panic("Failed to bind event %d to " 890 panic("Failed to bind event %d to VCPU %s %d",
891 "VCPU %"PRIuCPUID, evtch, ci->ci_cpuid); 891 evtch, device_xname(ci->ci_dev),
 892 ci->ci_vcpuid);
892 } 893 }
893 } 894 }
894 } else { 895 } else {
895 evts = evtsource[evtch]; 896 evts = evtsource[evtch];
896 /* sort by IPL order, higher first */ 897 /* sort by IPL order, higher first */
897 mutex_spin_enter(&evtlock[evtch]); 898 mutex_spin_enter(&evtlock[evtch]);
898 for (ihp = &evts->ev_handlers; ; ihp = &((*ihp)->ih_evt_next)) { 899 for (ihp = &evts->ev_handlers; ; ihp = &((*ihp)->ih_evt_next)) {
899 if ((*ihp)->ih_level < ih->ih_level) { 900 if ((*ihp)->ih_level < ih->ih_level) {
900 /* insert before *ihp */ 901 /* insert before *ihp */
901 ih->ih_evt_next = *ihp; 902 ih->ih_evt_next = *ihp;
902 *ihp = ih; 903 *ihp = ih;
903 break; 904 break;
904 } 905 }
@@ -945,35 +946,34 @@ event_set_iplhandler(struct cpu_info *ci @@ -945,35 +946,34 @@ event_set_iplhandler(struct cpu_info *ci
945 struct intrsource *ipls; 946 struct intrsource *ipls;
946 int sir = XEN_IPL2SIR(level); 947 int sir = XEN_IPL2SIR(level);
947 KASSERT(sir >= SIR_XENIPL_VM && sir <= SIR_XENIPL_HIGH); 948 KASSERT(sir >= SIR_XENIPL_VM && sir <= SIR_XENIPL_HIGH);
948 949
949 KASSERT(ci == ih->ih_cpu); 950 KASSERT(ci == ih->ih_cpu);
950 if (ci->ci_isources[sir] == NULL) { 951 if (ci->ci_isources[sir] == NULL) {
951 ipls = kmem_zalloc(sizeof (struct intrsource), 952 ipls = kmem_zalloc(sizeof (struct intrsource),
952 KM_NOSLEEP); 953 KM_NOSLEEP);
953 if (ipls == NULL) 954 if (ipls == NULL)
954 panic("can't allocate fixed interrupt source"); 955 panic("can't allocate fixed interrupt source");
955 ipls->is_recurse = xenev_stubs[level - IPL_VM].ist_recurse; 956 ipls->is_recurse = xenev_stubs[level - IPL_VM].ist_recurse;
956 ipls->is_resume = xenev_stubs[level - IPL_VM].ist_resume; 957 ipls->is_resume = xenev_stubs[level - IPL_VM].ist_resume;
957 ipls->is_handlers = ih; 958 ipls->is_handlers = ih;
958 ipls->is_maxlevel = level; 
959 ipls->is_pic = &xen_pic; 959 ipls->is_pic = &xen_pic;
960 ci->ci_isources[sir] = ipls; 960 ci->ci_isources[sir] = ipls;
961 x86_intr_calculatemasks(ci); 
962 } else { 961 } else {
963 ipls = ci->ci_isources[sir]; 962 ipls = ci->ci_isources[sir];
964 ih->ih_next = ipls->is_handlers; 963 ih->ih_next = ipls->is_handlers;
965 ipls->is_handlers = ih; 964 ipls->is_handlers = ih;
966 } 965 }
 966 x86_intr_calculatemasks(ci);
967} 967}
968 968
969int 969int
970event_remove_handler(int evtch, int (*func)(void *), void *arg) 970event_remove_handler(int evtch, int (*func)(void *), void *arg)
971{ 971{
972 struct intrsource *ipls; 972 struct intrsource *ipls;
973 struct evtsource *evts; 973 struct evtsource *evts;
974 struct intrhand *ih; 974 struct intrhand *ih;
975 struct intrhand **ihp; 975 struct intrhand **ihp;
976 struct cpu_info *ci; 976 struct cpu_info *ci;
977 977
978 evts = evtsource[evtch]; 978 evts = evtsource[evtch];
979 if (evts == NULL) 979 if (evts == NULL)