From a254aff64321fa41a6cb6ee3a4095d711dd8fae5 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 2 Aug 2022 13:09:44 +0300 Subject: [PATCH] anv: prevent trying to mmap non host visible memory Signed-off-by: Lionel Landwerlin Reviewed-by: Ivan Briano Part-of: --- src/intel/vulkan/anv_device.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index a355751a6ba..a1eca83cdce 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4171,6 +4171,16 @@ VkResult anv_MapMemory( return VK_SUCCESS; } + /* From the Vulkan spec version 1.0.32 docs for MapMemory: + * + * * memory must have been created with a memory type that reports + * VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT + */ + if (!(mem->type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { + return vk_errorf(device, VK_ERROR_MEMORY_MAP_FAILED, + "Memory object not mappable."); + } + if (size == VK_WHOLE_SIZE) size = mem->bo->size - offset;