SMMU: Fix Right Shift UB.
This commit is contained in:
parent
a874ab0133
commit
0672847330
|
@ -62,13 +62,13 @@ public:
|
||||||
DAddr subbits = static_cast<DAddr>(address & page_mask);
|
DAddr subbits = static_cast<DAddr>(address & page_mask);
|
||||||
const u32 base = compressed_device_addr[(address >> page_bits)];
|
const u32 base = compressed_device_addr[(address >> page_bits)];
|
||||||
if ((base >> MULTI_FLAG_BITS) == 0) [[likely]] {
|
if ((base >> MULTI_FLAG_BITS) == 0) [[likely]] {
|
||||||
const DAddr d_address = static_cast<DAddr>(base << page_bits) + subbits;
|
const DAddr d_address = (static_cast<DAddr>(base) << page_bits) + subbits;
|
||||||
operation(d_address);
|
operation(d_address);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InnerGatherDeviceAddresses(buffer, address);
|
InnerGatherDeviceAddresses(buffer, address);
|
||||||
for (u32 value : buffer) {
|
for (u32 value : buffer) {
|
||||||
operation(static_cast<DAddr>(value << page_bits) + subbits);
|
operation((static_cast<DAddr>(value) << page_bits) + subbits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ template <typename Traits>
|
||||||
u8* DeviceMemoryManager<Traits>::GetSpan(const DAddr src_addr, const std::size_t size) {
|
u8* DeviceMemoryManager<Traits>::GetSpan(const DAddr src_addr, const std::size_t size) {
|
||||||
size_t page_index = src_addr >> page_bits;
|
size_t page_index = src_addr >> page_bits;
|
||||||
size_t subbits = src_addr & page_mask;
|
size_t subbits = src_addr & page_mask;
|
||||||
if ((continuity_tracker[page_index] << page_bits) >= size + subbits) {
|
if ((static_cast<size_t>(continuity_tracker[page_index]) << page_bits) >= size + subbits) {
|
||||||
return GetPointer<u8>(src_addr);
|
return GetPointer<u8>(src_addr);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -311,7 +311,7 @@ template <typename Traits>
|
||||||
const u8* DeviceMemoryManager<Traits>::GetSpan(const DAddr src_addr, const std::size_t size) const {
|
const u8* DeviceMemoryManager<Traits>::GetSpan(const DAddr src_addr, const std::size_t size) const {
|
||||||
size_t page_index = src_addr >> page_bits;
|
size_t page_index = src_addr >> page_bits;
|
||||||
size_t subbits = src_addr & page_mask;
|
size_t subbits = src_addr & page_mask;
|
||||||
if ((continuity_tracker[page_index] << page_bits) >= size + subbits) {
|
if ((static_cast<size_t>(continuity_tracker[page_index]) << page_bits) >= size + subbits) {
|
||||||
return GetPointer<u8>(src_addr);
|
return GetPointer<u8>(src_addr);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Reference in New Issue