I am interested in flushing cache (L1, L2, and L3) only for a region of address space, for example all cache entries from address A to address B. Is there a mechanism to do
This is for ARM.
GCC provides __builtin___clear_cache which does should do syscall cacheflush. However it may have its caveats.
Important thing here is Linux provides a system call (ARM specific) to flush caches. You can check Android/Bionic flushcache for how to use this system call. However I'm not sure what kind of guarantees Linux gives when you call it or how it is implemented through its inner workings.
This blog post Caches and Self-Modifying Code may help further.