linux/arch/arm64
Will Deacon 0106d456c4 arm64: mm: always take dirty state from new pte in ptep_set_access_flags
Commit 66dbd6e61a ("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.

Cc: <stable@vger.kernel.org> # 4.3+
Fixes: 66dbd6e61a ("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>
2016-06-08 10:23:44 +01:00
..
boot ARM: SoC: late DT updates for v4.7 2016-05-24 15:46:06 -07:00
configs Merge git://www.linux-watchdog.org/linux-watchdog 2016-05-25 10:19:17 -07:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2016-03-17 11:22:54 -07:00
include arm64: move {PAGE,CONT}_SHIFT into Kconfig 2016-06-03 10:57:18 +01:00
kernel arm64: report CPU number in bad_mode 2016-06-03 10:16:20 +01:00
kvm arm64: KVM: vgic-v3: Relax synchronization when SRE==1 2016-05-31 16:12:17 +02:00
lib arm64 updates for 4.6: 2016-03-17 20:03:47 -07:00
mm arm64: mm: always take dirty state from new pte in ptep_set_access_flags 2016-06-08 10:23:44 +01:00
net bpf: arm64: remove callee-save registers use for tmp registers 2016-05-17 14:03:33 -04:00
xen xen/arm: introduce HYPERVISOR_platform_op on arm and arm64 2015-12-21 14:40:56 +00:00
Kconfig Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-06-03 16:12:35 -07:00
Kconfig.debug arm64: enable CONFIG_SET_MODULE_RONX by default 2016-05-31 14:23:29 +01:00
Kconfig.platforms ARM: SoC 64-bit changes for v4.7 2016-05-18 12:43:08 -07:00
Makefile arm64: fix alignment when RANDOMIZE_TEXT_OFFSET is enabled 2016-06-03 10:57:18 +01:00