Skip to content

Commit

Permalink
vm/mmap: add basic MAP_PRIVATE support
Browse files Browse the repository at this point in the history
JIRA: RTOS-756
  • Loading branch information
badochov committed Oct 6, 2024
1 parent d99dc74 commit a57a022
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define MAP_FIXED (1 << 7)
/* NOTE: vm uses u8 to store flags, if more flags are needed this type needs to be changed. */
#define MAP_SHARED 0x0
#define MAP_PRIVATE 0x0
#define MAP_PRIVATE MAP_NEEDSCOPY


#define PROT_NONE 0x0
Expand Down
4 changes: 4 additions & 0 deletions vm/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,10 @@ int vm_mprotect(vm_map_t *map, void *vaddr, size_t len, int prot)
e->prot = prot;

attr = vm_protToAttr(e->prot) | vm_flagsToAttr(e->flags);
/* If an entry needs copy, enter it as a readonly to copy it on first access. */
if ((e->flags & MAP_NEEDSCOPY) != 0) {
attr &= ~(vm_protToAttr(PROT_WRITE));
}
for (currVaddr = e->vaddr; currVaddr < (e->vaddr + e->size); currVaddr += SIZE_PAGE) {
pa = pmap_resolve(&map->pmap, currVaddr);
if (pa != 0) {
Expand Down

0 comments on commit a57a022

Please sign in to comment.