android_kernel_oneplus_msm8998/arch/arm64
Catalin Marinas db769a0310 arm64: Fix potential race with hardware DBM in ptep_set_access_flags()
[ Upstream commit 6d332747fa5f0a6843b56b5b129168ba909336d1 ]

In a system with DBM (dirty bit management) capable agents there is a
possible race between a CPU executing ptep_set_access_flags() (maybe
non-DBM capable) and a hardware update of the dirty state (clearing of
PTE_RDONLY). The scenario:

a) the pte is writable (PTE_WRITE set), clean (PTE_RDONLY set) and old
   (PTE_AF clear)
b) ptep_set_access_flags() is called as a result of a read access and it
   needs to set the pte to writable, clean and young (PTE_AF set)
c) a DBM-capable agent, as a result of a different write access, is
   marking the entry as young (setting PTE_AF) and dirty (clearing
   PTE_RDONLY)

The current ptep_set_access_flags() implementation would set the
PTE_RDONLY bit in the resulting value overriding the DBM update and
losing the dirty state.

This patch fixes such race by setting PTE_RDONLY to the most permissive
(lowest value) of the current entry and the new one.

Fixes: 66dbd6e61a52 ("arm64: Implement ptep_set_access_flags() for hardware AF/DBM")
Cc: Will Deacon <will.deacon@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Steve Capper <steve.capper@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10 07:41:37 -08:00
..
boot arm64: dts: qcom: db410c: Fix Bluetooth LED trigger 2018-09-26 08:35:06 +02:00
configs arm64 fixes and clean-ups: 2015-11-12 15:33:11 -08:00
crypto crypto: arm64/aes-blk - honour iv_out requirement in CBC and CTR modes 2017-02-09 08:02:45 +01:00
include arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto" 2018-10-10 08:52:12 +02:00
kernel arm64: cpufeature: Track 32bit EL0 support 2018-10-10 08:52:09 +02:00
kvm arm64: KVM: Sanitize PSTATE.M when being set from userspace 2018-10-10 08:52:09 +02:00
lib arm64: add KASAN support 2015-10-12 17:46:36 +01:00
mm arm64: Fix potential race with hardware DBM in ptep_set_access_flags() 2018-11-10 07:41:37 -08:00
net bpf, arm64: fix jit branch offset related to ldimm64 2017-05-14 13:32:58 +02:00
xen
Kconfig arm64: Add work around for Arm Cortex-A55 Erratum 1024718 2018-05-26 08:48:49 +02: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: tegra: select USB_ULPI from EHCI rather than platform 2018-02-25 11:03:51 +01:00
Makefile arm64: errata: Add -mpc-relative-literal-loads to build flags 2016-03-03 15:07:08 -08:00