arm64: hugetlb: Add break-before-make logic for contiguous entries
authorSteve Capper <steve.capper@arm.com>
Tue, 22 Aug 2017 10:42:44 +0000 (11:42 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 22 Aug 2017 14:53:19 +0000 (15:53 +0100)
commitd8bdcff2876424d44d08a4d16a54fee518f9d5b8
treec388888eff092f169ae0d477d8eec35904412d31
parent29a7287dceb76729960a15095fbbfcffa2179b07
arm64: hugetlb: Add break-before-make logic for contiguous entries

It has become apparent that one has to take special care when modifying
attributes of memory mappings that employ the contiguous bit.

Both the requirement and the architecturally correct "Break-Before-Make"
technique of updating contiguous entries can be found described in:
ARM DDI 0487A.k_iss10775, "Misprogramming of the Contiguous bit",
page D4-1762.

The huge pte accessors currently replace the attributes of contiguous
pte entries in place thus can, on certain platforms, lead to TLB
conflict aborts or even erroneous results returned from TLB lookups.

This patch adds two helper functions -

* get_clear_flush(.) - clears a contiguous entry and returns the head
  pte (whilst taking care to retain dirty bit information that could
  have been modified by DBM).

* clear_flush(.) that clears a contiguous entry

A tlb invalidate is performed to then ensure that there is no
possibility of multiple tlb entries being present for the same region.

Cc: David Woods <dwoods@mellanox.com>
Signed-off-by: Steve Capper <steve.capper@arm.com>
(Added helper clear_flush(), updated commit log, and some cleanup)
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
[catalin.marinas@arm.com: remove CONFIG_ARM64_HW_AFDBM check]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/mm/hugetlbpage.c