diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2020-03-23 17:22:30 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-03-23 17:22:30 +0000 |
commit | ae1111d4def40c6f592c3a307c599272b778eb65 (patch) | |
tree | bd47a6ea68c5544cbb1c5f0260c374bda6cbcf62 /target/arm | |
parent | 4dabf39592e92d692c6f2a1633571114ae25d843 (diff) | |
download | qemu-ae1111d4def40c6f592c3a307c599272b778eb65.zip qemu-ae1111d4def40c6f592c3a307c599272b778eb65.tar.gz qemu-ae1111d4def40c6f592c3a307c599272b778eb65.tar.bz2 |
target/arm: Rearrange disabled check for watchpoints
Coverity rightly notes that ctz32(bas) on 0 will return 32,
which makes the len calculation a BAD_SHIFT.
A value of 0 in DBGWCR<n>_EL1.BAS is reserved. Simply move
the existing check we have for this case.
Reported-by: Coverity (CID 1421964)
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200320160622.8040-2-richard.henderson@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target/arm')
-rw-r--r-- | target/arm/helper.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/target/arm/helper.c b/target/arm/helper.c index d2ec2c5..b7b6887 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6340,17 +6340,18 @@ void hw_watchpoint_update(ARMCPU *cpu, int n) int bas = extract64(wcr, 5, 8); int basstart; - if (bas == 0) { - /* This must act as if the watchpoint is disabled */ - return; - } - if (extract64(wvr, 2, 1)) { /* Deprecated case of an only 4-aligned address. BAS[7:4] are * ignored, and BAS[3:0] define which bytes to watch. */ bas &= 0xf; } + + if (bas == 0) { + /* This must act as if the watchpoint is disabled */ + return; + } + /* The BAS bits are supposed to be programmed to indicate a contiguous * range of bytes. Otherwise it is CONSTRAINED UNPREDICTABLE whether * we fire for each byte in the word/doubleword addressed by the WVR. |