Module Name: src
Committed By: bouyer
Date: Sun Jan 13 21:01:05 UTC 2013
Modified Files:
src/sys/arch/xen/include: hypervisor.h
src/sys/arch/xen/x86: hypervisor_machdep.c
src/sys/arch/xen/xen: evtchn.c
Log Message:
Re-apply
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039125.html
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039126.html
they're not involved in i386 domU hang shown by ATF.
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/xen/xen/evtchn.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/xen/include/hypervisor.h
diff -u src/sys/arch/xen/include/hypervisor.h:1.42 src/sys/arch/xen/include/hypervisor.h:1.43
--- src/sys/arch/xen/include/hypervisor.h:1.42 Sat Jan 12 21:09:10 2013
+++ src/sys/arch/xen/include/hypervisor.h Sun Jan 13 21:01:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.h,v 1.42 2013/01/12 21:09:10 bouyer Exp $ */
+/* $NetBSD: hypervisor.h,v 1.43 2013/01/13 21:01:05 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -142,8 +142,7 @@ void hypervisor_unmask_event(unsigned in
void hypervisor_mask_event(unsigned int);
void hypervisor_clear_event(unsigned int);
void hypervisor_enable_ipl(unsigned int);
-void hypervisor_set_ipending(struct cpu_info *,
- uint32_t, int, int);
+void hypervisor_set_ipending(uint32_t, int, int);
void hypervisor_machdep_attach(void);
void hypervisor_machdep_resume(void);
Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.26 src/sys/arch/xen/x86/hypervisor_machdep.c:1.27
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.26 Sat Jan 12 21:09:10 2013
+++ src/sys/arch/xen/x86/hypervisor_machdep.c Sun Jan 13 21:01:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor_machdep.c,v 1.26 2013/01/12 21:09:10 bouyer Exp $ */
+/* $NetBSD: hypervisor_machdep.c,v 1.27 2013/01/13 21:01:05 bouyer Exp $ */
/*
*
@@ -54,7 +54,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.26 2013/01/12 21:09:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.27 2013/01/13 21:01:05 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -87,11 +87,11 @@ static void update_p2m_frame_list_list(v
// #define EARLY_DEBUG_EVENT
/* callback function type */
-typedef void (*iterate_func_t)(struct cpu_info *, unsigned int,
- unsigned int, unsigned int, void *);
+typedef void (*iterate_func_t)(unsigned int, unsigned int,
+ unsigned int, void *);
static inline void
-evt_iterate_bits(struct cpu_info *ci, volatile unsigned long *pendingl1,
+evt_iterate_bits(volatile unsigned long *pendingl1,
volatile unsigned long *pendingl2,
volatile unsigned long *mask,
iterate_func_t iterate_pending, void *iterate_args)
@@ -109,7 +109,7 @@ evt_iterate_bits(struct cpu_info *ci, vo
l1 &= ~(1UL << l1i);
l2 = pendingl2[l1i] & (mask != NULL ? ~mask[l1i] : -1UL);
- l2 &= ci->ci_evtmask[l1i];
+ l2 &= curcpu()->ci_evtmask[l1i];
if (mask != NULL) xen_atomic_setbits_l(&mask[l1i], l2);
xen_atomic_clearbits_l(&pendingl2[l1i], l2);
@@ -120,7 +120,7 @@ evt_iterate_bits(struct cpu_info *ci, vo
port = (l1i << LONG_SHIFT) + l2i;
- iterate_pending(ci, port, l1i, l2i, iterate_args);
+ iterate_pending(port, l1i, l2i, iterate_args);
}
}
}
@@ -131,20 +131,18 @@ evt_iterate_bits(struct cpu_info *ci, vo
*/
static inline void
-evt_set_pending(struct cpu_info *ci, unsigned int port, unsigned int l1i,
+evt_set_pending(unsigned int port, unsigned int l1i,
unsigned int l2i, void *args)
{
KASSERT(args != NULL);
- KASSERT(ci != NULL);
int *ret = args;
if (evtsource[port]) {
- hypervisor_set_ipending(evtsource[port]->ev_cpu,
- evtsource[port]->ev_imask, l1i, l2i);
+ hypervisor_set_ipending(evtsource[port]->ev_imask, l1i, l2i);
evtsource[port]->ev_evcnt.ev_count++;
- if (*ret == 0 && ci->ci_ilevel <
+ if (*ret == 0 && curcpu()->ci_ilevel <
evtsource[port]->ev_maxlevel)
*ret = 1;
}
@@ -193,7 +191,7 @@ stipending(void)
vci->evtchn_upcall_pending = 0;
- evt_iterate_bits(ci, &vci->evtchn_pending_sel,
+ evt_iterate_bits(&vci->evtchn_pending_sel,
s->evtchn_pending, s->evtchn_mask,
evt_set_pending, &ret);
@@ -214,12 +212,12 @@ stipending(void)
/* Iterate through pending events and call the event handler */
static inline void
-evt_do_hypervisor_callback(struct cpu_info *ci, unsigned int port,
- unsigned int l1i, unsigned int l2i, void *args)
+evt_do_hypervisor_callback(unsigned int port, unsigned int l1i,
+ unsigned int l2i, void *args)
{
KASSERT(args != NULL);
- KASSERT(ci == curcpu());
+ struct cpu_info *ci = curcpu();
struct intrframe *regs = args;
#ifdef PORT_DEBUG
@@ -273,7 +271,7 @@ do_hypervisor_callback(struct intrframe
while (vci->evtchn_upcall_pending) {
vci->evtchn_upcall_pending = 0;
- evt_iterate_bits(ci, &vci->evtchn_pending_sel,
+ evt_iterate_bits(&vci->evtchn_pending_sel,
s->evtchn_pending, s->evtchn_mask,
evt_do_hypervisor_callback, regs);
}
@@ -390,10 +388,9 @@ hypervisor_clear_event(unsigned int ev)
}
static inline void
-evt_enable_event(struct cpu_info *ci, unsigned int port,
- unsigned int l1i, unsigned int l2i, void *args)
+evt_enable_event(unsigned int port, unsigned int l1i,
+ unsigned int l2i, void *args)
{
- KASSERT(ci != NULL);
KASSERT(args == NULL);
hypervisor_enable_event(port);
}
@@ -409,16 +406,21 @@ hypervisor_enable_ipl(unsigned int ipl)
* we know that all callback for this event have been processed.
*/
- evt_iterate_bits(ci, &ci->ci_isources[ipl]->ipl_evt_mask1,
+ evt_iterate_bits(&ci->ci_isources[ipl]->ipl_evt_mask1,
ci->ci_isources[ipl]->ipl_evt_mask2, NULL,
evt_enable_event, NULL);
}
void
-hypervisor_set_ipending(struct cpu_info *ci, uint32_t iplmask, int l1, int l2)
+hypervisor_set_ipending(uint32_t iplmask, int l1, int l2)
{
+
+ /* This function is not re-entrant */
+ KASSERT(x86_read_psl() != 0);
+
int ipl;
+ struct cpu_info *ci = curcpu();
/* set pending bit for the appropriate IPLs */
ci->ci_ipending |= iplmask;
Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.68 src/sys/arch/xen/xen/evtchn.c:1.69
--- src/sys/arch/xen/xen/evtchn.c:1.68 Sat Jan 12 21:09:10 2013
+++ src/sys/arch/xen/xen/evtchn.c Sun Jan 13 21:01:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: evtchn.c,v 1.68 2013/01/12 21:09:10 bouyer Exp $ */
+/* $NetBSD: evtchn.c,v 1.69 2013/01/13 21:01:05 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.68 2013/01/12 21:09:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.69 2013/01/13 21:01:05 bouyer Exp $");
#include "opt_xen.h"
#include "isa.h"
@@ -282,8 +282,7 @@ evtchn_do_event(int evtch, struct intrfr
printf("evtsource[%d]->ev_maxlevel %d <= ilevel %d\n",
evtch, evtsource[evtch]->ev_maxlevel, ilevel);
#endif
- hypervisor_set_ipending(evtsource[evtch]->ev_cpu,
- evtsource[evtch]->ev_imask,
+ hypervisor_set_ipending(evtsource[evtch]->ev_imask,
evtch >> LONG_SHIFT,
evtch & LONG_MASK);
@@ -298,21 +297,18 @@ evtchn_do_event(int evtch, struct intrfr
ih = evtsource[evtch]->ev_handlers;
while (ih != NULL) {
if (ih->ih_cpu != ci) {
- hypervisor_set_ipending(ih->ih_cpu, 1 << ih->ih_level,
- evtch >> LONG_SHIFT, evtch & LONG_MASK);
+ hypervisor_send_event(ih->ih_cpu, evtch);
iplmask &= ~IUNMASK(ci, ih->ih_level);
ih = ih->ih_evt_next;
continue;
}
if (ih->ih_level <= ilevel) {
- hypervisor_set_ipending(ih->ih_cpu, iplmask,
- evtch >> LONG_SHIFT, evtch & LONG_MASK);
#ifdef IRQ_DEBUG
if (evtch == IRQ_DEBUG)
printf("ih->ih_level %d <= ilevel %d\n", ih->ih_level, ilevel);
#endif
cli();
- hypervisor_set_ipending(ih->ih_cpu, iplmask,
+ hypervisor_set_ipending(iplmask,
evtch >> LONG_SHIFT, evtch & LONG_MASK);
/* leave masked */
mutex_spin_exit(&evtlock[evtch]);