History log of /netbsd-current/sys/arch/xen/xen/xenevt.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.68 22-Sep-2022 bouyer

Fix fallout from previous: ci_ipending is in the low bytes of ci_istate,
so we should not left-shift by 8 the ci_ipending value we want to add there.
Should fix KASSERT in Xen's idle_block() reported by Frank Kardel in private
mail.


# 1.67 07-Sep-2022 knakahara

NetBSD/x86: Raise the number of interrupt sources per CPU from 32 to 56.

There has been no objection for three years.
https://mail-index.netbsd.org/port-amd64/2019/09/22/msg003012.html
Implemented by nonaka@n.o, updated by me.


# 1.66 04-Sep-2022 bouyer

Release mutexes earlier in xenevt_free(), to call *destroy and kmem_free
without holding spin locks. Fixes an occasional deadlock seen when the qemu
backing a HVM domU exits.


# 1.65 27-May-2022 bouyer

xenevt_setipending(): also increase xenevt_ih->ih_pending, so that
the handler will be called when the IPL is lowered.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.64 24-Jul-2021 andvar

Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.63 11-Jan-2021 skrll

branches: 1.63.4;
Trailing whitespace


# 1.62 11-Jan-2021 skrll

Fix spelling of preferred in comments. While here improve grammar in
one of the comments.


# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


# 1.60 07-May-2020 bouyer

branches: 1.60.2;
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.67 07-Sep-2022 knakahara

NetBSD/x86: Raise the number of interrupt sources per CPU from 32 to 56.

There has been no objection for three years.
https://mail-index.netbsd.org/port-amd64/2019/09/22/msg003012.html
Implemented by nonaka@n.o, updated by me.


# 1.66 04-Sep-2022 bouyer

Release mutexes earlier in xenevt_free(), to call *destroy and kmem_free
without holding spin locks. Fixes an occasional deadlock seen when the qemu
backing a HVM domU exits.


# 1.65 27-May-2022 bouyer

xenevt_setipending(): also increase xenevt_ih->ih_pending, so that
the handler will be called when the IPL is lowered.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.64 24-Jul-2021 andvar

Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.63 11-Jan-2021 skrll

branches: 1.63.4;
Trailing whitespace


# 1.62 11-Jan-2021 skrll

Fix spelling of preferred in comments. While here improve grammar in
one of the comments.


# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


# 1.60 07-May-2020 bouyer

branches: 1.60.2;
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.66 04-Sep-2022 bouyer

Release mutexes earlier in xenevt_free(), to call *destroy and kmem_free
without holding spin locks. Fixes an occasional deadlock seen when the qemu
backing a HVM domU exits.


# 1.65 27-May-2022 bouyer

xenevt_setipending(): also increase xenevt_ih->ih_pending, so that
the handler will be called when the IPL is lowered.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.64 24-Jul-2021 andvar

Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.63 11-Jan-2021 skrll

branches: 1.63.4;
Trailing whitespace


# 1.62 11-Jan-2021 skrll

Fix spelling of preferred in comments. While here improve grammar in
one of the comments.


# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


# 1.60 07-May-2020 bouyer

branches: 1.60.2;
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.65 27-May-2022 bouyer

xenevt_setipending(): also increase xenevt_ih->ih_pending, so that
the handler will be called when the IPL is lowered.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.64 24-Jul-2021 andvar

Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base
# 1.63 11-Jan-2021 skrll

branches: 1.63.4;
Trailing whitespace


# 1.62 11-Jan-2021 skrll

Fix spelling of preferred in comments. While here improve grammar in
one of the comments.


# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


# 1.60 07-May-2020 bouyer

branches: 1.60.2;
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.64 24-Jul-2021 andvar

Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 11-Jan-2021 skrll

Trailing whitespace


# 1.62 11-Jan-2021 skrll

Fix spelling of preferred in comments. While here improve grammar in
one of the comments.


# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


# 1.60 07-May-2020 bouyer

branches: 1.60.2;
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.63 11-Jan-2021 skrll

Trailing whitespace


# 1.62 11-Jan-2021 skrll

Fix spelling of preferred in comments. While here improve grammar in
one of the comments.


