kernel - Fix live lock in vfs_conf.c mountroot>
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 14 Jul 2015 20:33:49 +0000 (13:33 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 14 Jul 2015 20:46:12 +0000 (13:46 -0700)
commitce7866b815cc808c6c038daf3ba274cc8bcf68f7
treeea4af232c963685971baa7848e8694bc8a3534ab
parent4511b225fb29adf3a54f6da82c3361f7f7cfebff
kernel - Fix live lock in vfs_conf.c mountroot>

* The mountroot> prompt calls cngetc() to process user input.  However, this
  function hard loops and can prevent other kernel threads from running on
  the current cpu.

* Rearrange the code to use cncheckc() and a 1/25 second tsleep().

* Fix a bug in the syscons code where NOKEY was not being properly returned
  as documented.  Modify all use cases to handle NOKEY.  This allows us to
  differentiate between a keyboard present but not key pressed and a keyboard
  not present.

* Pull the automatic polling mode code out of cncheckc() (or more precisely,
  out of sccncheckc()) and add a new cnpoll() API function to set it manually.

  This fixes issues in vfs_conf when normal keyboard processing interrupts
  are operational and cncheckc() is used with a tsleep() delay.  The normal
  processing interrupt wound up eating the keystrokes so the cncheckc()
  basically always failed.

  cncheckc() in general also always had a small window of opportunity where
  a keystroke could be lost due loops on it.

* Call cnpoll() in various places, such as when entering the debugger,
  asking for input in vfs_conf, and a few other places.
14 files changed:
sys/ddb/db_command.c
sys/dev/misc/dcons/dcons_os.c
sys/dev/misc/syscons/syscons.c
sys/dev/serial/sio/sio.c
sys/kern/kern_ktr.c
sys/kern/kern_shutdown.c
sys/kern/tty_cons.c
sys/kern/vfs_conf.c
sys/platform/pc64/isa/clock.c
sys/platform/pc64/x86_64/dump_machdep.c
sys/platform/pc64/x86_64/minidump_machdep.c
sys/platform/pc64/x86_64/mp_machdep.c
sys/platform/vkernel64/platform/console.c
sys/sys/cons.h