<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">On Sat, Feb 16, 2019, 03:33  <<a href="mailto:Las@protonmail.ch">Las@protonmail.ch</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Patch attached. This is my first contribution to wine, and I have checked through the wiki for what I should do, and have attempted to fulfill all criteria.<br></div><div><br></div><div>Commit message from patch:<br></div><div><br></div><div>Before, Wine would (very incorrectly) use the argument to specify<br></div><div>how many *low-order* address bits should be 0, when in fact,<br></div><div>in Windows it's used to specify how many *high-order* address bits<br></div><div>should be zero!<br></div><div><br></div><div>The functionality is taken from the documentation for NtAllocateVirtualMemory:<br></div><div>The number of high-order address bits that must be zero in the base address<br></div><div>of the section view. Used only when the operating system determines where<br></div><div>to allocate the region, as when BaseAddress is NULL. Note that when<br></div><div>ZeroBits is larger than 32, it becomes a bitmask.<br></div><div><br></div><div>and NtMapViewOfSection:<br></div><div>Specifies the number of high-order address bits that must be zero in the<br></div><div>base address of the section view. The value of this parameter must be less<br></div><div>than 21 and is used only if BaseAddress is NULL—in other words, when the<br></div><div>caller allows the system to determine where to allocate the view.<br></div><div><br></div><div>and from documentation for LuaJIT's allocator:<br></div><div>/* Number of top bits of the lower 32 bits of an address that must be zero.<br></div><div>** Apparently 0 gives us full 64 bit addresses and 1 gives us the lower 2GB.<br></div><div>*/<br></div><div>\#define NTAVM_ZEROBITS 1<br></div><div><br></div><div>Thus the interpretation done here is:<br></div><div>If zero_bits is 0, use the full address space.<br></div><div>If zero_bits is over 20, err (12-bit pointers are the smallest allowed).<br></div><div>Otherwise only the lower (32-zero_bits) bits should be used.<br></div><div><br></div><div>A lot of internal Wine functionality unfortunately depends on the old<br></div><div>Wine behavior, but thankfully, all of the uses seem to be redundant,<br></div><div>as no function requested an alignment higher than the minimum!<br></div><div>It may however be that I have not fully understood the code,<br></div><div>as it is not always clear what alignment is requested.<br></div><div><br></div><div>In addition, to implement this odd Windows API, Wine somehow has to<br></div><div>mmap an address below the maximum, which is not possible efficiently<br></div><div>on POSIX systems compared to the Windows API. Linux has the MAP_32BIT<br></div><div>flag, but it restricts the address space to just 1 GiB, which is not<br></div><div>enough. For that reason, the implementation of this API in Wine<br></div><div>uses pseudorandom heuristics ripped from the LuaJIT project (which<br></div><div>also seems to be the only project to use this Windows API) to achieve<br></div><div>this. It is not optimal, but it works. A proper implementation would<br></div><div>require extensions to the mmap API.</div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Looks like your patch didn't attach.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>