[PATCH v2 1/5] util/cacheflush: Use declarations from <OSCacheControl.h> on Darwin

Philippe Mathieu-Daudé posted 5 patches 2 years, 8 months ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>, Tyrone Ting <kfting@nuvoton.com>, Hao Wu <wuhaotsh@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Richard Henderson <richard.henderson@linaro.org>, Stefan Weil <sw@weilnetz.de>, Riku Voipio <riku.voipio@iki.fi>, Marcelo Tosatti <mtosatti@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>, Leonardo Bras <leobras@redhat.com>
[PATCH v2 1/5] util/cacheflush: Use declarations from <OSCacheControl.h> on Darwin
Posted by Philippe Mathieu-Daudé 2 years, 8 months ago
Per the cache(3) man page, sys_icache_invalidate() and
sys_dcache_flush() are declared in <libkern/OSCacheControl.h>.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 util/cacheflush.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util/cacheflush.c b/util/cacheflush.c
index 06c2333a60..de35616718 100644
--- a/util/cacheflush.c
+++ b/util/cacheflush.c
@@ -237,8 +237,8 @@ static void __attribute__((constructor)) init_cache_info(void)
 
 #ifdef CONFIG_DARWIN
 /* Apple does not expose CTR_EL0, so we must use system interfaces. */
-extern void sys_icache_invalidate(void *start, size_t len);
-extern void sys_dcache_flush(void *start, size_t len);
+#include <libkern/OSCacheControl.h>
+
 void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
 {
     sys_dcache_flush((void *)rw, len);
-- 
2.38.1


Re: [PATCH v2 1/5] util/cacheflush: Use declarations from <OSCacheControl.h> on Darwin
Posted by Richard Henderson 2 years, 8 months ago
On 6/5/23 10:56, Philippe Mathieu-Daudé wrote:
> Per the cache(3) man page, sys_icache_invalidate() and
> sys_dcache_flush() are declared in <libkern/OSCacheControl.h>.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   util/cacheflush.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

I'll note that a comment in OSCacheControl.h says that sys_icache_invalidate performs both 
dcache and icache flush, and so we don't need to call sys_dcache_flush.


r~