Revision tags: thorpej-futex-base
# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


# 1.60 07-May-2020 bouyer

branches: 1.60.2;
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.61 30-Nov-2020 bouyer

Work in progress on dom0 PVH support. kernel boots and xl info works,
but we can't start a domU yet.


Revision tags: thorpej-futex-base
# 1.60 07-May-2020 bouyer

Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.60 07-May-2020 bouyer

Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.59 06-May-2020 bouyer

The event channel is not necesserely bound to the primary CPU.
Use the CPU returned in the interrupt handler instead.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.58 05-May-2020 bouyer

Make DOM0OPS build for PVH/PVHVM too


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.57 25-Apr-2020 bouyer

Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base
# 1.56 07-Apr-2020 jdolecek

branches: 1.56.2;
switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.56 07-Apr-2020 jdolecek

switch from malloc() to kmem_zalloc()


Revision tags: phil-wifi-20200406
# 1.55 06-Apr-2020 jdolecek

just pass true as known_mpsafe for interrupt establish, drop the
(level != IPL_VM); NFCI, this uses IPL_HIGH so was mpsafe already


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.54 22-Nov-2019 martin

Make this files compilable w/o options DIAGNOSTIC


Revision tags: phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

branches: 1.53.4;
Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2; 1.48.4;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.53 25-Dec-2018 cherry

Excise XEN specific code out of x86/x86/intr.c into xen/x86/xen_intr.c

While at it, separate the source function tracking so that the interrupt
paths are truly independant.

Use weak symbol exporting to provision for future PVHVM co-existence
of both files, but with independant paths. Introduce assembler code
such that in a unified scenario, native interrupts get first priority
in spllower(), followed by XEN event callbacks. IPL management and
semantics are unchanged - native handlers and xen callbacks are
expected to maintain their ipl related semantics.

In summary, after this commit, native and XEN now have completely
unrelated interrupt handling mechanisms, including
intr_establish_xname() and assembler stubs and intr handler
management.

Happy Christmas!


# 1.52 24-Dec-2018 cherry

Bifurcate the interrupt establish functions between XEN and non-XEN

Thus intr_establish_xname() becomes xen_intr_establish_xname() etc.

One consequence of this is that dom0 devices expect the native
function calls to be available and we thus provide weak aliasing for
dom0 builds to succeed. XEN and non-XEN devices are distinguished by
the PIC they are established on. XEN interrupts are exclusively
established on xen_pic, while dom0 interrupts are established on
natively available PICs.

This allows us an orthogonal path to xen device management (eg:
xenstore events) in XENPVHVM, without having to worry about unifying
the vector entry paths, etc., which is quite challenging.


Revision tags: pgoyette-compat-1126
# 1.51 24-Oct-2018 cherry

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 (&xen_pic, port) is used for registration.


Revision tags: pgoyette-compat-1020
# 1.50 17-Oct-2018 cherry

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.


# 1.49 10-Oct-2018 cherry

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.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

branches: 1.48.2;
add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


Revision tags: tls-maxphys-base-20171202
# 1.48 30-Nov-2017 christos

add fo_name so we can identify the fileops in a simple way.


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.47 16-Jul-2017 cherry

branches: 1.47.2;
Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: matt-nb8-mediatek-base netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.47 16-Jul-2017 cherry

Unify the xen and native x86/ interrupt setup functions and
spl traversal data structures.

This is towards PVHVM.


Revision tags: netbsd-8-base
# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


# 1.46 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.45 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.44 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606
# 1.43 30-May-2015 joerg

Improve wording.


# 1.42 22-May-2015 bouyer

Fix off by one error, pointed out by Wei Liu in port-xen/49919


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.41 25-Jul-2014 dholland

branches: 1.41.2; 1.41.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.40 16-Mar-2014 dholland

branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base
# 1.39 03-Dec-2011 bouyer

branches: 1.39.4; 1.39.8; 1.39.10; 1.39.12; 1.39.18;
hypervisor_unmask_event(): don't check/update evtchn_pending_sel for the
current CPU, but for any CPU which may accept this event.
xen/xenevt.c: more use of atomic ops and locks where appropriate, and some
other SMP fixes. Handle all events on the primary CPU (may be revisited
later). Set/clear ci_evtmask[] for watched events.

