History log of /openbsd-current/sys/kern/kern_physio.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.49 03-Feb-2024 beck

Remove Softdep.

Softdep has been a no-op for some time now, this removes it to get
it out of the way.

Flensing mostly done in Talinn, with some help from krw@

ok deraadt@


# 1.48 24-Nov-2023 asou

Fix comments longer than 80 column.

ok miod@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.47 20-Feb-2020 krw

Relax the grip the dead hand of QBUS (a.k.a. MAXPHYS) has on the
throat of physio().

Allows individual devices to eventually be modified to support larger
physio() (a.k.a. 'raw') i/o's if they prove capable of them.

No immediate functional change.

Tested for many weeks by and ok robert@.


# 1.46 26-Jan-2020 krw

Use long for temporary variables handling b_bcount values in physio().

Add a KASSERTMSG() to check that strategy functions didn't screw
b_resid up too much.

ok beck@ tedu@


# 1.45 25-Jan-2020 krw

physio() just needs to check for b_bcount overflow. Let the provided
minphys() function check for MAXPHYS.

Feedback from tedu@ kettenis@ dlg@

ok cheloha@, robert@, jmatthew@ as part of larger diff


# 1.44 19-Dec-2019 mpi

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.48 24-Nov-2023 asou

Fix comments longer than 80 column.

ok miod@


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.47 20-Feb-2020 krw

Relax the grip the dead hand of QBUS (a.k.a. MAXPHYS) has on the
throat of physio().

Allows individual devices to eventually be modified to support larger
physio() (a.k.a. 'raw') i/o's if they prove capable of them.

No immediate functional change.

Tested for many weeks by and ok robert@.


# 1.46 26-Jan-2020 krw

Use long for temporary variables handling b_bcount values in physio().

Add a KASSERTMSG() to check that strategy functions didn't screw
b_resid up too much.

ok beck@ tedu@


# 1.45 25-Jan-2020 krw

physio() just needs to check for b_bcount overflow. Let the provided
minphys() function check for MAXPHYS.

Feedback from tedu@ kettenis@ dlg@

ok cheloha@, robert@, jmatthew@ as part of larger diff


# 1.44 19-Dec-2019 mpi

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.47 20-Feb-2020 krw

Relax the grip the dead hand of QBUS (a.k.a. MAXPHYS) has on the
throat of physio().

Allows individual devices to eventually be modified to support larger
physio() (a.k.a. 'raw') i/o's if they prove capable of them.

No immediate functional change.

Tested for many weeks by and ok robert@.


# 1.46 26-Jan-2020 krw

Use long for temporary variables handling b_bcount values in physio().

Add a KASSERTMSG() to check that strategy functions didn't screw
b_resid up too much.

ok beck@ tedu@


# 1.45 25-Jan-2020 krw

physio() just needs to check for b_bcount overflow. Let the provided
minphys() function check for MAXPHYS.

Feedback from tedu@ kettenis@ dlg@

ok cheloha@, robert@, jmatthew@ as part of larger diff


# 1.44 19-Dec-2019 mpi

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.46 26-Jan-2020 krw

Use long for temporary variables handling b_bcount values in physio().

Add a KASSERTMSG() to check that strategy functions didn't screw
b_resid up too much.

ok beck@ tedu@


# 1.45 25-Jan-2020 krw

physio() just needs to check for b_bcount overflow. Let the provided
minphys() function check for MAXPHYS.

Feedback from tedu@ kettenis@ dlg@

ok cheloha@, robert@, jmatthew@ as part of larger diff


# 1.44 19-Dec-2019 mpi

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.45 25-Jan-2020 krw

physio() just needs to check for b_bcount overflow. Let the provided
minphys() function check for MAXPHYS.

Feedback from tedu@ kettenis@ dlg@

ok cheloha@, robert@, jmatthew@ as part of larger diff


# 1.44 19-Dec-2019 mpi

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.44 19-Dec-2019 mpi

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.43 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.41 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_6_BASE
# 1.40 13-Jul-2014 uebayasi

KASSERTMSG(9): New kernel assertion with message

KASSERT() is annoying as it only prints the expression as a string. If you
(developers) want to know a little more information, you have to do:

#ifdef DIAGNOSTIC
if (bad)
panic(...);
#endif

KASSERTMSG() replaces it into a single line:

KASSERTMSG(!bad, ...);

Taken from NetBSD.

(There is a concern that KASSERT() messages are too long; consume more memory,
and not friendly for small monitors. This have to be considered & revisited
later.)

"Like" from henning@
Man page review & advices from jmc@ and schwarze@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.39 18-Jul-2011 matthew

Revert vnd(4) to its older less strict behavior.

Verified by deraadt@ to fix distrib/sgi/iso.


# 1.38 07-Jul-2011 beck

set flags correctly in physio - now with actual clearing of B_DONE and B_ERROR
between re-use of the same buffer to re-call strategy() - large dd's now
work again which were broken by my last commit of this.
ok krw@


# 1.37 07-Jul-2011 dhill

back out last change; it caused dd on usb drive to lock the machine.

ok oga@


# 1.36 06-Jul-2011 beck

stylistic clean of buffer flags assignment to be more obviously not a
destructive assignment of flags.
ok oga@


# 1.35 05-Jul-2011 matthew

