[smart] add mprotect config (#9082)
Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
parent
06ad67d549
commit
fa2d80679e
|
@ -46,6 +46,12 @@ if RT_USING_LWP
|
||||||
config RT_LWP_SHM_MAX_NR
|
config RT_LWP_SHM_MAX_NR
|
||||||
int "The maximum number of shared memory"
|
int "The maximum number of shared memory"
|
||||||
default 64
|
default 64
|
||||||
|
|
||||||
|
config LWP_USING_MPROTECT
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
ARCH has the support of mprotect
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ARCH_MM_MPU
|
if ARCH_MM_MPU
|
||||||
|
|
|
@ -216,6 +216,7 @@ rt_inline rt_size_t lwp_user_mm_attr_to_kernel(int prot)
|
||||||
|
|
||||||
rt_size_t k_attr = 0;
|
rt_size_t k_attr = 0;
|
||||||
|
|
||||||
|
#ifdef LWP_USING_MPROTECT
|
||||||
if ((prot & PROT_EXEC) || (prot & PROT_WRITE) ||
|
if ((prot & PROT_EXEC) || (prot & PROT_WRITE) ||
|
||||||
((prot & PROT_READ) && (prot & PROT_WRITE)))
|
((prot & PROT_READ) && (prot & PROT_WRITE)))
|
||||||
k_attr = MMU_MAP_U_RWCB;
|
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;
|
k_attr = MMU_MAP_K_RWCB;
|
||||||
else
|
else
|
||||||
k_attr = MMU_MAP_U_ROCB;
|
k_attr = MMU_MAP_U_ROCB;
|
||||||
|
#else /* !LWP_USING_MPROTECT */
|
||||||
|
k_attr = MMU_MAP_U_RWCB;
|
||||||
|
#endif /* LWP_USING_MPROTECT */
|
||||||
|
|
||||||
return k_attr;
|
return k_attr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,9 @@ static int _write_fault(rt_varea_t varea, void *pa, struct rt_aspace_fault_msg *
|
||||||
}
|
}
|
||||||
else
|
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)
|
else if (msg->fault_type == MM_FAULT_TYPE_PAGE_FAULT)
|
||||||
|
|
Loading…
Reference in New Issue