cputlb: atomically update tlb fields used by tlb_reset_dirty
commitb0706b716769494f321a0d2bfd9fa9893992f995
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 23 Feb 2017 18:29:21 +0000 (23 18:29 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Fri, 24 Feb 2017 10:32:46 +0000 (24 10:32 +0000)
tree662569f4cf78e18605e5f5ee5f1824bcf2a1dda3
parente72184455c2e479199823b617dbea0df6940e646
cputlb: atomically update tlb fields used by tlb_reset_dirty

The main use case for tlb_reset_dirty is to set the TLB_NOTDIRTY flags
in TLB entries to force the slow-path on writes. This is used to mark
page ranges containing code which has been translated so it can be
invalidated if written to. To do this safely we need to ensure the TLB
entries in question for all vCPUs are updated before we attempt to run
the code otherwise a race could be introduced.

To achieve this we atomically set the flag in tlb_reset_dirty_range and
take care when setting it when the TLB entry is filled.

On 32 bit systems attempting to emulate 64 bit guests we don't even
bother as we might not have the atomic primitives available. MTTCG is
disabled in this case and can't be forced on. The copy_tlb_helper
function helps keep the atomic semantics in one place to avoid
confusion.

The dirty helper function is made static as it isn't used outside of
cputlb.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
cputlb.c
include/exec/cputlb.h