From 12edfed73d2f601f7a23fded0d40a68cee958a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20M=C3=BCllner?= Date: Wed, 28 Apr 2021 14:51:58 +0200 Subject: pk: Fix __clear_cache() compilation issue with recent compilers (#240) Using recent compilers we get the following error message: ../pk/pk.c: In function 'run_loaded_program.constprop': ../pk/pk.c:177:3: error: both arguments to '__builtin___clear_cache' must be pointers 177 | __clear_cache(0, 0); | ^~~~~~~~~~~~~~~~~~~ Let's use the existing function __riscv_flush_icache(), give it a header with a prototype and use it to emits the FENCE.I instruction directly. See #239 Suggested-by: Andrew Waterman Signed-off-by: Christoph Muellner --- machine/flush_icache.h | 8 ++++++++ pk/pk.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 machine/flush_icache.h diff --git a/machine/flush_icache.h b/machine/flush_icache.h new file mode 100644 index 0000000..92166bc --- /dev/null +++ b/machine/flush_icache.h @@ -0,0 +1,8 @@ +// See LICENSE for license details. + +#ifndef _RISCV_FLUSH_ICACHE_H +#define _RISCV_FLUSH_ICACHE_H + +void __riscv_flush_icache(void); + +#endif /* _RISCV_FLUSH_ICACHE_H */ diff --git a/pk/pk.c b/pk/pk.c index 4f16abc..b8c9337 100644 --- a/pk/pk.c +++ b/pk/pk.c @@ -8,6 +8,7 @@ #include "frontend.h" #include "bits.h" #include "usermem.h" +#include "flush_icache.h" #include elf_info current; @@ -174,7 +175,7 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top) trapframe_t tf; init_tf(&tf, current.entry, stack_top); - __clear_cache(0, 0); + __riscv_flush_icache(); write_csr(sscratch, kstack_top); start_user(&tf); } -- cgit v1.1