CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Wed Oct 24 03:59:33 UTC 2018 Modified Files: src/sys/arch/xen/x86: xen_ipi.c src/sys/arch/xen/xen: clock.c if_xennet_xenbus.c pciback.c xbd_xenbus.c xbdback_xenbus.c xencons.c xenevt.c xennetback_xenbus.c xpci_xenbus.c src/sys/arch/xen/xenbus: xenbus_comms.c Log Message: When using the intr_establish_xname() interface to register XEN events, follow established x86/intr.c conventions - set the 'legacy' irq value to -1, to indicate that the pic, pin combination (_pic, port) is used for registration. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.79 -r1.80 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/xen/xen/pciback.c cvs rdiff -u -r1.88 -r1.89 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/xen/xen/xbdback_xenbus.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/xen/xen/xencons.c cvs rdiff -u -r1.50 -r1.51 src/sys/arch/xen/xen/xenevt.c cvs rdiff -u -r1.69 -r1.70 src/sys/arch/xen/xen/xennetback_xenbus.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/xen/xpci_xenbus.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/xenbus/xenbus_comms.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/x86/xen_ipi.c diff -u src/sys/arch/xen/x86/xen_ipi.c:1.26 src/sys/arch/xen/x86/xen_ipi.c:1.27 --- src/sys/arch/xen/x86/xen_ipi.c:1.26 Tue Jul 24 12:26:14 2018 +++ src/sys/arch/xen/x86/xen_ipi.c Wed Oct 24 03:59:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_ipi.c,v 1.26 2018/07/24 12:26:14 bouyer Exp $ */ +/* $NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -33,10 +33,10 @@ /* * Based on: x86/ipi.c - * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.26 2018/07/24 12:26:14 bouyer Exp $"); + * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.26 2018/07/24 12:26:14 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $"); #include "opt_ddb.h" @@ -137,7 +137,7 @@ xen_ipi_init(void) snprintf(intr_xname, sizeof(intr_xname), "%s ipi", device_xname(ci->ci_dev)); - if (intr_establish_xname(0, _pic, evtchn, IST_LEVEL, IPL_HIGH, + if (intr_establish_xname(-1, _pic, evtchn, IST_LEVEL, IPL_HIGH, xen_ipi_handler, ci, true, intr_xname) == NULL) { panic("%s: unable to register ipi handler\n", __func__); /* NOTREACHED */ Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.70 src/sys/arch/xen/xen/clock.c:1.71 --- src/sys/arch/xen/xen/clock.c:1.70 Sat Jun 30 14:59:38 2018 +++ src/sys/arch/xen/xen/clock.c Wed Oct 24 03:59:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.70 2018/06/30 14:59:38 riastradh Exp $ */ +/* $NetBSD: clock.c,v 1.71 2018/10/24 03:59:33 cherry Exp $ */ /*- * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.70 2018/06/30 14:59:38 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.71 2018/10/24 03:59:33 cherry Exp $"); #include #include @@ -763,7 +763,7 @@ xen_resumeclocks(struct cpu_info *ci) snprintf(intr_xname, sizeof(intr_xname), "%s clock", device_xname(ci->ci_dev)); /* XXX sketchy function pointer cast -- fix the API, please */ - ci->ci_xen_timer_intrhand = intr_establish_xname(0, _pic, evtch, + ci->ci_xen_timer_intrhand = intr_establish_xname(-1, _pic, evtch, IST_LEVEL, IPL_CLOCK, (int (*)(void *))xen_timer_handler, ci, true, intr_xname); if (ci->ci_xen_timer_intrhand == NULL) Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.79 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.80 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.79 Mon Sep 3 16:29:29 2018 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Wed Oct 24 03:59:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.79 2018/09/03 16:29:29 riastradh Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.80 2018/10/24 03:59:33 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.79 2018/09/03 16:29:29 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.80 2018/10/24 03:59:33 cherry Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -517,7 +517,7 @@ xennet_xenbus_resume(device_t dev, const goto abort_resume; aprint_verbose_dev(dev, "using event channel %d\n", sc->sc_evtchn); - sc->sc_ih = intr_establish_xname(0, _pic, sc->sc_evtchn, IST_LEVEL, + sc->sc_ih = intr_establish_xname(-1, _pic, sc->sc_evtchn, IST_LEVEL, IPL_NET, _handler, sc, false,
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Nov 18 10:24:10 UTC 2018 Modified Files: src/sys/arch/x86/include: cpu.h src/sys/arch/xen/x86: hypervisor_machdep.c src/sys/arch/xen/xen: clock.c Log Message: Save the interrupt trap/clockframe to a per-cpu copy. We can use this copy to pass on the trapframe to hardclock(9) from within the xen timer handler. This delinks the current dependency between MD code and the handler, which is specially prototyped to take the clockframe unlike any other handler. This change has performance implications, as each interrupt entry will copy the entire trapframe over to the per-cpu cached copy. This can be mitigated by selectively copying just the parts of the clockframe that are used by hardclock() et. al. Tested on amd64 XEN domU To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.72 -r1.73 src/sys/arch/xen/xen/clock.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/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.98 src/sys/arch/x86/include/cpu.h:1.99 --- src/sys/arch/x86/include/cpu.h:1.98 Fri Oct 5 18:51:52 2018 +++ src/sys/arch/x86/include/cpu.h Sun Nov 18 10:24:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.98 2018/10/05 18:51:52 maxv Exp $ */ +/* $NetBSD: cpu.h,v 1.99 2018/11/18 10:24:09 cherry Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -94,6 +94,15 @@ struct cpu_tss { } __packed; /* + * Arguments to hardclock, softclock and statclock + * encapsulate the previous machine state in an opaque + * clockframe; for now, use generic intrframe. + */ +struct clockframe { + struct intrframe cf_if; +}; + +/* * a bunch of this belongs in cpuvar.h; move it later.. */ @@ -273,6 +282,12 @@ struct cpu_info { /* Xen periodic timer interrupt handle. */ struct intrhand *ci_xen_timer_intrhand; + /* + * Clockframe for timer interrupt handler. + * Saved at entry via event callback. + */ + struct clockframe ci_event_clockframe; + /* Event counters for various pathologies that might happen. */ struct evcnt ci_xen_cpu_tsc_backwards_evcnt; struct evcnt ci_xen_tsc_delta_negative_evcnt; @@ -378,15 +393,6 @@ void cpu_speculation_init(struct cpu_inf #define curpcb ((struct pcb *)lwp_getpcb(curlwp)) /* - * Arguments to hardclock, softclock and statclock - * encapsulate the previous machine state in an opaque - * clockframe; for now, use generic intrframe. - */ -struct clockframe { - struct intrframe cf_if; -}; - -/* * Give a profiling tick to the current process when the user profiling * buffer pages are invalid. On the i386, request an ast to send us * through trap(), marking the proc as needing a profiling tick. Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.30 src/sys/arch/xen/x86/hypervisor_machdep.c:1.31 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.30 Sat Nov 17 05:26:46 2018 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sun Nov 18 10:24:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.30 2018/11/17 05:26:46 cherry Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.31 2018/11/18 10:24:09 cherry Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.30 2018/11/17 05:26:46 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.31 2018/11/18 10:24:09 cherry Exp $"); #include #include @@ -261,6 +261,10 @@ do_hypervisor_callback(struct intrframe vci = ci->ci_vcpu; level = ci->ci_ilevel; + /* Save trapframe for clock handler */ + KASSERT(regs != NULL); + ci->ci_event_clockframe.cf_if = *regs; + // DDD printf("do_hypervisor_callback\n"); #ifdef EARLY_DEBUG_EVENT Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.72 src/sys/arch/xen/xen/clock.c:1.73 --- src/sys/arch/xen/xen/clock.c:1.72 Fri Oct 26 05:33:21 2018 +++ src/sys/arch/xen/xen/clock.c Sun Nov 18 10:24:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.72 2018/10/26 05:33:21 cherry Exp $ */ +/* $NetBSD: clock.c,v 1.73 2018/11/18 10:24:10 cherry Exp $ */ /*- * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.72 2018/10/26 05:33:21 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.73 2018/11/18 10:24:10 cherry Exp $"); #include #include @@ -811,6 +811,7 @@ xen_timer_handler(void *cookie, struct c KASSERT(cpu_intr_p()); KASSERT(cookie == ci); + frame = >ci_event_clockframe; again: /* * Find how many nanoseconds of Xen system time has elapsed
CVS commit: src/sys/arch/xen/x86
Module Name:src Committed By: cherry Date: Sat Oct 6 16:37:11 UTC 2018 Modified Files: src/sys/arch/xen/x86: pintr.c Log Message: Teach intr_establish_xname() for XEN to tolerate shared legacy_irq registrations. The current XEN code has not been able to tolerate shared legacy_irq requests in xen_pirq_alloc(). This was never a problem because: i) The only potential callpath with shared legacy_irq was isa_intr_establish_xname(). ii) The other callpath, namely pci_intr_establish_xname() passed legacy_irq to intr_establish_xname(). However, this was ignored, and a value of zero was passed to xen_pirq_alloc() which in turn, allocated a new irq value, thus effectively demultiplexing any shared legacy_irq value intended across randomly allocated new irq values. iii) Presumably on all platforms that XEN runs on, the isa callpath mentioned in i) never had shared irqs, and thus this was never a problem. Except: We now use a unified path for both isa_intr_establish_xname() and pci_intr_establish_xname(). This means that now, intr_establish_xname() which is a callee of both, needs to have a way to discern who the caller was, and decide to pass on or discard the legacy_irq value, to preserve the old semantics. However, this is impossible to do so, because the callpath doesn't explicitly provide a mechanism for this discernment. This is however not a problem, because from XEN's point of view, a repeat registration of an irq is only a warning. legacy_irq is the only case in which this repeat should occur, per the current implementation of xen_pirq_alloc(). We thus tweak the KASSERT()s to tolerate a repeat value in the legacy_irq, while maintaining the original intent of the KASSERT() which was to ensure that existing unrelated irq registrations should never be overwritten. Once we re-organise XEN specific code and unify with the native intr_establish_xname() path, we will not run into this problem, because legacy_irq will be treated as the pin number of the i8259 pic exactly as it is now treated in native. In short, this commit should fix some of the panics being seen on -current for certain configurations of hardware on which dom0 runs. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/xen/x86/pintr.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/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.3 src/sys/arch/xen/x86/pintr.c:1.4 --- src/sys/arch/xen/x86/pintr.c:1.3 Sat Feb 17 18:51:53 2018 +++ src/sys/arch/xen/x86/pintr.c Sat Oct 6 16:37:11 2018 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.3 2018/02/17 18:51:53 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.4 2018/10/06 16:37:11 cherry Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -199,9 +199,13 @@ retry: panic("PHYSDEVOP_ASSIGN_VECTOR irq %d", irq); goto retry; } - KASSERT(irq2vect[irq] == 0); + KASSERT(irq2vect[irq] == 0 || +(irq > 0 && irq < 16 && + irq2vect[irq] == op.u.irq_op.vector)); irq2vect[irq] = op.u.irq_op.vector; - KASSERT(vect2irq[op.u.irq_op.vector] == 0); + KASSERT(vect2irq[op.u.irq_op.vector] == 0 || +(irq > 0 && irq < 16 && + vect2irq[op.u.irq_op.vector] == irq)); vect2irq[op.u.irq_op.vector] = irq; pic->pic_addroute(pic, _info_primary, pin, op.u.irq_op.vector, type);
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sat Oct 6 16:44:55 UTC 2018 Modified Files: src/sys/arch/x86/x86: intr.c src/sys/arch/xen/x86: pintr.c Log Message: Move the pic->pic_addroute() call from within pintr.c:xen_pirq_alloc() to intr.c:intr_establish_xname() xen_pirq_alloc() now returns a vector value, as is intended by the semantics of the call to the hypervisor, PHYSDEVOP_ASSIGN_VECTOR. This also brings our usage closer to native. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/xen/x86/pintr.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/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.130 src/sys/arch/x86/x86/intr.c:1.131 --- src/sys/arch/x86/x86/intr.c:1.130 Thu Sep 20 05:08:45 2018 +++ src/sys/arch/x86/x86/intr.c Sat Oct 6 16:44:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.130 2018/09/20 05:08:45 cherry Exp $ */ +/* $NetBSD: intr.c,v 1.131 2018/10/06 16:44:55 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.130 2018/09/20 05:08:45 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.131 2018/10/06 16:44:55 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1264,7 +1264,7 @@ intr_establish_xname(int legacy_irq, str #if NPCI > 0 || NISA > 0 struct pintrhand *pih; intr_handle_t irq; - int evtchn; + int vector, evtchn; KASSERTMSG(legacy_irq == -1 || (0 <= legacy_irq && legacy_irq < NUM_XEN_IRQS), "bad legacy IRQ value: %d", legacy_irq); @@ -1290,10 +1290,21 @@ intr_establish_xname(int legacy_irq, str intrstr = intr_create_intrid(irq, pic, pin, intrstr_buf, sizeof(intrstr_buf)); - evtchn = xen_pirq_alloc(, type); - irq = (legacy_irq == -1) ? irq : legacy_irq; /* ISA compat */ + vector = xen_pirq_alloc(, type); + irq = (legacy_irq == -1) ? irq : legacy_irq; /* ISA compat */ + +#if NIOAPIC > 0 + extern struct cpu_info phycpu_info_primary; /* XXX */ + struct cpu_info *ci = _info_primary; + pic->pic_addroute(pic, ci, pin, vector, type); +#else + +#endif /* NIOAPIC */ + evtchn = irq2port[vect2irq[vector]]; + KASSERT(evtchn > 0); + pih = pirq_establish(irq & 0xff, evtchn, handler, arg, level, - intrstr, xname); + intrstr, xname); pih->pic_type = pic->pic_type; return pih; #endif /* NPCI > 0 || NISA > 0 */ Index: src/sys/arch/xen/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.4 src/sys/arch/xen/x86/pintr.c:1.5 --- src/sys/arch/xen/x86/pintr.c:1.4 Sat Oct 6 16:37:11 2018 +++ src/sys/arch/xen/x86/pintr.c Sat Oct 6 16:44:55 2018 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.4 2018/10/06 16:37:11 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.5 2018/10/06 16:44:55 cherry Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -165,7 +165,7 @@ xen_pirq_alloc(intr_handle_t *pirq, int physdev_op_t op; int irq = *pirq; #if NIOAPIC > 0 - extern struct cpu_info phycpu_info_primary; /* XXX */ + /* * The hypervisor has already allocated vectors and IRQs for the * devices. Reusing the same IRQ doesn't work because as we bind @@ -179,7 +179,6 @@ xen_pirq_alloc(intr_handle_t *pirq, int */ static int xen_next_irq = 200; struct ioapic_softc *ioapic = ioapic_find(APIC_IRQ_APIC(*pirq)); - struct pic *pic = >sc_pic; int pin = APIC_IRQ_PIN(*pirq); if (*pirq & APIC_INT_VIA_APIC) { @@ -207,8 +206,6 @@ retry: (irq > 0 && irq < 16 && vect2irq[op.u.irq_op.vector] == irq)); vect2irq[op.u.irq_op.vector] = irq; - pic->pic_addroute(pic, _info_primary, pin, - op.u.irq_op.vector, type); } *pirq &= ~0xff; *pirq |= irq; @@ -229,7 +226,6 @@ retry: irq2port[irq] = bind_pirq_to_evtch(irq) + 1; } } - KASSERT(irq2port[irq] > 0); - return (irq2port[irq] - 1); + return (irq2vect[irq]); } #endif /* defined(DOM0OPS) || NPCI > 0 */
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sat Oct 6 16:49:54 UTC 2018 Modified Files: src/sys/arch/x86/x86: intr.c src/sys/arch/xen/include: intr.h src/sys/arch/xen/x86: pintr.c Log Message: Change the name of xen_pirq_alloc() to xen_vec_alloc() to reflect its actual job. The idea is that we will strip this down until it is as close to idt_vec_alloc() as possible. To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/xen/include/intr.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/xen/x86/pintr.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/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.131 src/sys/arch/x86/x86/intr.c:1.132 --- src/sys/arch/x86/x86/intr.c:1.131 Sat Oct 6 16:44:55 2018 +++ src/sys/arch/x86/x86/intr.c Sat Oct 6 16:49:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.131 2018/10/06 16:44:55 cherry Exp $ */ +/* $NetBSD: intr.c,v 1.132 2018/10/06 16:49:54 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.131 2018/10/06 16:44:55 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.132 2018/10/06 16:49:54 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1290,7 +1290,8 @@ intr_establish_xname(int legacy_irq, str intrstr = intr_create_intrid(irq, pic, pin, intrstr_buf, sizeof(intrstr_buf)); - vector = xen_pirq_alloc(, type); + vector = xen_vec_alloc(irq); + irq = vect2irq[vector]; irq = (legacy_irq == -1) ? irq : legacy_irq; /* ISA compat */ #if NIOAPIC > 0 Index: src/sys/arch/xen/include/intr.h diff -u src/sys/arch/xen/include/intr.h:1.46 src/sys/arch/xen/include/intr.h:1.47 --- src/sys/arch/xen/include/intr.h:1.46 Sun Jun 24 13:35:32 2018 +++ src/sys/arch/xen/include/intr.h Sat Oct 6 16:49:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.46 2018/06/24 13:35:32 jdolecek Exp $ */ +/* $NetBSD: intr.h,v 1.47 2018/10/06 16:49:54 cherry Exp $ */ /* NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp */ /*- @@ -71,7 +71,7 @@ int xen_intr_biglock_wrapper(void *); #endif #if defined(DOM0OPS) || NPCI > 0 -int xen_pirq_alloc(intr_handle_t *, int); +int xen_vec_alloc(intr_handle_t); #endif /* defined(DOM0OPS) || NPCI > 0 */ #ifdef MULTIPROCESSOR Index: src/sys/arch/xen/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.5 src/sys/arch/xen/x86/pintr.c:1.6 --- src/sys/arch/xen/x86/pintr.c:1.5 Sat Oct 6 16:44:55 2018 +++ src/sys/arch/xen/x86/pintr.c Sat Oct 6 16:49:54 2018 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.5 2018/10/06 16:44:55 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.6 2018/10/06 16:49:54 cherry Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -160,10 +160,10 @@ int vect2irq[256] = {0}; #if defined(DOM0OPS) || NPCI > 0 int -xen_pirq_alloc(intr_handle_t *pirq, int type) +xen_vec_alloc(intr_handle_t pirq) { physdev_op_t op; - int irq = *pirq; + int irq = pirq; #if NIOAPIC > 0 /* @@ -178,14 +178,14 @@ xen_pirq_alloc(intr_handle_t *pirq, int * or none is available. */ static int xen_next_irq = 200; - struct ioapic_softc *ioapic = ioapic_find(APIC_IRQ_APIC(*pirq)); - int pin = APIC_IRQ_PIN(*pirq); + struct ioapic_softc *ioapic = ioapic_find(APIC_IRQ_APIC(pirq)); + int pin = APIC_IRQ_PIN(pirq); - if (*pirq & APIC_INT_VIA_APIC) { + if (pirq & APIC_INT_VIA_APIC) { irq = vect2irq[ioapic->sc_pins[pin].ip_vector]; if (ioapic->sc_pins[pin].ip_vector == 0 || irq == 0) { /* allocate IRQ */ - irq = APIC_IRQ_LEGACY_IRQ(*pirq); + irq = APIC_IRQ_LEGACY_IRQ(pirq); if (irq <= 0 || irq > 15) irq = xen_next_irq--; retry: @@ -207,8 +207,6 @@ retry: vect2irq[op.u.irq_op.vector] == irq)); vect2irq[op.u.irq_op.vector] = irq; } - *pirq &= ~0xff; - *pirq |= irq; } else #endif /* NIOAPIC */ {
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Fri Oct 26 05:33:21 UTC 2018 Modified Files: src/sys/arch/xen/include: hypervisor.h src/sys/arch/xen/x86: hypervisor_machdep.c xen_ipi.c src/sys/arch/xen/xen: clock.c evtchn.c if_xennet_xenbus.c pciback.c xbd_xenbus.c xbdback_xenbus.c xencons.c xennetback_xenbus.c src/sys/arch/xen/xenbus: xenbus_comms.c Log Message: Decompose hypervisor_enable_event() into functional steps. The hypervisor_unmask_event() step is relevant for any event. The pirq related step is only relevant for pirq bound events. Prune blanket usage of this, so that usage is semantically appropriate. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.28 -r1.29 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.71 -r1.72 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.81 -r1.82 src/sys/arch/xen/xen/evtchn.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/xen/xen/pciback.c cvs rdiff -u -r1.89 -r1.90 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.68 -r1.69 src/sys/arch/xen/xen/xbdback_xenbus.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/xen/xencons.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/xen/xen/xennetback_xenbus.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/xenbus/xenbus_comms.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.45 src/sys/arch/xen/include/hypervisor.h:1.46 --- src/sys/arch/xen/include/hypervisor.h:1.45 Sun Sep 23 02:27:24 2018 +++ src/sys/arch/xen/include/hypervisor.h Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.45 2018/09/23 02:27:24 cherry Exp $ */ +/* $NetBSD: hypervisor.h,v 1.46 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -55,7 +55,8 @@ #define _XEN_HYPERVISOR_H_ #include "opt_xen.h" - +#include "isa.h" +#include "pci.h" struct hypervisor_attach_args { const char *haa_busname; @@ -130,8 +131,10 @@ extern volatile shared_info_t *HYPERVISO struct intrframe; struct cpu_info; void do_hypervisor_callback(struct intrframe *regs); +#if NPCI > 0 || NISA > 0 void hypervisor_prime_pirq_event(int, unsigned int); -void hypervisor_enable_event(unsigned int); +void hypervisor_ack_pirq_event(unsigned int); +#endif /* NPCI > 0 || NISA > 0 */ extern int xen_version; #define XEN_MAJOR(x) (((x) & 0x) >> 16) Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.28 src/sys/arch/xen/x86/hypervisor_machdep.c:1.29 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.28 Sun Sep 21 12:46:15 2014 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.28 2014/09/21 12:46:15 bouyer Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.29 2018/10/26 05:33:21 cherry Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.28 2014/09/21 12:46:15 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.29 2018/10/26 05:33:21 cherry Exp $"); #include #include @@ -71,6 +71,8 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor_m #include #include "opt_xen.h" +#include "isa.h" +#include "pci.h" /* * arch-dependent p2m frame lists list (L3 and L2) @@ -392,7 +394,10 @@ evt_enable_event(unsigned int port, unsi unsigned int l2i, void *args) { KASSERT(args == NULL); - hypervisor_enable_event(port); + hypervisor_unmask_event(port); +#if NPCI > 0 || NISA > 0 + hypervisor_ack_pirq_event(port); +#endif /* NPCI > 0 || NISA > 0 */ } void Index: src/sys/arch/xen/x86/xen_ipi.c diff -u src/sys/arch/xen/x86/xen_ipi.c:1.27 src/sys/arch/xen/x86/xen_ipi.c:1.28 --- src/sys/arch/xen/x86/xen_ipi.c:1.27 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/x86/xen_ipi.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xen_ipi.c,v 1.28 2018/10/26 05:33:21 cherry Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -33,10 +33,10 @@ /* * Based on: x86/ipi.c - * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $"); + * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.28 2018/10/26 05:33:21 cherry Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.28 2018/10/26 05:33:21 cherry Exp $"); #include "opt_ddb.h" @@ -143,7 +143,7 @@ xen_ipi_init(void) /* NOTREACHED */ } - hypervisor_enable_event(evtchn); + hypervisor_unmask_event(evtchn); } #ifdef DIAGNOSTIC Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.71
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Sun Oct 7 16:36:36 UTC 2018 Modified Files: src/sys/arch/x86/x86: i8259.c ioapic.c Log Message: In the case of a shared GSI, bind will fail, so we do not attempt this. The sharing is accomplished by demultiplexing the port event of the first bind. This is accomplished in intr.c:intr_establish_xname() Note that the pic_delroute() is buggy (commented suitably) for the shared gsi case, since it will unbind reset it unconditionally, leaving the other shared callbacks stranded. This problem will go awaywhen we unify further with native code, as this case is taken care of appropriately in that case. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/x86/i8259.c cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/x86/ioapic.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/x86/x86/i8259.c diff -u src/sys/arch/x86/x86/i8259.c:1.19 src/sys/arch/x86/x86/i8259.c:1.20 --- src/sys/arch/x86/x86/i8259.c:1.19 Sun Oct 7 05:28:51 2018 +++ src/sys/arch/x86/x86/i8259.c Sun Oct 7 16:36:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: i8259.c,v 1.19 2018/10/07 05:28:51 cherry Exp $ */ +/* $NetBSD: i8259.c,v 1.20 2018/10/07 16:36:36 cherry Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.19 2018/10/07 05:28:51 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.20 2018/10/07 16:36:36 cherry Exp $"); #include #include @@ -267,6 +267,14 @@ i8259_setup(struct pic *pic, struct cpu_ int port, irq; irq = vect2irq[idtvec]; KASSERT(irq != 0); + if (irq2port[irq] != 0) { + /* + * Shared interrupt - we can't rebind. + * The port is shared instead. + */ + return; + } + port = bind_pirq_to_evtch(irq); KASSERT(port < NR_EVENT_CHANNELS); KASSERT(port >= 0); @@ -292,6 +300,7 @@ i8259_unsetup(struct pic *pic, struct cp KASSERT(port < NR_EVENT_CHANNELS); + /* XXX: This is problematic for shared interrupts */ KASSERT(irq2port[irq] != 0); irq2port[irq] = 0; Index: src/sys/arch/x86/x86/ioapic.c diff -u src/sys/arch/x86/x86/ioapic.c:1.57 src/sys/arch/x86/x86/ioapic.c:1.58 --- src/sys/arch/x86/x86/ioapic.c:1.57 Sun Oct 7 05:28:51 2018 +++ src/sys/arch/x86/x86/ioapic.c Sun Oct 7 16:36:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ioapic.c,v 1.57 2018/10/07 05:28:51 cherry Exp $ */ +/* $NetBSD: ioapic.c,v 1.58 2018/10/07 16:36:36 cherry Exp $ */ /*- * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.57 2018/10/07 05:28:51 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.58 2018/10/07 16:36:36 cherry Exp $"); #include "opt_ddb.h" @@ -576,6 +576,15 @@ ioapic_addroute(struct pic *pic, struct int port, irq; irq = vect2irq[idtvec]; KASSERT(irq != 0); + + if (irq2port[irq] != 0) { + /* + * Shared interrupt - we can't rebind. + * The port is shared instead. + */ + return; + } + port = bind_pirq_to_evtch(irq); KASSERT(port < NR_EVENT_CHANNELS); KASSERT(port >= 0); @@ -602,6 +611,7 @@ ioapic_delroute(struct pic *pic, struct KASSERT(port < NR_EVENT_CHANNELS); + /* XXX: This is problematic for shared interrupts */ KASSERT(irq2port[irq] != 0); irq2port[irq] = 0;
CVS commit: src/sys/arch/xen/x86
Module Name:src Committed By: cherry Date: Wed Oct 10 02:16:34 UTC 2018 Modified Files: src/sys/arch/xen/x86: pintr.c Log Message: Since GSIs are invented by the mpbios/mpacpi interrupt routing probe code, it's possible for shared GSIs to popup even outside the original legacy_irq range. Relax this latter, older assumption. Thanks to Brad Spencer for extensive trialing on interesting hardware. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/xen/x86/pintr.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/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.7 src/sys/arch/xen/x86/pintr.c:1.8 --- src/sys/arch/xen/x86/pintr.c:1.7 Sun Oct 7 05:23:01 2018 +++ src/sys/arch/xen/x86/pintr.c Wed Oct 10 02:16:34 2018 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.7 2018/10/07 05:23:01 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.8 2018/10/10 02:16:34 cherry Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -176,8 +176,7 @@ xen_vec_alloc(int gsi) irq2vect[gsi] == op.u.irq_op.vector); irq2vect[gsi] = op.u.irq_op.vector; KASSERT(vect2irq[op.u.irq_op.vector] == 0 || - (gsi > 0 && gsi < 16 && - vect2irq[op.u.irq_op.vector] == gsi)); + vect2irq[op.u.irq_op.vector] == gsi); vect2irq[op.u.irq_op.vector] = gsi; }
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Wed Oct 10 02:34:08 UTC 2018 Modified Files: src/sys/arch/xen/include: intr.h src/sys/arch/xen/x86: pintr.c Log Message: Do not export the 'irq<->vector' abstraction outside of pintr.c anymore. We now think of them as a unified thing called 'gsi', which is generated by mpacpi/mpbios To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/xen/include/intr.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/x86/pintr.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/intr.h diff -u src/sys/arch/xen/include/intr.h:1.48 src/sys/arch/xen/include/intr.h:1.49 --- src/sys/arch/xen/include/intr.h:1.48 Sun Oct 7 05:23:01 2018 +++ src/sys/arch/xen/include/intr.h Wed Oct 10 02:34:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.48 2018/10/07 05:23:01 cherry Exp $ */ +/* $NetBSD: intr.h,v 1.49 2018/10/10 02:34:08 cherry Exp $ */ /* NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp */ /*- @@ -62,8 +62,6 @@ struct evtsource { }; extern struct intrstub xenev_stubs[]; -extern int irq2vect[256]; -extern int vect2irq[256]; extern int irq2port[NR_EVENT_CHANNELS]; /* actually port + 1, so that 0 is invaid */ #ifdef MULTIPROCESSOR Index: src/sys/arch/xen/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.8 src/sys/arch/xen/x86/pintr.c:1.9 --- src/sys/arch/xen/x86/pintr.c:1.8 Wed Oct 10 02:16:34 2018 +++ src/sys/arch/xen/x86/pintr.c Wed Oct 10 02:34:08 2018 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.8 2018/10/10 02:16:34 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.9 2018/10/10 02:34:08 cherry Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -143,8 +143,8 @@ struct intrstub x2apic_edge_stubs[MAX_IN struct intrstub x2apic_level_stubs[MAX_INTR_SOURCES] = {{0,0}}; #include int irq2port[NR_EVENT_CHANNELS] = {0}; /* actually port + 1, so that 0 is invaid */ -int irq2vect[256] = {0}; -int vect2irq[256] = {0}; +static int irq2vect[256] = {0}; +static int vect2irq[256] = {0}; #endif /* NIOAPIC */ #if NACPICA > 0 #include
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Sat Sep 29 13:19:38 UTC 2018 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: For i386 XEN3PAE_DOM0, use the "native" idt registration infrastructure by removing the #ifndef XEN clause. This will hopefully be the last commit to "fix" boot breakage of XEN3PAE_DOM0 Thanks to bouyer@ to focussed bug reports with # xl dmesg and relevant ddb> bt To generate a diff of this commit: cvs rdiff -u -r1.307 -r1.308 src/sys/arch/x86/x86/pmap.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/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.307 src/sys/arch/x86/x86/pmap.c:1.308 --- src/sys/arch/x86/x86/pmap.c:1.307 Wed Aug 29 16:26:25 2018 +++ src/sys/arch/x86/x86/pmap.c Sat Sep 29 13:19:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.307 2018/08/29 16:26:25 maxv Exp $ */ +/* $NetBSD: pmap.c,v 1.308 2018/09/29 13:19:38 cherry Exp $ */ /* * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.307 2018/08/29 16:26:25 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.308 2018/09/29 13:19:38 cherry Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -1225,7 +1225,7 @@ pmap_bootstrap(vaddr_t kva_start) #endif ldt_paddr = pmap_bootstrap_palloc(1); -#if !defined(__x86_64__) && !defined(XEN) +#if !defined(__x86_64__) /* pentium f00f bug stuff */ pentium_idt_vaddr = pmap_bootstrap_valloc(1); #endif
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: cherry Date: Wed Oct 10 03:54:54 UTC 2018 Modified Files: src/sys/arch/xen/xen: xenevt.c Log Message: Do not re-expose the innards of evtchn.c, now that we have a way to register interrupts via intr.c:intr_establish_xname() evtchn.c is going to get refactored soon, so use the latter method. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/xen/xen/xenevt.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/xen/xenevt.c diff -u src/sys/arch/xen/xen/xenevt.c:1.48 src/sys/arch/xen/xen/xenevt.c:1.49 --- src/sys/arch/xen/xen/xenevt.c:1.48 Thu Nov 30 20:25:54 2017 +++ src/sys/arch/xen/xen/xenevt.c Wed Oct 10 03:54:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xenevt.c,v 1.48 2017/11/30 20:25:54 christos Exp $ */ +/* $NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.48 2017/11/30 20:25:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $"); #include "opt_xen.h" #include @@ -145,15 +145,28 @@ long xenevt_ev1; long xenevt_ev2[NR_EVENT_CHANNELS]; static int xenevt_processevt(void *); +static evtchn_port_t xenevt_alloc_event(void) +{ + evtchn_op_t op; + op.cmd = EVTCHNOP_alloc_unbound; + op.u.alloc_unbound.dom = DOMID_SELF; + op.u.alloc_unbound.remote_dom = DOMID_SELF; + if (HYPERVISOR_event_channel_op() != 0) + panic("%s: Failed to allocate loopback event\n", __func__); + + return op.u.alloc_unbound.port; +} + /* called at boot time */ void xenevtattach(int n) { struct intrhand *ih; - int s; int level = IPL_HIGH; #ifdef MULTIPROCESSOR bool mpsafe = (level != IPL_VM); +#else + bool mpsafe = false; #endif /* MULTIPROCESSOR */ mutex_init(_lock, MUTEX_DEFAULT, IPL_HIGH); @@ -165,26 +178,19 @@ xenevtattach(int n) xenevt_ev1 = 0; memset(xenevt_ev2, 0, sizeof(xenevt_ev2)); - /* register a handler at splhigh, so that spllower() will call us */ - ih = malloc(sizeof (struct intrhand), M_DEVBUF, - M_WAITOK|M_ZERO); - if (ih == NULL) - panic("can't allocate xenevt interrupt source"); - ih->ih_level = level; - ih->ih_fun = ih->ih_realfun = xenevt_processevt; - ih->ih_arg = ih->ih_realarg = NULL; - ih->ih_next = NULL; - ih->ih_cpu = _info_primary; -#ifdef MULTIPROCESSOR - if (!mpsafe) { - ih->ih_fun = xen_intr_biglock_wrapper; - ih->ih_arg = ih; - } -#endif /* MULTIPROCESSOR */ + /* + * Allocate a loopback event port. + * This helps us massage xenevt_processevt() into the + * callchain at the appropriate level using only + * intr_establish_xname(). + */ + evtchn_port_t evtchn = xenevt_alloc_event(); + + /* The real objective here is to wiggle into the ih callchain for IPL level */ + ih = intr_establish_xname(0, _pic, evtchn, IST_LEVEL, level, + xenevt_processevt, NULL, mpsafe, "xenevt"); - s = splhigh(); - event_set_iplhandler(ih->ih_cpu, ih, level); - splx(s); + KASSERT(ih != NULL); } /* register pending event - always called with interrupt disabled */
CVS commit: src/sys/arch/xen/include
Module Name:src Committed By: cherry Date: Wed Oct 10 04:16:58 UTC 2018 Modified Files: src/sys/arch/xen/include: xen.h Log Message: In xen_atomic_test_and_clear_bit() Use the appropriate sized variable for inline assembler. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/arch/xen/include/xen.h 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/xen.h diff -u src/sys/arch/xen/include/xen.h:1.40 src/sys/arch/xen/include/xen.h:1.41 --- src/sys/arch/xen/include/xen.h:1.40 Sun Oct 7 11:25:55 2018 +++ src/sys/arch/xen/include/xen.h Wed Oct 10 04:16:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xen.h,v 1.40 2018/10/07 11:25:55 mlelstv Exp $ */ +/* $NetBSD: xen.h,v 1.41 2018/10/10 04:16:58 cherry Exp $ */ /* * @@ -248,7 +248,7 @@ xen_atomic_clearbits_l (volatile XATOMIC static __inline XATOMIC_T xen_atomic_test_and_clear_bit(volatile void *ptr, unsigned long bitno) { - int result; + long result; __asm volatile(__LOCK_PREFIX #ifdef __x86_64__
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: cherry Date: Wed Oct 17 03:43:24 UTC 2018 Modified Files: src/sys/arch/xen/xen: xenevt.c Log Message: The known_mpsafe parameter is used by intr.c:intr_establish_xname() especially in the non -D MULTIPROCESSOR case. We used it incorrectly. Fix this. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/arch/xen/xen/xenevt.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/xen/xenevt.c diff -u src/sys/arch/xen/xen/xenevt.c:1.49 src/sys/arch/xen/xen/xenevt.c:1.50 --- src/sys/arch/xen/xen/xenevt.c:1.49 Wed Oct 10 03:54:54 2018 +++ src/sys/arch/xen/xen/xenevt.c Wed Oct 17 03:43:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $ */ +/* $NetBSD: xenevt.c,v 1.50 2018/10/17 03:43:24 cherry Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.50 2018/10/17 03:43:24 cherry Exp $"); #include "opt_xen.h" #include @@ -163,11 +163,7 @@ xenevtattach(int n) { struct intrhand *ih; int level = IPL_HIGH; -#ifdef MULTIPROCESSOR bool mpsafe = (level != IPL_VM); -#else - bool mpsafe = false; -#endif /* MULTIPROCESSOR */ mutex_init(_lock, MUTEX_DEFAULT, IPL_HIGH); STAILQ_INIT(_pending);
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Thu Sep 20 05:08:45 UTC 2018 Modified Files: src/sys/arch/x86/x86: intr.c Log Message: When we removed the XEN special case from isa/isa_machdep.c there was a corner case that was missed in x86/intr.c:intr_establish_xname() In isa_machdep.c:isa_intr_establish_xname() the legacy_irq parameter is never set to -1. It is also incorrect to call isa_intr_establish_xname() with a legacy_irq parameter of -1. Thus we infer that whenever we see (legacy_irq == -1) in intr_establish_xname() which is downstream, we were *NOT* called from isa_machdep.c:isa_intr_establish_xname() Given that there are no other users of intr_establish_xnam() which pass a valid legacy_irq != -1, we assume therefore that we *WERE* called from isa_machdep.c:isa_intr_establish_xname() in this case. This is an important distinction in the case where a valid legacy_irq > NUM_LEGACY_IRQS was passed down from isa_intr_establish_xname() but was ignored by xen_pirq_alloc() and overwritten with the "pseudo" irq which is then passed back. We thus pass the incorrect "legacy" irq value to pirq_establish(). Even though non ISA (ie; PCI and MSI(X) cases), this is the correct behaviour, we need to maintain (bug?) compatibility with the isa case. Thus the one liner diff. CVS: -- CVS: CVSROOT cvs.NetBSD.org:/cvsroot CVS: please use "PR category/123" to have the commitmsg appended to PR 123 CVS: CVS: Please evaluate your changes and consider the following. CVS: Abort checkin if you answer no. CVS: => For all changes: CVS: Do the changed files compile? CVS: Has the change been tested? CVS: => If you are not completely familiar with the changed components: CVS: Has the change been posted for review? CVS: Have you allowed enough time for feedback? CVS: => If the change is major: CVS: => If the change adds files to, or removes files from $DESTDIR: CVS: => If you are changing a library or kernel interface: CVS: Have you successfully run "./build.sh release"? To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/arch/x86/x86/intr.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/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.129 src/sys/arch/x86/x86/intr.c:1.130 --- src/sys/arch/x86/x86/intr.c:1.129 Fri Sep 14 01:50:51 2018 +++ src/sys/arch/x86/x86/intr.c Thu Sep 20 05:08:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.129 2018/09/14 01:50:51 mrg Exp $ */ +/* $NetBSD: intr.c,v 1.130 2018/09/20 05:08:45 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.129 2018/09/14 01:50:51 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.130 2018/09/20 05:08:45 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1291,6 +1291,7 @@ intr_establish_xname(int legacy_irq, str sizeof(intrstr_buf)); evtchn = xen_pirq_alloc(, type); + irq = (legacy_irq == -1) ? irq : legacy_irq; /* ISA compat */ pih = pirq_establish(irq & 0xff, evtchn, handler, arg, level, intrstr, xname); pih->pic_type = pic->pic_type;
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Sep 23 15:28:49 UTC 2018 Modified Files: src/sys/arch/i386/i386: cpufunc.S machdep.c src/sys/arch/i386/include: segments.h src/sys/arch/x86/x86: idt.c src/sys/arch/xen/x86: xenfunc.c Log Message: Fix for i386, functionality intended in: http://mail-index.netbsd.org/source-changes/2018/09/23/msg099357.html This should fix the build for both GENERIC and XEN3PAE_DOM0 This has not been boot tested on native or xen3pae Notes: pmap_changeprot_local() seems to be x86_64 only. I was a bit surprised by this initially, but I suspect that the table protections are enforced via ring0/ring1 fencing rather than page protections the gdt registration code in i386 is still messy. I will leave it as is for now - to avoid a rabbit hole. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.809 -r1.810 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.66 -r1.67 src/sys/arch/i386/include/segments.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/x86/idt.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/xen/x86/xenfunc.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/i386/i386/cpufunc.S diff -u src/sys/arch/i386/i386/cpufunc.S:1.23 src/sys/arch/i386/i386/cpufunc.S:1.24 --- src/sys/arch/i386/i386/cpufunc.S:1.23 Sat Jul 21 16:21:27 2018 +++ src/sys/arch/i386/i386/cpufunc.S Sun Sep 23 15:28:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.23 2018/07/21 16:21:27 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.24 2018/09/23 15:28:48 cherry Exp $ */ /*- * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.23 2018/07/21 16:21:27 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.24 2018/09/23 15:28:48 cherry Exp $"); #include "opt_xen.h" @@ -65,11 +65,13 @@ ENTRY(x86_mfence) ret END(x86_mfence) -ENTRY(lidt) +#ifndef XEN + ENTRY(lidt) movl 4(%esp), %eax lidt (%eax) ret END(lidt) +#endif /* XEN */ ENTRY(rcr3) movl %cr3, %eax Index: src/sys/arch/i386/i386/machdep.c diff -u src/sys/arch/i386/i386/machdep.c:1.809 src/sys/arch/i386/i386/machdep.c:1.810 --- src/sys/arch/i386/i386/machdep.c:1.809 Sun Sep 23 00:59:59 2018 +++ src/sys/arch/i386/i386/machdep.c Sun Sep 23 15:28:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.809 2018/09/23 00:59:59 cherry Exp $ */ +/* $NetBSD: machdep.c,v 1.810 2018/09/23 15:28:48 cherry Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017 @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.809 2018/09/23 00:59:59 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.810 2018/09/23 15:28:48 cherry Exp $"); #include "opt_beep.h" #include "opt_compat_freebsd.h" @@ -1360,19 +1360,20 @@ init386(paddr_t first_avail) default: break; } - set_istgate([x], IDTVEC(exceptions)[x], 0, SDT_SYS386IGT, + set_idtgate([x], IDTVEC(exceptions)[x], 0, SDT_SYS386IGT, sel, GSEL(GCODE_SEL, SEL_KPL)); } /* new-style interrupt gate for syscalls */ idt_vec_reserve(128); - set_istgate([128], (syscall), 0, SDT_SYS386IGT, SEL_UPL, + set_idtgate([128], (syscall), 0, SDT_SYS386IGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); +#ifndef XEN setregion(, gdtstore, NGDT * sizeof(gdtstore[0]) - 1); lgdt(); - - cpu_init_idt(); +#endif + lldt(GSEL(GLDT_SEL, SEL_KPL)); cpu_init_idt(); Index: src/sys/arch/i386/include/segments.h diff -u src/sys/arch/i386/include/segments.h:1.66 src/sys/arch/i386/include/segments.h:1.67 --- src/sys/arch/i386/include/segments.h:1.66 Sun Sep 23 07:54:42 2018 +++ src/sys/arch/i386/include/segments.h Sun Sep 23 15:28:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: segments.h,v 1.66 2018/09/23 07:54:42 cherry Exp $ */ +/* $NetBSD: segments.h,v 1.67 2018/09/23 15:28:49 cherry Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -200,7 +200,7 @@ extern idt_descriptor_t *idt; extern union descriptor *gdtstore, *ldtstore; void setgate(struct gate_descriptor *, void *, int, int, int, int); -void set_idtgate(idt_descriptor_t *, void *, int, int, int); +void set_idtgate(idt_descriptor_t *, void *, int, int, int, int); void unset_idtgate(idt_descriptor_t *); void setregion(struct region_descriptor *, void *, size_t); void setsegment(struct segment_descriptor *, const void *, size_t, int, int, Index: src/sys/arch/x86/x86/idt.c diff -u src/sys/arch/x86/x86/idt.c:1.7 src/sys/arch/x86/x86/idt.c:1.8 --- src/sys/arch/x86/x86/idt.c:1.7 Sun Sep 23 00:59:59 2018 +++ src/sys/arch/x86/x86/idt.c Sun Sep 23 15:28:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: idt.c,v 1.7 2018/09/23 00:59:59 cherry Exp $ */ +/* $NetBSD: idt.c,v 1.8 2018/09/23 15:28:49 cherry Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2009 The NetBSD Foundation, Inc. @@ -65,7
CVS commit: src/sys/arch/xen/x86
Module Name:src Committed By: cherry Date: Thu Oct 18 04:17:18 UTC 2018 Modified Files: src/sys/arch/xen/x86: xenfunc.c Log Message: Zero out page table memory for IDT before use. To copy the IDT entry before registration, de-reference the indexed value, not the first entry. Add a MAX_XEN_IDT value for max entries we expect and KASSERT() for this as a sanity check. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/xen/x86/xenfunc.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/x86/xenfunc.c diff -u src/sys/arch/xen/x86/xenfunc.c:1.21 src/sys/arch/xen/x86/xenfunc.c:1.22 --- src/sys/arch/xen/x86/xenfunc.c:1.21 Sun Sep 23 15:28:49 2018 +++ src/sys/arch/xen/x86/xenfunc.c Thu Oct 18 04:17:18 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xenfunc.c,v 1.21 2018/09/23 15:28:49 cherry Exp $ */ +/* $NetBSD: xenfunc.c,v 1.22 2018/10/18 04:17:18 cherry Exp $ */ /* * Copyright (c) 2004 Christian Limpach. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.21 2018/09/23 15:28:49 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.22 2018/10/18 04:17:18 cherry Exp $"); #include @@ -41,6 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v #include #include +#define MAX_XEN_IDT 128 + void xen_set_ldt(vaddr_t, uint32_t); void @@ -59,7 +61,8 @@ lidt(struct region_descriptor *rd) * will be available at the boot stage when this is called. */ static char xen_idt_page[PAGE_SIZE] __attribute__((__aligned__ (PAGE_SIZE))); - + memset(xen_idt_page, 0, PAGE_SIZE); + struct trap_info *xen_idt = (void * )xen_idt_page; int xen_idt_idx = 0; @@ -73,9 +76,9 @@ lidt(struct region_descriptor *rd) * back in the requestor array. */ for (i = 0; i < nidt; i++) { - if (idd->address == 0) /* Skip gap */ + if (idd[i].address == 0) /* Skip gap */ continue; - + KASSERT(xen_idt_idx < MAX_XEN_IDT); /* Copy over entry */ xen_idt[xen_idt_idx++] = idd[i]; }
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: cherry Date: Thu Oct 18 04:22:22 UTC 2018 Modified Files: src/sys/arch/i386/i386: machdep.c Log Message: Use memory allocated for the ldt, not the idt. This must have been a typo that we got away with because we were not using the idt[] so far. This fix should now allow -current i386 XEN to boot, as before. To generate a diff of this commit: cvs rdiff -u -r1.811 -r1.812 src/sys/arch/i386/i386/machdep.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/i386/i386/machdep.c diff -u src/sys/arch/i386/i386/machdep.c:1.811 src/sys/arch/i386/i386/machdep.c:1.812 --- src/sys/arch/i386/i386/machdep.c:1.811 Sat Sep 29 07:00:20 2018 +++ src/sys/arch/i386/i386/machdep.c Thu Oct 18 04:22:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $ */ +/* $NetBSD: machdep.c,v 1.812 2018/10/18 04:22:22 cherry Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017 @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.812 2018/10/18 04:22:22 cherry Exp $"); #include "opt_beep.h" #include "opt_compat_freebsd.h" @@ -1326,7 +1326,7 @@ init386(paddr_t first_avail) GSEL(GCODE_SEL, SEL_KPL), (unsigned long)hypervisor_callback, GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback); - ldtstore = (union descriptor *)idt_vaddr; + ldtstore = (union descriptor *)ldt_vaddr; #endif /* XEN */ /* make ldt gates and memory segments */
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: cherry Date: Thu Oct 18 04:11:14 UTC 2018 Modified Files: src/sys/arch/i386/i386: cpufunc.S Log Message: Whitespace self-police. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/i386/i386/cpufunc.S 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/i386/i386/cpufunc.S diff -u src/sys/arch/i386/i386/cpufunc.S:1.24 src/sys/arch/i386/i386/cpufunc.S:1.25 --- src/sys/arch/i386/i386/cpufunc.S:1.24 Sun Sep 23 15:28:48 2018 +++ src/sys/arch/i386/i386/cpufunc.S Thu Oct 18 04:11:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.24 2018/09/23 15:28:48 cherry Exp $ */ +/* $NetBSD: cpufunc.S,v 1.25 2018/10/18 04:11:14 cherry Exp $ */ /*- * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.24 2018/09/23 15:28:48 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.25 2018/10/18 04:11:14 cherry Exp $"); #include "opt_xen.h" @@ -66,7 +66,7 @@ ENTRY(x86_mfence) END(x86_mfence) #ifndef XEN - ENTRY(lidt) +ENTRY(lidt) movl 4(%esp), %eax lidt (%eax) ret
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Thu Oct 18 04:14:07 UTC 2018 Modified Files: src/sys/arch/x86/x86: idt.c Log Message: Make compile-time type differentiation more explicit. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/idt.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/x86/x86/idt.c diff -u src/sys/arch/x86/x86/idt.c:1.8 src/sys/arch/x86/x86/idt.c:1.9 --- src/sys/arch/x86/x86/idt.c:1.8 Sun Sep 23 15:28:49 2018 +++ src/sys/arch/x86/x86/idt.c Thu Oct 18 04:14:07 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: idt.c,v 1.8 2018/09/23 15:28:49 cherry Exp $ */ +/* $NetBSD: idt.c,v 1.9 2018/10/18 04:14:07 cherry Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2009 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.8 2018/09/23 15:28:49 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.9 2018/10/18 04:14:07 cherry Exp $"); #include #include @@ -89,7 +89,7 @@ static char idt_allocmap[NIDT]; #if defined(XEN) void -set_idtgate(idt_descriptor_t *xen_idd, void *function, int ist, +set_idtgate(struct trap_info *xen_idd, void *function, int ist, int type, int dpl, int sel) { /* @@ -120,7 +120,7 @@ set_idtgate(idt_descriptor_t *xen_idd, v * implicitly part of an idt, which we infer as * xen_idt_vaddr. (See above). */ - xen_idd->vector = xen_idd - (idt_descriptor_t *)xen_idt_vaddr; + xen_idd->vector = xen_idd - (struct trap_info *)xen_idt_vaddr; /* Back to read-only, as it should be. */ #if defined(__x86_64__) @@ -129,7 +129,7 @@ set_idtgate(idt_descriptor_t *xen_idd, v //kpreempt_enable(); } void -unset_idtgate(idt_descriptor_t *xen_idd) +unset_idtgate(struct trap_info *xen_idd) { #if defined(__x86_64__) vaddr_t xen_idt_vaddr = ((vaddr_t) xen_idd) & PAGE_MASK; @@ -148,12 +148,12 @@ unset_idtgate(idt_descriptor_t *xen_idd) } #else /* XEN */ void -set_idtgate(idt_descriptor_t *idd, void *function, int ist, int type, int dpl, int sel) +set_idtgate(struct gate_descriptor *idd, void *function, int ist, int type, int dpl, int sel) { setgate(idd, function, ist, type, dpl, sel); } void -unset_idtgate(idt_descriptor_t *idd) +unset_idtgate(struct gate_descriptor *idd) { unsetgate(idd); }
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Dec 2 08:19:44 UTC 2018 Modified Files: src/sys/arch/amd64/amd64: mainbus.c src/sys/arch/i386/i386: mainbus.c src/sys/arch/x86/pci: pci_intr_machdep.c src/sys/arch/x86/x86: intr.c Log Message: make options NO_PCI_MSI_MSIX work again for arch/x86/ To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/amd64/amd64/mainbus.c cvs rdiff -u -r1.103 -r1.104 src/sys/arch/i386/i386/mainbus.c cvs rdiff -u -r1.47 -r1.48 src/sys/arch/x86/pci/pci_intr_machdep.c cvs rdiff -u -r1.135 -r1.136 src/sys/arch/x86/x86/intr.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/amd64/amd64/mainbus.c diff -u src/sys/arch/amd64/amd64/mainbus.c:1.38 src/sys/arch/amd64/amd64/mainbus.c:1.39 --- src/sys/arch/amd64/amd64/mainbus.c:1.38 Tue May 23 08:54:38 2017 +++ src/sys/arch/amd64/amd64/mainbus.c Sun Dec 2 08:19:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.38 2017/05/23 08:54:38 nonaka Exp $ */ +/* $NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.38 2017/05/23 08:54:38 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp $"); #include #include @@ -74,7 +74,9 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v #include #endif #endif +#ifdef __HAVE_PCI_MSI_MSIX #include +#endif /* __HAVE_PCI_MSI_MSIX */ #endif /* @@ -179,7 +181,9 @@ mainbus_attach(device_t parent, device_t #endif #if NPCI > 0 +#ifdef __HAVE_PCI_MSI_MSIX msipic_init(); +#endif /* * ACPI needs to be able to access PCI configuration space. @@ -209,9 +213,9 @@ mainbus_attach(device_t parent, device_t */ if (acpi_present) mpacpi_active = mpacpi_scan_apics(self, ) != 0; -#endif if (!mpacpi_active) { +#endif #ifdef MPBIOS if (mpbios_present) mpbios_scan(self, ); @@ -227,7 +231,9 @@ mainbus_attach(device_t parent, device_t config_found_ia(self, "cpubus", , mainbus_print); } +#if NACPICA > 0 } +#endif #if NISADMA > 0 && NACPICA > 0 /* Index: src/sys/arch/i386/i386/mainbus.c diff -u src/sys/arch/i386/i386/mainbus.c:1.103 src/sys/arch/i386/i386/mainbus.c:1.104 --- src/sys/arch/i386/i386/mainbus.c:1.103 Tue May 23 08:54:38 2017 +++ src/sys/arch/i386/i386/mainbus.c Sun Dec 2 08:19:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.103 2017/05/23 08:54:38 nonaka Exp $ */ +/* $NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.103 2017/05/23 08:54:38 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp $"); #include #include @@ -86,7 +86,9 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v #include #endif #endif +#ifdef __HAVE_PCI_MSI_MSIX #include +#endif /* __HAVE_PCI_MSI_MSIX */ #endif void mainbus_childdetached(device_t, device_t); Index: src/sys/arch/x86/pci/pci_intr_machdep.c diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.47 src/sys/arch/x86/pci/pci_intr_machdep.c:1.48 --- src/sys/arch/x86/pci/pci_intr_machdep.c:1.47 Tue Nov 27 21:03:50 2018 +++ src/sys/arch/x86/pci/pci_intr_machdep.c Sun Dec 2 08:19:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.47 2018/11/27 21:03:50 jdolecek Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.48 2018/12/02 08:19:44 cherry Exp $ */ /*- * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.47 2018/11/27 21:03:50 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.48 2018/12/02 08:19:44 cherry Exp $"); #include #include @@ -102,6 +102,8 @@ __KERNEL_RCSID(0, "$NetBSD: pci_intr_mac #include #include #include +#else +#include #endif #ifdef MPBIOS @@ -232,8 +234,10 @@ pci_intr_string(pci_chipset_tag_t pc, pc buf, len); } +#if defined(__HAVE_PCI_MSI_MSIX) if (INT_VIA_MSI(ih)) return x86_pci_msi_string(pc, ih, buf, len); +#endif return intr_string(ih & ~MPSAFE_MASK, buf, len); } @@ -319,6 +323,8 @@ pci_intr_establish_xname_internal(pci_ch pc, ih, level, func, arg); } + +#ifdef __HAVE_PCI_MSI_MSIX if (INT_VIA_MSI(ih)) { if (MSI_INT_IS_MSIX(ih)) return x86_pci_msix_establish(pc, ih, level, func, arg, @@ -327,7 +333,7 @@ pci_intr_establish_xname_internal(pci_ch return x86_pci_msi_establish(pc, ih, level, func, arg, xname); } - +#endif if (pci_intr_find_intx_irq(ih, , , )) { aprint_normal("%s: bad pic %d\n", __func__, APIC_IRQ_APIC(ih)); Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.135
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Mon Dec 3 19:46:43 UTC 2018 Modified Files: src/sys/arch/x86/x86: efi.c Log Message: Do not assume that all uses of efi are pci aware. Allow efi.c to compile in the case where pci is not enabled. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/x86/efi.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/x86/x86/efi.c diff -u src/sys/arch/x86/x86/efi.c:1.18 src/sys/arch/x86/x86/efi.c:1.19 --- src/sys/arch/x86/x86/efi.c:1.18 Thu Nov 15 16:58:56 2018 +++ src/sys/arch/x86/x86/efi.c Mon Dec 3 19:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: efi.c,v 1.18 2018/11/15 16:58:56 riastradh Exp $ */ +/* $NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.18 2018/11/15 16:58:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $"); #include #include @@ -40,7 +40,9 @@ __KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.18 #include #include +#if NPCI > 0 #include /* for pci_mapreg_map_enable_decode */ +#endif const struct uuid EFI_UUID_ACPI20 = EFI_TABLE_ACPI20; const struct uuid EFI_UUID_ACPI10 = EFI_TABLE_ACPI10; @@ -419,7 +421,9 @@ efi_init(void) return; } bootmethod_efi = true; +#if NPCI > 0 pci_mapreg_map_enable_decode = true; /* PR port-amd64/53286 */ +#endif } bool
CVS commit: src/sys/arch/x86/isa
Module Name:src Committed By: cherry Date: Mon Dec 3 19:51:09 UTC 2018 Modified Files: src/sys/arch/x86/isa: isa_machdep.c Log Message: Allow isa_machdep.c to compile in the case of no ioapic support. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/isa/isa_machdep.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/x86/isa/isa_machdep.c diff -u src/sys/arch/x86/isa/isa_machdep.c:1.40 src/sys/arch/x86/isa/isa_machdep.c:1.41 --- src/sys/arch/x86/isa/isa_machdep.c:1.40 Mon Sep 10 07:04:08 2018 +++ src/sys/arch/x86/isa/isa_machdep.c Mon Dec 3 19:51:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: isa_machdep.c,v 1.40 2018/09/10 07:04:08 cherry Exp $ */ +/* $NetBSD: isa_machdep.c,v 1.41 2018/12/03 19:51:09 cherry Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.40 2018/09/10 07:04:08 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.41 2018/12/03 19:51:09 cherry Exp $"); #include #include @@ -210,8 +210,8 @@ isa_intr_establish_xname(isa_chipset_tag { struct pic *pic; int pin; - intr_handle_t mpih = 0; #if NIOAPIC > 0 + intr_handle_t mpih = 0; struct ioapic_softc *ioapic = NULL; #endif
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Mon Sep 10 05:08:55 UTC 2018 Modified Files: src/sys/arch/x86/x86: intr.c src/sys/arch/xen/include: intrdefs.h Log Message: Make the use of 'irqs' in the range 0 < irq < 255 by xen as a handle for internal use explicit. This allows us to pass up the handle as "legacy" irq while establishing interrupt handlers for xen. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/xen/include/intrdefs.h 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/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.127 src/sys/arch/x86/x86/intr.c:1.128 --- src/sys/arch/x86/x86/intr.c:1.127 Tue Jul 3 11:45:54 2018 +++ src/sys/arch/x86/x86/intr.c Mon Sep 10 05:08:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.127 2018/07/03 11:45:54 kamil Exp $ */ +/* $NetBSD: intr.c,v 1.128 2018/09/10 05:08:55 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.127 2018/07/03 11:45:54 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.128 2018/09/10 05:08:55 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1266,15 +1266,18 @@ intr_establish_xname(int legacy_irq, str intr_handle_t irq; int evtchn; - KASSERTMSG(legacy_irq == -1 || (0 <= legacy_irq && legacy_irq < 16), + KASSERTMSG(legacy_irq == -1 || (0 <= legacy_irq && legacy_irq < NUM_XEN_IRQS), "bad legacy IRQ value: %d", legacy_irq); KASSERTMSG(!(legacy_irq == -1 && pic == _pic), "non-legacy IRQon i8259 "); if (pic->pic_type != PIC_I8259) { #if NIOAPIC > 0 + /* Are we passing mp tranmogrified/cascaded irqs ? */ + irq = (legacy_irq == -1) ? 0 : legacy_irq; + /* will do interrupts via I/O APIC */ - irq = APIC_INT_VIA_APIC; + irq |= APIC_INT_VIA_APIC; irq |= pic->pic_apicid << APIC_INT_APIC_SHIFT; irq |= pin << APIC_INT_PIN_SHIFT; #else /* NIOAPIC */ Index: src/sys/arch/xen/include/intrdefs.h diff -u src/sys/arch/xen/include/intrdefs.h:1.12 src/sys/arch/xen/include/intrdefs.h:1.13 --- src/sys/arch/xen/include/intrdefs.h:1.12 Mon May 19 22:47:54 2014 +++ src/sys/arch/xen/include/intrdefs.h Mon Sep 10 05:08:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intrdefs.h,v 1.12 2014/05/19 22:47:54 rmind Exp $ */ +/* $NetBSD: intrdefs.h,v 1.13 2018/09/10 05:08:55 cherry Exp $ */ /* This file co-exists, and is included via machine/intrdefs.h */ @@ -17,4 +17,7 @@ /* Note: IPI_KICK does not have a handler. */ #define XEN_NIPIS 6 +/* The number of 'irqs' that XEN understands */ +#define NUM_XEN_IRQS 256 + #endif /* _XEN_INTRDEFS_H_ */
CVS commit: src/sys/arch/x86/isa
Module Name:src Committed By: cherry Date: Mon Sep 10 07:04:08 UTC 2018 Modified Files: src/sys/arch/x86/isa: isa_machdep.c Log Message: Remove the last usage of xen_pirq_alloc() and pirq_establish() outside of the x86 interrupt and xen events framework. This allows us to finally unify the interrupt path for both Xen and x86 as changes 'internal' to the subsystem. This change has been kindly tested on real hardware by gson@ The change is not cosmetic and may thus affect users on various hardware configurations - especially involving legacy hardware. I look forward to bug reports. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/x86/isa/isa_machdep.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/x86/isa/isa_machdep.c diff -u src/sys/arch/x86/isa/isa_machdep.c:1.39 src/sys/arch/x86/isa/isa_machdep.c:1.40 --- src/sys/arch/x86/isa/isa_machdep.c:1.39 Sun Jun 24 13:35:33 2018 +++ src/sys/arch/x86/isa/isa_machdep.c Mon Sep 10 07:04:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: isa_machdep.c,v 1.39 2018/06/24 13:35:33 jdolecek Exp $ */ +/* $NetBSD: isa_machdep.c,v 1.40 2018/09/10 07:04:08 cherry Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.39 2018/06/24 13:35:33 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.40 2018/09/10 07:04:08 cherry Exp $"); #include #include @@ -237,31 +237,8 @@ isa_intr_establish_xname(isa_chipset_tag printf("isa_intr_establish: no MP mapping found\n"); } #endif -#if defined(XEN) - KASSERT(APIC_IRQ_ISLEGACY(irq)); - - int evtch; - const char *intrstr; - char intrstr_buf[INTRIDBUF]; - - mpih |= APIC_IRQ_LEGACY_IRQ(irq); - - evtch = xen_pirq_alloc(, type); /* XXX: legacy - xen just tosses irq back at us */ - if (evtch == -1) - return NULL; - - intrstr = intr_create_intrid(irq, pic, pin, intrstr_buf, - sizeof(intrstr_buf)); - - aprint_debug("irq: %d requested on pic: %s.\n", irq, pic->pic_name); - - return (void *)pirq_establish(irq, evtch, ih_fun, ih_arg, level, - intrstr, xname); -#else /* defined(XEN) */ return intr_establish_xname(irq, pic, pin, type, level, ih_fun, ih_arg, false, xname); -#endif - } /* Deregister an interrupt handler. */
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: cherry Date: Mon Sep 10 02:49:23 UTC 2018 Modified Files: src/sys/arch/x86/pci: pci_intr_machdep.c Log Message: In the NIOAPIC case, we do not need to support "legacy" irqs, ie; We don't need to simultaneously pass back the irq in the range 0 < irq < 16 (which are sometimes described as "legacy" in src This was non-obvious, until the semantics of "legacy" were used in inconsistent ways in Xen (to also mean interrupts in the 0 < irq < 256 range) which causes problems with attempting to unify the sys/arch/x86/isa/isa_machdep.c:isa_intr_establish_xname() function between XEN and !XEN This commit should not affect current functionality on any either native or Xen. It is needed for future code reorg, and published now as a preview. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/pci/pci_intr_machdep.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/x86/pci/pci_intr_machdep.c diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.43 src/sys/arch/x86/pci/pci_intr_machdep.c:1.44 --- src/sys/arch/x86/pci/pci_intr_machdep.c:1.43 Sun Jun 24 11:51:15 2018 +++ src/sys/arch/x86/pci/pci_intr_machdep.c Mon Sep 10 02:49:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.43 2018/06/24 11:51:15 jdolecek Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $ */ /*- * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.43 2018/06/24 11:51:15 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $"); #include #include @@ -294,9 +294,7 @@ pci_intr_find_intx_irq(pci_intr_handle_t return ENOENT; *pic = >sc_pic; *pin = APIC_IRQ_PIN(ih); - *irq = APIC_IRQ_LEGACY_IRQ(ih); - if (*irq < 0 || *irq >= NUM_LEGACY_IRQS) - *irq = -1; + *irq = -1; /* PCI doesn't use legacy irq */ } #endif
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Sep 23 01:00:00 UTC 2018 Modified Files: src/sys/arch/amd64/amd64: db_interface.c machdep.c src/sys/arch/amd64/include: segments.h src/sys/arch/i386/i386: machdep.c src/sys/arch/i386/include: segments.h src/sys/arch/x86/x86: idt.c lapic.c src/sys/arch/xen/x86: xenfunc.c Log Message: Make XEN use the same api as native, for idt vector allocation and registration. lidt() placed in xenfunc() on maxv@ suggestion. There should be no functional change due to this commit. Tested on amd64 native and XEN. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/amd64/amd64/db_interface.c cvs rdiff -u -r1.318 -r1.319 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/include/segments.h cvs rdiff -u -r1.808 -r1.809 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.64 -r1.65 src/sys/arch/i386/include/segments.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/x86/idt.c cvs rdiff -u -r1.66 -r1.67 src/sys/arch/x86/x86/lapic.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/x86/xenfunc.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/amd64/amd64/db_interface.c diff -u src/sys/arch/amd64/amd64/db_interface.c:1.33 src/sys/arch/amd64/amd64/db_interface.c:1.34 --- src/sys/arch/amd64/amd64/db_interface.c:1.33 Tue Apr 3 07:20:52 2018 +++ src/sys/arch/amd64/amd64/db_interface.c Sun Sep 23 00:59:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.33 2018/04/03 07:20:52 christos Exp $ */ +/* $NetBSD: db_interface.c,v 1.34 2018/09/23 00:59:59 cherry Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.33 2018/04/03 07:20:52 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.34 2018/09/23 00:59:59 cherry Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -113,7 +113,7 @@ db_machine_init(void) handler = _x2apic_ddbipi; #endif ddb_vec = idt_vec_alloc(0xf0, 0xff); - setgate([ddb_vec], handler, 1, SDT_SYS386IGT, SEL_KPL, + set_idtgate([ddb_vec], handler, 1, SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); #else /* Initialised as part of xen_ipi_init() */ Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.318 src/sys/arch/amd64/amd64/machdep.c:1.319 --- src/sys/arch/amd64/amd64/machdep.c:1.318 Wed Aug 29 16:26:25 2018 +++ src/sys/arch/amd64/amd64/machdep.c Sun Sep 23 00:59:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.318 2018/08/29 16:26:25 maxv Exp $ */ +/* $NetBSD: machdep.c,v 1.319 2018/09/23 00:59:59 cherry Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.318 2018/08/29 16:26:25 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.319 2018/09/23 00:59:59 cherry Exp $"); #include "opt_modular.h" #include "opt_user_ldt.h" @@ -1397,11 +1397,6 @@ setregs(struct lwp *l, struct exec_packa /* * Initialize segments and descriptor tables */ - -#ifdef XEN -struct trap_info *xen_idt; -int xen_idt_idx; -#endif char *ldtstore; char *gdtstore; @@ -1486,15 +1481,10 @@ set_sys_segment(struct sys_segment_descr void cpu_init_idt(void) { -#ifndef XEN struct region_descriptor region; setregion(, idt, NIDT * sizeof(idt[0]) - 1); lidt(); -#else - if (HYPERVISOR_set_trap_table(xen_idt)) - panic("HYPERVISOR_set_trap_table() failed"); -#endif } #define IDTVEC(name) __CONCAT(X, name) @@ -1681,7 +1671,6 @@ init_x86_64(paddr_t first_avail) extern vaddr_t lwp0uarea; #ifndef XEN extern paddr_t local_apic_pa; - int ist; #endif KASSERT(first_avail % PAGE_SIZE == 0); @@ -1806,12 +1795,7 @@ init_x86_64(paddr_t first_avail) pmap_update(pmap_kernel()); -#ifndef XEN - idt = (struct gate_descriptor *)idt_vaddr; -#else - xen_idt = (struct trap_info *)idt_vaddr; - xen_idt_idx = 0; -#endif + idt = (idt_descriptor_t *)idt_vaddr; gdtstore = (char *)gdt_vaddr; ldtstore = (char *)ldt_vaddr; @@ -1870,8 +1854,14 @@ init_x86_64(paddr_t first_avail) /* CPU-specific IDT exceptions. */ for (x = 0; x < NCPUIDT; x++) { -#ifndef XEN + int sel, ist; + + /* Reset to default. Special cases below */ + sel = SEL_KPL; + ist = 0; + idt_vec_reserve(x); + switch (x) { case 1: /* DB */ ist = 4; @@ -1879,56 +1869,31 @@ init_x86_64(paddr_t first_avail) case 2: /* NMI */ ist = 3; break; + case 3: + case 4: + sel = SEL_UPL; + break; case 8: /* double fault */ ist = 2; break; - default: - ist = 0; - break; - } - setgate([x], x86_exceptions[x], ist, SDT_SYS386IGT, - (x == 3 || x == 4) ? SEL_UPL : SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); -#else /* XEN */ - pmap_changeprot_local(idt_vaddr, VM_PROT_READ|VM_PROT_WRITE); - idt_vec_reserve(x); -
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Sun Sep 23 02:27:25 UTC 2018 Modified Files: src/sys/arch/xen/include: hypervisor.h src/sys/arch/xen/xen: evtchn.c Log Message: Encapsulate pre-processing of registered (pirq,evtchn) pair in preparation for API reorg. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.80 -r1.81 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.44 src/sys/arch/xen/include/hypervisor.h:1.45 --- src/sys/arch/xen/include/hypervisor.h:1.44 Sat Jun 14 02:53:02 2014 +++ src/sys/arch/xen/include/hypervisor.h Sun Sep 23 02:27:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.44 2014/06/14 02:53:02 pgoyette Exp $ */ +/* $NetBSD: hypervisor.h,v 1.45 2018/09/23 02:27:24 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -130,6 +130,7 @@ extern volatile shared_info_t *HYPERVISO struct intrframe; struct cpu_info; void do_hypervisor_callback(struct intrframe *regs); +void hypervisor_prime_pirq_event(int, unsigned int); void hypervisor_enable_event(unsigned int); extern int xen_version; Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.80 src/sys/arch/xen/xen/evtchn.c:1.81 --- src/sys/arch/xen/xen/evtchn.c:1.80 Sun Jun 24 13:35:33 2018 +++ src/sys/arch/xen/xen/evtchn.c Sun Sep 23 02:27:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.80 2018/06/24 13:35:33 jdolecek Exp $ */ +/* $NetBSD: evtchn.c,v 1.81 2018/09/23 02:27:24 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.80 2018/06/24 13:35:33 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.81 2018/09/23 02:27:24 cherry Exp $"); #include "opt_xen.h" #include "isa.h" @@ -737,7 +737,6 @@ pirq_establish(int pirq, int evtch, int const char *intrname, const char *xname) { struct pintrhand *ih; - physdev_op_t physdev_op; ih = kmem_zalloc(sizeof(struct pintrhand), cold ? KM_NOSLEEP : KM_SLEEP); @@ -759,17 +758,7 @@ pirq_establish(int pirq, int evtch, int return NULL; } - physdev_op.cmd = PHYSDEVOP_IRQ_STATUS_QUERY; - physdev_op.u.irq_status_query.irq = pirq; - if (HYPERVISOR_physdev_op(_op) < 0) - panic("HYPERVISOR_physdev_op(PHYSDEVOP_IRQ_STATUS_QUERY)"); - if (physdev_op.u.irq_status_query.flags & - PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY) { - pirq_needs_unmask_notify[evtch >> 5] |= (1 << (evtch & 0x1f)); -#ifdef IRQ_DEBUG - printf("pirq %d needs notify\n", pirq); -#endif - } + hypervisor_prime_pirq_event(pirq, evtch); hypervisor_enable_event(evtch); return ih; } @@ -1006,6 +995,25 @@ event_remove_handler(int evtch, int (*fu } void +hypervisor_prime_pirq_event(int pirq, unsigned int evtch) +{ +#if NPCI > 0 || NISA > 0 + physdev_op_t physdev_op; + physdev_op.cmd = PHYSDEVOP_IRQ_STATUS_QUERY; + physdev_op.u.irq_status_query.irq = pirq; + if (HYPERVISOR_physdev_op(_op) < 0) + panic("HYPERVISOR_physdev_op(PHYSDEVOP_IRQ_STATUS_QUERY)"); + if (physdev_op.u.irq_status_query.flags & + PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY) { + pirq_needs_unmask_notify[evtch >> 5] |= (1 << (evtch & 0x1f)); +#ifdef IRQ_DEBUG + printf("pirq %d needs notify\n", pirq); +#endif + } +#endif /* NPCI > 0 || NISA > 0 */ +} + +void hypervisor_enable_event(unsigned int evtch) { #ifdef IRQ_DEBUG
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: cherry Date: Sun Sep 23 02:51:06 UTC 2018 Modified Files: src/sys/arch/x86/pci: pci_intr_machdep.c Log Message: Revert: http://mail-index.netbsd.org/source-changes/2018/09/10/msg098995.html It is incorrect to infer semantics from usage. the problem for which the original commit was intended should be fixed within the callee intr_establish_xname() and not the caller: pci_intr_find_intx_irq() This was accomplished via: http://mail-index.netbsd.org/source-changes/2018/09/20/msg099286.html To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x86/pci/pci_intr_machdep.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/x86/pci/pci_intr_machdep.c diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.44 src/sys/arch/x86/pci/pci_intr_machdep.c:1.45 --- src/sys/arch/x86/pci/pci_intr_machdep.c:1.44 Mon Sep 10 02:49:23 2018 +++ src/sys/arch/x86/pci/pci_intr_machdep.c Sun Sep 23 02:51:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.45 2018/09/23 02:51:06 cherry Exp $ */ /*- * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.45 2018/09/23 02:51:06 cherry Exp $"); #include #include @@ -294,7 +294,9 @@ pci_intr_find_intx_irq(pci_intr_handle_t return ENOENT; *pic = >sc_pic; *pin = APIC_IRQ_PIN(ih); - *irq = -1; /* PCI doesn't use legacy irq */ + *irq = APIC_IRQ_LEGACY_IRQ(ih); + if (*irq < 0 || *irq >= NUM_LEGACY_IRQS) + *irq = -1; } #endif
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Oct 7 05:23:01 UTC 2018 Modified Files: src/sys/arch/x86/x86: i8259.c intr.c src/sys/arch/xen/include: intr.h src/sys/arch/xen/x86: pintr.c Log Message: Switch over to a "GSI" concept for guest irqs. On XEN there is a namespace called GSI which includes: i) legacy_irq (0 - 16) ii) "gsi" (16-nr_irqs_gsi) iii) msi We try to mirror this in guest space, but are mindful that legacy_irq is 1:1 bound to actual hardware legacy_irq. Apart from this, XEN doesn't really care what number scheme we use, as long as it doesn't encroach on the MSI space, which is TBD for us. Thus we trust the mpbios.c/mpacpi.c code to correctly map the pic,pin tuples into the correct global gsi space, which we then register with xen. As we now do, we allow for duplicate gsi registrations, in case any hardware shares the same (pic,pin); This enables us to now use the (pic,pin) tuple as the canonical reference for device interrupt addresses, and leave any global mappings to specific code. Thus xen_pic_to_gsi(). Note that this requires separate support for MSI, which I will get around to once things stabilise - however the API change facilitates this nicely. I note that the msi addroute() function does not use the "pin" parameter. This can be made use of, to encode the gsi number, for XEN. This is however TBD. We further tweak the xen_vec_alloc() code to be uniform for the NIOAPICS and other cases, and ensure that i8259.c DTRT wrt to route(). This will allow us to use pic->pic_addroute() without needing to worry about pic specific issues. The next step is to consolidate the pic_addroute() XEN related #ifdefs into a -DXEN specific file, so that we don't clutter x86/ code with #ifdef XENs. This change has functional implications, and there is likely breakage coming especially on bespoke platforms that I haven't been able to test yet. I am especially interested in bug reports from platforms with legacy (esp. i386) and with multiple ioapics. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/x86/i8259.c cvs rdiff -u -r1.132 -r1.133 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/include/intr.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/xen/x86/pintr.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/x86/x86/i8259.c diff -u src/sys/arch/x86/x86/i8259.c:1.17 src/sys/arch/x86/x86/i8259.c:1.18 --- src/sys/arch/x86/x86/i8259.c:1.17 Sat Feb 17 18:51:53 2018 +++ src/sys/arch/x86/x86/i8259.c Sun Oct 7 05:23:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: i8259.c,v 1.17 2018/02/17 18:51:53 maxv Exp $ */ +/* $NetBSD: i8259.c,v 1.18 2018/10/07 05:23:01 cherry Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.17 2018/02/17 18:51:53 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.18 2018/10/07 05:23:01 cherry Exp $"); #include #include @@ -88,6 +88,9 @@ __KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1. #include #include +#ifdef XEN +#include +#endif #ifndef __x86_64__ #include "mca.h" @@ -99,6 +102,7 @@ __KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1. static void i8259_hwmask(struct pic *, int); static void i8259_hwunmask(struct pic *, int); static void i8259_setup(struct pic *, struct cpu_info *, int, int, int); +static void i8259_unsetup(struct pic *, struct cpu_info *, int, int, int); static void i8259_reinit_irqs(void); unsigned i8259_imen; @@ -115,7 +119,7 @@ struct pic i8259_pic = { .pic_hwmask = i8259_hwmask, .pic_hwunmask = i8259_hwunmask, .pic_addroute = i8259_setup, - .pic_delroute = i8259_setup, + .pic_delroute = i8259_unsetup, .pic_level_stubs = legacy_stubs, .pic_edge_stubs = legacy_stubs, }; @@ -252,10 +256,48 @@ static void i8259_setup(struct pic *pic, struct cpu_info *ci, int pin, int idtvec, int type) { +#if defined(XEN) + /* + * This is kludgy, and not the right place, but we can't bind + * before the routing has been set to the appropriate 'vector'. + * in x86/intr.c, this is done after idt_vec_set(), where this + * would have been more appropriate to put this. + */ + + int port, irq; + irq = vect2irq[idtvec]; + KASSERT(irq != 0); + port = bind_pirq_to_evtch(irq); + KASSERT(port < NR_EVENT_CHANNELS); + KASSERT(port >= 0); + + KASSERT(irq2port[irq] == 0); + irq2port[irq] = port + 1; + + xen_atomic_set_bit(>ci_evtmask[0], port); +#else + if (CPU_IS_PRIMARY(ci)) + i8259_reinit_irqs(); +#endif +} + +static void +i8259_unsetup(struct pic *pic, struct cpu_info *ci, +int pin, int idtvec, int type) +{ +#if defined(XEN) + int port, irq; + irq = vect2irq[idtvec]; + port = unbind_pirq_from_evtch(irq); + + KASSERT(port < NR_EVENT_CHANNELS); +#else if (CPU_IS_PRIMARY(ci)) i8259_reinit_irqs(); +#endif } + void i8259_reinit(void) { Index: src/sys/arch/x86/x86/intr.c diff -u
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Sun Oct 7 05:28:51 UTC 2018 Modified Files: src/sys/arch/x86/x86: i8259.c ioapic.c Log Message: While we're here, fix pic->pic_delroute() to DTRT on XEN and cleanup after itself. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/x86/i8259.c cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/x86/ioapic.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/x86/x86/i8259.c diff -u src/sys/arch/x86/x86/i8259.c:1.18 src/sys/arch/x86/x86/i8259.c:1.19 --- src/sys/arch/x86/x86/i8259.c:1.18 Sun Oct 7 05:23:01 2018 +++ src/sys/arch/x86/x86/i8259.c Sun Oct 7 05:28:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: i8259.c,v 1.18 2018/10/07 05:23:01 cherry Exp $ */ +/* $NetBSD: i8259.c,v 1.19 2018/10/07 05:28:51 cherry Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.18 2018/10/07 05:23:01 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.19 2018/10/07 05:28:51 cherry Exp $"); #include #include @@ -291,6 +291,11 @@ i8259_unsetup(struct pic *pic, struct cp port = unbind_pirq_from_evtch(irq); KASSERT(port < NR_EVENT_CHANNELS); + + KASSERT(irq2port[irq] != 0); + irq2port[irq] = 0; + + xen_atomic_clear_bit(>ci_evtmask[0], port); #else if (CPU_IS_PRIMARY(ci)) i8259_reinit_irqs(); Index: src/sys/arch/x86/x86/ioapic.c diff -u src/sys/arch/x86/x86/ioapic.c:1.56 src/sys/arch/x86/x86/ioapic.c:1.57 --- src/sys/arch/x86/x86/ioapic.c:1.56 Wed Dec 13 16:30:18 2017 +++ src/sys/arch/x86/x86/ioapic.c Sun Oct 7 05:28:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ioapic.c,v 1.56 2017/12/13 16:30:18 bouyer Exp $ */ +/* $NetBSD: ioapic.c,v 1.57 2018/10/07 05:28:51 cherry Exp $ */ /*- * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.56 2017/12/13 16:30:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.57 2018/10/07 05:28:51 cherry Exp $"); #include "opt_ddb.h" @@ -601,6 +601,12 @@ ioapic_delroute(struct pic *pic, struct port = unbind_pirq_from_evtch(irq); KASSERT(port < NR_EVENT_CHANNELS); + + KASSERT(irq2port[irq] != 0); + irq2port[irq] = 0; + + xen_atomic_clear_bit(>ci_evtmask[0], port); + #endif }
CVS commit: src/sys/arch/i386/include
Module Name:src Committed By: cherry Date: Sun Sep 23 07:54:42 UTC 2018 Modified Files: src/sys/arch/i386/include: segments.h Log Message: Summary: Remove older and now conflicting type declaration for global variable 'idt'. This should fix the i386 build failure now. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/arch/i386/include/segments.h 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/i386/include/segments.h diff -u src/sys/arch/i386/include/segments.h:1.65 src/sys/arch/i386/include/segments.h:1.66 --- src/sys/arch/i386/include/segments.h:1.65 Sun Sep 23 00:59:59 2018 +++ src/sys/arch/i386/include/segments.h Sun Sep 23 07:54:42 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: segments.h,v 1.65 2018/09/23 00:59:59 cherry Exp $ */ +/* $NetBSD: segments.h,v 1.66 2018/09/23 07:54:42 cherry Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -198,7 +198,6 @@ typedef struct gate_descriptor idt_descr #endif /* XEN */ extern idt_descriptor_t *idt; extern union descriptor *gdtstore, *ldtstore; -extern struct gate_descriptor *idt; void setgate(struct gate_descriptor *, void *, int, int, int, int); void set_idtgate(idt_descriptor_t *, void *, int, int, int);
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: cherry Date: Sat Sep 29 07:00:20 UTC 2018 Modified Files: src/sys/arch/i386/i386: machdep.c Log Message: Fix "use before init" of *idt. This should fix boot time pagefaulting and panic(9) on XEN kernels due to the boottime idt API reorg. To generate a diff of this commit: cvs rdiff -u -r1.810 -r1.811 src/sys/arch/i386/i386/machdep.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/i386/i386/machdep.c diff -u src/sys/arch/i386/i386/machdep.c:1.810 src/sys/arch/i386/i386/machdep.c:1.811 --- src/sys/arch/i386/i386/machdep.c:1.810 Sun Sep 23 15:28:48 2018 +++ src/sys/arch/i386/i386/machdep.c Sat Sep 29 07:00:20 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.810 2018/09/23 15:28:48 cherry Exp $ */ +/* $NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017 @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.810 2018/09/23 15:28:48 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.811 2018/09/29 07:00:20 cherry Exp $"); #include "opt_beep.h" #include "opt_compat_freebsd.h" @@ -1307,13 +1307,13 @@ init386(paddr_t first_avail) memset((void *)gdt_vaddr, 0, PAGE_SIZE); memset((void *)ldt_vaddr, 0, PAGE_SIZE); -#ifndef XEN pmap_kenter_pa(pentium_idt_vaddr, idt_paddr, VM_PROT_READ, 0); pmap_update(pmap_kernel()); pentium_idt = (union descriptor *)pentium_idt_vaddr; + idt = (idt_descriptor_t *)idt_vaddr; +#ifndef XEN tgdt = gdtstore; - idt = (struct gate_descriptor *)idt_vaddr; gdtstore = (union descriptor *)gdt_vaddr; ldtstore = (union descriptor *)ldt_vaddr;
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Mon Oct 8 08:05:08 UTC 2018 Modified Files: src/sys/arch/x86/x86: i8259.c intr.c ioapic.c Log Message: Clean up XEN specific stuff from the apic code, and move to intr.c No functional change. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/x86/i8259.c cvs rdiff -u -r1.133 -r1.134 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/x86/ioapic.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/x86/x86/i8259.c diff -u src/sys/arch/x86/x86/i8259.c:1.20 src/sys/arch/x86/x86/i8259.c:1.21 --- src/sys/arch/x86/x86/i8259.c:1.20 Sun Oct 7 16:36:36 2018 +++ src/sys/arch/x86/x86/i8259.c Mon Oct 8 08:05:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: i8259.c,v 1.20 2018/10/07 16:36:36 cherry Exp $ */ +/* $NetBSD: i8259.c,v 1.21 2018/10/08 08:05:08 cherry Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.20 2018/10/07 16:36:36 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.21 2018/10/08 08:05:08 cherry Exp $"); #include #include @@ -88,9 +88,6 @@ __KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1. #include #include -#ifdef XEN -#include -#endif #ifndef __x86_64__ #include "mca.h" @@ -102,7 +99,6 @@ __KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1. static void i8259_hwmask(struct pic *, int); static void i8259_hwunmask(struct pic *, int); static void i8259_setup(struct pic *, struct cpu_info *, int, int, int); -static void i8259_unsetup(struct pic *, struct cpu_info *, int, int, int); static void i8259_reinit_irqs(void); unsigned i8259_imen; @@ -119,7 +115,7 @@ struct pic i8259_pic = { .pic_hwmask = i8259_hwmask, .pic_hwunmask = i8259_hwunmask, .pic_addroute = i8259_setup, - .pic_delroute = i8259_unsetup, + .pic_delroute = i8259_setup, .pic_level_stubs = legacy_stubs, .pic_edge_stubs = legacy_stubs, }; @@ -256,62 +252,10 @@ static void i8259_setup(struct pic *pic, struct cpu_info *ci, int pin, int idtvec, int type) { -#if defined(XEN) - /* - * This is kludgy, and not the right place, but we can't bind - * before the routing has been set to the appropriate 'vector'. - * in x86/intr.c, this is done after idt_vec_set(), where this - * would have been more appropriate to put this. - */ - - int port, irq; - irq = vect2irq[idtvec]; - KASSERT(irq != 0); - if (irq2port[irq] != 0) { - /* - * Shared interrupt - we can't rebind. - * The port is shared instead. - */ - return; - } - - port = bind_pirq_to_evtch(irq); - KASSERT(port < NR_EVENT_CHANNELS); - KASSERT(port >= 0); - - KASSERT(irq2port[irq] == 0); - irq2port[irq] = port + 1; - - xen_atomic_set_bit(>ci_evtmask[0], port); -#else if (CPU_IS_PRIMARY(ci)) i8259_reinit_irqs(); -#endif } -static void -i8259_unsetup(struct pic *pic, struct cpu_info *ci, -int pin, int idtvec, int type) -{ -#if defined(XEN) - int port, irq; - irq = vect2irq[idtvec]; - port = unbind_pirq_from_evtch(irq); - - KASSERT(port < NR_EVENT_CHANNELS); - - /* XXX: This is problematic for shared interrupts */ - KASSERT(irq2port[irq] != 0); - irq2port[irq] = 0; - - xen_atomic_clear_bit(>ci_evtmask[0], port); -#else - if (CPU_IS_PRIMARY(ci)) - i8259_reinit_irqs(); -#endif -} - - void i8259_reinit(void) { Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.133 src/sys/arch/x86/x86/intr.c:1.134 --- src/sys/arch/x86/x86/intr.c:1.133 Sun Oct 7 05:23:01 2018 +++ src/sys/arch/x86/x86/intr.c Mon Oct 8 08:05:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.133 2018/10/07 05:23:01 cherry Exp $ */ +/* $NetBSD: intr.c,v 1.134 2018/10/08 08:05:08 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.133 2018/10/07 05:23:01 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.134 2018/10/08 08:05:08 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1278,12 +1278,24 @@ intr_establish_xname(int legacy_irq, str vector = xen_vec_alloc(gsi); - extern struct cpu_info phycpu_info_primary; /* XXX */ - struct cpu_info *ci = _info_primary; - pic->pic_addroute(pic, ci, pin, vector, type); - - evtchn = irq2port[vect2irq[vector]]; - KASSERT(evtchn > 0); + if (irq2port[gsi] == 0) { + extern struct cpu_info phycpu_info_primary; /* XXX */ + struct cpu_info *ci = _info_primary; + + pic->pic_addroute(pic, ci, pin, vector, type); + + evtchn = bind_pirq_to_evtch(gsi); + KASSERT(evtchn > 0); + KASSERT(evtchn < NR_EVENT_CHANNELS); + irq2port[gsi] = evtchn + 1; + xen_atomic_set_bit(>ci_evtmask[0], evtchn); + } else { + /* + * Shared interrupt - we can't rebind. + * The port is shared instead. + */ + evtchn = irq2port[gsi]; + } pih = pirq_establish(gsi, evtchn, handler, arg, level, intrstr,
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: cherry Date: Mon Oct 8 05:42:45 UTC 2018 Modified Files: src/sys/arch/xen/xen: pciback.c xpci_xenbus.c Log Message: Convert the last remaining users of event_set_handler() to intr_establish_xname(,_pic,...) To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/xen/xen/pciback.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/xen/xpci_xenbus.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/xen/pciback.c diff -u src/sys/arch/xen/xen/pciback.c:1.14 src/sys/arch/xen/xen/pciback.c:1.15 --- src/sys/arch/xen/xen/pciback.c:1.14 Sun Jun 24 20:15:00 2018 +++ src/sys/arch/xen/xen/pciback.c Mon Oct 8 05:42:44 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pciback.c,v 1.14 2018/06/24 20:15:00 jdolecek Exp $ */ +/* $NetBSD: pciback.c,v 1.15 2018/10/08 05:42:44 cherry Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.14 2018/06/24 20:15:00 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.15 2018/10/08 05:42:44 cherry Exp $"); #include "opt_xen.h" @@ -188,6 +188,7 @@ struct pb_xenbus_instance { struct pciback_pci_devlist pbx_pb_pci_dev; /* list of exported PCI devices */ /* communication with the domU */ unsigned int pbx_evtchn; /* our even channel */ + struct intrhand *pbx_ih; struct xen_pci_sharedinfo *pbx_sh_info; struct xen_pci_op op; grant_handle_t pbx_shinfo_handle; /* to unmap shared page */ @@ -524,9 +525,7 @@ pciback_xenbus_destroy(void *arg) int err; hypervisor_mask_event(pbxi->pbx_evtchn); - event_remove_handler(pbxi->pbx_evtchn, - pciback_xenbus_evthandler, pbxi); - + intr_disestablish(pbxi->pbx_ih); mutex_enter(_xenbus_lock); SLIST_REMOVE(_xenbus_instances, pbxi, pb_xenbus_instance, pbx_next); @@ -620,8 +619,9 @@ pciback_xenbus_frontend_changed(void *ar x86_sfence(); xenbus_switch_state(xbusd, NULL, XenbusStateConnected); x86_sfence(); - event_set_handler(pbxi->pbx_evtchn, pciback_xenbus_evthandler, - pbxi, IPL_BIO, "pciback", "pciback"); // XXX intr info? + pbxi->pbx_ih = intr_establish_xname(0, _pic, pbxi->pbx_evtchn, IST_LEVEL, IPL_BIO, + pciback_xenbus_evthandler, pbxi, true, "pciback"); + KASSERT(pbxi->pbx_ih != NULL); hypervisor_enable_event(pbxi->pbx_evtchn); hypervisor_notify_via_evtchn(pbxi->pbx_evtchn); break; Index: src/sys/arch/xen/xen/xpci_xenbus.c diff -u src/sys/arch/xen/xen/xpci_xenbus.c:1.18 src/sys/arch/xen/xen/xpci_xenbus.c:1.19 --- src/sys/arch/xen/xen/xpci_xenbus.c:1.18 Sun Aug 19 01:33:26 2018 +++ src/sys/arch/xen/xen/xpci_xenbus.c Mon Oct 8 05:42:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xpci_xenbus.c,v 1.18 2018/08/19 01:33:26 riastradh Exp $ */ +/* $NetBSD: xpci_xenbus.c,v 1.19 2018/10/08 05:42:45 cherry Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xpci_xenbus.c,v 1.18 2018/08/19 01:33:26 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xpci_xenbus.c,v 1.19 2018/10/08 05:42:45 cherry Exp $"); #include "opt_xen.h" @@ -188,8 +188,9 @@ xpci_xenbus_resume(void *p) aprint_verbose_dev(sc->sc_dev, "using event channel %d\n", sc->sc_evtchn); #if 0 - event_set_handler(sc->sc_evtchn, _handler, sc, - IPL_BIO, device_xname(sc->sc_dev)); + intr_establish_xname(0, _pic, pbxi->pbx_evtchn, IST_LEVEL, + IPL_BIO, _handler, sc, true, + device_xname(sc->sc_dev)); #endif again:
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Wed Oct 24 03:51:21 UTC 2018 Modified Files: src/sys/arch/x86/x86: intr.c Log Message: When returning a cached shared irq event value, DTRT To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/arch/x86/x86/intr.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/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.134 src/sys/arch/x86/x86/intr.c:1.135 --- src/sys/arch/x86/x86/intr.c:1.134 Mon Oct 8 08:05:08 2018 +++ src/sys/arch/x86/x86/intr.c Wed Oct 24 03:51:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.134 2018/10/08 08:05:08 cherry Exp $ */ +/* $NetBSD: intr.c,v 1.135 2018/10/24 03:51:21 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.134 2018/10/08 08:05:08 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.135 2018/10/24 03:51:21 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1294,7 +1294,7 @@ intr_establish_xname(int legacy_irq, str * Shared interrupt - we can't rebind. * The port is shared instead. */ - evtchn = irq2port[gsi]; + evtchn = irq2port[gsi] - 1; } pih = pirq_establish(gsi, evtchn, handler, arg, level,
CVS commit: src/sys/arch/xen/x86
Module Name:src Committed By: cherry Date: Sat Nov 17 05:26:46 UTC 2018 Modified Files: src/sys/arch/xen/x86: hypervisor_machdep.c Log Message: Use hypervisor provided interface to unmask specific ports. Although at first glance this looks suboptimal, the unmask operation fast path does not use hypervisor_unmask_event(). Instead, it directly operates on the mask and pending bit arrays to provide what would effectively be an "auto mask/eoi" semantic. This change is thus not in the fast path, and has the advantage of performance improvements since cross CPU state updates etc. is handled within the hypervisor instead of domU IPIs. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/arch/xen/x86/hypervisor_machdep.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/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.29 src/sys/arch/xen/x86/hypervisor_machdep.c:1.30 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.29 Fri Oct 26 05:33:21 2018 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sat Nov 17 05:26:46 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.29 2018/10/26 05:33:21 cherry Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.30 2018/11/17 05:26:46 cherry Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.29 2018/10/26 05:33:21 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.30 2018/11/17 05:26:46 cherry Exp $"); #include #include @@ -322,47 +322,22 @@ hypervisor_send_event(struct cpu_info *c void hypervisor_unmask_event(unsigned int ev) { - volatile shared_info_t *s = HYPERVISOR_shared_info; - CPU_INFO_ITERATOR cii; - struct cpu_info *ci; - volatile struct vcpu_info *vci; + + KASSERT(ev > 0 && ev < NR_EVENT_CHANNELS); #ifdef PORT_DEBUG if (ev == PORT_DEBUG) printf("hypervisor_unmask_event %d\n", ev); #endif - xen_atomic_clear_bit(>evtchn_mask[0], ev); - /* - * The following is basically the equivalent of - * 'hw_resend_irq'. Just like a real IO-APIC we 'lose the - * interrupt edge' if the channel is masked. - */ - if (!xen_atomic_test_bit(>evtchn_pending[0], ev)) - return; + /* Xen unmasks the evtchn_mask[0]:ev bit for us. */ + evtchn_op_t op; + op.cmd = EVTCHNOP_unmask; + op.u.unmask.port = ev; + if (HYPERVISOR_event_channel_op() != 0) + panic("Failed to unmask event %d\n", ev); - for (CPU_INFO_FOREACH(cii, ci)) { - if (!xen_atomic_test_bit(>ci_evtmask[0], ev)) - continue; - vci = ci->ci_vcpu; - if (__predict_true(ci == curcpu())) { - if (!xen_atomic_test_and_set_bit(>evtchn_pending_sel, -ev>>LONG_SHIFT)) -xen_atomic_set_bit(>evtchn_upcall_pending, 0); - } - if (!vci->evtchn_upcall_mask) { - if (__predict_true(ci == curcpu())) { -hypervisor_force_callback(); - } else { -if (__predict_false( -xen_send_ipi(ci, XEN_IPI_HVCB))) { - panic("xen_send_ipi(cpu%d, " - "XEN_IPI_HVCB) failed\n", - (int) ci->ci_cpuid); -} - } - } - } + return; } void
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sun Nov 18 23:50:48 UTC 2018 Modified Files: src/sys/arch/amd64/include: cpu.h src/sys/arch/i386/include: cpu.h src/sys/arch/x86/include: cpu.h src/sys/arch/xen/x86: hypervisor_machdep.c src/sys/arch/xen/xen: clock.c Log Message: On Xen, copy just the bits we need from the trapframe for hardclock(9) and statclock(9). Current, the macros that use the trapframe are: CLKF_USERMODE() CLKF_PC() CLKF_INTR() Of these, CLKF_INTR() already ignores the frame and uses the ci_idepth variable to do its job. Convert the two remaining ones to do this, but only for XEN. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/amd64/include/cpu.h cvs rdiff -u -r1.179 -r1.180 src/sys/arch/i386/include/cpu.h cvs rdiff -u -r1.99 -r1.100 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.73 -r1.74 src/sys/arch/xen/xen/clock.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/amd64/include/cpu.h diff -u src/sys/arch/amd64/include/cpu.h:1.62 src/sys/arch/amd64/include/cpu.h:1.63 --- src/sys/arch/amd64/include/cpu.h:1.62 Fri Mar 16 12:21:50 2018 +++ src/sys/arch/amd64/include/cpu.h Sun Nov 18 23:50:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.62 2018/03/16 12:21:50 maxv Exp $ */ +/* $NetBSD: cpu.h,v 1.63 2018/11/18 23:50:48 cherry Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -83,8 +83,13 @@ cpu_set_curpri(int pri) } #endif /* __GNUC__ && !_MODULE */ +#ifdef XEN +#define CLKF_USERMODE(frame) (curcpu()->ci_xen_clockf_usermode) +#define CLKF_PC(frame) (curcpu()->ci_xen_clockf_pc) +#else /* XEN */ #define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_tf.tf_cs) #define CLKF_PC(frame) ((frame)->cf_if.if_tf.tf_rip) +#endif /* XEN */ #define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) #define LWP_PC(l) ((l)->l_md.md_regs->tf_rip) Index: src/sys/arch/i386/include/cpu.h diff -u src/sys/arch/i386/include/cpu.h:1.179 src/sys/arch/i386/include/cpu.h:1.180 --- src/sys/arch/i386/include/cpu.h:1.179 Sun Sep 17 09:41:35 2017 +++ src/sys/arch/i386/include/cpu.h Sun Nov 18 23:50:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.179 2017/09/17 09:41:35 maxv Exp $ */ +/* $NetBSD: cpu.h,v 1.180 2018/11/18 23:50:48 cherry Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -81,8 +81,13 @@ cpu_set_curpri(int pri) } #endif +#ifdef XEN +#define CLKF_USERMODE(frame) (curcpu()->ci_xen_clockf_usermode) +#define CLKF_PC(frame) (curcpu()->ci_xen_clockf_pc) +#else /* XEN */ #define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_cs) #define CLKF_PC(frame) ((frame)->cf_if.if_eip) +#endif /* XEN */ #define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) #define LWP_PC(l) ((l)->l_md.md_regs->tf_eip) Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.99 src/sys/arch/x86/include/cpu.h:1.100 --- src/sys/arch/x86/include/cpu.h:1.99 Sun Nov 18 10:24:09 2018 +++ src/sys/arch/x86/include/cpu.h Sun Nov 18 23:50:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.99 2018/11/18 10:24:09 cherry Exp $ */ +/* $NetBSD: cpu.h,v 1.100 2018/11/18 23:50:48 cherry Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -286,7 +286,8 @@ struct cpu_info { * Clockframe for timer interrupt handler. * Saved at entry via event callback. */ - struct clockframe ci_event_clockframe; + vaddr_t ci_xen_clockf_pc; /* RIP at last event interrupt */ + bool ci_xen_clockf_usermode; /* Was the guest in usermode ? */ /* Event counters for various pathologies that might happen. */ struct evcnt ci_xen_cpu_tsc_backwards_evcnt; Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.31 src/sys/arch/xen/x86/hypervisor_machdep.c:1.32 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.31 Sun Nov 18 10:24:09 2018 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sun Nov 18 23:50:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.31 2018/11/18 10:24:09 cherry Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.32 2018/11/18 23:50:48 cherry Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.31 2018/11/18 10:24:09 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.32 2018/11/18 23:50:48 cherry Exp $"); #include #include @@ -263,7 +263,8 @@ do_hypervisor_callback(struct intrframe /* Save trapframe for clock handler */ KASSERT(regs != NULL); - ci->ci_event_clockframe.cf_if = *regs; + ci->ci_xen_clockf_usermode = USERMODE(regs->if_tf.tf_cs); + ci->ci_xen_clockf_pc = regs->if_tf.tf_rip; // DDD printf("do_hypervisor_callback\n"); Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.73
CVS commit: src/sys/dev/acpi
Module Name:src Committed By: cherry Date: Mon Dec 3 05:22:03 UTC 2018 Modified Files: src/sys/dev/acpi: acpi_mcfg.c Log Message: Define macro before using it. This macro is used as a compile time "plugin" mechanism to use various platform specific enumeration functions. It is currently separately defined for 'native' and XEN, but the mechanism is not exported globally as it should be. XXX: fix this. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/acpi/acpi_mcfg.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/dev/acpi/acpi_mcfg.c diff -u src/sys/dev/acpi/acpi_mcfg.c:1.13 src/sys/dev/acpi/acpi_mcfg.c:1.14 --- src/sys/dev/acpi/acpi_mcfg.c:1.13 Fri Nov 2 19:51:08 2018 +++ src/sys/dev/acpi/acpi_mcfg.c Mon Dec 3 05:22:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_mcfg.c,v 1.13 2018/11/02 19:51:08 jmcneill Exp $ */ +/* $NetBSD: acpi_mcfg.c,v 1.14 2018/12/03 05:22:03 cherry Exp $ */ /*- * Copyright (C) 2015 NONAKA Kimihiro @@ -28,7 +28,7 @@ #include "opt_pci.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.13 2018/11/02 19:51:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.14 2018/12/03 05:22:03 cherry Exp $"); #include #include @@ -539,6 +539,10 @@ acpimcfg_device_probe(const struct pci_a return 0; } +#ifdef PCI_MACHDEP_ENUMERATE_BUS +#define pci_enumerate_bus PCI_MACHDEP_ENUMERATE_BUS +#endif + static void acpimcfg_scan_bus(struct pci_softc *sc, pci_chipset_tag_t pc, int bus) {
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Tue Dec 4 19:27:22 UTC 2018 Modified Files: src/sys/arch/x86/x86: cpu.c intr.c Log Message: Hypothetically speaking, if one were to want to compile a 'no options MULTIPROCESSOR' kernel, these files may trip up the build. Fix them by moving around the #defines as originally intended. No Functional Changes. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.136 -r1.137 src/sys/arch/x86/x86/intr.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/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.163 src/sys/arch/x86/x86/cpu.c:1.164 --- src/sys/arch/x86/x86/cpu.c:1.163 Tue Dec 4 19:22:42 2018 +++ src/sys/arch/x86/x86/cpu.c Tue Dec 4 19:27:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.163 2018/12/04 19:22:42 cherry Exp $ */ +/* $NetBSD: cpu.c,v 1.164 2018/12/04 19:27:22 cherry Exp $ */ /* * Copyright (c) 2000-2012 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.163 2018/12/04 19:22:42 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.164 2018/12/04 19:27:22 cherry Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -188,10 +188,10 @@ struct cpu_info *cpu_starting; void cpu_hatch(void *); static void cpu_boot_secondary(struct cpu_info *ci); static void cpu_start_secondary(struct cpu_info *ci); -#endif #if NLAPIC > 0 static void cpu_copy_trampoline(paddr_t); #endif +#endif /* MULTIPROCESSOR */ /* * Runs once per boot once multiprocessor goo has been detected and @@ -987,6 +987,7 @@ cpu_debug_dump(void) } #endif +#ifdef MULTIPROCESSOR #if NLAPIC > 0 static void cpu_copy_trampoline(paddr_t pdir_pa) @@ -1028,7 +1029,6 @@ cpu_copy_trampoline(paddr_t pdir_pa) } #endif -#ifdef MULTIPROCESSOR int mp_cpu_start(struct cpu_info *ci, paddr_t target) { Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.136 src/sys/arch/x86/x86/intr.c:1.137 --- src/sys/arch/x86/x86/intr.c:1.136 Sun Dec 2 08:19:44 2018 +++ src/sys/arch/x86/x86/intr.c Tue Dec 4 19:27:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.136 2018/12/02 08:19:44 cherry Exp $ */ +/* $NetBSD: intr.c,v 1.137 2018/12/04 19:27:22 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.136 2018/12/02 08:19:44 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.137 2018/12/04 19:27:22 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1493,7 +1493,9 @@ void cpu_intr_init(struct cpu_info *ci) { #if !defined(XEN) +#if (NLAPIC > 0) || defined(MULTIPROCESSOR) || defined(__HAVE_PREEMPTION) struct intrsource *isp; +#endif #if NLAPIC > 0 static int first = 1; #if defined(MULTIPROCESSOR)
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Tue Dec 4 19:22:42 UTC 2018 Modified Files: src/sys/arch/x86/x86: cpu.c Log Message: Stop panic()ing on a UP system. The reason for the panic is that the cpu_attach() doesn't run to completion because it thinks it's run past maxcpus (which in the case of UP), is 1. This is because on x86 at least, mi_cpu_attach() is called *before* configure() (and thus the cpu_match()/cpu_attach() pair). Thus ncpu has already been incremented by the time MD cpu_attach() is called. Fix this. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/arch/x86/x86/cpu.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/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.162 src/sys/arch/x86/x86/cpu.c:1.163 --- src/sys/arch/x86/x86/cpu.c:1.162 Mon Nov 12 18:10:36 2018 +++ src/sys/arch/x86/x86/cpu.c Tue Dec 4 19:22:42 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.162 2018/11/12 18:10:36 maxv Exp $ */ +/* $NetBSD: cpu.c,v 1.163 2018/12/04 19:22:42 cherry Exp $ */ /* * Copyright (c) 2000-2012 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.162 2018/11/12 18:10:36 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.163 2018/12/04 19:22:42 cherry Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -320,7 +320,7 @@ cpu_attach(device_t parent, device_t sel sc->sc_dev = self; - if (ncpu == maxcpus) { + if (ncpu > maxcpus) { #ifndef _LP64 aprint_error(": too many CPUs, please use NetBSD/amd64\n"); #else
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: cherry Date: Wed Feb 6 12:24:46 UTC 2019 Modified Files: src/sys/arch/xen/xen: xengnt.c Log Message: Add the codepath for grant table updates for VMs with an auto translated physmap. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/xen/xen/xengnt.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/xen/xengnt.c diff -u src/sys/arch/xen/xen/xengnt.c:1.25 src/sys/arch/xen/xen/xengnt.c:1.26 --- src/sys/arch/xen/xen/xengnt.c:1.25 Wed Oct 24 13:07:46 2012 +++ src/sys/arch/xen/xen/xengnt.c Wed Feb 6 12:24:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xengnt.c,v 1.25 2012/10/24 13:07:46 royger Exp $ */ +/* $NetBSD: xengnt.c,v 1.26 2019/02/06 12:24:46 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.25 2012/10/24 13:07:46 royger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.26 2019/02/06 12:24:46 cherry Exp $"); #include #include @@ -174,22 +174,44 @@ xengnt_more_entries(void) if (pages == NULL) return ENOMEM; - setup.dom = DOMID_SELF; - setup.nr_frames = nframes_new; - set_xen_guest_handle(setup.frame_list, pages); - - /* - * setup the grant table, made of nframes_new frames - * and return the list of their virtual addresses - * in 'pages' - */ - if (HYPERVISOR_grant_table_op(GNTTABOP_setup_table, , 1) != 0) - panic("%s: setup table failed", __func__); - if (setup.status != GNTST_okay) { - aprint_error("%s: setup table returned %d\n", - __func__, setup.status); - free(pages, M_DEVBUF); - return ENOMEM; + if (xen_feature(XENFEAT_auto_translated_physmap)) { + /* + * Note: Although we allocate space for the entire + * table, in this mode we only update one entry at a + * time. + */ + struct vm_page *pg; + struct xen_add_to_physmap xmap; + + pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE|UVM_PGA_ZERO); + pages[gnt_nr_grant_frames] = atop(uvm_vm_page_to_phys(pg)); + + xmap.domid = DOMID_SELF; + xmap.space = XENMAPSPACE_grant_table; + xmap.idx = gnt_nr_grant_frames; + xmap.gpfn = pages[gnt_nr_grant_frames]; + + if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, ) < 0) + panic("%s: Unable to register HYPERVISOR_shared_info\n", __func__); + + } else { + setup.dom = DOMID_SELF; + setup.nr_frames = nframes_new; + set_xen_guest_handle(setup.frame_list, pages); + + /* + * setup the grant table, made of nframes_new frames + * and return the list of their virtual addresses + * in 'pages' + */ + if (HYPERVISOR_grant_table_op(GNTTABOP_setup_table, , 1) != 0) + panic("%s: setup table failed", __func__); + if (setup.status != GNTST_okay) { + aprint_error("%s: setup table returned %d\n", + __func__, setup.status); + free(pages, M_DEVBUF); + return ENOMEM; + } } DPRINTF(("xengnt_more_entries: map 0x%lx -> %p\n",
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Wed Feb 13 05:01:58 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: vector.S src/sys/arch/i386/i386: vector.S src/sys/arch/xen/xen: evtchn.c Log Message: In preparation for debut-ing PVHVM mode: - Make the struct intrstub uniform across native and XEN. - Introduce vector callback entrypoints for PVHVM mode. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amd64/amd64/vector.S cvs rdiff -u -r1.80 -r1.81 src/sys/arch/i386/i386/vector.S cvs rdiff -u -r1.83 -r1.84 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/amd64/amd64/vector.S diff -u src/sys/arch/amd64/amd64/vector.S:1.66 src/sys/arch/amd64/amd64/vector.S:1.67 --- src/sys/arch/amd64/amd64/vector.S:1.66 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/amd64/amd64/vector.S Wed Feb 13 05:01:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vector.S,v 1.66 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: vector.S,v 1.67 2019/02/13 05:01:57 cherry Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -631,19 +631,7 @@ LABEL(name ## _stubs); \ INTRSTUB_ENTRY(name ## 31) ; \ END(name ## _stubs) - .section .rodata - -INTRSTUB_ARRAY_16(legacy) - -#if NIOAPIC > 0 -INTRSTUB_ARRAY_32(ioapic_edge) -INTRSTUB_ARRAY_32(ioapic_level) - -INTRSTUB_ARRAY_32(x2apic_edge) -INTRSTUB_ARRAY_32(x2apic_level) -#endif - -#endif /* !defined(XENPV) */ +#endif /* !XENPV */ #if defined(XEN) /* Resume/recurse procedures for spl() */ @@ -715,39 +703,49 @@ XENINTRSTUB(xenev,29,voidop,voidop,voido XENINTRSTUB(xenev,30,voidop,voidop,voidop,hypervisor_asm_unmask,voidop) XENINTRSTUB(xenev,31,voidop,voidop,voidop,hypervisor_asm_unmask,voidop) +/* On Xen, the xenev_stubs are purely for spl entry, since there is no + * vector based mechanism. We however provide the entrypoint to ensure + * that native and Xen struct intrstub ; definitions are uniform. + */ +panicmsg: .ascii "vector Xen event entry path entered." +LABEL(entry_xenev) + movq $panicmsg, %rdi + callq _C_LABEL(panic) +END(entry_xenev) + LABEL(xenev_stubs) - .quad _C_LABEL(Xrecurse_xenev0), _C_LABEL(Xresume_xenev0) - .quad _C_LABEL(Xrecurse_xenev1) ,_C_LABEL(Xresume_xenev1) - .quad _C_LABEL(Xrecurse_xenev2) ,_C_LABEL(Xresume_xenev2) - .quad _C_LABEL(Xrecurse_xenev3) ,_C_LABEL(Xresume_xenev3) - .quad _C_LABEL(Xrecurse_xenev4) ,_C_LABEL(Xresume_xenev4) - .quad _C_LABEL(Xrecurse_xenev5) ,_C_LABEL(Xresume_xenev5) - .quad _C_LABEL(Xrecurse_xenev6) ,_C_LABEL(Xresume_xenev6) - .quad _C_LABEL(Xrecurse_xenev7) ,_C_LABEL(Xresume_xenev7) - .quad _C_LABEL(Xrecurse_xenev8) ,_C_LABEL(Xresume_xenev8) - .quad _C_LABEL(Xrecurse_xenev9) ,_C_LABEL(Xresume_xenev9) - .quad _C_LABEL(Xrecurse_xenev10), _C_LABEL(Xresume_xenev10) - .quad _C_LABEL(Xrecurse_xenev11), _C_LABEL(Xresume_xenev11) - .quad _C_LABEL(Xrecurse_xenev12), _C_LABEL(Xresume_xenev12) - .quad _C_LABEL(Xrecurse_xenev13), _C_LABEL(Xresume_xenev13) - .quad _C_LABEL(Xrecurse_xenev14), _C_LABEL(Xresume_xenev14) - .quad _C_LABEL(Xrecurse_xenev15), _C_LABEL(Xresume_xenev15) - .quad _C_LABEL(Xrecurse_xenev16), _C_LABEL(Xresume_xenev16) - .quad _C_LABEL(Xrecurse_xenev17), _C_LABEL(Xresume_xenev17) - .quad _C_LABEL(Xrecurse_xenev18), _C_LABEL(Xresume_xenev18) - .quad _C_LABEL(Xrecurse_xenev19), _C_LABEL(Xresume_xenev19) - .quad _C_LABEL(Xrecurse_xenev20), _C_LABEL(Xresume_xenev20) - .quad _C_LABEL(Xrecurse_xenev21), _C_LABEL(Xresume_xenev21) - .quad _C_LABEL(Xrecurse_xenev22), _C_LABEL(Xresume_xenev22) - .quad _C_LABEL(Xrecurse_xenev23), _C_LABEL(Xresume_xenev23) - .quad _C_LABEL(Xrecurse_xenev24), _C_LABEL(Xresume_xenev24) - .quad _C_LABEL(Xrecurse_xenev25), _C_LABEL(Xresume_xenev25) - .quad _C_LABEL(Xrecurse_xenev26), _C_LABEL(Xresume_xenev26) - .quad _C_LABEL(Xrecurse_xenev27), _C_LABEL(Xresume_xenev27) - .quad _C_LABEL(Xrecurse_xenev28), _C_LABEL(Xresume_xenev28) - .quad _C_LABEL(Xrecurse_xenev29), _C_LABEL(Xresume_xenev29) - .quad _C_LABEL(Xrecurse_xenev30), _C_LABEL(Xresume_xenev30) - .quad _C_LABEL(Xrecurse_xenev31), _C_LABEL(Xresume_xenev31) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev0), _C_LABEL(Xresume_xenev0) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev1) ,_C_LABEL(Xresume_xenev1) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev2) ,_C_LABEL(Xresume_xenev2) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev3) ,_C_LABEL(Xresume_xenev3) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev4) ,_C_LABEL(Xresume_xenev4) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev5) ,_C_LABEL(Xresume_xenev5) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev6) ,_C_LABEL(Xresume_xenev6) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev7) ,_C_LABEL(Xresume_xenev7) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev8) ,_C_LABEL(Xresume_xenev8) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev9) ,_C_LABEL(Xresume_xenev9) + .quad entry_xenev, _C_LABEL(Xrecurse_xenev10),
CVS commit: src/sys/arch/xen/x86
Module Name:src Committed By: cherry Date: Wed Feb 13 06:15:51 UTC 2019 Modified Files: src/sys/arch/xen/x86: pintr.c Log Message: Catchup with struct intrstub; unification. This should fix dom0 build breakage. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/x86/pintr.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/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.9 src/sys/arch/xen/x86/pintr.c:1.10 --- src/sys/arch/xen/x86/pintr.c:1.9 Wed Oct 10 02:34:08 2018 +++ src/sys/arch/xen/x86/pintr.c Wed Feb 13 06:15:51 2019 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.9 2018/10/10 02:34:08 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.10 2019/02/13 06:15:51 cherry Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -135,17 +135,19 @@ __KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1. /* XXX: todo - compat with lapic.c and XEN for x2apic */ bool x2apic_mode __read_mostly = false; /* for x86/i8259.c */ -struct intrstub legacy_stubs[NUM_LEGACY_IRQS] = {{0,0}}; +struct intrstub legacy_stubs[NUM_LEGACY_IRQS] = {{0,0,0}}; /* for x86/ioapic.c */ -struct intrstub ioapic_edge_stubs[MAX_INTR_SOURCES] = {{0,0}}; -struct intrstub ioapic_level_stubs[MAX_INTR_SOURCES] = {{0,0}}; -struct intrstub x2apic_edge_stubs[MAX_INTR_SOURCES] = {{0,0}}; -struct intrstub x2apic_level_stubs[MAX_INTR_SOURCES] = {{0,0}}; +struct intrstub ioapic_edge_stubs[MAX_INTR_SOURCES] = {{0,0,0}}; +struct intrstub ioapic_level_stubs[MAX_INTR_SOURCES] = {{0,0,0}}; +struct intrstub x2apic_edge_stubs[MAX_INTR_SOURCES] = {{0,0,0}}; +struct intrstub x2apic_level_stubs[MAX_INTR_SOURCES] = {{0,0,0}}; #include +#endif /* NIOAPIC */ + int irq2port[NR_EVENT_CHANNELS] = {0}; /* actually port + 1, so that 0 is invaid */ static int irq2vect[256] = {0}; static int vect2irq[256] = {0}; -#endif /* NIOAPIC */ + #if NACPICA > 0 #include #include
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Wed Feb 13 05:36:59 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S src/sys/arch/i386/i386: locore.S Log Message: Rig the hypercall callback page such that when the kernel happens to run without a XEN domain loader having previously overwritten the hypercall page with its hypercall trampoline machine code, we still get to detect its presence by calling the xen_version hypercall stub. We use this hack to detect the presence or absence of the hypervisor, without relying on the MSR support on HVM domains. This works as an added sanity check that the hypercall page registration has indeed succeeded in HVM mode. To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.163 -r1.164 src/sys/arch/i386/i386/locore.S 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/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.176 src/sys/arch/amd64/amd64/locore.S:1.177 --- src/sys/arch/amd64/amd64/locore.S:1.176 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/amd64/amd64/locore.S Wed Feb 13 05:36:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.176 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: locore.S,v 1.177 2019/02/13 05:36:59 cherry Exp $ */ /* * Copyright-o-rama! @@ -278,6 +278,8 @@ #define __ASSEMBLY__ #include #include +#endif /* XEN */ + #ifdef XENPV #define ELFNOTE(name, type, desctype, descdata...) \ .pushsection .note.name ; \ @@ -312,7 +314,6 @@ ELFNOTE(Xen, XEN_ELFNOTE_BSD_SYMTAB, .asciz, "yes") #endif #endif /* XENPV */ -#endif /* XEN */ /* * Initialization @@ -979,9 +980,12 @@ END(start) #if defined(XEN) /* space for the hypercall call page */ #define HYPERCALL_PAGE_OFFSET 0x1000 -.org HYPERCALL_PAGE_OFFSET -ENTRY(hypercall_page) -.skip 0x1000 +.align HYPERCALL_PAGE_OFFSET +ENTRY(hypercall_page) /* Returns -1, on HYPERVISOR_xen_version() */ +.skip (__HYPERVISOR_xen_version*32), 0x90 + movq $-1, %rax + retq +.align HYPERCALL_PAGE_OFFSET, 0x90 END(hypercall_page) #endif /* XEN */ Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.163 src/sys/arch/i386/i386/locore.S:1.164 --- src/sys/arch/i386/i386/locore.S:1.163 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/i386/i386/locore.S Wed Feb 13 05:36:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.163 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: locore.S,v 1.164 2019/02/13 05:36:59 cherry Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.163 2019/02/11 14:59:32 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.164 2019/02/13 05:36:59 cherry Exp $"); #include "opt_copy_symtab.h" #include "opt_ddb.h" @@ -242,6 +242,20 @@ __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1 loop 1b ; +#ifdef XEN +/* + * Unfortunately, the Xen codebase uses nonstandard preprocessing tools. + * See: https://xenbits.xen.org/gitweb/?p=xen.git=search=HEAD=grep=__UnDeF__ + * for a fine selection of examples. + * + * What this means for us here is that we can't include the standard + * xen.h header in assembler code. + * + * So we have to manually define, and keep track of the values we need, ourselves. + */ +#define __HYPERVISOR_xen_version 17 +#endif /* XEN */ + #ifdef XENPV /* * Xen guest identifier and loader selection @@ -916,9 +930,12 @@ END(start) #if defined(XEN) /* space for the hypercall call page */ #define HYPERCALL_PAGE_OFFSET 0x1000 -.org HYPERCALL_PAGE_OFFSET -ENTRY(hypercall_page) -.skip 0x1000 +.align HYPERCALL_PAGE_OFFSET +ENTRY(hypercall_page) /* Returns -1, on HYPERVISOR_xen_version() */ +.skip (__HYPERVISOR_xen_version*32), 0x90 + movl $-1, %eax + retl +.align HYPERCALL_PAGE_OFFSET, 0x90 END(hypercall_page) #ifdef XENPV
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: cherry Date: Wed Feb 13 05:28:50 UTC 2019 Modified Files: src/sys/arch/x86/include: intr.h Log Message: Missed the crucial header file in previous commit. struct intrstub; is now uniform across native and XEN This should fix the XEN builds. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/include/intr.h 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/x86/include/intr.h diff -u src/sys/arch/x86/include/intr.h:1.58 src/sys/arch/x86/include/intr.h:1.59 --- src/sys/arch/x86/include/intr.h:1.58 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/x86/include/intr.h Wed Feb 13 05:28:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.58 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: intr.h,v 1.59 2019/02/13 05:28:50 cherry Exp $ */ /*- * Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -71,9 +71,7 @@ */ struct intrstub { -#if !defined(XENPV) void *ist_entry; -#endif void *ist_recurse; void *ist_resume; };
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Wed Feb 13 06:52:43 UTC 2019 Modified Files: src/sys/arch/xen/include: xenpmap.h src/sys/arch/xen/xen: evtchn.c hypervisor.c xen_machdep.c Log Message: Further restrict the scope of XENPV to relevant parts. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/arch/xen/include/xenpmap.h cvs rdiff -u -r1.84 -r1.85 src/sys/arch/xen/xen/evtchn.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/xen/xen/xen_machdep.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/xenpmap.h diff -u src/sys/arch/xen/include/xenpmap.h:1.40 src/sys/arch/xen/include/xenpmap.h:1.41 --- src/sys/arch/xen/include/xenpmap.h:1.40 Thu Jul 26 17:20:08 2018 +++ src/sys/arch/xen/include/xenpmap.h Wed Feb 13 06:52:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xenpmap.h,v 1.40 2018/07/26 17:20:08 maxv Exp $ */ +/* $NetBSD: xenpmap.h,v 1.41 2019/02/13 06:52:43 cherry Exp $ */ /* * @@ -72,6 +72,7 @@ void xen_kpm_sync(struct pmap *, int); #define xpq_queue_pin_l4_table(pa) \ xpq_queue_pin_table(pa, MMUEXT_PIN_L4_TABLE) +#ifdef XENPV extern unsigned long *xpmap_phys_to_machine_mapping; static __inline paddr_t @@ -121,6 +122,8 @@ xpmap_ptom_isvalid(paddr_t ppa) != INVALID_P2M_ENTRY); } +#endif /* XENPV */ + static inline void MULTI_update_va_mapping( multicall_entry_t *mcl, vaddr_t va, Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.84 src/sys/arch/xen/xen/evtchn.c:1.85 --- src/sys/arch/xen/xen/evtchn.c:1.84 Wed Feb 13 05:01:58 2019 +++ src/sys/arch/xen/xen/evtchn.c Wed Feb 13 06:52:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.84 2019/02/13 05:01:58 cherry Exp $ */ +/* $NetBSD: evtchn.c,v 1.85 2019/02/13 06:52:43 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.84 2019/02/13 05:01:58 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.85 2019/02/13 06:52:43 cherry Exp $"); #include "opt_xen.h" #include "isa.h" @@ -256,6 +256,7 @@ void events_init(void) { mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); +#ifdef XENPV debug_port = bind_virq_to_evtch(VIRQ_DEBUG); KASSERT(debug_port != -1); @@ -273,6 +274,7 @@ events_init(void) #if NPCI > 0 || NISA > 0 hypervisor_ack_pirq_event(debug_port); #endif /* NPCI > 0 || NISA > 0 */ +#endif /* XENPV */ x86_enable_intr(); /* at long last... */ } @@ -1080,6 +1082,7 @@ xen_debug_handler(void *arg) return 0; } +#ifdef XENPV static struct evtsource * event_get_handler(const char *intrid) { @@ -1207,3 +1210,4 @@ interrupt_construct_intrids(const kcpuse return ii_handler; } +#endif /* XENPV */ Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.70 src/sys/arch/xen/xen/hypervisor.c:1.71 --- src/sys/arch/xen/xen/hypervisor.c:1.70 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/xen/hypervisor.c Wed Feb 13 06:52:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.70 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: hypervisor.c,v 1.71 2019/02/13 06:52:43 cherry Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.70 2019/02/02 12:32:55 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.71 2019/02/13 06:52:43 cherry Exp $"); #include #include @@ -373,20 +373,22 @@ hypervisor_attach(device_t parent, devic static bool hypervisor_suspend(device_t dev, const pmf_qual_t *qual) { +#ifdef XENPV events_suspend(); xengnt_suspend(); - +#endif return true; } static bool hypervisor_resume(device_t dev, const pmf_qual_t *qual) { +#ifdef XENPV hypervisor_machdep_resume(); xengnt_resume(); events_resume(); - +#endif return true; } Index: src/sys/arch/xen/xen/xen_machdep.c diff -u src/sys/arch/xen/xen/xen_machdep.c:1.20 src/sys/arch/xen/xen/xen_machdep.c:1.21 --- src/sys/arch/xen/xen/xen_machdep.c:1.20 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/xen/xen_machdep.c Wed Feb 13 06:52:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_machdep.c,v 1.20 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: xen_machdep.c,v 1.21 2019/02/13 06:52:43 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.20 2019/02/02 12:32:55 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.21 2019/02/13 06:52:43 cherry Exp $"); #include "opt_xen.h" @@ -80,6 +80,7 @@ u_int tsc_get_timecount(struct timecount bool xen_suspend_allow; +#ifdef XENPV extern uint64_t tsc_freq; /* XXX */ static int sysctl_xen_suspend(SYSCTLFN_ARGS); @@ -419,6 +420,7 @@ xen_suspend_domain(void) aprint_verbose("domain resumed\n"); } +#endif /* XENPV */ #define PRINTK_BUFSIZE 1024 void
CVS commit: src/sys/arch/xen/x86
Module Name:src Committed By: cherry Date: Wed Feb 13 09:57:46 UTC 2019 Modified Files: src/sys/arch/xen/x86: xen_mainbus.c Log Message: Conditionally compile a conditionally used variable. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/xen/x86/xen_mainbus.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/x86/xen_mainbus.c diff -u src/sys/arch/xen/x86/xen_mainbus.c:1.4 src/sys/arch/xen/x86/xen_mainbus.c:1.5 --- src/sys/arch/xen/x86/xen_mainbus.c:1.4 Sat Dec 22 08:35:04 2018 +++ src/sys/arch/xen/x86/xen_mainbus.c Wed Feb 13 09:57:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $ */ +/* $NetBSD: xen_mainbus.c,v 1.5 2019/02/13 09:57:46 cherry Exp $ */ /* NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp */ /* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */ @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.5 2019/02/13 09:57:46 cherry Exp $"); #include #include @@ -130,7 +130,9 @@ xen_mainbus_match(device_t parent, cfdat void xen_mainbus_attach(device_t parent, device_t self, void *aux) { +#if NIPMI > 0 || NHYPERVISOR > 0 union xen_mainbus_attach_args mba; +#endif #if NIPMI > 0 memset(_ipmi, 0, sizeof(mba.mba_ipmi));
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Thu Feb 14 06:59:25 UTC 2019 Modified Files: src/sys/arch/xen/conf: files.xen src/sys/arch/xen/include: bus_private.h src/sys/arch/xen/include/amd64: vmparam.h Log Message: Snag the final bits of PV only code to conditionally compile under -DXENPV This completes the bifurcation. The next step is to add -DXENPVHVM code. To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/include/bus_private.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/xen/include/amd64/vmparam.h 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/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.176 src/sys/arch/xen/conf/files.xen:1.177 --- src/sys/arch/xen/conf/files.xen:1.176 Sun Jan 27 02:08:39 2019 +++ src/sys/arch/xen/conf/files.xen Thu Feb 14 06:59:24 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.176 2019/01/27 02:08:39 pgoyette Exp $ +# $NetBSD: files.xen,v 1.177 2019/02/14 06:59:24 cherry Exp $ # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp @@ -36,7 +36,7 @@ defflag opt_pcifixup.h PCI_ADDR_FIXUP PC defparam PCI_CONF_MODE -file arch/xen/x86/autoconf.c +file arch/xen/x86/autoconf.c xenpv ifdef i386 file arch/i386/i386/aout_machdep.c exec_aout file arch/i386/i386/busfunc.S @@ -86,10 +86,10 @@ file arch/xen/x86/hypervisor_machdep.c file arch/x86/x86/kgdb_machdep.c kgdb # file arch/x86/x86/mtrr_i686.c mtrr file arch/x86/x86/syscall.c -file arch/xen/x86/x86_xpmap.c -file arch/xen/x86/xen_pmap.c +file arch/xen/x86/x86_xpmap.c xenpv +file arch/xen/x86/xen_pmap.c xenpv file arch/xen/x86/xen_intr.c -file arch/xen/x86/xenfunc.c +file arch/xen/x86/xenfunc.c xenpv file arch/x86/x86/cpu_ucode.c dom0ops & cpu_ucode needs-flag file arch/x86/x86/cpu_ucode_amd.c dom0ops & cpu_ucode needs-flag @@ -97,9 +97,9 @@ file arch/x86/x86/cpu_ucode_intel.c dom0 file arch/x86/x86/compat_60_cpu_ucode.c compat_60 & dom0ops & cpu_ucode -file arch/xen/xen/xen_machdep.c +file arch/xen/xen/xen_machdep.c xenpv -file arch/xen/xen/clock.c +file arch/xen/xen/clock.c xenpv file arch/x86/isa/rtc.c dom0ops file arch/xen/xen/evtchn.c @@ -133,12 +133,12 @@ file dev/md_root.c memory_disk_hooks file arch/x86/x86/bus_dma.c machdep file arch/x86/x86/core_machdep.c coredump -file arch/xen/x86/xen_bus_dma.c machdep +file arch/xen/x86/xen_bus_dma.c machdep & xenpv file arch/x86/x86/bus_space.c machdep -file arch/xen/x86/consinit.c machdep +file arch/xen/x86/consinit.c machdep & xenpv file arch/x86/x86/identcpu.c machdep -file arch/xen/x86/pintr.c machdep & dom0ops -file arch/xen/x86/xen_ipi.c multiprocessor +file arch/xen/x86/pintr.c machdep & dom0ops & xenpv +file arch/xen/x86/xen_ipi.c multiprocessor & xenpv file arch/x86/x86/idt.c machdep file arch/x86/x86/pmap.c machdep file arch/x86/x86/x86_tlb.c machdep @@ -253,7 +253,7 @@ device fdc {drive = -1} #XXX include "dev/apm/files.apm" include "dev/acpi/files.acpi" -file arch/xen/xen/xen_acpi_machdep.c acpi +file arch/xen/xen/xen_acpi_machdep.c acpi & xenpv file arch/x86/x86/mpacpi.c acpi file arch/x86/x86/i8259.c dom0ops @@ -289,8 +289,7 @@ attach cpu at cpubus device vcpu attach vcpu at xendevbus - -file arch/xen/x86/cpu.c cpu | vcpu +file arch/xen/x86/cpu.c xenpv & vcpu # CPU features # Index: src/sys/arch/xen/include/bus_private.h diff -u src/sys/arch/xen/include/bus_private.h:1.9 src/sys/arch/xen/include/bus_private.h:1.10 --- src/sys/arch/xen/include/bus_private.h:1.9 Wed Jan 23 19:46:45 2008 +++ src/sys/arch/xen/include/bus_private.h Thu Feb 14 06:59:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_private.h,v 1.9 2008/01/23 19:46:45 bouyer Exp $ */ +/* $NetBSD: bus_private.h,v 1.10 2019/02/14 06:59:24 cherry Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -29,6 +29,7 @@ #include #include "opt_xen.h" +#ifdef XENPV #define _BUS_PHYS_TO_BUS(pa) ((bus_addr_t)xpmap_ptom(pa)) #define _BUS_BUS_TO_PHYS(ba) ((paddr_t)xpmap_mtop(ba)) #define _BUS_VIRT_TO_BUS(pm, va) _bus_virt_to_bus((pm), (va)) @@ -65,5 +66,6 @@ int _xen_bus_dmamem_alloc_range(bus_dma_ #else #define _BUS_AVAIL_END ((bus_addr_t)0x) #endif - +#endif /* XENPV */ #include + Index: src/sys/arch/xen/include/amd64/vmparam.h diff -u src/sys/arch/xen/include/amd64/vmparam.h:1.2 src/sys/arch/xen/include/amd64/vmparam.h:1.3 --- src/sys/arch/xen/include/amd64/vmparam.h:1.2 Thu Nov 22 16:17:02 2007 +++ src/sys/arch/xen/include/amd64/vmparam.h Thu Feb 14 06:59:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.2 2007/11/22 16:17:02 bouyer Exp $ */ +/* $NetBSD: vmparam.h,v 1.3 2019/02/14 06:59:24 cherry Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -29,10 +29,13 @@ #if !defined(_VMPARAM_H_) #include +#ifdef XENPV
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Thu Feb 14 07:12:40 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: amd64_mainbus.c db_interface.c src/sys/arch/i386/i386: db_interface.c src/sys/arch/x86/x86: cpu.c Log Message: Fix NLAPIC, NISA and NIOAPIC related conditional compile errors. This will allow us to now compile an amd64 kernel without PCI. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/amd64/amd64_mainbus.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/amd64/db_interface.c cvs rdiff -u -r1.83 -r1.84 src/sys/arch/i386/i386/db_interface.c cvs rdiff -u -r1.164 -r1.165 src/sys/arch/x86/x86/cpu.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/amd64/amd64/amd64_mainbus.c diff -u src/sys/arch/amd64/amd64/amd64_mainbus.c:1.4 src/sys/arch/amd64/amd64/amd64_mainbus.c:1.5 --- src/sys/arch/amd64/amd64/amd64_mainbus.c:1.4 Sat Dec 22 08:35:04 2018 +++ src/sys/arch/amd64/amd64/amd64_mainbus.c Thu Feb 14 07:12:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: amd64_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $ */ +/* $NetBSD: amd64_mainbus.c,v 1.5 2019/02/14 07:12:40 cherry Exp $ */ /* NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: amd64_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amd64_mainbus.c,v 1.5 2019/02/14 07:12:40 cherry Exp $"); #include #include @@ -155,7 +155,7 @@ amd64_mainbus_match(device_t parent, cfd void amd64_mainbus_attach(device_t parent, device_t self, void *aux) { -#if NPCI > 0 || NACPICA > 0 || NIPMI > 0 +#if NISA > 0 || NPCI > 0 || NACPICA > 0 || NIPMI > 0 union amd64_mainbus_attach_args mba; #endif Index: src/sys/arch/amd64/amd64/db_interface.c diff -u src/sys/arch/amd64/amd64/db_interface.c:1.35 src/sys/arch/amd64/amd64/db_interface.c:1.36 --- src/sys/arch/amd64/amd64/db_interface.c:1.35 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/amd64/amd64/db_interface.c Thu Feb 14 07:12:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.35 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: db_interface.c,v 1.36 2019/02/14 07:12:40 cherry Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.35 2019/02/11 14:59:32 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.36 2019/02/14 07:12:40 cherry Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -52,9 +52,13 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface #include #include #include +#if NIOAPIC > 0 #include +#endif +#if NLAPIC > 0 #include #include +#endif #include #include @@ -145,7 +149,9 @@ db_suspend_others(void) #ifdef XENPV xen_broadcast_ipi(XEN_IPI_DDB); #else +#if NLAPIC > 0 x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED); +#endif #endif /* XENPV */ } ddb_mp_online = x86_mp_online; Index: src/sys/arch/i386/i386/db_interface.c diff -u src/sys/arch/i386/i386/db_interface.c:1.83 src/sys/arch/i386/i386/db_interface.c:1.84 --- src/sys/arch/i386/i386/db_interface.c:1.83 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/i386/i386/db_interface.c Thu Feb 14 07:12:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.83 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: db_interface.c,v 1.84 2019/02/14 07:12:40 cherry Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.83 2019/02/11 14:59:32 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.84 2019/02/14 07:12:40 cherry Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -150,7 +150,9 @@ db_suspend_others(void) #ifdef XENPV xen_broadcast_ipi(XEN_IPI_DDB); #else +#if NLAPIC > 0 x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED); +#endif #endif /* XENPV */ } ddb_mp_online = x86_mp_online; Index: src/sys/arch/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.164 src/sys/arch/x86/x86/cpu.c:1.165 --- src/sys/arch/x86/x86/cpu.c:1.164 Tue Dec 4 19:27:22 2018 +++ src/sys/arch/x86/x86/cpu.c Thu Feb 14 07:12:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.164 2018/12/04 19:27:22 cherry Exp $ */ +/* $NetBSD: cpu.c,v 1.165 2019/02/14 07:12:40 cherry Exp $ */ /* * Copyright (c) 2000-2012 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.164 2018/12/04 19:27:22 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.165 2019/02/14 07:12:40 cherry Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -754,12 +754,14 @@ cpu_init_idle_lwps(void) void cpu_start_secondary(struct cpu_info *ci) { - paddr_t mp_pdirpa; u_long psl; int i; +#if NLAPIC > 0 + paddr_t mp_pdirpa; mp_pdirpa = pmap_init_tmp_pgtbl(mp_trampoline_paddr); cpu_copy_trampoline(mp_pdirpa);
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Thu Feb 14 08:18:26 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S machdep.c spl.S vector.S src/sys/arch/amd64/include: frame.h src/sys/arch/i386/i386: machdep.c vector.S src/sys/arch/i386/include: frame.h frameasm.h src/sys/arch/x86/include: cpu.h intr.h src/sys/arch/x86/x86: cpu.c intr.c mainbus.c pmap.c x86_machdep.c src/sys/arch/xen/conf: files.xen src/sys/arch/xen/x86: xen_intr.c xen_mainbus.c src/sys/arch/xen/xen: hypervisor.c if_xennet_xenbus.c Added Files: src/sys/arch/amd64/conf: XEN3_PVHVM src/sys/arch/i386/conf: XEN3PAE_PVHVM Log Message: Welcome XENPVHVM mode. It is UP only, has xbd(4) and xennet(4) as PV drivers. The console is com0 at isa and the native portion is very rudimentary AT architecture, so is probably suboptimal to run without PV support. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.325 -r1.326 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.39 -r1.40 src/sys/arch/amd64/amd64/spl.S cvs rdiff -u -r1.67 -r1.68 src/sys/arch/amd64/amd64/vector.S cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/conf/XEN3_PVHVM cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/include/frame.h cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/conf/XEN3PAE_PVHVM cvs rdiff -u -r1.815 -r1.816 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.81 -r1.82 src/sys/arch/i386/i386/vector.S cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/include/frame.h cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/include/frameasm.h cvs rdiff -u -r1.103 -r1.104 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.59 -r1.60 src/sys/arch/x86/include/intr.h cvs rdiff -u -r1.165 -r1.166 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.142 -r1.143 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/x86/mainbus.c cvs rdiff -u -r1.322 -r1.323 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.122 -r1.123 src/sys/arch/x86/x86/x86_machdep.c cvs rdiff -u -r1.177 -r1.178 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.14 -r1.15 src/sys/arch/xen/x86/xen_intr.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/xen/x86/xen_mainbus.c cvs rdiff -u -r1.71 -r1.72 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r1.84 -r1.85 src/sys/arch/xen/xen/if_xennet_xenbus.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/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.177 src/sys/arch/amd64/amd64/locore.S:1.178 --- src/sys/arch/amd64/amd64/locore.S:1.177 Wed Feb 13 05:36:59 2019 +++ src/sys/arch/amd64/amd64/locore.S Thu Feb 14 08:18:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.177 2019/02/13 05:36:59 cherry Exp $ */ +/* $NetBSD: locore.S,v 1.178 2019/02/14 08:18:25 cherry Exp $ */ /* * Copyright-o-rama! @@ -1112,7 +1112,7 @@ ENTRY(cpu_switchto) .Lskip_svs: #endif -#ifndef XENPV +#ifndef XEN movq %r13,%rdi movq %r12,%rsi callq _C_LABEL(speculation_barrier) Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.325 src/sys/arch/amd64/amd64/machdep.c:1.326 --- src/sys/arch/amd64/amd64/machdep.c:1.325 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/amd64/amd64/machdep.c Thu Feb 14 08:18:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.325 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: machdep.c,v 1.326 2019/02/14 08:18:25 cherry Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.325 2019/02/11 14:59:32 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.326 2019/02/14 08:18:25 cherry Exp $"); #include "opt_modular.h" #include "opt_user_ldt.h" @@ -193,7 +193,9 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include #include -#endif +#include +#include +#endif /* XEN */ #ifdef DDB #include @@ -1693,7 +1695,7 @@ init_x86_64(paddr_t first_avail) svs_init(); #endif cpu_init_msrs(_info_primary, true); -#ifndef XENPV +#ifndef XEN cpu_speculation_init(_info_primary); #endif @@ -1905,6 +1907,7 @@ init_x86_64(paddr_t first_avail) (unsigned long) Xsyscall)) panic("HYPERVISOR_set_callbacks() failed"); #endif /* XENPV */ + cpu_init_idt(); init_x86_64_ksyms(); Index: src/sys/arch/amd64/amd64/spl.S diff -u src/sys/arch/amd64/amd64/spl.S:1.39 src/sys/arch/amd64/amd64/spl.S:1.40 --- src/sys/arch/amd64/amd64/spl.S:1.39 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/amd64/amd64/spl.S Thu Feb 14 08:18:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.39 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: spl.S,v 1.40 2019/02/14 08:18:25 cherry Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -211,7 +211,9 @@ IDTVEC(resume_preempt) cli jmp *%r13 /* back to Xdoreti */ IDTVEC_END(resume_preempt) +#endif /* XEN */ +#ifndef XENPV /* * void
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Mon Feb 11 18:50:15 UTC 2019 Modified Files: src/sys/arch/x86/x86: identcpu.c Log Message: Detect and report running in a XEN hvm container. This allows the lapic code to apply its x2apic probe logic while running in a XEN hvm container. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/arch/x86/x86/identcpu.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/x86/x86/identcpu.c diff -u src/sys/arch/x86/x86/identcpu.c:1.87 src/sys/arch/x86/x86/identcpu.c:1.88 --- src/sys/arch/x86/x86/identcpu.c:1.87 Mon Feb 11 14:59:33 2019 +++ src/sys/arch/x86/x86/identcpu.c Mon Feb 11 18:50:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.87 2019/02/11 14:59:33 cherry Exp $ */ +/* $NetBSD: identcpu.c,v 1.88 2019/02/11 18:50:15 cherry Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.87 2019/02/11 14:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.88 2019/02/11 18:50:15 cherry Exp $"); #include "opt_xen.h" @@ -1125,6 +1125,8 @@ identify_hypervisor(void) vm_guest = VM_GUEST_HV; else if (memcmp(hv_vendor, "KVMKVMKVM\0\0\0", 12) == 0) vm_guest = VM_GUEST_KVM; + else if (memcmp(hv_vendor, "XenVMMXenVMM", 12) == 0) +vm_guest = VM_GUEST_XEN; /* FreeBSD bhyve: "bhyve bhyve " */ /* OpenBSD vmm: "OpenBSDVMM58" */ /* NetBSD nvmm: "___ NVMM ___" */
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: cherry Date: Mon Feb 11 17:28:52 UTC 2019 Modified Files: src/sys/arch/i386/i386: i386_trap.S Log Message: Remove redundant conditional IDT_VEC() entries. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/i386/i386_trap.S 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/i386/i386/i386_trap.S diff -u src/sys/arch/i386/i386/i386_trap.S:1.17 src/sys/arch/i386/i386/i386_trap.S:1.18 --- src/sys/arch/i386/i386/i386_trap.S:1.17 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/i386/i386/i386_trap.S Mon Feb 11 17:28:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: i386_trap.S,v 1.17 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -66,7 +66,7 @@ #if 0 #include -__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.17 2019/02/11 14:59:32 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $"); #endif /* @@ -345,13 +345,8 @@ IDTVEC_END(trap17) IDTVEC_END(trap16) IDTVEC_END(trap15) IDTVEC_END(trap14) -#ifndef XENPV IDTVEC_END(trap13) IDTVEC_END(trap12) -#else -IDTVEC_END(trap13) -IDTVEC_END(trap12) -#endif IDTVEC_END(trap11) IDTVEC(exceptions)
CVS commit: src/sys/arch/xen/include
Module Name:src Committed By: cherry Date: Sun Feb 10 11:10:34 UTC 2019 Modified Files: src/sys/arch/xen/include/amd64: hypercalls.h src/sys/arch/xen/include/i386: hypercalls.h Log Message: Catchup hypercall interfaces for HYPERVISOR_sched_op which use arguments to __XEN_INTERFACE_VERSION__ >= 0x00030201 We've been using the sched_op_compat API with sched_op arguments. fixes PR port-xen/53965 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/xen/include/amd64/hypercalls.h cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/include/i386/hypercalls.h 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/amd64/hypercalls.h diff -u src/sys/arch/xen/include/amd64/hypercalls.h:1.11 src/sys/arch/xen/include/amd64/hypercalls.h:1.12 --- src/sys/arch/xen/include/amd64/hypercalls.h:1.11 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/include/amd64/hypercalls.h Sun Feb 10 11:10:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.11 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: hypercalls.h,v 1.12 2019/02/10 11:10:34 cherry Exp $ */ /** * hypercall.h * @@ -320,8 +320,18 @@ static inline int HYPERVISOR_suspend( unsigned long srec) { +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + + struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_suspend, + }; + + return _hypercall3(int, sched_op, SCHEDOP_shutdown, + _reason, srec); +#else return _hypercall3(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_suspend, srec); +#endif } static inline long @@ -342,21 +352,51 @@ static inline long HYPERVISOR_shutdown( void) { - return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_poweroff); +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + + struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_poweroff, + }; + + return _hypercall2(int, sched_op, SCHEDOP_shutdown, + _reason); +#else +- return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_poweroff); +#endif } static inline long HYPERVISOR_crash( void) { +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + + struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_crash, + }; + + return _hypercall2(int, sched_op, SCHEDOP_shutdown, + _reason); +#else return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_crash); +#endif } static inline long HYPERVISOR_reboot( void) { +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + + struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_reboot, + }; + + return _hypercall2(int, sched_op, SCHEDOP_shutdown, + _reason); +#else return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_reboot); +#endif } static inline int Index: src/sys/arch/xen/include/i386/hypercalls.h diff -u src/sys/arch/xen/include/i386/hypercalls.h:1.18 src/sys/arch/xen/include/i386/hypercalls.h:1.19 --- src/sys/arch/xen/include/i386/hypercalls.h:1.18 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/include/i386/hypercalls.h Sun Feb 10 11:10:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.18 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: hypercalls.h,v 1.19 2019/02/10 11:10:34 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -368,9 +368,21 @@ HYPERVISOR_shutdown(void) long ret; unsigned long ign1, ign2; +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + +struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_poweroff +}; + _hypercall(__HYPERVISOR_sched_op, - _harg("1" (SCHEDOP_shutdown), "2" (SHUTDOWN_poweroff)), + _harg("1" (SCHEDOP_shutdown), "2" (_reason)), _harg("=a" (ret), "=b" (ign1), "=c" (ign2))); +#else + _hypercall(__HYPERVISOR_sched_op, + _harg("1" (SCHEDOP_shutdown), "2" (SHUTDOWN_poweroff)), + _harg("=a" (ret), "=b" (ign1), "=c" (ign2))); + +#endif return ret; } @@ -381,9 +393,20 @@ HYPERVISOR_crash(void) long ret; unsigned long ign1, ign2; +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + +struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_crash +}; + +_hypercall(__HYPERVISOR_sched_op, + _harg("1" (SCHEDOP_shutdown), "2" (_reason)), + _harg("=a" (ret), "=b" (ign1), "=c" (ign2))); +#else _hypercall(__HYPERVISOR_sched_op, _harg("1" (SCHEDOP_shutdown), "2" (SHUTDOWN_crash)), _harg("=a" (ret), "=b" (ign1), "=c" (ign2))); +#endif return ret; } @@ -394,9 +417,20 @@ HYPERVISOR_reboot(void) long ret; unsigned long ign1, ign2; +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 + +struct sched_shutdown shutdown_reason = { + .reason = SHUTDOWN_reboot +}; + +_hypercall(__HYPERVISOR_sched_op, + _harg("1" (SCHEDOP_shutdown), "2" (_reason)), + _harg("=a" (ret), "=b" (ign1), "=c" (ign2))); +#else _hypercall(__HYPERVISOR_sched_op, _harg("1" (SCHEDOP_shutdown), "2" (SHUTDOWN_reboot)), _harg("=a"
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: cherry Date: Tue Feb 12 03:13:50 UTC 2019 Modified Files: src/sys/arch/x86/x86: intr.c Log Message: Fix typo: Parameters are seperated by ','. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/arch/x86/x86/intr.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/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.141 src/sys/arch/x86/x86/intr.c:1.142 --- src/sys/arch/x86/x86/intr.c:1.141 Tue Dec 25 06:50:12 2018 +++ src/sys/arch/x86/x86/intr.c Tue Feb 12 03:13:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.141 2018/12/25 06:50:12 cherry Exp $ */ +/* $NetBSD: intr.c,v 1.142 2019/02/12 03:13:50 cherry Exp $ */ /* * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.141 2018/12/25 06:50:12 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.142 2019/02/12 03:13:50 cherry Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1131,7 +1131,7 @@ intr_string(intr_handle_t ih, char *buf, snprintf(buf, len, "irq %d", APIC_IRQ_LEGACY_IRQ(ih)); #elif NLAPIC > 0 - snprintf(buf, len, "irq %d" APIC_IRQ_LEGACY_IRQ(ih)); + snprintf(buf, len, "irq %d", APIC_IRQ_LEGACY_IRQ(ih)); #else snprintf(buf, len, "irq %d", (int) ih); #endif
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Tue Feb 12 08:04:53 UTC 2019 Modified Files: src/sys/arch/xen/include: xenfunc.h src/sys/arch/xen/x86: xen_intr.c Log Message: Move xen event related code which interfaces with the NetBSD interrupt subsystem into a separate namespace where it can co-exist with the native equivalent in PVHVM mode. On PV, we alias and export the native symbols - this means that although the namespace is different, the semantics must be identical. Eg: xen_intr_establish_xname() vs. intr_establish_xname(). The specific functions we need in PVHVM are: - spllower, xen_spllower (for native as well as XEN event spl despatch/defer) - xen_disable_intr()/xen_enable_intr() , x86_disable_intr()/x86_enable_intr() - xen_read_psl()/xen_write_psl(), x86_read_psl()/x86_write_psl() - intr_establish() et. al, xen_intr_establish() et. al. This gives us the ability to manage Paravirtualised drivers such as xbd(4) as well as fully emulated ones such as wd(4)., for eg To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/xen/include/xenfunc.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/xen/x86/xen_intr.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/xenfunc.h diff -u src/sys/arch/xen/include/xenfunc.h:1.16 src/sys/arch/xen/include/xenfunc.h:1.17 --- src/sys/arch/xen/include/xenfunc.h:1.16 Thu Jul 26 15:46:09 2018 +++ src/sys/arch/xen/include/xenfunc.h Tue Feb 12 08:04:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xenfunc.h,v 1.16 2018/07/26 15:46:09 maxv Exp $ */ +/* $NetBSD: xenfunc.h,v 1.17 2019/02/12 08:04:53 cherry Exp $ */ /* * @@ -36,5 +36,10 @@ #include #include +void xen_disable_intr(void); +void xen_enable_intr(void); +u_long xen_read_psl(void); +void xen_write_psl(u_long); + void xen_set_ldt(vaddr_t, uint32_t); #endif /* _XEN_XENFUNC_H_ */ Index: src/sys/arch/xen/x86/xen_intr.c diff -u src/sys/arch/xen/x86/xen_intr.c:1.13 src/sys/arch/xen/x86/xen_intr.c:1.14 --- src/sys/arch/xen/x86/xen_intr.c:1.13 Wed Dec 26 11:12:57 2018 +++ src/sys/arch/xen/x86/xen_intr.c Tue Feb 12 08:04:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_intr.c,v 1.13 2018/12/26 11:12:57 cherry Exp $ */ +/* $NetBSD: xen_intr.c,v 1.14 2019/02/12 08:04:53 cherry Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.13 2018/12/26 11:12:57 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.14 2019/02/12 08:04:53 cherry Exp $"); #include #include @@ -66,17 +66,14 @@ __KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v #include #endif -void xen_disable_intr(void); -void xen_enable_intr(void); -u_long xen_read_psl(void); -void xen_write_psl(u_long); - /* * Restore a value to cpl (unmasking interrupts). If any unmasked * interrupts are pending, call Xspllower() to process them. */ +void xen_spllower(int nlevel); + void -spllower(int nlevel) +xen_spllower(int nlevel) { struct cpu_info *ci = curcpu(); uint32_t xmask; @@ -186,7 +183,7 @@ xen_intr_establish_xname(int legacy_irq, return rih; } /* Else we assume pintr */ -#if NPCI > 0 || NISA > 0 +#if (NPCI > 0 || NISA > 0) && defined(XENPV) /* XXX: support PVHVM pirq */ struct pintrhand *pih; int gsi; int vector, evtchn; @@ -306,8 +303,9 @@ redzone_const_or_zero(int x) } #endif +void xen_cpu_intr_init(struct cpu_info *); void -cpu_intr_init(struct cpu_info *ci) +xen_cpu_intr_init(struct cpu_info *ci) { int i; /* XXX: duplicate */ @@ -393,8 +391,10 @@ legacy_intr_string(int ih, char *buf, si return buf; } +const char * xintr_string(intr_handle_t ih, char *buf, size_t len); + const char * -intr_string(intr_handle_t ih, char *buf, size_t len) +xintr_string(intr_handle_t ih, char *buf, size_t len) { #if NIOAPIC > 0 struct ioapic_softc *pic; @@ -420,7 +420,7 @@ intr_string(intr_handle_t ih, char *buf, snprintf(buf, len, "irq %d", APIC_IRQ_LEGACY_IRQ(ih)); #elif NLAPIC > 0 - snprintf(buf, len, "irq %d" APIC_IRQ_LEGACY_IRQ(ih)); + snprintf(buf, len, "irq %d", APIC_IRQ_LEGACY_IRQ(ih)); #else snprintf(buf, len, "irq %d", (int) ih); #endif @@ -432,8 +432,11 @@ intr_string(intr_handle_t ih, char *buf, * Create an interrupt id such as "ioapic0 pin 9". This interrupt id is used * by MI code and intrctl(8). */ +const char * xen_intr_create_intrid(int legacy_irq, struct pic *pic, +int pin, char *buf, size_t len); + const char * -intr_create_intrid(int legacy_irq, struct pic *pic, int pin, char *buf, size_t len) +xen_intr_create_intrid(int legacy_irq, struct pic *pic, int pin, char *buf, size_t len) { int ih = 0; @@ -487,14 +490,19 @@ intr_create_intrid(int legacy_irq, struc return NULL; /* No pic found! */ } -__weak_alias(x86_disable_intr, xen_disable_intr); -__weak_alias(x86_enable_intr, xen_enable_intr); -__weak_alias(x86_read_psl,
CVS commit: src/sys/arch/xen
Module Name:src Committed By: cherry Date: Tue Feb 12 07:58:26 UTC 2019 Modified Files: src/sys/arch/xen/include: pci_machdep.h src/sys/arch/xen/x86: hypervisor_machdep.c Log Message: conditionally include XENPV specific code. This explicitly excludes PV only functionality that would be wrong to attempt to use in other modes, for eg: p2m table management. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/include/pci_machdep.h cvs rdiff -u -r1.34 -r1.35 src/sys/arch/xen/x86/hypervisor_machdep.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/pci_machdep.h diff -u src/sys/arch/xen/include/pci_machdep.h:1.19 src/sys/arch/xen/include/pci_machdep.h:1.20 --- src/sys/arch/xen/include/pci_machdep.h:1.19 Sun Jul 16 06:14:24 2017 +++ src/sys/arch/xen/include/pci_machdep.h Tue Feb 12 07:58:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.h,v 1.19 2017/07/16 06:14:24 cherry Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.20 2019/02/12 07:58:26 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -66,7 +66,7 @@ typedef intr_handle_t pci_intr_handle_t; #include "opt_xen.h" -#ifndef DOM0OPS +#if !defined(DOM0OPS) && defined(XENPV) int xpci_enumerate_bus(struct pci_softc *, const int *, int (*)(const struct pci_attach_args *), struct pci_attach_args *); Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.34 src/sys/arch/xen/x86/hypervisor_machdep.c:1.35 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.34 Tue Dec 25 06:50:12 2018 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Tue Feb 12 07:58:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.34 2018/12/25 06:50:12 cherry Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.35 2019/02/12 07:58:26 cherry Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.34 2018/12/25 06:50:12 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.35 2019/02/12 07:58:26 cherry Exp $"); #include #include @@ -74,6 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor_m #include "isa.h" #include "pci.h" +#ifdef XENPV /* * arch-dependent p2m frame lists list (L3 and L2) * used by Xen for save/restore mappings @@ -85,6 +86,8 @@ static int l2_p2m_page_size; /* size of static void build_p2m_frame_list_list(void); static void update_p2m_frame_list_list(void); +#endif + // #define PORT_DEBUG 4 // #define EARLY_DEBUG_EVENT @@ -434,21 +437,26 @@ hypervisor_set_ipending(uint32_t iplmask void hypervisor_machdep_attach(void) { +#ifdef XENPV /* dom0 does not require the arch-dependent P2M translation table */ if (!xendomain_is_dom0()) { build_p2m_frame_list_list(); sysctl_xen_suspend_setup(); } +#endif } void hypervisor_machdep_resume(void) { +#ifdef XENPV /* dom0 does not require the arch-dependent P2M translation table */ if (!xendomain_is_dom0()) update_p2m_frame_list_list(); +#endif } +#ifdef XENPV /* * Generate the p2m_frame_list_list table, * needed for guest save/restore @@ -532,3 +540,4 @@ update_p2m_frame_list_list(void) HYPERVISOR_shared_info->arch.max_pfn = max_pfn; } +#endif /* XENPV */
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Mon Feb 11 14:59:33 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S cpufunc.S db_interface.c gdt.c genassym.cf lock_stubs.S locore.S machdep.c process_machdep.c spl.S trap.c vector.S src/sys/arch/amd64/conf: XEN3_DOM0 XEN3_DOMU src/sys/arch/amd64/include: cpu.h frame.h frameasm.h param.h pmap.h profile.h segments.h types.h vmparam.h src/sys/arch/i386/conf: XEN3PAE_DOM0 XEN3PAE_DOMU src/sys/arch/i386/i386: cpufunc.S db_interface.c gdt.c genassym.cf i386_trap.S lock_stubs.S locore.S machdep.c spl.S trap.c vector.S src/sys/arch/i386/include: cpu.h frame.h frameasm.h pmap.h segments.h vmparam.h src/sys/arch/x86/acpi: acpi_machdep.c src/sys/arch/x86/include: cpu.h cpuvar.h intr.h intrdefs.h pmap.h specialreg.h src/sys/arch/x86/isa: isa_machdep.c src/sys/arch/x86/pci: pci_intr_machdep.c pci_machdep.c pcib.c src/sys/arch/x86/x86: bios32.c bus_space.c cpu_ucode.c fpu.c i8259.c identcpu.c idt.c pmap.c sys_machdep.c vm_machdep.c x86_machdep.c x86_tlb.c Log Message: We reorganise definitions for XEN source support as follows: XEN - common sources required for baseline XEN support. XENPV - sources required for support of XEN in PV mode. XENPVHVM - sources required for support for XEN in HVM mode. XENPVH - sources required for support for XEN in PVH mode. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/amd64/amd64/amd64_trap.S \ src/sys/arch/amd64/amd64/gdt.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/db_interface.c cvs rdiff -u -r1.72 -r1.73 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.30 -r1.31 src/sys/arch/amd64/amd64/lock_stubs.S cvs rdiff -u -r1.175 -r1.176 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.324 -r1.325 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.38 -r1.39 src/sys/arch/amd64/amd64/process_machdep.c \ src/sys/arch/amd64/amd64/spl.S cvs rdiff -u -r1.116 -r1.117 src/sys/arch/amd64/amd64/trap.c cvs rdiff -u -r1.65 -r1.66 src/sys/arch/amd64/amd64/vector.S cvs rdiff -u -r1.165 -r1.166 src/sys/arch/amd64/conf/XEN3_DOM0 cvs rdiff -u -r1.87 -r1.88 src/sys/arch/amd64/conf/XEN3_DOMU cvs rdiff -u -r1.63 -r1.64 src/sys/arch/amd64/include/cpu.h cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/include/frame.h cvs rdiff -u -r1.41 -r1.42 src/sys/arch/amd64/include/frameasm.h cvs rdiff -u -r1.28 -r1.29 src/sys/arch/amd64/include/param.h cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/include/pmap.h \ src/sys/arch/amd64/include/types.h cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amd64/include/profile.h cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/include/segments.h cvs rdiff -u -r1.50 -r1.51 src/sys/arch/amd64/include/vmparam.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/conf/XEN3PAE_DOM0 cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/conf/XEN3PAE_DOMU cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.82 -r1.83 src/sys/arch/i386/i386/db_interface.c cvs rdiff -u -r1.68 -r1.69 src/sys/arch/i386/i386/gdt.c cvs rdiff -u -r1.109 -r1.110 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.29 -r1.30 src/sys/arch/i386/i386/lock_stubs.S cvs rdiff -u -r1.162 -r1.163 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.814 -r1.815 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/i386/spl.S cvs rdiff -u -r1.297 -r1.298 src/sys/arch/i386/i386/trap.c cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/i386/vector.S cvs rdiff -u -r1.180 -r1.181 src/sys/arch/i386/include/cpu.h cvs rdiff -u -r1.38 -r1.39 src/sys/arch/i386/include/frame.h cvs rdiff -u -r1.26 -r1.27 src/sys/arch/i386/include/frameasm.h cvs rdiff -u -r1.121 -r1.122 src/sys/arch/i386/include/pmap.h cvs rdiff -u -r1.67 -r1.68 src/sys/arch/i386/include/segments.h cvs rdiff -u -r1.85 -r1.86 src/sys/arch/i386/include/vmparam.h cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/acpi/acpi_machdep.c cvs rdiff -u -r1.102 -r1.103 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.50 -r1.51 src/sys/arch/x86/include/cpuvar.h cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/include/intr.h cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/include/intrdefs.h cvs rdiff -u -r1.95 -r1.96 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.139 -r1.140 src/sys/arch/x86/include/specialreg.h cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/isa/isa_machdep.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/x86/pci/pci_intr_machdep.c cvs rdiff -u -r1.83 -r1.84 src/sys/arch/x86/pci/pci_machdep.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/pci/pcib.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/x86/bios32.c cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/x86/bus_space.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/x86/cpu_ucode.c cvs rdiff -u -r1.49 -r1.50
CVS commit: src/sys/arch/xen/include/amd64
Module Name:src Committed By: cherry Date: Thu Jan 24 04:11:38 UTC 2019 Modified Files: src/sys/arch/xen/include/amd64: hypercalls.h Log Message: hvm_op returns a signed value. The pattern is that a hypercall which returns a value < 0 may imply an error. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/include/amd64/hypercalls.h 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/amd64/hypercalls.h diff -u src/sys/arch/xen/include/amd64/hypercalls.h:1.8 src/sys/arch/xen/include/amd64/hypercalls.h:1.9 --- src/sys/arch/xen/include/amd64/hypercalls.h:1.8 Wed Dec 7 16:01:39 2011 +++ src/sys/arch/xen/include/amd64/hypercalls.h Thu Jan 24 04:11:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.8 2011/12/07 16:01:39 cegger Exp $ */ +/* $NetBSD: hypercalls.h,v 1.9 2019/01/24 04:11:38 cherry Exp $ */ /** * hypercall.h * @@ -361,11 +361,11 @@ HYPERVISOR_nmi_op( return _hypercall2(int, nmi_op, op, arg); } -static inline unsigned long +static inline long HYPERVISOR_hvm_op( int op, void *arg) { -return _hypercall2(unsigned long, hvm_op, op, arg); +return _hypercall2(long, hvm_op, op, arg); } static inline int
CVS commit: src/sys/arch/xen/include
Module Name:src Committed By: cherry Date: Thu Jan 24 04:16:16 UTC 2019 Modified Files: src/sys/arch/xen/include/amd64: hypercalls.h src/sys/arch/xen/include/i386: hypercalls.h Log Message: The event_channel_op hypercall uses a newer API since __XEN_INTERFACE_VERSION__ 0x00030202 Since hvm_op only supports event_channel_op via the newer API, we can't get away with our current event_channel_op_compat shim. We thus introduce the new API to our internal hypercall C API interface. This change should have no effect on the PV kernels, since they will continue to use the pre 0x00030202 API. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/include/amd64/hypercalls.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/xen/include/i386/hypercalls.h 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/amd64/hypercalls.h diff -u src/sys/arch/xen/include/amd64/hypercalls.h:1.9 src/sys/arch/xen/include/amd64/hypercalls.h:1.10 --- src/sys/arch/xen/include/amd64/hypercalls.h:1.9 Thu Jan 24 04:11:38 2019 +++ src/sys/arch/xen/include/amd64/hypercalls.h Thu Jan 24 04:16:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.9 2019/01/24 04:11:38 cherry Exp $ */ +/* $NetBSD: hypercalls.h,v 1.10 2019/01/24 04:16:16 cherry Exp $ */ /** * hypercall.h * @@ -242,9 +242,14 @@ HYPERVISOR_update_va_mapping( } static inline int -HYPERVISOR_event_channel_op(void *op) +HYPERVISOR_event_channel_op(evtchn_op_t *op) { + KASSERT(op != NULL); +#if __XEN_INTERFACE_VERSION__ < 0x00030202 return _hypercall1(int, event_channel_op, op); +#else + return _hypercall2(int, event_channel_op, op->cmd, >u); +#endif } static inline int Index: src/sys/arch/xen/include/i386/hypercalls.h diff -u src/sys/arch/xen/include/i386/hypercalls.h:1.16 src/sys/arch/xen/include/i386/hypercalls.h:1.17 --- src/sys/arch/xen/include/i386/hypercalls.h:1.16 Thu Jul 26 17:20:08 2018 +++ src/sys/arch/xen/include/i386/hypercalls.h Thu Jan 24 04:16:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.16 2018/07/26 17:20:08 maxv Exp $ */ +/* $NetBSD: hypercalls.h,v 1.17 2019/01/24 04:16:16 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -457,14 +457,20 @@ HYPERVISOR_multicall(void *call_list, in static __inline int -HYPERVISOR_event_channel_op(void *op) +HYPERVISOR_event_channel_op(evtchn_op_t *op) { int ret; unsigned long ign1; +#if __XEN_INTERFACE_VERSION__ < 0x00030202 _hypercall(__HYPERVISOR_event_channel_op, _harg("1" (op)), _harg("=a" (ret), "=b" (ign1))); +#else +unsigned long ign2; +_hypercall(__HYPERVISOR_event_channel_op, _harg("1" (op->cmd), "2" (>u)), + _harg("=a" (ret), "=b" (ign1), "=c" (ign2))); +#endif return ret; }
CVS import: src/sys/external/mit/xen-include-public/dist/xen/include/public
Module Name:src Committed By: cherry Date: Sat Feb 2 08:03:48 UTC 2019 Update of /cvsroot/src/sys/external/mit/xen-include-public/dist/xen/include/public In directory ivanova.netbsd.org:/tmp/cvs-serv20221 Log Message: Import Xen public headers version 4.11.1 Release tag: RELEASE-4-11-1 git log of the freeze is as follows: commit 96cbd0893f783997caaf117e897d5fa8f2dc7b5f Author: Jan Beulich Date: Thu Nov 29 15:04:11 2018 +0100 update Xen version to 4.11.1 Status: Vendor Tag: RELEASE-4-11-1 Release Tags: xen-4-11-1 N src/sys/external/mit/xen-include-public/dist/xen/include/public/COPYING N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-arm.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86_32.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86_64.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/callback.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/dom0_ops.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/domctl.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/elfnote.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/features.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/errno.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/event_channel.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/kexec.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/grant_table.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/memory.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/nmi.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/physdev.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/platform.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/trace.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/pmu.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/sched.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/sysctl.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/tmem.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/vcpu.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/version.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/vm_event.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/xen-compat.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/xen.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/xencomm.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/xenoprof.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-arm/smccc.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-arm/hvm/save.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/cpufeatureset.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/cpuid.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/pmu.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/xen-mca.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/xen-x86_32.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/xen-x86_64.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/xen.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/hvm/save.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/arch-x86/hvm/start_info.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/dm_op.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/e820.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/hvm_info_table.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/hvm_op.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/hvm_vcpu.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/hvm_xs_strings.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/ioreq.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/params.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/pvdrivers.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/hvm/save.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/io/9pfs.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/io/blkif.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/io/console.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/io/displif.h N src/sys/external/mit/xen-include-public/dist/xen/include/public/io/fbif.h N
CVS commit: src/sys/arch/xen/include/xen-public
Module Name:src Committed By: cherry Date: Sat Feb 2 12:40:32 UTC 2019 Removed Files: src/sys/arch/xen/include/xen-public: COPYING arch-ia64.h arch-x86_32.h arch-x86_64.h callback.h dom0_ops.h domctl.h elfnote.h elfstructs.h event_channel.h features.h grant_table.h kexec.h libelf.h mem_event.h memory.h nmi.h physdev.h platform.h sched.h sysctl.h tmem.h trace.h vcpu.h version.h xen-compat.h xen.h xencomm.h xenoprof.h src/sys/arch/xen/include/xen-public/arch-ia64: debug_op.h sioemu.h src/sys/arch/xen/include/xen-public/arch-ia64/hvm: memmap.h save.h src/sys/arch/xen/include/xen-public/arch-x86: cpuid.h xen-mca.h xen-x86_32.h xen-x86_64.h xen.h src/sys/arch/xen/include/xen-public/arch-x86/hvm: save.h src/sys/arch/xen/include/xen-public/hvm: e820.h hvm_info_table.h hvm_op.h ioreq.h params.h save.h vmx_assist.h src/sys/arch/xen/include/xen-public/io: blkif.h console.h fbif.h fsif.h kbdif.h netif.h pciif.h protocols.h ring.h tpmif.h usbif.h vscsiif.h xenbus.h xs_wire.h src/sys/arch/xen/include/xen-public/xsm: acm.h acm_ops.h flask_op.h Log Message: Remove legacy XEN source public API from source. These have now been moved to sys/external/mit/xen-include-public/dist To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r0 src/sys/arch/xen/include/xen-public/COPYING \ src/sys/arch/xen/include/xen-public/arch-ia64.h \ src/sys/arch/xen/include/xen-public/callback.h \ src/sys/arch/xen/include/xen-public/elfnote.h \ src/sys/arch/xen/include/xen-public/features.h \ src/sys/arch/xen/include/xen-public/kexec.h \ src/sys/arch/xen/include/xen-public/memory.h \ src/sys/arch/xen/include/xen-public/nmi.h \ src/sys/arch/xen/include/xen-public/platform.h \ src/sys/arch/xen/include/xen-public/sched.h \ src/sys/arch/xen/include/xen-public/vcpu.h \ src/sys/arch/xen/include/xen-public/version.h \ src/sys/arch/xen/include/xen-public/xen-compat.h \ src/sys/arch/xen/include/xen-public/xencomm.h \ src/sys/arch/xen/include/xen-public/xenoprof.h cvs rdiff -u -r1.5 -r0 src/sys/arch/xen/include/xen-public/arch-x86_32.h \ src/sys/arch/xen/include/xen-public/arch-x86_64.h \ src/sys/arch/xen/include/xen-public/dom0_ops.h cvs rdiff -u -r1.2 -r0 src/sys/arch/xen/include/xen-public/domctl.h \ src/sys/arch/xen/include/xen-public/elfstructs.h \ src/sys/arch/xen/include/xen-public/sysctl.h cvs rdiff -u -r1.6 -r0 src/sys/arch/xen/include/xen-public/event_channel.h \ src/sys/arch/xen/include/xen-public/grant_table.h \ src/sys/arch/xen/include/xen-public/trace.h cvs rdiff -u -r1.1.1.1 -r0 src/sys/arch/xen/include/xen-public/libelf.h \ src/sys/arch/xen/include/xen-public/mem_event.h \ src/sys/arch/xen/include/xen-public/tmem.h cvs rdiff -u -r1.7 -r0 src/sys/arch/xen/include/xen-public/physdev.h cvs rdiff -u -r1.11 -r0 src/sys/arch/xen/include/xen-public/xen.h cvs rdiff -u -r1.1.1.2 -r0 \ src/sys/arch/xen/include/xen-public/arch-ia64/debug_op.h \ src/sys/arch/xen/include/xen-public/arch-ia64/sioemu.h cvs rdiff -u -r1.1.1.2 -r0 \ src/sys/arch/xen/include/xen-public/arch-ia64/hvm/memmap.h \ src/sys/arch/xen/include/xen-public/arch-ia64/hvm/save.h cvs rdiff -u -r1.1.1.2 -r0 \ src/sys/arch/xen/include/xen-public/arch-x86/cpuid.h \ src/sys/arch/xen/include/xen-public/arch-x86/xen-x86_64.h cvs rdiff -u -r1.2 -r0 src/sys/arch/xen/include/xen-public/arch-x86/xen-mca.h \ src/sys/arch/xen/include/xen-public/arch-x86/xen-x86_32.h \ src/sys/arch/xen/include/xen-public/arch-x86/xen.h cvs rdiff -u -r1.1.1.2 -r0 \ src/sys/arch/xen/include/xen-public/arch-x86/hvm/save.h cvs rdiff -u -r1.1.1.2 -r0 src/sys/arch/xen/include/xen-public/hvm/e820.h \ src/sys/arch/xen/include/xen-public/hvm/hvm_info_table.h \ src/sys/arch/xen/include/xen-public/hvm/hvm_op.h \ src/sys/arch/xen/include/xen-public/hvm/ioreq.h \ src/sys/arch/xen/include/xen-public/hvm/params.h \ src/sys/arch/xen/include/xen-public/hvm/save.h cvs rdiff -u -r1.1.1.1 -r0 \ src/sys/arch/xen/include/xen-public/hvm/vmx_assist.h cvs rdiff -u -r1.7 -r0 src/sys/arch/xen/include/xen-public/io/blkif.h cvs rdiff -u -r1.1.1.2 -r0 src/sys/arch/xen/include/xen-public/io/console.h \ src/sys/arch/xen/include/xen-public/io/fbif.h \ src/sys/arch/xen/include/xen-public/io/fsif.h \ src/sys/arch/xen/include/xen-public/io/kbdif.h \ src/sys/arch/xen/include/xen-public/io/pciif.h \ src/sys/arch/xen/include/xen-public/io/protocols.h \ src/sys/arch/xen/include/xen-public/io/tpmif.h \ src/sys/arch/xen/include/xen-public/io/xenbus.h cvs rdiff -u -r1.6 -r0 src/sys/arch/xen/include/xen-public/io/netif.h cvs rdiff -u -r1.3 -r0 src/sys/arch/xen/include/xen-public/io/ring.h cvs rdiff -u -r1.1.1.1 -r0 src/sys/arch/xen/include/xen-public/io/usbif.h \
CVS commit: src/sys/arch/xen/include
Module Name:src Committed By: cherry Date: Sat Feb 2 14:50:15 UTC 2019 Modified Files: src/sys/arch/xen/include: hypervisor.h xenring.h Log Message: Remove mb(), rmb() and wmb() from the kernel namespace. These are introduced by external/bsd/common/include/asm/barrier.h The purpose of barrier.h is to bridge the use of linux API calls within code which uses them, such as drm code. The XEN api implicitly uses these calls which are linuxisms within io/ring.h This diff undos the damage. The correct fix is to modify io/ring.h to not assume that all OSs that XEN runs on has these functions, and to appropriately conditionally via #ifdef __NetBSD__/#endif use the appropriate NetBSD functions. These changes then need to be pushed upstream. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/xen/include/xenring.h 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.47 src/sys/arch/xen/include/hypervisor.h:1.48 --- src/sys/arch/xen/include/hypervisor.h:1.47 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/include/hypervisor.h Sat Feb 2 14:50:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.47 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: hypervisor.h,v 1.48 2019/02/02 14:50:15 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -80,7 +80,7 @@ struct xen_npx_attach_args { #define s32 int32_t #define s64 int64_t -#include /* Linux mb() and friends */ +#include #include #include @@ -94,6 +94,18 @@ struct xen_npx_attach_args { #include #include +/* Undo namespace damage from xen/include/public/io/ring.h + * The proper fix is to get upstream to stop assuming that all OSs use + * mb(), rmb(), wmb(). + */ +#undef xen_mb +#undef xen_rmb +#undef xen_wmb + +#define xen_mb() membar_sync() +#define xen_rmb() membar_producer() +#define xen_wmb() membar_consumer() + #include #undef u8 Index: src/sys/arch/xen/include/xenring.h diff -u src/sys/arch/xen/include/xenring.h:1.1 src/sys/arch/xen/include/xenring.h:1.2 --- src/sys/arch/xen/include/xenring.h:1.1 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/include/xenring.h Sat Feb 2 14:50:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xenring.h,v 1.1 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: xenring.h,v 1.2 2019/02/02 14:50:15 cherry Exp $ */ /* * Glue goop for xbd ring request/response protocol structures. @@ -10,10 +10,28 @@ #ifndef _XEN_RING_H #define _XEN_RING_H -#if __XEN_INTERFACE_VERSION__ >= 0x00030201 +#if (__XEN_INTERFACE_VERSION__ >= 0x00030201) && + (__XEN_INTERFACE_VERSION < 0x00030208) #include +/* + * Undo namespace damage from xen/include/public/io/ring.h + * The proper fix is to get upstream to stop assuming that all OSs use + * mb(), rmb(), wmb(). + */ +#undef xen_mb +#undef xen_rmb +#undef xen_wmb + +#define xen_mb() membar_sync() +#define xen_rmb() membar_producer() +#define xen_wmb() membar_consumer() + +/* + * Define ring types. These were previously part of the public API. + * Not anymore. + */ DEFINE_RING_TYPES(blkif_x86_32, struct blkif_request, struct blkif_response); DEFINE_RING_TYPES(blkif_x86_64, struct blkif_request, struct blkif_response); @@ -30,5 +48,6 @@ union blkif_back_ring_proto { }; typedef union blkif_back_ring_proto blkif_back_ring_proto_t; -#endif /* __XEN_INTERFACE_VERSION__ >= 0x00030201 */ +#endif /* __XEN_INTERFACE_VERSION__ */ + #endif /* _XEN_RING_H_ */
CVS commit: src/sys/arch/amd64/conf
Module Name:src Committed By: cherry Date: Sat Feb 2 12:05:09 UTC 2019 Modified Files: src/sys/arch/amd64/conf: XEN3_DOM0 Log Message: Summary: Disable ixg(4) until the linuxist mb() API re-definition within the XEN amd64 dom0 build is resolved. Detail: The xen public headers >= 0x00030201 depend on a linuxism - a memory barrier "API" namely mb(), rmb() and wmb(). These are made accessible to NetBSD code via the interface sys/external/bsd/common/include/asm/barrier.h Currently the ixg(4) driver uses an identical API by defining them (incorrectly) to inline assembler macro definitions in sys/dev/pci/ixgbe/ixgbe_osdep.h This will result in the dom0 builds failing to build due to this redefinition of the macros. We therefore disable the driver in NetBSD/amd64 dom0 in order to facilitate smoothly moving the XEN kernel builds to the new XEN source level API (RELEASE-4.11.1). The fix for this is trivial, but needs the attention of the driver maintainer. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/arch/amd64/conf/XEN3_DOM0 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/amd64/conf/XEN3_DOM0 diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.162 src/sys/arch/amd64/conf/XEN3_DOM0:1.163 --- src/sys/arch/amd64/conf/XEN3_DOM0:1.162 Tue Dec 25 11:56:14 2018 +++ src/sys/arch/amd64/conf/XEN3_DOM0 Sat Feb 2 12:05:09 2019 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.162 2018/12/25 11:56:14 mlelstv Exp $ +# $NetBSD: XEN3_DOM0,v 1.163 2019/02/02 12:05:09 cherry Exp $ include "arch/amd64/conf/std.xen" @@ -10,7 +10,7 @@ options INCLUDE_CONFIG_FILE # embed con #options UVMHIST_PRINT #options SYSCALL_DEBUG -#ident "XEN3_DOM0-$Revision: 1.162 $" +#ident "XEN3_DOM0-$Revision: 1.163 $" maxusers 32 # estimated number of users @@ -371,7 +371,7 @@ ipw* at pci? dev ? function ? # Intel PR iwi* at pci? dev ? function ? # Intel PRO/Wireless 2200BG iwn* at pci? dev ? function ? # Intel PRO/Wireless 4965AGN iwm* at pci? dev ? function ? # Intel Wireless WiFi Link 7xxx -ixg* at pci? dev ? function ? # Intel 8259x 10 gigabit +#ixg* at pci? dev ? function ? # Intel 8259x 10 gigabit jme* at pci? dev ? function ? # JMicron JMC2[56]0 ethernet le* at pci? dev ? function ? # PCnet-PCI Ethernet lii* at pci? dev ? function ? # Atheros L2 Fast-Ethernet
CVS commit: src/sys/arch/amd64/conf
Module Name:src Committed By: cherry Date: Sat Feb 2 15:13:54 UTC 2019 Modified Files: src/sys/arch/amd64/conf: XEN3_DOM0 Log Message: Re-enable ixg(4) on NetBSD/xen dom0 Namespace conflicts have been resolved. Note that driver still has an incorrect us of __asm() gnu primitives via #if __FreeBSD_version < 80 ... #endif Since __FreeBSD_version is undefined and thus equates to 0 and thus satisfies the inequality. Needs fixing by driver maintainer. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/arch/amd64/conf/XEN3_DOM0 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/amd64/conf/XEN3_DOM0 diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.163 src/sys/arch/amd64/conf/XEN3_DOM0:1.164 --- src/sys/arch/amd64/conf/XEN3_DOM0:1.163 Sat Feb 2 12:05:09 2019 +++ src/sys/arch/amd64/conf/XEN3_DOM0 Sat Feb 2 15:13:54 2019 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.163 2019/02/02 12:05:09 cherry Exp $ +# $NetBSD: XEN3_DOM0,v 1.164 2019/02/02 15:13:54 cherry Exp $ include "arch/amd64/conf/std.xen" @@ -10,7 +10,7 @@ options INCLUDE_CONFIG_FILE # embed con #options UVMHIST_PRINT #options SYSCALL_DEBUG -#ident "XEN3_DOM0-$Revision: 1.163 $" +#ident "XEN3_DOM0-$Revision: 1.164 $" maxusers 32 # estimated number of users @@ -371,7 +371,7 @@ ipw* at pci? dev ? function ? # Intel PR iwi* at pci? dev ? function ? # Intel PRO/Wireless 2200BG iwn* at pci? dev ? function ? # Intel PRO/Wireless 4965AGN iwm* at pci? dev ? function ? # Intel Wireless WiFi Link 7xxx -#ixg* at pci? dev ? function ? # Intel 8259x 10 gigabit +ixg* at pci? dev ? function ? # Intel 8259x 10 gigabit jme* at pci? dev ? function ? # JMicron JMC2[56]0 ethernet le* at pci? dev ? function ? # PCnet-PCI Ethernet lii* at pci? dev ? function ? # Atheros L2 Fast-Ethernet
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Sat Feb 2 12:32:55 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: genassym.cf locore.S src/sys/arch/amd64/conf: std.xen src/sys/arch/i386/i386: genassym.cf src/sys/arch/x86/include: cpu.h src/sys/arch/x86/x86: cpu_ucode.c pmap.c src/sys/arch/xen/conf: Makefile.xen std.xen src/sys/arch/xen/include: granttables.h hypervisor.h intr.h xen.h xenbus.h src/sys/arch/xen/include/amd64: hypercalls.h src/sys/arch/xen/include/i386: hypercalls.h src/sys/arch/xen/x86: cpu.c xen_ipi.c xen_pmap.c src/sys/arch/xen/xen: clock.c hypervisor.c if_xennet_xenbus.c pciback.c xbd_xenbus.c xbdback_xenbus.c xen_machdep.c xencons.c xpci_xenbus.c Added Files: src/sys/arch/xen/include: xenring.h Log Message: Switch NetBSD/xen to use XEN api tag RELEASE-4.11.1 The headers for this api are in sys/external/mit/xen-include-public/dist/ To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.174 -r1.175 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/conf/std.xen cvs rdiff -u -r1.108 -r1.109 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.101 -r1.102 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/x86/cpu_ucode.c cvs rdiff -u -r1.319 -r1.320 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/conf/Makefile.xen cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/conf/std.xen cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/include/granttables.h cvs rdiff -u -r1.46 -r1.47 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.51 -r1.52 src/sys/arch/xen/include/intr.h cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/include/xen.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/xen/include/xenbus.h cvs rdiff -u -r0 -r1.1 src/sys/arch/xen/include/xenring.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/xen/include/amd64/hypercalls.h cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/include/i386/hypercalls.h cvs rdiff -u -r1.127 -r1.128 src/sys/arch/xen/x86/cpu.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/x86/xen_pmap.c cvs rdiff -u -r1.76 -r1.77 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.69 -r1.70 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r1.82 -r1.83 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/xen/pciback.c cvs rdiff -u -r1.91 -r1.92 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/xen/xen/xbdback_xenbus.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/xen/xen_machdep.c cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/xen/xencons.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/xen/xen/xpci_xenbus.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/amd64/amd64/genassym.cf diff -u src/sys/arch/amd64/amd64/genassym.cf:1.71 src/sys/arch/amd64/amd64/genassym.cf:1.72 --- src/sys/arch/amd64/amd64/genassym.cf:1.71 Tue Dec 25 06:50:11 2018 +++ src/sys/arch/amd64/amd64/genassym.cf Sat Feb 2 12:32:54 2019 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.71 2018/12/25 06:50:11 cherry Exp $ +# $NetBSD: genassym.cf,v 1.72 2019/02/02 12:32:54 cherry Exp $ # # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -119,7 +119,7 @@ include endif ifdef XEN -include +include endif include Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.174 src/sys/arch/amd64/amd64/locore.S:1.175 --- src/sys/arch/amd64/amd64/locore.S:1.174 Sun Aug 12 15:31:01 2018 +++ src/sys/arch/amd64/amd64/locore.S Sat Feb 2 12:32:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.174 2018/08/12 15:31:01 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.175 2019/02/02 12:32:54 cherry Exp $ */ /* * Copyright-o-rama! @@ -276,8 +276,8 @@ #ifdef XEN #define __ASSEMBLY__ -#include -#include +#include +#include #define ELFNOTE(name, type, desctype, descdata...) \ .pushsection .note.name ; \ .align 4; \ Index: src/sys/arch/amd64/conf/std.xen diff -u src/sys/arch/amd64/conf/std.xen:1.9 src/sys/arch/amd64/conf/std.xen:1.10 --- src/sys/arch/amd64/conf/std.xen:1.9 Thu Jan 12 05:24:36 2017 +++ src/sys/arch/amd64/conf/std.xen Sat Feb 2 12:32:54 2019 @@ -1,4 +1,4 @@ -# $NetBSD: std.xen,v 1.9 2017/01/12 05:24:36 ryo Exp $ +# $NetBSD: std.xen,v 1.10 2019/02/02 12:32:54 cherry Exp $ # NetBSD: std.i386,v 1.24 2003/02/26 21:33:36 fvdl Exp # # standard, required NetBSD/i386 'options' @@ -7,6 +7,7 @@ machine xen amd64 include "conf/std" # MI standard options options XEN #Xen support +options __XEN_INTERFACE_VERSION__=0x00030201 # Xen 3.1 interface #options __XEN_INTERFACE_VERSION__=0x00030205 # Xen 3.1 interface options CPU_IN_CKSUM Index: src/sys/arch/i386/i386/genassym.cf diff -u
CVS commit: src/sys/arch/xen/include
Module Name:src Committed By: cherry Date: Sat Feb 2 15:09:32 UTC 2019 Modified Files: src/sys/arch/xen/include: xenring.h Log Message: Fix build. A multiline macro needs 'line continuation'. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/xen/include/xenring.h 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/xenring.h diff -u src/sys/arch/xen/include/xenring.h:1.2 src/sys/arch/xen/include/xenring.h:1.3 --- src/sys/arch/xen/include/xenring.h:1.2 Sat Feb 2 14:50:15 2019 +++ src/sys/arch/xen/include/xenring.h Sat Feb 2 15:09:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xenring.h,v 1.2 2019/02/02 14:50:15 cherry Exp $ */ +/* $NetBSD: xenring.h,v 1.3 2019/02/02 15:09:32 cherry Exp $ */ /* * Glue goop for xbd ring request/response protocol structures. @@ -10,7 +10,7 @@ #ifndef _XEN_RING_H #define _XEN_RING_H -#if (__XEN_INTERFACE_VERSION__ >= 0x00030201) && +#if (__XEN_INTERFACE_VERSION__ >= 0x00030201) && \ (__XEN_INTERFACE_VERSION < 0x00030208) #include
CVS commit: src/sys/arch
Module Name:src Committed By: cherry Date: Mon Feb 4 18:14:54 UTC 2019 Modified Files: src/sys/arch/amd64/conf: std.xen src/sys/arch/xen/conf: std.xen src/sys/arch/xen/include: hypervisor.h xen.h src/sys/arch/xen/x86: x86_xpmap.c Log Message: Bump up XEN source API compatibility to 0x00030208 from 0x00030201, but maintain backwards source API compilation compatibility. ie; sources with config(5) options __XEN_INTERFACE_VERSION__=0x00030201 # Xen 3.1 interface should compile and run without problems. Not that API version 0x00030201 is the lowest version we support now. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/conf/std.xen cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/conf/std.xen cvs rdiff -u -r1.48 -r1.49 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.42 -r1.43 src/sys/arch/xen/include/xen.h cvs rdiff -u -r1.81 -r1.82 src/sys/arch/xen/x86/x86_xpmap.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/amd64/conf/std.xen diff -u src/sys/arch/amd64/conf/std.xen:1.10 src/sys/arch/amd64/conf/std.xen:1.11 --- src/sys/arch/amd64/conf/std.xen:1.10 Sat Feb 2 12:32:54 2019 +++ src/sys/arch/amd64/conf/std.xen Mon Feb 4 18:14:53 2019 @@ -1,4 +1,4 @@ -# $NetBSD: std.xen,v 1.10 2019/02/02 12:32:54 cherry Exp $ +# $NetBSD: std.xen,v 1.11 2019/02/04 18:14:53 cherry Exp $ # NetBSD: std.i386,v 1.24 2003/02/26 21:33:36 fvdl Exp # # standard, required NetBSD/i386 'options' @@ -7,7 +7,7 @@ machine xen amd64 include "conf/std" # MI standard options options XEN #Xen support -options __XEN_INTERFACE_VERSION__=0x00030201 # Xen 3.1 interface +options __XEN_INTERFACE_VERSION__=0x00030208 # Xen 3.1 interface #options __XEN_INTERFACE_VERSION__=0x00030205 # Xen 3.1 interface options CPU_IN_CKSUM Index: src/sys/arch/xen/conf/std.xen diff -u src/sys/arch/xen/conf/std.xen:1.9 src/sys/arch/xen/conf/std.xen:1.10 --- src/sys/arch/xen/conf/std.xen:1.9 Sat Feb 2 12:32:54 2019 +++ src/sys/arch/xen/conf/std.xen Mon Feb 4 18:14:53 2019 @@ -1,4 +1,4 @@ -# $NetBSD: std.xen,v 1.9 2019/02/02 12:32:54 cherry Exp $ +# $NetBSD: std.xen,v 1.10 2019/02/04 18:14:53 cherry Exp $ # NetBSD: std.i386,v 1.24 2003/02/26 21:33:36 fvdl Exp # # standard, required NetBSD/i386 'options' @@ -6,7 +6,7 @@ machine xen i386 include "conf/std" # MI standard options -options __XEN_INTERFACE_VERSION__=0x00030201 # Xen 3.1 interface +options __XEN_INTERFACE_VERSION__=0x00030208 # Xen 3.1 interface options EXEC_AOUT # exec a.out binaries options EXEC_ELF32 # exec ELF binaries Index: src/sys/arch/xen/include/hypervisor.h diff -u src/sys/arch/xen/include/hypervisor.h:1.48 src/sys/arch/xen/include/hypervisor.h:1.49 --- src/sys/arch/xen/include/hypervisor.h:1.48 Sat Feb 2 14:50:15 2019 +++ src/sys/arch/xen/include/hypervisor.h Mon Feb 4 18:14:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.48 2019/02/02 14:50:15 cherry Exp $ */ +/* $NetBSD: hypervisor.h,v 1.49 2019/02/04 18:14:53 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -94,6 +94,7 @@ struct xen_npx_attach_args { #include #include +#if __XEN_INTERFACE_VERSION < 0x00030208 /* Undo namespace damage from xen/include/public/io/ring.h * The proper fix is to get upstream to stop assuming that all OSs use * mb(), rmb(), wmb(). @@ -105,6 +106,7 @@ struct xen_npx_attach_args { #define xen_mb() membar_sync() #define xen_rmb() membar_producer() #define xen_wmb() membar_consumer() +#endif /* __XEN_INTERFACE_VERSION */ #include Index: src/sys/arch/xen/include/xen.h diff -u src/sys/arch/xen/include/xen.h:1.42 src/sys/arch/xen/include/xen.h:1.43 --- src/sys/arch/xen/include/xen.h:1.42 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/include/xen.h Mon Feb 4 18:14:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: xen.h,v 1.42 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: xen.h,v 1.43 2019/02/04 18:14:53 cherry Exp $ */ /* * @@ -122,6 +122,12 @@ void printk(const char *, ...); /* Everything below this point is not included by assembler (.S) files. */ #ifndef _LOCORE +/* Version Specific Glue */ +#if __XEN_INTERFACE_VERSION__ >= 0x00030203 +#define console_mfnconsole.domU.mfn +#define console_evtchn console.domU.evtchn +#endif + /* some function prototypes */ void trap_init(void); void xpq_flush_cache(void); Index: src/sys/arch/xen/x86/x86_xpmap.c diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.81 src/sys/arch/xen/x86/x86_xpmap.c:1.82 --- src/sys/arch/xen/x86/x86_xpmap.c:1.81 Sun Jul 29 08:02:24 2018 +++ src/sys/arch/xen/x86/x86_xpmap.c Mon Feb 4 18:14:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_xpmap.c,v 1.81 2018/07/29 08:02:24 maxv Exp $ */ +/* $NetBSD: x86_xpmap.c,v 1.82 2019/02/04 18:14:53 cherry Exp $ */ /* * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.81