qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/9] include/exec: Replace reserved_va with max_reserved_v


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 3/9] include/exec: Replace reserved_va with max_reserved_va
Date: Mon, 20 Mar 2023 22:32:05 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

On 17/3/23 16:54, Richard Henderson wrote:
In addition to the rename, change the semantics to be the
last byte of the guest va, rather than the following byte.
This avoids some overflow conditions.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
  include/exec/cpu-all.h      | 11 ++++++++++-
  linux-user/arm/target_cpu.h |  2 +-
  bsd-user/main.c             | 10 +++-------
  bsd-user/mmap.c             |  4 ++--
  linux-user/elfload.c        | 21 +++++++++++----------
  linux-user/main.c           | 27 +++++++++++++--------------
  linux-user/mmap.c           |  4 ++--
  7 files changed, 42 insertions(+), 37 deletions(-)


diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 28135c9e6a..cf14930c30 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -283,7 +283,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, 
abi_ulong size,
      end_addr = start + size;
      if (start > reserved_va - size) {
          /* Start at the top of the address space.  */
-        end_addr = ((reserved_va - size) & -align) + size;
+        end_addr = ((reserved_va + 1 - size) & -align) + size;
          looped = true;
      }
@@ -297,7 +297,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size,
                  return (abi_ulong)-1;
              }
              /* Re-start at the top of the address space.  */
-            addr = end_addr = ((reserved_va - size) & -align) + size;
+            addr = end_addr = ((reserved_va + 1 - size) & -align) + size;

Possible follow-up cleanup:

  addr = end_addr = ROUND_DOWN(reserved_va + 1 - size, align) + size;

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

Better with another R-b on top ;)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]