Skip to content

[smart] add mprotect config #9082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/lwp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions components/lwp/lwp_user_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,17 @@ 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;
else if (prot == PROT_NONE)
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;
}
Expand Down
4 changes: 3 additions & 1 deletion components/mm/mm_fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading