msm: vidc: Validate userspace buffer count

Makesure the number of buffers count is less than
the maximum limit to avoid structure overflow errors.

Change-Id: Icf3850de36325637ae43ac95f1c8f0f63e201d31
CRs-fixed: 563694
Signed-off-by: Pachika, Vikas Reddy <vpachi@codeaurora.org>
msm: vidc: Validate userspace buffer count before using it

Validate the number of buffers count variable before
using it to avoid structure overflow error.

Change-Id: I61582c93e0f26ec6842e437134fb8a42bdbc36ff
CRs-fixed: 563654
Signed-off-by: Pachika, Vikas Reddy <vpachi@codeaurora.org>
msm: kgsl: Mark the IOMMU setstate memory as read only

Mark the IOMMU setstate memory as read only in the pagetable.

Change-Id: Ic0dedbadb19e499c749cd744c3e89be3bcb4c2a2
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Enable protected mode for A3XX

Enable protected register mode for A3XX with these commits from
msm-3.10:

msm: kgsl: Enable protected register mode for A3XX
msm: kgsl: Print the register that causes a protected mode error
msm: kgsl: Unprotect the VBIF performance counters

Change-Id: Ic0dedbad950ffbd063fd861d9440bb5dce8d5fb1
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Protect SMMU registers from being written by the GPU

Put the SMMU register range in protected mode to shield them from
IB1/IB2 writes from userspace.

CRs-Fixed: 599971
Change-Id: Ic0dedbad8c03fc1c54ff73221231e2440d3c34dd
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Protect CP_STATE_DEBUG_INDEX

Put CP_STATE_DEBUG_INDEX and CP_STATE_DEBUG_DATA under protection
to keep it from being written from an IB1. Doing so however opens
up a subtle "feature" in the microcode: memory read opcodes turn off
protected mode in the microcode to do the read and then turns it
back on regardless of the initial state. This is a problem if the
memory read happens while protected mode is turned off and then we
try to access a protected register which then complains and goes boom.

To account for this irregularity explicitly turn back off protected
mode in all the places where we know this will be a problem.

Change-Id: Ic0dedbad1397ca9b80132241ac006560a615e042
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Revert "msm: kgsl: Mark the IOMMU setstate memory as read only"

This reverts commit aacfff9844d0c551df5ff01c111b83dcfa26ca9e

Change-Id: I63667af03f876eeab6cc702a911d06f872702ccc
Revert "msm: kgsl: Enable protected mode for A3XX"

This reverts commit 91b00abaf366c9d4e1f53b73a814f6bc05356349

Change-Id: Icd068d6e2cb89c0238947ae8c212a34909901d29
Revert "msm: kgsl: Protect SMMU registers from being written by the GPU"

This reverts commit 187bd0b956ab59052397a1388fac924c504f19a5

Change-Id: Ida4fa90657566f9abc4004a96080878969b874d9
Revert "msm: kgsl: Protect CP_STATE_DEBUG_INDEX"

This reverts commit ff0ab07241f7377102435751e87737e9d0701792

Change-Id: I3c91215404b701b05af24c731bf2ae2b4c35930e
Merge "Revert "msm: kgsl: Mark the IOMMU setstate memory as read only"" into LNX.LA.3.2.5.1
Merge "Revert "msm: kgsl: Protect CP_STATE_DEBUG_INDEX"" into LNX.LA.3.2.5.1
Merge "Revert "msm: kgsl: Protect SMMU registers from being written by the GPU"" into LNX.LA.3.2.5.1
Merge "Revert "msm: kgsl: Enable protected mode for A3XX"" into LNX.LA.3.2.5.1