Provides current_errstr()

Instead of using the per-proc current->errstr, now use the per-syscall errstr.
Adds per cpu errbuf pointers

So we don't need to track perrbuf throughout all of the waserror-using code.

I'm tracking it as a void*, since the errbuf stuff isn't even in this branch
yet.
udelay_sched()

Sleeps a kthread for 'usec' microseconds.
strtoul()

Ron's old version, based off strtol().
Common helper defines (XCC)

Dropping these in the kernel header for now, though they aren't used in part of
the kernel interface.
Set errno when only errstr was called

Some error paths set errstr, but not errno.  Glibc will ignore errstr if there
isn't an errno too, so we need something.

Ultimately, we should be setting both errno and errstr (given a glibc-world
with errno).  Til then, we'll set a generic errno.

This won't harm the current glibc, which 0's sysc.errstr before calling, but
that isn't actually part of the ABI.  So with this hack, it is possible to set
errno when there wasn't actually an error.  Luckily, userspace shouldn't look
at errno unless it was told too (via a bad retval), in which case, we probably
wanted errno set anyway.  Still, be careful.
Busybox perror knows about errstr

Busybox rolls their own perror.  I made an ugly patch that hacks in errstr.
Feel free to more elegantly add ", errstr" to their 'msg'.

If you're interested in using it, you'll get better error messages from the 9ns
code.  For example:

/ $ cat sdfsd
cat: can't open 'sdfsd': No such file or directory
/ $ cat /9/sdfsf
cat: can't open '/9/sdfsf': No such file or directory, file does not exist
/ $ cat '#p/1/args'
cat: read error: Unspecified, ken has left the building

You'll need to manually patch busybox for this.
Busybox doesn't use internal echo

The builtin echo breaks up its write in a way that messes with 9ns
control files.

Copy out the bb config and rebuild busybox.  Be sure to set up a symlink
for echo.
x86: Fixes 64 bit VPT mapping

You can't have global entries on certain interior PML PTEs.  For
instance, in the 4K walk (which we're doing for VPT/VPD), PML4 and PML3
both need the global bit to be 0.
Kthread poison checker

Drop this wherever you want to see if you have already clobbered your
current stack's canary.  It'll printk your message and panic.  If you
call this while you are still off your stack, you'll get a Bad Stacktop
panic.
Make set_errstr take a printf-like format

One of the things I really disliked about Plan 9 was that we
could return an errstr, and we only ever returned 52 errors
even though errstr was called in over 112 places. It gets
even more confusing if a program or library transforms the args:
what did the args look like precisely? Hard to say.

So on Plan 9 we get errors no more informative than errno. That's a very
low bar, to say the least.

This change allows for more useful error messages. We include an
example -- not a great one, but hey, it already cleared something
up for me.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Make the errstr a more reasonable size. (XCC)

Note from brho: rebuild your cross compiler and userspace.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
RFC: support pipe reads based on a condition.

This is a proposal for pipe reading conditioned on a function. It is often
necessary to read lock a pipe and read data from it until some condition is met.
It is essential that we keep the lock for our own uses until we are done, to ensure
integral copyout of possibly fragmented RPC and other requests. Note this
was not an issue with the Plan 9 'il' protocol, became an issue with IP V4,
and will not be an issue with IP V6. But we have to support v4, even though
we're supposed to be beyond all that now. Legacy sucks.

The apipe_read_cond is called with a function, f, and an arg. Each time the
pipe is non-empty, f is called with the pipe and arg as parameters. F returns
0 until some condition is met, in which case it returns > 0, or until failure,
in which case it returns < 0. f may read data from the pipe by calling
apipe_read_locked.

If this design meets with approval (ha!) then I can create a qio function that
uses these semantics. But, I expect the Akaros guys will do something
better :-)

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Can associate multiple CVs with spinlocks

You can associate a CV with any spinlock.  This is so you can easily
have multiple conditions protected by the same lock.  Calling cv_lock()
on any of them grabs the common spinlock.
Fixes apipe_read_cond()

Uses a priority_reader CV, so that we can have only one reader at a
time.  In the process, I separated the reader and writer CVs too.  Since
we have multiple CVs sharing a lock, it's clearer to use a standalone
lock.  Maybe I'll switch over to the POSIX CV style in the future...

Note: this was cherry-picked and had some minor issues.  I blame any bugs on
that.
Poor-mans ftrace with spatch

Will add a printk to the entry and exit of every function you spatch.
Doesn't work with multicore, so only use it on core 0.
Checks for running off the stack

Printing takes up a shitload of stack, esp when deep in a call stack (FS, net,
etc).  This will try to catch stack clobbers caused by calls to print that
cause print to run off the stack.
Spinlock debugging improvements

Can blacklist locks from collection, and the output also says where the lock
was last grabbed.

Also, catches any attempt to unlock a lock that is already unlocked.
spin_trylock()

When lock checking, it won't check for IRQs when trylocking.
Reader-writer queue locks

These will be the qlocks in 9ns/inferno.