libcortex_a9: fix UB in UncachedSlice #121
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "srenblad/zynq-rs:fix_uncached"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Clean up UB and unnecessary asserts in
UncachedSlice
Added assertion on allocation failure. The global allocator returns a
nullptr
on allocation error, so check it here.Removed redundant alignment check.
align
is always a multiple ofL1_PAGE_SIZE
. Ifalign_of::<T>() > L1_PAGE_SIZE
it will still be a multiple (all aligns are powers of 2).start
will be a multiple ofk * L1_PAGE_SIZE
and thus a multiple ofL1_PAGE_SIZE
. If there is no allocation/layout error, this is always true.Removed UB during "size verification". From the docs,
slice.get_unchecked(len)
is always UB. This is not a problem at the moment, but results in a data abort in laterrustc
versions. It is also a redundant assertion:len * size_of::<T>() <= size
is established from line 15, and thus (if the allocation is successful) the slice will be contained inside the allocation object (assertion is always true).Tested all HITL with Kasli-SoC demo variant from master branches: artiq-zynq and artiq. No noticeable performance regressions.