diff options
| author | 2020-10-29 21:13:48 -0700 | |
|---|---|---|
| committer | 2020-11-01 01:52:38 -0700 | |
| commit | c6e1c46ac70bf31b54f756f9611b1cf086b63fb0 (patch) | |
| tree | edf5e2a33941aba44f11c5ed42b1d658cc6bf20e | |
| parent | video_core: dma_pusher: Add support for prefetched command lists. (diff) | |
| download | yuzu-c6e1c46ac70bf31b54f756f9611b1cf086b63fb0.tar.gz yuzu-c6e1c46ac70bf31b54f756f9611b1cf086b63fb0.tar.xz yuzu-c6e1c46ac70bf31b54f756f9611b1cf086b63fb0.zip | |
video_core: dma_pusher: Add support for integrity checks.
- Log corrupted command lists, rather than crash.
| -rw-r--r-- | src/video_core/dma_pusher.cpp | 24 | ||||
| -rw-r--r-- | src/video_core/dma_pusher.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index 9c49c6153..105b85a92 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/cityhash.h" | ||
| 5 | #include "common/microprofile.h" | 6 | #include "common/microprofile.h" |
| 6 | #include "core/core.h" | 7 | #include "core/core.h" |
| 7 | #include "core/memory.h" | 8 | #include "core/memory.h" |
| @@ -12,6 +13,20 @@ | |||
| 12 | 13 | ||
| 13 | namespace Tegra { | 14 | namespace Tegra { |
| 14 | 15 | ||
| 16 | void CommandList::RefreshIntegrityChecks(GPU& gpu) { | ||
| 17 | command_list_hashes.resize(command_lists.size()); | ||
| 18 | |||
| 19 | for (std::size_t index = 0; index < command_lists.size(); ++index) { | ||
| 20 | const CommandListHeader command_list_header = command_lists[index]; | ||
| 21 | std::vector<CommandHeader> command_headers(command_list_header.size); | ||
| 22 | gpu.MemoryManager().ReadBlockUnsafe(command_list_header.addr, command_headers.data(), | ||
| 23 | command_list_header.size * sizeof(u32)); | ||
| 24 | command_list_hashes[index] = | ||
| 25 | Common::CityHash64(reinterpret_cast<char*>(command_headers.data()), | ||
| 26 | command_list_header.size * sizeof(u32)); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 15 | DmaPusher::DmaPusher(Core::System& system, GPU& gpu) : gpu{gpu}, system{system} {} | 30 | DmaPusher::DmaPusher(Core::System& system, GPU& gpu) : gpu{gpu}, system{system} {} |
| 16 | 31 | ||
| 17 | DmaPusher::~DmaPusher() = default; | 32 | DmaPusher::~DmaPusher() = default; |
| @@ -80,6 +95,15 @@ bool DmaPusher::Step() { | |||
| 80 | command_headers.resize(command_list_header.size); | 95 | command_headers.resize(command_list_header.size); |
| 81 | gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(), | 96 | gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(), |
| 82 | command_list_header.size * sizeof(u32)); | 97 | command_list_header.size * sizeof(u32)); |
| 98 | |||
| 99 | // Integrity check | ||
| 100 | const u64 new_hash = Common::CityHash64(reinterpret_cast<char*>(command_headers.data()), | ||
| 101 | command_list_header.size * sizeof(u32)); | ||
| 102 | if (new_hash != next_hash) { | ||
| 103 | LOG_CRITICAL(HW_GPU, "CommandList at addr=0x{:X} is corrupt, skipping!", dma_get); | ||
| 104 | dma_pushbuffer.pop(); | ||
| 105 | return true; | ||
| 106 | } | ||
| 83 | } | 107 | } |
| 84 | for (std::size_t index = 0; index < command_headers.size();) { | 108 | for (std::size_t index = 0; index < command_headers.size();) { |
| 85 | const CommandHeader& command_header = command_headers[index]; | 109 | const CommandHeader& command_header = command_headers[index]; |
diff --git a/src/video_core/dma_pusher.h b/src/video_core/dma_pusher.h index 99b30ca0d..8496ba2da 100644 --- a/src/video_core/dma_pusher.h +++ b/src/video_core/dma_pusher.h | |||
| @@ -91,7 +91,10 @@ struct CommandList final { | |||
| 91 | explicit CommandList(std::vector<Tegra::CommandHeader>&& prefetch_command_list) | 91 | explicit CommandList(std::vector<Tegra::CommandHeader>&& prefetch_command_list) |
| 92 | : prefetch_command_list{std::move(prefetch_command_list)} {} | 92 | : prefetch_command_list{std::move(prefetch_command_list)} {} |
| 93 | 93 | ||
| 94 | void RefreshIntegrityChecks(GPU& gpu); | ||
| 95 | |||
| 94 | std::vector<Tegra::CommandListHeader> command_lists; | 96 | std::vector<Tegra::CommandListHeader> command_lists; |
| 97 | std::vector<u64> command_list_hashes; | ||
| 95 | std::vector<Tegra::CommandHeader> prefetch_command_list; | 98 | std::vector<Tegra::CommandHeader> prefetch_command_list; |
| 96 | }; | 99 | }; |
| 97 | 100 | ||