Revert "Replace the TDP_NOSLEEPING flag with a counter so that the"

This reverts commit d59969d3e4b8b3855e69c0209395a963fdcf2841.
Assert that system calls do not leak a pinned thread (via sched_pin()) to
userland.

(cherry picked from commit 9e9c95ef1d9199a55e30c8f9f85adc3e3f2d19eb)
userret() already checks for td_locks when INVARIANTS is enabled, so
there is no need to check if Giant is acquired after it.

Reviewed by:	kib
MFC after:	1 week

(cherry picked from commit 8dece93b14588b73bf5dec69091706dcdccba2fc)
Move PT_UPDATED_FLUSH() before td_locks check in order to have more
coverage also in the XEN case.

Reviewed by:	kib
MFC after:	1 week

(cherry picked from commit 1e61b37b3fa32dbd38244eaef86701972d1c07fc)
Move the checks for td_pinned, td_critnest, TDP_NOFAULTING and
TDP_NOSLEEPING leaking from syscallret() to userret() so that also
trap handling is covered. Also, the check on td_locks is not duplicated
between the two functions.

Reported by:	avg
Reviewed by:	kib
MFC after:	1 week

(cherry picked from commit 7f498fac4af60ae0a9278ccffe36bed96963ea3d)
Replace the TDP_NOSLEEPING flag with a counter so that the
THREAD_NO_SLEEPING() and THREAD_SLEEPING_OK() macros can nest.

Reviewed by:	attilio

(cherry picked from commit 8857575b13cf118cc89efb1b462dd314df09c180)

Ticket: #3509