If uvm_vslock_device() fails, just exit the loop. None of the
after_unlock code is needed if this happens, and running it was even
wrong because we weren't setting b_resid, so uio_offset (and higher
up, f_offset) would be incorrectly adjusted.

Discussed with deraadt@.


# 1.34 05-Jul-2011 matthew

Enforce that raw disk I/O is only initiated on block boundaries in
physio().

ok deraadt@


# 1.33 08-May-2011 dlg

because bufs now come out of a pool rather than a global list of staticly
allocated structs, they wont be shared. we dont have to do the silly
B_WANTED dance anymore. get rid of a bunch of comments that talk about
how we're stealing from the swapper, which is a lie now.

tweaks from oga@ scrutiny by matthew@
ok miod@ oga@ thib@ beck@


Revision tags: OPENBSD_4_9_BASE
# 1.32 22-Sep-2010 matthew

All users of physio(9) now pass NULL as the buf pointer argument, so
no point in keeping it around.

"i like this" thib@ (a while back); ok krw@ and oga@; reminder to
update the man page and tweaks jmc@


Revision tags: OPENBSD_4_8_BASE
# 1.31 01-Jul-2010 art

Implement vs{,un}lock_device and use it for physio.

Just like normal vs{,un}lock, but in case the pages we get are not dma
accessible, we bounce them, if they are dma acessible, the functions behave
exactly like normal vslock. The plan for the future is to have fault_wire
allocate dma acessible pages so that we don't need to bounce (especially
in cases where the same buffer is reused for physio over and over again),
but for now, keep it as simple as possible.


# 1.30 23-Jun-2010 thib

No need to do the splbio/splx dance around the pool_get in
getphysbuf() as the bufpool is already protected.

From Matthew Dempsky <matthew at dempsky dot org>
OK blambert@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.29 04-Jun-2009 oga

obvious shrinkage.

ok krw@, miod@.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.28 26-May-2007 pedro

Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.


Revision tags: OPENBSD_4_1_BASE
# 1.27 21-Dec-2006 krw

'tranfer' -> 'transfer' in comments.


# 1.26 29-Nov-2006 miod

Kernel stack can be swapped. This means that stuff that's on the stack
should never be referenced outside the context of the process to which
this stack belongs unless we do the PHOLD/PRELE dance. Loads of code
doesn't follow the rules here. Instead of trying to track down all
offenders and fix this hairy situation, it makes much more sense
to not swap kernel stacks.

From art@, tested by many some time ago.


# 1.25 15-Nov-2006 jmc

typos; from bret lambert


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.24 08-Dec-2005 krw

Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues
in SCIOCCOMMAND code before calling physio.

Similar to what NetBSD does.

Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers"
problem noted by Alexandre Ratchov. Tested by Alexandre.

ok marco@ pedro@ deraadt@ mickey@


# 1.23 28-Nov-2005 jsg

ansi/deregister.
'go for it' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE SMP_SYNC_A SMP_SYNC_B
# 1.22 08-Nov-2003 jmc

typos from Jonathon Gray;


Revision tags: OPENBSD_3_4_BASE
# 1.21 21-Jul-2003 tedu

remove caddr_t casts. it's just silly to cast something when the function
takes a void *. convert uiomove to take a void * as well. ok deraadt@


# 1.20 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.19 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.18 10-Dec-2001 art

branches: 1.18.2;
No need for uvm_useracc here now. vslock catches those problems.


# 1.17 28-Nov-2001 art

Sync in more uvm changes from NetBSD.
This time we're getting rid of KERN_* and VM_PAGER_* error codes and
use errnos instead.


# 1.16 15-Nov-2001 art

Remove creds from struct buf, move the creds that nfs need into the nfs node.
While in the area, convert nfs node allocation from malloc to pool and do
some cleanups.
Based on the UBC changes in NetBSD. niklas@ ok.


# 1.15 09-Nov-2001 art

Use bufpool, not malloc.


# 1.14 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.13 27-Jun-2001 art

remove old vm


# 1.12 26-Jun-2001 aaron

Appease gcc by not using void pointers in arithmetic operations; art@ ok


# 1.11 22-Jun-2001 deraadt

KNF


# 1.10 07-May-2001 art

Check for failure now that uvm_vslock can return one. Before this, there was
a risk that we could crash when doing physio/sysctl when the system was
completly out of RAM and swap.


Revision tags: OPENBSD_2_9_BASE
# 1.9 09-Nov-2000 art

Use PHOLD/PRELE instead of manually fiddling with p_holdcnt.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 16-Mar-2000 art

Bring in some new UVM code from NetBSD (not current).

- Introduce a new type of map that are interrupt safe and never allow faults
in them. mb_map and kmem_map are made intrsafe.
- Add "access protection" to uvm_vslock (to be passed down to uvm_fault and
later to pmap_enter).
- madvise(2) now works.
- various cleanups.


Revision tags: SMP_BASE kame_19991208
# 1.7 02-Dec-1999 art

branches: 1.7.2;
Init the buffer dependency list.


# 1.6 05-Nov-1999 mickey

s/memset/bzero/; art@ ok


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.5 26-Feb-1999 art

mostly name changes and allocation chnges for uvm


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.4 25-Jul-1997 deraadt

indent properly


# 1.3 25-Jul-1997 mickey

from netbsd: check user access rights only if UIO_USERSPACE


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision