Sat Apr 18 20:36:31 2020 UTC ()
If we get an event for another CPU just ignore it. The hypervisor will
callback on the other CPU anyway.


(bouyer)
diff -r1.88.2.5 -r1.88.2.6 src/sys/arch/xen/xen/evtchn.c

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

--- src/sys/arch/xen/xen/evtchn.c 2020/04/18 15:06:18 1.88.2.5
+++ src/sys/arch/xen/xen/evtchn.c 2020/04/18 20:36:31 1.88.2.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: evtchn.c,v 1.88.2.5 2020/04/18 15:06:18 bouyer Exp $ */ 1/* $NetBSD: evtchn.c,v 1.88.2.6 2020/04/18 20:36:31 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.5 2020/04/18 15:06:18 bouyer Exp $"); 57__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.6 2020/04/18 20:36:31 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>
@@ -331,35 +331,34 @@ evtchn_do_event(int evtch, struct intrfr @@ -331,35 +331,34 @@ evtchn_do_event(int evtch, struct intrfr
331 * Shortcut for the debug handler, we want it to always run, 331 * Shortcut for the debug handler, we want it to always run,
332 * regardless of the IPL level. 332 * regardless of the IPL level.
333 */ 333 */
334 if (__predict_false(evtch == debug_port)) { 334 if (__predict_false(evtch == debug_port)) {
335 xen_debug_handler(NULL); 335 xen_debug_handler(NULL);
336 hypervisor_unmask_event(debug_port); 336 hypervisor_unmask_event(debug_port);
337#if NPCI > 0 || NISA > 0 337#if NPCI > 0 || NISA > 0
338 hypervisor_ack_pirq_event(debug_port); 338 hypervisor_ack_pirq_event(debug_port);
339#endif /* NPCI > 0 || NISA > 0 */  339#endif /* NPCI > 0 || NISA > 0 */
340 return 0; 340 return 0;
341 } 341 }
342 342
343 KASSERTMSG(evtsource[evtch] != NULL, "unknown event %d", evtch); 343 KASSERTMSG(evtsource[evtch] != NULL, "unknown event %d", evtch);
 344
 345 if (evtsource[evtch]->ev_cpu != ci)
 346 return 0;
 347
344 ci->ci_data.cpu_nintr++; 348 ci->ci_data.cpu_nintr++;
345 evtsource[evtch]->ev_evcnt.ev_count++; 349 evtsource[evtch]->ev_evcnt.ev_count++;
346 ilevel = ci->ci_ilevel; 350 ilevel = ci->ci_ilevel;
347 351
348 if (evtsource[evtch]->ev_cpu != ci /* XXX: get stats */) { 
349 hypervisor_send_event(evtsource[evtch]->ev_cpu, evtch); 
350 return 0; 
351 } 
352 
353 if (evtsource[evtch]->ev_maxlevel <= ilevel) { 352 if (evtsource[evtch]->ev_maxlevel <= ilevel) {
354#ifdef IRQ_DEBUG 353#ifdef IRQ_DEBUG
355 if (evtch == IRQ_DEBUG) 354 if (evtch == IRQ_DEBUG)
356 printf("evtsource[%d]->ev_maxlevel %d <= ilevel %d\n", 355 printf("evtsource[%d]->ev_maxlevel %d <= ilevel %d\n",
357 evtch, evtsource[evtch]->ev_maxlevel, ilevel); 356 evtch, evtsource[evtch]->ev_maxlevel, ilevel);
358#endif 357#endif
359 hypervisor_set_ipending(evtsource[evtch]->ev_imask, 358 hypervisor_set_ipending(evtsource[evtch]->ev_imask,
360 evtch >> LONG_SHIFT, 359 evtch >> LONG_SHIFT,
361 evtch & LONG_MASK); 360 evtch & LONG_MASK);
362 361
363 /* leave masked */ 362 /* leave masked */
364 363
365 return 0; 364 return 0;