But when someone releases a new CPU with a larger or smaller cache, all old software continues to work.
Secret page size would offer the same benefit.
And like with page sizes, the big problems with cache line sizes is not when people design things against a specific line size, but the (much more numerous) cases where they design something that only works well for a fixed size but they don't even know that, because they literally never thought about it, and it worked fine because every machine they used was similar.
It doesn't matter what apis you were provided or what analysis you did, you don't know your software works with different hardware until you test it on it.
And that 'copy' might be zero-overhead remapping of the original pages.
"possibly copying a load of data into it for you incase you asked for a readonly range."
uint8_t* mem = malloc_pages(1024);
mprotect_paged(mem, 1024);I think it's even part of POSIX: “The system performs mapping operations over whole pages. Thus, while the parameter len need not meet a size or alignment constraint, the system shall include, in any mapping operation, any partial page specified by the address range starting at pa and continuing for len bytes.”
Considering that it'd be literally completely entirely unacceptable to ever hit such an emulated range in code of any significance as it'd be a slowdown in the thousands of times, it'd make mprotect entirely pointless and effectively broken. Unless of course you add "padding" of expected page size (not applicable for guard pages though, those are just SOL), which is basically status quo except that, instead of apps doing hard-coding crashing on unexpected page size, they just become potentially 1000x slower, but of course in practice there's no difference between a crash and 1000x slower. I'd even say a crash is better - means a bug report of it can't be dismissed as just a perf issue, and it's clear that something's going wrong in the first place.
The size of the mprotect region does not matter. What matters is worst-case behavior, and, regardless of the size, if a single critical byte of memory ends up in the emulated region, your program is dead to the user, causing data loss or whatever consequences from being, practically speaking, completely frozen your program has.
Trying to emulate that under 16kb pages would fault every memory operation.
By not being part of the official stable APIs, Google is free to break whatever userspace application they feel like.
There are seccomp and sandboxing filters in place for what is exposed to non-system apps, aka regular PlayStore apps.