Page MenuHomeFreeBSD

riscv: Fix copyin/copyout
ClosedPublic

Authored by kp on Jul 29 2019, 12:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Aug 6 2023, 10:12 AM
Unknown Object (File)
May 14 2023, 6:35 PM
Unknown Object (File)
Apr 25 2023, 6:54 PM
Unknown Object (File)
Dec 2 2022, 6:49 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 25563

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.