kp b3d04ff660 riscv: Fix copyin/copyout
r343275 introduced a performance optimisation to the copyin/copyout
routines by attempting to copy word-per-word rather than byte-per-byte
where possible.

This optimisation failed to account for cases where the buffer is longer
than XLEN_BYTES, but due to misalignment does not not allow for any
word-sized copies. E.g. a 9 byte buffer (with XLEN_BYTES == 8) which is
misaligned by 2 bytes. The code nevertheless did a single full-word
copy, which meant we copied too much data. This potentially clobbered
other data.

This is most easily demonstrated by a simple `sysctl -a`.

Fix it by not assuming that we'll always have at least one full-word
copy to do, but instead checking the remaining length first.

Reviewed by:	markj@, mhorne@, br@ (previous version)
MFC after:	1 week
Sponsored by:	Axiado
Differential Revision:	https://reviews.freebsd.org/D21100
2019-07-29 14:59:14 +00:00
..
2019-07-17 16:38:29 +00:00
2019-07-10 13:47:10 +00:00
2019-05-27 00:47:51 +00:00
2019-06-22 05:35:23 +00:00
2019-05-08 19:27:30 +00:00
2019-07-28 16:07:27 +00:00
2019-07-22 16:01:20 +00:00
2019-07-24 21:26:17 +00:00
2019-07-25 22:23:34 +00:00
2019-07-29 14:59:14 +00:00
2019-02-04 21:28:25 +00:00
2019-06-08 16:26:56 +00:00
2019-07-14 21:08:54 +00:00