Skip to contentSkip to conversation

hugemmap15: Support RISC-V to do __cache_flush. (#79)

PATCH Superseded Hui Min Mina Chou via ltp 2 participants 3 messages May 9, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hugemmap15: Support RISC-V to do __cache_flush. (#79)

AndesCore CPU test fails due to an illegal instruction at the first jumpfunc(), caused by executing incorrect instructions after self-modifying code.

On RISC-V CPUs, a FENCE.i synchronizes instruction and data streams, ensuring that subsequent instruction fetch on a RISC-V hart will see any previous data stores already visible to the same RISC-V hart.

Thus, cacheflush() in the test should also use __clear_cache for RISC-V. In SMP systems, it invokes the kernel syscall riscv_flush_icache to inform each hart to flush their local i-caches.

---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c +1 -1
index 4d198407044a..a84ba6476f1e 100644
@@ -47,7 +47,7 @@ static void cacheflush(void *p)
 {
 #if defined(__powerpc__)
 	asm volatile("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r"(p));
-#elif defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm__) || defined(__aarch64__) || defined(__riscv)
 	__clear_cache(p, p + COPY_SIZE);
 #else
 	(void)p;
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Hui,

Quoted 11 lines

AndesCore CPU test fails due to an illegal instruction at the first jumpfunc(), caused by executing incorrect instructions after self-modifying code.

On RISC-V CPUs, a FENCE.i synchronizes instruction and data streams, ensuring that subsequent instruction fetch on a RISC-V hart will see any previous data stores already visible to the same RISC-V hart.

Thus, cacheflush() in the test should also use __clear_cache for RISC-V. In SMP systems, it invokes the kernel syscall riscv_flush_icache to inform each hart to flush their local i-caches.

BTW what "#79" in the git message subject means?

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH] hugemmap15: Support RISC-V to do __cache_flush.

Quoted 16 lines · Petr Vorel

[EXTERNAL MAIL]

Hi Hui,

Quoted 11 lines

AndesCore CPU test fails due to an illegal instruction at the first jumpfunc(), caused by executing incorrect instructions after self-modifying code.

On RISC-V CPUs, a FENCE.i synchronizes instruction and data streams, ensuring that subsequent instruction fetch on a RISC-V hart will see any previous data stores already visible to the same RISC-V hart.

Thus, cacheflush() in the test should also use __clear_cache for RISC-V. In SMP systems, it invokes the kernel syscall riscv_flush_icache to inform each hart to flush their local i-caches.

Quoted 6 lines

BTW what "#79" in the git message subject means?

Kind regards,
Petr

Hi Petr,

Sorry, that was my mistake. I'll remove it and send another one.

Thanks,
Mina

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp