mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-21 00:43:29 +02:00
video_core: dma_pusher: Add support for integrity checks.
- Log corrupted command lists, rather than crash.
This commit is contained in:
parent
c64545d07a
commit
c6e1c46ac7
@ -2,6 +2,7 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "common/cityhash.h"
|
||||||
#include "common/microprofile.h"
|
#include "common/microprofile.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
@ -12,6 +13,20 @@
|
|||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
|
|
||||||
|
void CommandList::RefreshIntegrityChecks(GPU& gpu) {
|
||||||
|
command_list_hashes.resize(command_lists.size());
|
||||||
|
|
||||||
|
for (std::size_t index = 0; index < command_lists.size(); ++index) {
|
||||||
|
const CommandListHeader command_list_header = command_lists[index];
|
||||||
|
std::vector<CommandHeader> command_headers(command_list_header.size);
|
||||||
|
gpu.MemoryManager().ReadBlockUnsafe(command_list_header.addr, command_headers.data(),
|
||||||
|
command_list_header.size * sizeof(u32));
|
||||||
|
command_list_hashes[index] =
|
||||||
|
Common::CityHash64(reinterpret_cast<char*>(command_headers.data()),
|
||||||
|
command_list_header.size * sizeof(u32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DmaPusher::DmaPusher(Core::System& system, GPU& gpu) : gpu{gpu}, system{system} {}
|
DmaPusher::DmaPusher(Core::System& system, GPU& gpu) : gpu{gpu}, system{system} {}
|
||||||
|
|
||||||
DmaPusher::~DmaPusher() = default;
|
DmaPusher::~DmaPusher() = default;
|
||||||
@ -80,6 +95,15 @@ bool DmaPusher::Step() {
|
|||||||
command_headers.resize(command_list_header.size);
|
command_headers.resize(command_list_header.size);
|
||||||
gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(),
|
gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(),
|
||||||
command_list_header.size * sizeof(u32));
|
command_list_header.size * sizeof(u32));
|
||||||
|
|
||||||
|
// Integrity check
|
||||||
|
const u64 new_hash = Common::CityHash64(reinterpret_cast<char*>(command_headers.data()),
|
||||||
|
command_list_header.size * sizeof(u32));
|
||||||
|
if (new_hash != next_hash) {
|
||||||
|
LOG_CRITICAL(HW_GPU, "CommandList at addr=0x{:X} is corrupt, skipping!", dma_get);
|
||||||
|
dma_pushbuffer.pop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (std::size_t index = 0; index < command_headers.size();) {
|
for (std::size_t index = 0; index < command_headers.size();) {
|
||||||
const CommandHeader& command_header = command_headers[index];
|
const CommandHeader& command_header = command_headers[index];
|
||||||
|
@ -91,7 +91,10 @@ struct CommandList final {
|
|||||||
explicit CommandList(std::vector<Tegra::CommandHeader>&& prefetch_command_list)
|
explicit CommandList(std::vector<Tegra::CommandHeader>&& prefetch_command_list)
|
||||||
: prefetch_command_list{std::move(prefetch_command_list)} {}
|
: prefetch_command_list{std::move(prefetch_command_list)} {}
|
||||||
|
|
||||||
|
void RefreshIntegrityChecks(GPU& gpu);
|
||||||
|
|
||||||
std::vector<Tegra::CommandListHeader> command_lists;
|
std::vector<Tegra::CommandListHeader> command_lists;
|
||||||
|
std::vector<u64> command_list_hashes;
|
||||||
std::vector<Tegra::CommandHeader> prefetch_command_list;
|
std::vector<Tegra::CommandHeader> prefetch_command_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user