On 4/1/20 2:47 AM, Alex Bennée wrote: > + /* > + * Now we are going to try and map something, we start by trying > + * to satisfy exactly what the guest wants. This is unlikely to > + * succeed but will make the code generators job easier if it can > + * be done. > + * > + * If the commpage check isn't happy after we allocate we need to > + * fall back to finding a big enough hole in the address space. > */ > + map_addr = (void *) guest_start; > + if (mmap(map_addr, host_size, PROT_NONE, flags, -1, 0) == map_addr) {
Not recording the result of the mmap is wrong. There are not just two options, as implied by your "== map_addr" check: you are missing out on the mmap succeeds (!= MAP_FAILED) but still not equal to map_addr. If the kernel gives us a different address than the one requested, we can either decide to use it, or unmap it again. We can't do either with the above. This is definitely going to have to wait for 5.1. r~