microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.57k stars 823 forks source link

Need some readonly /proc/sys/vm values on WSL1 #10049

Open Artoria2e5 opened 1 year ago

Artoria2e5 commented 1 year ago

Is your feature request related to a problem? Please describe. WSL1 currently does not work with qemu. The symptoms are basically the same as termux/termux-packages#6172, with:

qemu-i386-static: Unable to reserve 0xfffff000 bytes of virtual address space at 0x1000 (Operation not supported) for use as guest address space (check your virtual memory ulimit setting, min_mmap_addr or reserve less using -R option)

This is due to /proc/sys/vm/mmap_min_addr not existing, at all.

Describe the solution you'd like Add some readonly values so applications can read them. I know changing them is not something to really expect, but reading is required for a lot of things.

This is the same as @Dakkaron's question in https://github.com/microsoft/WSL/issues/3126#issuecomment-476236942:

Would it be possible to create that file as read-only with a fitting value in it? I keep getting errors with programs that expect that value to exist, e.g. Elastic Search. I don't care too much about what that value is, but scripts keep crashing because that file does not exist. Maybe just make that file writable but ignored or something.

Describe alternatives you've considered I suppose I could use WSL2 or compile my own qemu. Hyper-V is kept off due to gaming reasons. Building my own qemu or asking my distribution to do a patch does not make sense.

Additional context Linux [hostname] 4.4.0-22621-Microsoft #1610-Microsoft Fri Jan 01 08:00:00 PST 2016 x86_64 GNU/Linux

Artoria2e5 commented 1 year ago

We need another test case! qemu is failing due to a different reason (#10102). I should try elastic search or whatever it's called.

mmap fiddle Huh, this might still be a different issue. The default 4K address actually seems to work at least with this test program: ```c #include #include #include int main(){ void* a = mmap((void*) (4096 ), 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0); printf("%08lx", (long)a); perror("mmap"); } ``` Huuuuuhhhhh I changed the 4096 requested size to 0xfffff000 and it still worked. Something's wrong with my test case. strace says ``` mmap(0x1000, 4294963200, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE|MAP_FIXED_NOREPLACE, -1, 0) = -1 EOPNOTSUPP (Operation not supported) ```