HomeFreeBSD

Improve i386_get_ldt().

Description

Improve i386_get_ldt().

Provide consistent snapshot of the requested descriptors by preventing
other threads from modifying LDT while we fetch the data, lock dt_lock
around the read. Copy the data into intermediate buffer, which is
copied out after the lock is dropped.

Comparing with the amd64 version, the read is done byte by byte, since
there is no atomic 64bit read (cmpxchg8b method is too heavy comparing
with the avoided issues).

Improve overflow checking for the descriptors range calculations and
remove unneeded casts. Use unsigned types for sizes.

Allow zero num argument to i386_get_ldt() and i386_set_ldt(). This
case is handled naturally by the code flow.

Reviewed by: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Details

Provenance
kibAuthored on
Parents
rS324365: Note about workaround for native armv7 builds using a kernel prior to
Branches
Unknown
Tags
Unknown