diff mbox series

[v2,1/9] linux-user: Diagnose misaligned -R size

Message ID 20230317155455.341843-2-richard.henderson@linaro.org
State Superseded
Headers show
Series accel/tcg: Fix page_set_flags and related [#1528] | expand

Commit Message

Richard Henderson March 17, 2023, 3:54 p.m. UTC
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.henderson@linaro.org>
---
 linux-user/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Philippe Mathieu-Daudé March 20, 2023, 9:24 p.m. UTC | #1
On 17/3/23 16:54, Richard Henderson wrote:
> 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.henderson@linaro.org>
> ---
>   linux-user/main.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 4b18461969..39d9bd4d7a 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -793,6 +793,12 @@ int main(int argc, char **argv, char **envp)
>        */
>       max_reserved_va = MAX_RESERVED_VA(cpu);
>       if (reserved_va != 0) {
> +        if (reserved_va % qemu_host_page_size) {
> +            char *s = size_to_str(qemu_host_page_size);
> +            fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s);
> +            g_free(s);
> +            exit(EXIT_FAILURE);
> +        }
>           if (max_reserved_va && reserved_va > max_reserved_va) {
>               fprintf(stderr, "Reserved virtual address too big\n");
>               exit(EXIT_FAILURE);

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index 4b18461969..39d9bd4d7a 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -793,6 +793,12 @@  int main(int argc, char **argv, char **envp)
      */
     max_reserved_va = MAX_RESERVED_VA(cpu);
     if (reserved_va != 0) {
+        if (reserved_va % qemu_host_page_size) {
+            char *s = size_to_str(qemu_host_page_size);
+            fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s);
+            g_free(s);
+            exit(EXIT_FAILURE);
+        }
         if (max_reserved_va && reserved_va > max_reserved_va) {
             fprintf(stderr, "Reserved virtual address too big\n");
             exit(EXIT_FAILURE);