From 0d6eafe11a12863295e05fb7d9d18302b667d583 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 23 Apr 2018 11:10:00 -0500 Subject: NvDrv/nvhost-as-gpu: Ensure that the object passed to MapBufferEx has already been allocated. Also added a consistency check and a comment for the case when the object id is different than its handle. The real nvservices doesn't make a distinction between ids and handles, each object gets an unique handle which doubles as its id. --- src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/core') 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 8c56fa150..8e7ca6123 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -108,6 +108,16 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector& input, std::vector& ou auto object = nvmap_dev->GetObject(params.nvmap_handle); ASSERT(object); + // We can only map objects that have already been assigned a CPU address. + ASSERT(object->status == nvmap::Object::Status::Allocated); + + ASSERT(params.buffer_offset == 0); + + // The real nvservices doesn't make a distinction between handles and ids, and + // object can only have one handle and it will be the same as its id. Assert that this is the + // case to prevent unexpected behavior. + ASSERT(object->id == params.nvmap_handle); + auto& gpu = Core::System::GetInstance().GPU(); if (params.flags & 1) { -- cgit v1.2.3