mmap and fileobj: handle MF_ZEROFILL properly

Change-Id: I6ee52b4cab212b1973339bc8d49065c1ec9263b0
This commit is contained in:
Balazs Gerofi
2019-09-17 14:05:31 +09:00
committed by Masamichi Takagi
parent d15a396d5a
commit c0c80b71ca
2 changed files with 30 additions and 23 deletions

View File

@@ -398,8 +398,9 @@ static void fileobj_free(struct memobj *memobj)
}
}
/* Pre-mapped? */
if (to_memobj(obj)->flags & MF_PREMAP) {
/* Pre-mapped zerofilled? */
if (to_memobj(obj)->flags & MF_PREMAP &&
to_memobj(obj)->flags & MF_ZEROFILL) {
int i;
for (i = 0; i < to_memobj(obj)->nr_pages; ++i) {
@@ -440,7 +441,7 @@ static void fileobj_free(struct memobj *memobj)
error = syscall_generic_forwarding(__NR_mmap, &ctx);
if (error) {
kprintf("%s(%p %lx): free failed. %d\n", __func__,
dkprintf("%s(%p %lx): free failed. %d\n", __func__,
obj, obj->handle, error);
/* through */
}
@@ -570,7 +571,8 @@ static int fileobj_get_page(struct memobj *memobj, off_t off,
profile_event_add(PROFILE_page_fault_file, PAGE_SIZE);
#endif // PROFILE_ENABLE
if (memobj->flags & MF_PREMAP) {
if (memobj->flags & MF_PREMAP &&
memobj->flags & MF_ZEROFILL) {
int page_ind = off >> PAGE_SHIFT;
if (!memobj->pages[page_ind]) {