Zero is the value for 'off', and should not be used with -R. We have been enforcing host page alignment for the non-R fallback of MAX_RESERVED_VA, but failing to enforce for -R.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 4ff30ff980..f4dea25242 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -395,6 +395,16 @@ static void handle_arg_reserved_va(const char *arg) fprintf(stderr, "Unrecognised -R size suffix '%s'\n", p); exit(EXIT_FAILURE); } + if (reserved_va == 0) { + fprintf(stderr, "Invalid -R size value 0\n"); + exit(EXIT_FAILURE); + } + /* Must be aligned with the host page size as it is used with mmap. */ + if (reserved_va & qemu_host_page_mask) { + fprintf(stderr, "Invalid -R size value %lu: must be aligned mod %lu\n", + reserved_va, qemu_host_page_size); + exit(EXIT_FAILURE); + } } static void handle_arg_singlestep(const char *arg) -- 2.34.1