[PATCH] D37788: [ARM] builtins: Do not abort in clear_cache.

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 23:38:33 PDT 2017


peter.smith added a comment.

Apologies for taking so long to respond, I've been trying to find a reference as to whether the Arm cache clean using MRC CP15, ... should always cause a Data Abort if there is no write permission as with the AArch64 version, or only when it tries to actually write to memory, which would only occur if the data in the cache were dirty.

The best I can come up with is in the v7A Arm Architecture Reference Manual. By tracing through the pseudo code; the permission checks are done on a TranslationTable look up (as would be done when looking up an entry in the physically tagged cache by VA). The permission check on the TranslationTable look up will fail if the operation is a write but no write permission is available. The cache maintenance operations are considered write-only so this implies that on Arm v7A the cache maintenance operations need the memory to be writeable.

I think that this makes sense as you cannot clean a cache to main memory if the memory has been made read-only. As a result I think it is incorrect on Arm and AArch64 to do mprotect to remove write access and then flush the caches. The mprotect() implementation on Linux will do the cache maintenance to make sure any dirty data for the range is flushed so another call to clean the cache is not necessary.

I think that compnerd's idea of using an assert is a good one as this will give people the chance to find errors, while maintaining the same interface as the other architectures and libgcc.


https://reviews.llvm.org/D37788





More information about the llvm-commits mailing list