←back to thread

95 points ingve | 1 comments | | HN request time: 0.21s | source
Show context
nephanth ◴[] No.44568300[source]
From my noobish standpoint, it feels like most code shounldn't care what the page size is? Why does it need te be recompiled?

What typically tends to break when changing it?

replies(6): >>44568475 #>>44568482 #>>44568492 #>>44568560 #>>44568984 #>>44569166 #
1. junon ◴[] No.44568984[source]
Performance, safety and IO critical code must care, because the page size affects TLB caching and is the finest granularity for security flags such as read-only, no execute, etc. which are critical for e.g. guard pages.

If your code that created two guard pages sandwiching a security critical page to make sure that under/overruns caused a page fault and crashed that assumed the boundary was at 4KiB, but is really now at 16KiB, that means that buffer overruns now will not get caught.

Further, code that assumed it was on a page boundary for some reason, for performance reasons, will now have only a 25% chance of being so.

It also means that MMIO physical pages that were expected to be contained within a 4KiB page such that when mapped into a sensitive user space driver context, neighboring MMIO control blocks wouldn't be touched, might be affected too since you'll get up to 3 neighboring blocks in either direction. This probably doesn't happen so often, I don't know Android internals much, but still something to consider.

This is in large part because PAGE_SIZE in a lot of C code is a macro or constant, rather than something populated at runtime depending on the system the code is running - something I've always felt is a bit problematic.

That being said, code that's hard coding PAGE_SIZE won't run anyway if using e.g. mmap() because it validates the page size and will error on mismatch.

This is going to wreak general havoc for a while no matter how you spin it.