maxmem is defined earlier in this patch:
+#if TARGET_ABI_BITS != HOST_LONG_BITS
+ const abi_ulong maxmem = -0x100c000;
but I'm not at all sure how that number was arrived at...
It's a little less than ULONG_MAX is all I can say for
sure.
As to why it's a special case only sometimes, I believe that it's there for
32-bit
targets running on 64-bit hosts so that we return a sane amount of memory
because
64-bit hosts can have > 4GB of ram... I'm not 100% sure of this, and it would
likely be wrong for 32-bit host and 64-bit target, but that case isn't
supported at
all by the bsd-user project (though in the past it may have been, we no longer
built even 32 on 32 target/host emulation).
I would expect a 64-bit guest to rescale the result for TARGET_PAGE_SIZE !=
getpagesize().
I would too. I suspect that the reason this is here like this is that an attempt
was being made to handle it, but since TARGET_PAGE_SIZE == getpagesize() on
all hosts / target pairs until very recently (with the 16k arm64 kernels), this
was
a latent bug in the code and I should fix it before my next submission. And
aarch64
hosts for this are quite rare (most people use bsd-user on amd64 hosts to build
for
all the other architectures).