GPUCORE-36682 Lock MMU while disabling AS to prevent use after free

During an invalid GPU page fault, kbase will try to flush the GPU cache
and disable the faulting address space (AS). There is a small window
between flushing of the GPU L2 cache (MMU resumes) and when the AS is
disabled where existing jobs on the GPU may access memory for that AS,
dirtying the GPU cache.

This is a problem as the kctx->as_nr is marked as KBASEP_AS_NR_INVALID
and thus no cache maintenance will be performed on the AS of the faulty
context when cleaning up the csg_slot and releasing the context.

This patch addresses that issue by:
1. locking the AS via a GPU command
2. flushing the cache
3. disabling the AS
4. unlocking the AS

This ensures that any jobs remaining on the GPU will not be able to
access the memory due to the locked AS. Once the AS is unlocked, any
memory access will fail as the AS is now disabled.

The issue only happens on CSF GPUs. To avoid any issues, the code path
for non-CSF GPUs is left undisturbed.

(cherry picked from commit 566789dffda3dfec00ecf00f9819e7a515fb2c61)
Bug: 274014055
Change-Id: I2028182878b4f88505cc135a5f53ae4c7e734650
3 files changed
tree: 6974de665b4e2693c8a1d827204c2c68d7f4bfd5
  1. common/
  2. mali_kbase/
  3. mali_pixel/