From 7e6130baebbac623c95ec0beda37365f4c6cc344 Mon Sep 17 00:00:00 2001 From: maya Date: Tue, 29 Oct 2019 20:01:22 +0000 Subject: [PATCH] Define PMAP_NEED_PROCWR, providing strategically placed i-cache synchronization where just-changed memory is about to be executed. Fixes SIGILLs seen when running Mono 6 on QEMU Cortex-A57. ok ryo --- sys/arch/aarch64/aarch64/pmap.c | 20 ++++++++++++++++++-- sys/arch/aarch64/include/pmap.h | 4 +++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/sys/arch/aarch64/aarch64/pmap.c b/sys/arch/aarch64/aarch64/pmap.c index 13974378a7a6..73189f432990 100644 --- a/sys/arch/aarch64/aarch64/pmap.c +++ b/sys/arch/aarch64/aarch64/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.47 2019/09/22 13:57:55 jmcneill Exp $ */ +/* $NetBSD: pmap.c,v 1.48 2019/10/29 20:01:22 maya Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.47 2019/09/22 13:57:55 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.48 2019/10/29 20:01:22 maya Exp $"); #include "opt_arm_debug.h" #include "opt_ddb.h" @@ -877,6 +877,22 @@ pmap_icache_sync_range(pmap_t pm, vaddr_t sva, vaddr_t eva) pm_unlock(pm); } +/* + * Routine: pmap_procwr + * + * Function: + * Synchronize caches corresponding to [addr, addr+len) in p. + * + */ +void +pmap_procwr(struct proc *p, vaddr_t va, int len) +{ + + /* We only need to do anything if it is the current process. */ + if (p == curproc) + cpu_icache_sync_range(va, len); +} + static pt_entry_t _pmap_pte_adjust_prot(pt_entry_t pte, vm_prot_t prot, vm_prot_t protmask, bool user) diff --git a/sys/arch/aarch64/include/pmap.h b/sys/arch/aarch64/include/pmap.h index 91c39a7fc5d1..f93c09ff23d7 100644 --- a/sys/arch/aarch64/include/pmap.h +++ b/sys/arch/aarch64/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.25 2019/08/12 10:28:04 skrll Exp $ */ +/* $NetBSD: pmap.h,v 1.26 2019/10/29 20:01:22 maya Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -46,6 +46,7 @@ #include +#define PMAP_NEED_PROCWR #define PMAP_GROWKERNEL #define PMAP_STEAL_MEMORY @@ -272,6 +273,7 @@ aarch64_mmap_flags(paddr_t mdpgno) #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +void pmap_procwr(struct proc *, vaddr_t, int); bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *); void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t);