From 067284733075fb0604dbcdc6238d23cfa27c5355 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 7 Jan 2024 04:50:06 +0100 Subject: [PATCH] SMMU: Fix Right Shift UB. --- src/core/device_memory_manager.h | 4 ++-- src/core/device_memory_manager.inc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h index f9cb13a7a..cc9fd023f 100644 --- a/src/core/device_memory_manager.h +++ b/src/core/device_memory_manager.h @@ -62,13 +62,13 @@ public: DAddr subbits = static_cast(address & page_mask); const u32 base = compressed_device_addr[(address >> page_bits)]; if ((base >> MULTI_FLAG_BITS) == 0) [[likely]] { - const DAddr d_address = static_cast(base << page_bits) + subbits; + const DAddr d_address = (static_cast(base) << page_bits) + subbits; operation(d_address); return; } InnerGatherDeviceAddresses(buffer, address); for (u32 value : buffer) { - operation(static_cast(value << page_bits) + subbits); + operation((static_cast(value) << page_bits) + subbits); } } diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index 5241293b6..d7b4abacc 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -301,7 +301,7 @@ template u8* DeviceMemoryManager::GetSpan(const DAddr src_addr, const std::size_t size) { size_t page_index = src_addr >> page_bits; size_t subbits = src_addr & page_mask; - if ((continuity_tracker[page_index] << page_bits) >= size + subbits) { + if ((static_cast(continuity_tracker[page_index]) << page_bits) >= size + subbits) { return GetPointer(src_addr); } return nullptr; @@ -311,7 +311,7 @@ template const u8* DeviceMemoryManager::GetSpan(const DAddr src_addr, const std::size_t size) const { size_t page_index = src_addr >> page_bits; size_t subbits = src_addr & page_mask; - if ((continuity_tracker[page_index] << page_bits) >= size + subbits) { + if ((static_cast(continuity_tracker[page_index]) << page_bits) >= size + subbits) { return GetPointer(src_addr); } return nullptr;