rsx: Implement crash-proofing for 308A_COLOR dst address

This commit is contained in:
Eladash 2021-08-13 19:24:50 +03:00 committed by kd-11
parent 24d7374a22
commit 2ce164be09
3 changed files with 37 additions and 17 deletions

View file

@ -74,7 +74,7 @@ namespace rsx
{
std::function<bool(u32 addr, bool is_writing)> g_access_violation_handler;
u32 get_address(u32 offset, u32 location, bool allow_failure, u32 line, u32 col, const char* file, const char* func)
u32 get_address(u32 offset, u32 location, u32 size_to_check, u32 line, u32 col, const char* file, const char* func)
{
const auto render = get_current_renderer();
std::string_view msg;
@ -84,7 +84,7 @@ namespace rsx
case CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER:
case CELL_GCM_LOCATION_LOCAL:
{
if (offset < render->local_mem_size)
if (offset < render->local_mem_size && render->local_mem_size - offset >= size_to_check)
{
return rsx::constants::local_mem_base + offset;
}
@ -98,7 +98,10 @@ namespace rsx
{
if (const u32 ea = render->iomap_table.get_addr(offset); ea + 1)
{
return ea;
if (!size_to_check || vm::check_addr(ea, 0, size_to_check))
{
return ea;
}
}
msg = "RSXIO memory not mapped!"sv;
@ -120,7 +123,10 @@ namespace rsx
{
if (const u32 ea = offset < 0x1000000 ? render->iomap_table.get_addr(0x0e000000 + offset) : -1; ea + 1)
{
return ea;
if (!size_to_check || vm::check_addr(ea, 0, size_to_check))
{
return ea;
}
}
msg = "RSXIO REPORT memory not mapped!"sv;
@ -181,8 +187,11 @@ namespace rsx
}
}
if (allow_failure)
if (size_to_check)
{
// Allow failure if specified size
// This is to allow accurate recovery for failures
rsx_log.warning("rsx::get_address(offset=0x%x, location=0x%x, size=0x%x): %s%s", offset, location, size_to_check, msg, src_loc{line, col, file, func});
return 0;
}