mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-21 05:51:39 +00:00
video_core: Add bounds checking for subspan use in liverpool functions (#717)
This commit is contained in:
parent
1bf9be89bf
commit
3f8a8d3a24
|
@ -20,6 +20,20 @@ static const char* acb_task_name{"ACB_TASK"};
|
||||||
|
|
||||||
std::array<u8, 48_KB> Liverpool::ConstantEngine::constants_heap;
|
std::array<u8, 48_KB> Liverpool::ConstantEngine::constants_heap;
|
||||||
|
|
||||||
|
static std::span<const u32> NextPacket(std::span<const u32> span, size_t offset) {
|
||||||
|
if (offset > span.size()) {
|
||||||
|
LOG_ERROR(
|
||||||
|
Lib_GnmDriver,
|
||||||
|
": packet length exceeds remaining submission size. Packet dword count={}, remaining "
|
||||||
|
"submission dwords={}",
|
||||||
|
offset, span.size());
|
||||||
|
// Return empty subspan so check for next packet bails out
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return span.subspan(offset);
|
||||||
|
}
|
||||||
|
|
||||||
Liverpool::Liverpool() {
|
Liverpool::Liverpool() {
|
||||||
process_thread = std::jthread{std::bind_front(&Liverpool::Process, this)};
|
process_thread = std::jthread{std::bind_front(&Liverpool::Process, this)};
|
||||||
}
|
}
|
||||||
|
@ -150,7 +164,7 @@ Liverpool::Task Liverpool::ProcessCeUpdate(std::span<const u32> ccb) {
|
||||||
UNREACHABLE_MSG("Unknown PM4 type 3 opcode {:#x} with count {}",
|
UNREACHABLE_MSG("Unknown PM4 type 3 opcode {:#x} with count {}",
|
||||||
static_cast<u32>(opcode), count);
|
static_cast<u32>(opcode), count);
|
||||||
}
|
}
|
||||||
ccb = ccb.subspan(header->type3.NumWords() + 1);
|
ccb = NextPacket(ccb, header->type3.NumWords() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TracyFiberLeave;
|
TracyFiberLeave;
|
||||||
|
@ -184,7 +198,7 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// Type-2 packet are used for padding purposes
|
// Type-2 packet are used for padding purposes
|
||||||
dcb = dcb.subspan(1);
|
dcb = NextPacket(dcb, 1);
|
||||||
continue;
|
continue;
|
||||||
case 3:
|
case 3:
|
||||||
const u32 count = header->type3.NumWords();
|
const u32 count = header->type3.NumWords();
|
||||||
|
@ -525,7 +539,7 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
|
||||||
UNREACHABLE_MSG("Unknown PM4 type 3 opcode {:#x} with count {}",
|
UNREACHABLE_MSG("Unknown PM4 type 3 opcode {:#x} with count {}",
|
||||||
static_cast<u32>(opcode), count);
|
static_cast<u32>(opcode), count);
|
||||||
}
|
}
|
||||||
dcb = dcb.subspan(header->type3.NumWords() + 1);
|
dcb = NextPacket(dcb, header->type3.NumWords() + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,7 +641,7 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
|
||||||
static_cast<u32>(opcode), count);
|
static_cast<u32>(opcode), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
acb = acb.subspan(header->type3.NumWords() + 1);
|
acb = NextPacket(acb, header->type3.NumWords() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TracyFiberLeave;
|
TracyFiberLeave;
|
||||||
|
|
Loading…
Reference in a new issue