diff options
| author | 2018-10-11 20:32:21 +1100 | |
|---|---|---|
| committer | 2018-10-11 20:32:21 +1100 | |
| commit | 5dd538cace2718584c51d52c1f7ce9ce294bb58e (patch) | |
| tree | 587359e8d3ea885b013368a7bc663edcfb25ee1c /src | |
| parent | Merge pull request #1458 from FernandoS27/fix-render-target-block-settings (diff) | |
| download | yuzu-5dd538cace2718584c51d52c1f7ce9ce294bb58e.tar.gz yuzu-5dd538cace2718584c51d52c1f7ce9ce294bb58e.tar.xz yuzu-5dd538cace2718584c51d52c1f7ce9ce294bb58e.zip | |
Passing an invalid nmap handle to Remap should throw an error
Added error for invalid nmap handles
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 7555bbe7d..7424fa72f 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | |||
| @@ -15,6 +15,11 @@ | |||
| 15 | #include "video_core/renderer_base.h" | 15 | #include "video_core/renderer_base.h" |
| 16 | 16 | ||
| 17 | namespace Service::Nvidia::Devices { | 17 | namespace Service::Nvidia::Devices { |
| 18 | namespace NvErrCodes { | ||
| 19 | enum { | ||
| 20 | InvalidNmapHandle = -22, | ||
| 21 | }; | ||
| 22 | } | ||
| 18 | 23 | ||
| 19 | nvhost_as_gpu::nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {} | 24 | nvhost_as_gpu::nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {} |
| 20 | nvhost_as_gpu::~nvhost_as_gpu() = default; | 25 | nvhost_as_gpu::~nvhost_as_gpu() = default; |
| @@ -79,14 +84,17 @@ u32 nvhost_as_gpu::Remap(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 79 | std::memcpy(entries.data(), input.data(), input.size()); | 84 | std::memcpy(entries.data(), input.data(), input.size()); |
| 80 | 85 | ||
| 81 | auto& gpu = Core::System::GetInstance().GPU(); | 86 | auto& gpu = Core::System::GetInstance().GPU(); |
| 82 | 87 | bool failed_remap{}; | |
| 83 | for (const auto& entry : entries) { | 88 | for (const auto& entry : entries) { |
| 84 | LOG_WARNING(Service_NVDRV, "remap entry, offset=0x{:X} handle=0x{:X} pages=0x{:X}", | 89 | LOG_WARNING(Service_NVDRV, "remap entry, offset=0x{:X} handle=0x{:X} pages=0x{:X}", |
| 85 | entry.offset, entry.nvmap_handle, entry.pages); | 90 | entry.offset, entry.nvmap_handle, entry.pages); |
| 86 | Tegra::GPUVAddr offset = static_cast<Tegra::GPUVAddr>(entry.offset) << 0x10; | 91 | Tegra::GPUVAddr offset = static_cast<Tegra::GPUVAddr>(entry.offset) << 0x10; |
| 87 | |||
| 88 | auto object = nvmap_dev->GetObject(entry.nvmap_handle); | 92 | auto object = nvmap_dev->GetObject(entry.nvmap_handle); |
| 89 | ASSERT(object); | 93 | if (!object) { |
| 94 | LOG_CRITICAL(Service_NVDRV, "nvmap {} is an invalid handle!", entry.nvmap_handle); | ||
| 95 | failed_remap = true; | ||
| 96 | continue; | ||
| 97 | } | ||
| 90 | 98 | ||
| 91 | ASSERT(object->status == nvmap::Object::Status::Allocated); | 99 | ASSERT(object->status == nvmap::Object::Status::Allocated); |
| 92 | 100 | ||
| @@ -97,6 +105,9 @@ u32 nvhost_as_gpu::Remap(const std::vector<u8>& input, std::vector<u8>& output) | |||
| 97 | ASSERT(returned == offset); | 105 | ASSERT(returned == offset); |
| 98 | } | 106 | } |
| 99 | std::memcpy(output.data(), entries.data(), output.size()); | 107 | std::memcpy(output.data(), entries.data(), output.size()); |
| 108 | if (failed_remap) { | ||
| 109 | return static_cast<u32>(NvErrCodes::InvalidNmapHandle); | ||
| 110 | } | ||
| 100 | return 0; | 111 | return 0; |
| 101 | } | 112 | } |
| 102 | 113 | ||