diff --git a/components/lwp/Kconfig b/components/lwp/Kconfig index 969a9bd000..22cfbea47c 100644 --- a/components/lwp/Kconfig +++ b/components/lwp/Kconfig @@ -46,6 +46,12 @@ if RT_USING_LWP config RT_LWP_SHM_MAX_NR int "The maximum number of shared memory" default 64 + + config LWP_USING_MPROTECT + bool + default n + help + ARCH has the support of mprotect endif if ARCH_MM_MPU diff --git a/components/lwp/lwp_user_mm.h b/components/lwp/lwp_user_mm.h index f38c855f94..48fb7b778e 100644 --- a/components/lwp/lwp_user_mm.h +++ b/components/lwp/lwp_user_mm.h @@ -216,6 +216,7 @@ rt_inline rt_size_t lwp_user_mm_attr_to_kernel(int prot) rt_size_t k_attr = 0; +#ifdef LWP_USING_MPROTECT if ((prot & PROT_EXEC) || (prot & PROT_WRITE) || ((prot & PROT_READ) && (prot & PROT_WRITE))) k_attr = MMU_MAP_U_RWCB; @@ -223,6 +224,9 @@ rt_inline rt_size_t lwp_user_mm_attr_to_kernel(int prot) k_attr = MMU_MAP_K_RWCB; else k_attr = MMU_MAP_U_ROCB; +#else /* !LWP_USING_MPROTECT */ + k_attr = MMU_MAP_U_RWCB; +#endif /* LWP_USING_MPROTECT */ return k_attr; } diff --git a/components/mm/mm_fault.c b/components/mm/mm_fault.c index 40af11d4c4..b0a7d11527 100644 --- a/components/mm/mm_fault.c +++ b/components/mm/mm_fault.c @@ -71,7 +71,9 @@ static int _write_fault(rt_varea_t varea, void *pa, struct rt_aspace_fault_msg * } else { - LOG_I("%s: No permission on %s(attr=0x%lx)", __func__, VAREA_NAME(varea), varea->attr); + LOG_I("%s: No permission on %s(attr=0x%lx,writable=%s,fault_type=%d)", + __func__, VAREA_NAME(varea), varea->attr, + VAREA_IS_WRITABLE(varea) ? "True" : "False", msg->fault_type); } } else if (msg->fault_type == MM_FAULT_TYPE_PAGE_FAULT)