android_kernel_oneplus_msm8998/arch/arm64
Will Deacon 5e8b53a4db arm64: mm: always take dirty state from new pte in ptep_set_access_flags
commit 0106d456c4cb1770253fefc0ab23c9ca760b43f7 upstream.

Commit 66dbd6e61a52 ("arm64: Implement ptep_set_access_flags() for
hardware AF/DBM") ensured that pte flags are updated atomically in the
face of potential concurrent, hardware-assisted updates. However, Alex
reports that:

 | This patch breaks swapping for me.
 | In the broken case, you'll see either systemd cpu time spike (because
 | it's stuck in a page fault loop) or the system hang (because the
 | application owning the screen is stuck in a page fault loop).

It turns out that this is because the 'dirty' argument to
ptep_set_access_flags is always 0 for read faults, and so we can't use
it to set PTE_RDONLY. The failing sequence is:

  1. We put down a PTE_WRITE | PTE_DIRTY | PTE_AF pte
  2. Memory pressure -> pte_mkold(pte) -> clear PTE_AF
  3. A read faults due to the missing access flag
  4. ptep_set_access_flags is called with dirty = 0, due to the read fault
  5. pte is then made PTE_WRITE | PTE_DIRTY | PTE_AF | PTE_RDONLY (!)
  6. A write faults, but pte_write is true so we get stuck

The solution is to check the new page table entry (as would be done by
the generic, non-atomic definition of ptep_set_access_flags that just
calls set_pte_at) to establish the dirty state.

Fixes: 66dbd6e61a52 ("arm64: Implement ptep_set_access_flags() for hardware AF/DBM")
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Alexander Graf <agraf@suse.de>
Tested-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-24 10:18:19 -07:00
..
boot ls2080a/dts: Add little endian property for GPIO IP block 2015-12-11 16:13:03 -08:00
configs arm64 fixes and clean-ups: 2015-11-12 15:33:11 -08:00
crypto arm64: crypto: reduce priority of core AES cipher 2015-11-18 12:09:08 +00:00
include arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks 2016-06-24 10:18:19 -07:00
kernel arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks 2016-06-24 10:18:19 -07:00
kvm kvm: arm64: Fix EC field in inject_abt64 2016-06-01 12:15:48 -07:00
lib arm64: add KASAN support 2015-10-12 17:46:36 +01:00
mm arm64: mm: always take dirty state from new pte in ptep_set_access_flags 2016-06-24 10:18:19 -07:00
net arm64: bpf: add 'store immediate' instruction 2015-12-03 11:38:31 -05:00
xen
Kconfig arm64 fixes: 2015-11-27 11:09:59 -08:00
Kconfig.debug arm64: remove redundant FRAME_POINTER kconfig option and force to select it 2015-11-10 10:36:00 +00:00
Kconfig.platforms ARM: DT updates for v4.4 2015-11-10 15:06:26 -08:00
Makefile arm64: errata: Add -mpc-relative-literal-loads to build flags 2016-03-03 15:07:08 -08:00