This should fix the problems on dom0 kernels reported by jym@


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base jym-xensuspend-nbase jym-xensuspend-base
# 1.38 11-Aug-2011 cherry

branches: 1.38.2;
Make event/interrupt handling MP aware


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.37 22-May-2011 rmind

branches: 1.37.2;
- Replace uses of simple_lock and ltsleep with mutex and condvar.
- Improve some parts of the code to be more MP-friendly.

Tested by jakllsch@.


Revision tags: uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.36 20-Dec-2009 dsl

branches: 1.36.4; 1.36.6;
If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567


Revision tags: matt-premerge-20091211
# 1.35 09-Dec-2009 dsl

Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.


# 1.34 19-Oct-2009 bouyer

Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.33 29-Jul-2009 cegger

remove Xen2 support.
ok bouyer@


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.32 04-Apr-2009 ad

Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)


# 1.31 10-Mar-2009 bouyer

More i386PAE fixes:
- x86_round_page, x86_trunc_page, x86_btop and x86_ptob macros are used with
physical addresses; cast to paddr_t instead of u_long. Issue pointed out
by jym@
- machine_to_phys_mapping[] is a long. This is fine as it holds page
frame numbers (and this fits in a 32bit int as physical addresses are
only 36bits), but cast to paddr_t before << PAGE_SHIFT
- xen_start_info.store_mfn is a long; cast it to paddr_t before << PAGE_SHIFT.
should fix issue pointed out by cegger@


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.30 17-Dec-2008 cegger

branches: 1.30.2;
kill MALLOC and FREE macros.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.29 05-Sep-2008 tron

branches: 1.29.2; 1.29.4;
Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.28 07-Jun-2008 bouyer

branches: 1.28.4;
Initialize ih_ilevel for the special xenevt_processevt() handler.
Should fix KASSERT panic reported by Sarton O'Brien and Kazushi Marukawa
on port-xen@


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base
# 1.27 19-Apr-2008 cegger

branches: 1.27.2; 1.27.4;
Use interrupt biglock wrapper as in x86/x86/intr.c
This change is based on http://mail-index.netbsd.org/port-amd64/2004/02/22/0000.html
OK bouyer


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.26 14-Apr-2008 cegger

branches: 1.26.2;
- use POSIX integer types
- ansify functions


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14
# 1.25 22-Mar-2008 ad

Make it compile.


Revision tags: keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.24 01-Mar-2008 rmind

Fix my previous confuse of the code: use selinit/seldestroy in correct
places, and fix missed selnotify call.


# 1.23 01-Mar-2008 rmind

Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base hpcarm-cleanup-base
# 1.22 19-Feb-2008 bouyer

branches: 1.22.2; 1.22.6;
The event bitmasks provided by the hypervisor are unsigned long (so 64bits
on amd64). Make sure to use the right type to store and manipulate them.
This fixes amd64, where basically any event channel > 31 was not working
(and you get there after starting/stopping a domU a few times). Things
would occasionally unwedge though the spllower() callbacks.


# 1.21 19-Feb-2008 bouyer

Fix xenevt to not call softint_schedule() above IPL_HIGH:
Register a ipl callback for IPL_HIGH.
if the current ipl level is too high, just record the event in a bitmap,
and record IPL_HIGH as pending. The callback will process the pending events.


Revision tags: mjf-devfs-base
# 1.20 17-Feb-2008 bouyer

Add missing __KERNEL_RCSID()


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.19 11-Jan-2008 bouyer

Merge the bouyer-xeni386 branch to head, at tag bouyer-xeni386-merge1 (the
branch is still active and will see i386PAE support developement).
Sumary of changes:
- switch xeni386 to the x86/x86/pmap.c, and the xen/x86/x86_xpmap.c
pmap bootstrap.
- merge back most of xen/i386/ to i386/i386
- change the build to reduce diffs between i386 and amd64 in file locations
- remove include files that were identical to the i386/amd64 counterparts,
the build will find them via the xen-ma/machine link.


