]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/misc/tz-mpc: Fix value of BLK_MAX register
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 7 Jan 2019 15:23:48 +0000 (15:23 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 7 Jan 2019 15:23:48 +0000 (15:23 +0000)
In the TZ Memory Protection Controller, the BLK_MAX register is supposed
to return the maximum permitted value of the BLK_IDX register. Our
implementation incorrectly returned max+1 (ie the total number of
valid index values, since BLK_IDX is zero-based).

Correct this off-by-one error. Since we consistently initialize
and use s->blk_max throughout the implementation as the 'size'
of the LUT, just adjust the value we return when the guest reads
the BLK_MAX register, rather than trying to change the semantics
of the s->blk_max internal struct field.

Fixes: https://bugs.launchpad.net/qemu/+bug/1806824
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20181213183249.3468-1-peter.maydell@linaro.org

hw/misc/tz-mpc.c

index fb48a1540b9b2724ee00a35c31c725221a189640..9a84be75ed661c4fd19a3ea828b0119f9eca0202 100644 (file)
@@ -150,7 +150,7 @@ static MemTxResult tz_mpc_reg_read(void *opaque, hwaddr addr,
         r = s->ctrl;
         break;
     case A_BLK_MAX:
-        r = s->blk_max;
+        r = s->blk_max - 1;
         break;
     case A_BLK_CFG:
         /* We are never in "init in progress state", so this just indicates