summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2014-10-09 09:37:36 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:11:42 -0400
commit026781c82ca42371c9263f449c2fd1d45d60dc20 (patch)
tree6bf86e2c86cef922d492f034e5aa61f3ff040b61 /drivers/gpu/nvgpu/gk20a/mm_gk20a.c
parent835be94af5ef74b6de972b2dea69c34a90b11d1b (diff)
gpu: nvgpu: require mapped buffer be inside va
When validating buffers to be mapped, check that the buffer end does not overflow over the virtual address node space. Bug 1562361 Change-Id: I3c78ec7380584ae55f1e6bf576f524abee846ddd Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index e8e80a99..dd23023b 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -1080,6 +1080,13 @@ static int validate_fixed_buffer(struct vm_gk20a *vm,
1080 struct device *dev = dev_from_vm(vm); 1080 struct device *dev = dev_from_vm(vm);
1081 struct vm_reserved_va_node *va_node; 1081 struct vm_reserved_va_node *va_node;
1082 struct mapped_buffer_node *buffer; 1082 struct mapped_buffer_node *buffer;
1083 u64 map_end = map_offset + map_size;
1084
1085 /* can wrap around with insane map_size; zero is disallowed too */
1086 if (map_end <= map_offset) {
1087 gk20a_warn(dev, "fixed offset mapping with invalid map_size");
1088 return -EINVAL;
1089 }
1083 1090
1084 if (map_offset & gmmu_page_offset_masks[bfr->pgsz_idx]) { 1091 if (map_offset & gmmu_page_offset_masks[bfr->pgsz_idx]) {
1085 gk20a_err(dev, "map offset must be buffer page size aligned 0x%llx", 1092 gk20a_err(dev, "map offset must be buffer page size aligned 0x%llx",
@@ -1094,6 +1101,12 @@ static int validate_fixed_buffer(struct vm_gk20a *vm,
1094 return -EINVAL; 1101 return -EINVAL;
1095 } 1102 }
1096 1103
1104 /* mapped area should fit inside va */
1105 if (map_end > va_node->vaddr_start + va_node->size) {
1106 gk20a_warn(dev, "fixed offset mapping size overflows va node");
1107 return -EINVAL;
1108 }
1109
1097 /* check that this mappings does not collide with existing 1110 /* check that this mappings does not collide with existing
1098 * mappings by checking the overlapping area between the current 1111 * mappings by checking the overlapping area between the current
1099 * buffer and all other mapped buffers */ 1112 * buffer and all other mapped buffers */