Skip to content

Miri's hardcoded PAGE_SIZE is sometimes inaccurate #2644

Closed
@thomcc

Description

@thomcc

Miri always claims the page size is 4k, but on some targets this is not the case. Programs generally should query it at runtime, but a lot of code just hard-codes 4k (like miri), which is not right sometimes.

Plausibly this is an argument for it being configurable, but I think that's likely overkill (and deciding what values are allowable seems tricky). Thankfully, the targets I know of where this varies are seem to be statically fixed in practice, so Miri should just return the accurate-in-practice value. Specifically:

  • On aarch64-apple-darwin the page size seems to be 16k (apple made a point about this changing in the move to M1). (Unsure if miri supports it, but this is true for aarch64-apple-ios too, and perhaps all aarch64-apple-*).
  • The web assembly spec defines it as 64k (kinda wild, but so it goes): https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances, and WASI seems to follow this.

I don't know of other targets which happen to have different values, and have looked around a bit (according to https://linux.die.net/man/2/getpagesize, on sun4 is a real example where it depended on the specific machine rather than the target, but Rust probably doesn't support it).

Anyway, currently it doesn't matter much, but if #2520 lands (CC @saethlin) it would matter more. It might make sense to do as part of that PR, but this is certainly not necessary, so I filed it as a separate thing rather than asking on that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-good-first-issueA good way to start contributing, mentoring is available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions