[Top][All Lists]

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

Re: [Qemu-arm] [PATCH for-4.1] target/arm: Stop using variable length ar

From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-arm] [PATCH for-4.1] target/arm: Stop using variable length array in dc_zva
Date: Thu, 28 Mar 2019 19:54:13 +0100

Le jeu. 28 mars 2019 15:30, Peter Maydell <address@hidden> a écrit :
Currently the dc_zva helper function uses a variable length
array. In fact we know (as the comment above remarks) that
the length of this array is bounded because the architecture
limits the block size and QEMU limits the target page size.
Use a fixed array size and assert that we don't run off it.

Signed-off-by: Peter Maydell <address@hidden>
A small move in the direction of "avoid using variable length
arrays in QEMU"...

 target/arm/helper.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index a36f4b3d699..1b6225cb598 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "target/arm/idau.h"
 #include "trace.h"
 #include "cpu.h"
@@ -12412,11 +12413,13 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
          * same QEMU executable.
         int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
-        void *hostaddr[maxidx];
+        void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];

Or g_new()... For 2K nowadays that is fine.

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

         int try, i;
         unsigned mmu_idx = cpu_mmu_index(env, false);
         TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);

+        assert(maxidx <= sizeof(hostaddr));
         for (try = 0; try < 2; try++) {

             for (i = 0; i < maxidx; i++) {

reply via email to

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