rhine: update CM defconfig for MR2

Change-Id: If67166846acfcfe688a377b61049e96dc99e130f
Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs

With this change, calling
  prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)
disables privilege granting operations at execve-time.  For example, a
process will not be able to execute a setuid binary to change their uid
or gid if this bit is set.  The same is true for file capabilities.

Additionally, LSM_UNSAFE_NO_NEW_PRIVS is defined to ensure that
LSMs respect the requested behavior.

To determine if the NO_NEW_PRIVS bit is set, a task may call
  prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
It returns 1 if set and 0 if it is not set. If any of the arguments are
non-zero, it will return -1 and set errno to -EINVAL.
(PR_SET_NO_NEW_PRIVS behaves similarly.)

This functionality is desired for the proposed seccomp filter patch
series.  By using PR_SET_NO_NEW_PRIVS, it allows a task to modify the
system call behavior for itself and its child tasks without being
able to impact the behavior of a more privileged task.

Another potential use is making certain privileged operations
unprivileged.  For example, chroot may be considered "safe" if it cannot
affect privileged tasks.

Note, this patch causes execve to fail when PR_SET_NO_NEW_PRIVS is
set and AppArmor is in use.  It is fixed in a subsequent patch.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Will Drewry <wad@chromium.org>
Acked-by: Eric Paris <eparis@redhat.com>
Acked-by: Kees Cook <keescook@chromium.org>

v18: updated change desc
v17: using new define values as per 3.4
Signed-off-by: James Morris <james.l.morris@oracle.com>
ion: msm: Add null-pointer check to info struct

Add null-pointer check after allocation to avoid null-pointer
deference and subsequent crash of the kernel.

Change-Id: Idba61f5047225323d83425863222808522e89f53
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
ion: Add null-pointer check to info structure

Add null-pointer check to info structure to avoid null-pointer
dereference and subsequent kernel crash.

Change-Id: I88135c1efa0b6ddc333e16511016d3618d9d5cf3
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
msm: kgsl: reset GPU when GDSC is forced on

Sometimes for debug purposes the GPU regulators can be left
on, make sure we reset the gpu while waking up.

Change-Id: Ie18c9f45d9f5a5a7587a1bea2c7c9bb5ce000316
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
msm: kgsl: Do not wait 100ms before checking for GPU idle

When checking for GPU idle do not wait 100ms first, this
delays detection of GPU idle by 100ms.For example in
GPU fault tolerance we check for GPU idle, this
additional 100ms wait is delaying GPU FT by 100ms in
each step.

Change-Id: I028541f6e0ef765f505a2792b0b1c313665e1ba5
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: On release only detach contexts owned by the instance

There can be multiple device instances open for a process. When
a instance is released only destroy the contexts owned by that
instance.

Change-Id: Ic0dedbad818224f01397db8a8f5a83072492dc59
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Use the kmalloc/vmalloc trick for the sharedmem page array

It was previously assumed that most GPU memory allocations would be
small enough to allow us to fit the array of page pointers into one
or two pages allocated via kmalloc.  Recent reports have proven
those assumptions to be wrong - allocations on the order of 32MB will
end up trying to get 8 pages from kmalloc and 8 contiguous pages
on a busy system are a rare beast indeed.

So use the usual kmalloc/vmalloc trick instead - use kmalloc for the
page array when we can and vmalloc if we can't.

CRs-fixed: 513469
Change-Id: Ic0dedbad0a5b14abe6a8bd73342b3e68faa8c8b7
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Fail if sysfs or debugfs initialization fails

While creating a new process struct for kgsl, clean up resources
and bail if sysfs or debugfs initialization fails. This prevents
errors further down the line.

CRs-fixed: 509931
Change-Id: If0857628a56eecf4855013aaf313de28ac9ad108
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: fix NULL check in kgsl_mem_entry_set_pend()

Checking NULL before derefencing usually works better.

Change-Id: I2e2936eb9532dae4b0ef471b5cb2dd1c3a8f0975
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Option to disable GPU fault tolerance

When GPU Fault tolerance is set to KGSL_FT_OFF do not run
fault tolerance. When we turn off fault tolerance
a) If GPU continues executing commands then
   GPU stall detection is false
b) If GPU does not execute further commands then
   GPU stall detection is correct

When GPU stall detection is suspected to be false,
we can use this option to confirm stall detection.

Change-Id: Iac4d235377df015db223df9ec5597fb43d4c8878
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Configure FT behaviour from sysfs instead of debugfs

FT behaviour is changed to be configured from sysfs
instead of debugfs. Sysfs control gives us the advantage
of configuring FT at bootup and also across bootups.
Persistant configuration across bootups helps
testing by configuring FT once and testing the FT
config across bootups.

Change-Id: Ia3378f214371a6a4b9f205f9f884976f58585971
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Get an active count before snapshotting GPU

Acquire an active count before attempting to capture a snapshot.
Doing so prevents instances of not being able to snapshot because of
switched off clocks.

CRs-fixed: 511878
Change-Id: Ib80b57c127566e274d4018001561f4da7ea38265
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Enable GPU hang interrupt

Enable and use GPU hang interrupt to detect GPU hangs.
If the GPU hang is not detected using the interrupt we
still have the hang timer to detect GPU hangs. When
hang is detected using GPU hang interrupt fault tolerance
is triggered. Fault tolerance time is less than 50ms with
GPU hang interrupt.

CRs-Fixed: 512795
Change-Id: I9327803f178ae1b5e8248fe3450499b7bba2a68d
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Option to not stall IOMMU V1 on pagefault based on FT policy

There are cases where GPU has a pagefault and executes
fine after pagefault without GPU stall. init.qcom.graphics.sh
script can be used to change FT pagefault policy
to not stall IOMMU V1 on pagefault and check if pagefault is harmless.

Change-Id: If061230b66181bfd94c697ea106e7bf4de352e91
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Count user and kernel performance counters seperately

Rather than just storing if the performance counter was referenced by the
kernel in a flag, keep track of user space and kernel space references
seperately.  This allows finer grained manipulations on the performance
counters (ie when allowed to be released).  This is needed to be able to
turn off certain performance counters when fault tolerance is disabled
at runtime.

Change-Id: I7b5593459e64557dabd594aeb6532a0c9af6a9c5
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Implement the A3XX power-on shader workaround

On some targets (A330v2) the hardware is in a wonky state following
a power collapse. Send a special command buffer before the first
submission to put everything back in place.

Change-Id: Ic0dedbadb8e676677b9db95defd53f7bd3fba338
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Wake up gpu on kgsl_ioctl_timestamp_event only if necessary

Any call of kgsl_ioctl_timestamp_event wakes up gpu. In some cases
(like retired timestamp) it's not necessary. Wake up gpu only if it's
necessary.

Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Change-Id: I845faf6e9c6e4c9882a68489b64223919be3d21c
msm: mdss: Do not call set rate for handoff enabled clocks

When continuous splash screen is enabled, DSI branch clocks
are never turned off in the bootloader and are handed off
during kernel bootup. When the DSI controller is probed, it
needs to vote for keeping these clocks enabled. However,
calling set rate may result in a screen blink. Remove the
set rate call to fix this issue.

CRs-Fixed: 506037
Change-Id: I46074ff93456899de6b0e36a185d00d16f5f762e
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: Fix order of DSI clocks operations

For DSI branch clocks, set rate should be called
before calling the prepare and enable ops. This is
the recommended order for clock operations and is
required before moving the DSI pll enable sequences
to the prepare op.

Change-Id: I5f53f424a6665e2ce41076734eb6379596fa1d00
CRs-Fixed: 513361
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>