staging: etnaviv: validation: ensure space for the LINK command

Ensure that we reject command buffers which are fully populated, as
we always need to append two words for a LINK command to the end of
the buffer.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: validation: improve command buffer size checks

Additions can overflow, when they do, they can lead to incorrect
results.  When we verify that the buffer offset and size fit within
the buffer object, we must do this safely.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: validation: improve relocation validation

Currently, relocations can apply an unbounded amount of offset to the
address member.  This permits the offset to be used to access memory
outside of the associated buffer.

Ensure that the offset is within the size of the object.  This is not
a complete fix, as we are unaware of the size of the GPU rectangles
operation, but this at least ensures that we catch this form of abuse.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: fix sparse warnings

.../etnaviv_gem_submit.c:72:37: warning: dereference of noderef expression
.../etnaviv_gem_submit.c:364:37: warning: dereference of noderef expression
.../etnaviv_gem_submit.c:423:58: warning: dereference of noderef expression
.../etnaviv_iommu.c:139:13: warning: symbol 'etnaviv_iommu_iova_to_phys' was not declared. Should it be static?
.../etnaviv_iommu.c:156:21: warning: symbol 'etnaviv_iommu_domain_alloc' was not declared. Should it be static?
.../etnaviv_iommu_v2.c:28:21: warning: symbol 'etnaviv_iommu_v2_domain_alloc' was not declared. Should it be static?

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: use devm_ioremap_resource()

Use devm_ioremap_resource() rather than devm_ioremap_nocache() when
remapping resources.  devm_ioremap_resource() is the preferred interface
for this, and is less error-prone than the older devm_ioremap_nocache().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>