Page MenuHomeFreeBSD

riscv: Fix copyin/copyout
ClosedPublic

Authored by kp on Jul 29 2019, 12:58 PM.
Tags
None
Referenced Files
F106179172: D21100.id60235.diff
Thu, Dec 26, 4:59 PM
F106149209: D21100.diff
Thu, Dec 26, 5:13 AM
Unknown Object (File)
Wed, Dec 25, 4:51 AM
Unknown Object (File)
Tue, Dec 17, 8:21 AM
Unknown Object (File)
Tue, Dec 10, 6:00 AM
Unknown Object (File)
Sun, Dec 1, 3:37 PM
Unknown Object (File)
Nov 24 2024, 7:49 AM
Unknown Object (File)
Nov 22 2024, 11:57 AM
Subscribers

Details

Summary

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.

Sponsored by: Axiado

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Looks okay to me, but would you mind updating the diff with full context?

This revision is now accepted and ready to land.Jul 29 2019, 2:22 PM
This revision was automatically updated to reflect the committed changes.