shithub: riscv

Download patch

ref: 656dd953a85b043c1eb085d5d8e1f7f7f1e4452f
parent: 85e144dcb0c621161ca4275f7613d606da088ca0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Apr 13 19:18:56 EDT 2015

segment: fix read/write g->dlen race, avoid copying kernel memory, qlock

code like "return g->dlen;" is wrong as we do not hold the
qlock of the global segment. another process could come in
and override g->dlen making us return the wrong byte count.

avoid copying when we already got a kernel address (kernel memory
is the same on processes) which is the case with bread()/bwrite().
this is the same optimization that devsd does.

also avoid allocating/freeing and copying while holding the qlock.
when we copy to/from user memory, we might fault preventing
others from accessing the segment while fault handling is in
progress.