# 1.18 08-Jan-2008 bouyer

Allocating up to 8k on stack isn't a good idea ...


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.17 03-Dec-2007 ad

branches: 1.17.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.


# 1.16 22-Nov-2007 bouyer

Pull up the bouyer-xenamd64 branch to HEAD. This brings in amd64 support
to NetBSD/Xen, both Dom0 and DomU.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base
# 1.15 17-Oct-2007 garbled

branches: 1.15.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base nick-csl-alignment-base matt-mips64-base ppcoea-renovation-base mjf-ufs-trans-base vmlocking-base
# 1.14 08-Jun-2007 jld

branches: 1.14.8; 1.14.10; 1.14.14;
Add needed locking in xenevt_fpoll; this fixes at least a lost-wakeup bug.
OK'ed by bouyer@.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base ad-audiomp-base
# 1.13 22-Feb-2007 thorpej

branches: 1.13.4; 1.13.6; 1.13.12;
TRUE -> true, FALSE -> false


# 1.12 21-Feb-2007 thorpej

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.


Revision tags: post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base netbsd-4-base
# 1.11 10-Sep-2006 bouyer

branches: 1.11.4; 1.11.6; 1.11.8;
Hypercalls returns negative error codes, so return -error in ioctl
function.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 rpaulo-netinet-merge-pcb-base
# 1.10 25-Jul-2006 riz

branches: 1.10.4;
Adapt to change in args for falloc(). Reported by Hisashi T Fujinaka
on current-users.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.9 14-May-2006 elad

integrate kauth.


Revision tags: elad-kernelauth-base
# 1.8 07-May-2006 bouyer

Add dom0 operation support for Xen3. Probably buggy, but it's enouth to have
xend and xenstored starting; xm info and xm list works.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.7 12-Dec-2005 jld

branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Make xenevt.c compile after lwp changes; not tested yet.


# 1.6 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base kent-audio2-base ktrace-lwp-base
# 1.5 19-Apr-2005 bouyer

branches: 1.5.2; 1.5.4;
Avoid a race between do_hypervisor_event() and stipending() that could
cause an event to be both handled and marked as pending, or being
marked as pending twice (triggering the diagnostic check
evtch_maskcount[port] == 0 in hypervisor_set_ipending):
mask and clear event by word of 32bit in do_hypervisor_event() or stipending(),
instead of by indiviual bits in do_event() or xenevt_event().
In addition this is marginally more efficient.


# 1.4 16-Apr-2005 bouyer

Get rid of the event to pseudo-irq mapping. We are limited to 32 pseudo-irq,
including soft interrupt, and this is way too low in some use (lots of domains,
or domains with lots of xennet, or even hardware with lots of devices at
different interrupts).
Based on idea from YAMAMOTO Takashi, keep one list of handler per-event and
one per-IPL (so the same handler is now in 2 lists). In the common case were
an event is received at low IPL, we can call the handlers quickly (there
is usually only one handler per event, unless the event is mapped to a
physical interrupt and this interrupt is shared by different devices).
Deffered events and software interrupts are handled by a bitmask (as before)
with one bit per IPL. When one IPL has an event pending all handlers for
this IPL will be called.
With this change, it is now possible to have all the 1024 events active.

While here, handle debug event in a special way: the handler is always called,
regardless of the current IPL. Make the handler print usefull informations
about events and IPL states.
Also remove code not used on Xen in files inherited from the x86 port.


# 1.3 11-Apr-2005 yamt

fix a bug which corrupts runqueue.
when dealing with events, which are handed to xenevt pseudo device,
don't call wakeup(9)/selnotify(9) at too high IPL. PR/29792.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.2 09-Mar-2005 bouyer

branches: 1.2.2; 1.2.4; 1.2.6;
Merge the bouyer-xen2 branch. This add supports for the Xen 2.0 virtual
machine kernel (both privileged and non-privileged domains), and remove support
for the old xen 1.2.


Revision tags: yamt-km-base2
# 1.1 31-Jan-2005 bouyer

branches: 1.1.2;
file xenevt.c was initially added on branch bouyer-xen2.