Page MenuHomeFreeBSD

sys/compat/linux/linux_mmap.c Updated Linuxulator unmapping behaviour to match linux
Needs ReviewPublic

Authored by siri_racha.ca on Tue, May 12, 3:47 PM.
Referenced Files
F157007695: D56975.diff
Sun, May 17, 10:31 PM
Unknown Object (File)
Sat, May 16, 2:00 PM
Unknown Object (File)
Sat, May 16, 1:59 PM
Unknown Object (File)
Fri, May 15, 5:10 PM
Unknown Object (File)
Fri, May 15, 3:02 PM
Unknown Object (File)
Thu, May 14, 1:29 PM
Unknown Object (File)
Thu, May 14, 1:28 PM
Unknown Object (File)
Tue, May 12, 4:05 PM
Subscribers

Details

Summary

Hello everyone, I was given; https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294912 and did some digging, and found that FreeBSD's Linuxulator did not follow Linux's behaviour when it came to unmapping memory. So I spent some time to implement it as Linux does, and this is the co-responding diff of the fix.
I should note that although I fixed this issue, the game in the original bug report still does not work, and will likely need quite a few more patches to work.
Thank you,
Sourojeet

Test Plan

To test this code I wrote a short script, compiled it using the Linux compiler (installed from linux-rl9-devtools), then marked it as a Linux binary, and ran it. It seemed to pass the test cases I wrote as far as I can tell, and the results are the same as on Linux.

#include <stdio.h>
#include <sys/mman.h>
#include <errno.h>
#include <unistd.h>

int main() {

    size_t ps = getpagesize();
    void *ptr = mmap(NULL, ps*2, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

    if(munmap(ptr,0) != 0)
    {
    printf("Pass: Failed zero length test\n");
}

    if(munmap(ptr+1,ps) != 0) 
{
    printf("Pass: Unaligned address failure\n");
}

    if(munmap(ptr, 1) == 0) 
{
    printf("Pass: Partial length unmapped successfully\n");
}

}

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

I did not originally include all the syscall.master files' changes, they've now been included, @Nimish Jain also helped point out that I could simplify the function quite a bit.