[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/5] target/arm: Rearrange disabled check for watchpoints
From: |
Peter Maydell |
Subject: |
[PULL 3/5] target/arm: Rearrange disabled check for watchpoints |
Date: |
Mon, 23 Mar 2020 17:40:04 +0000 |
From: Richard Henderson <address@hidden>
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 <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
target/arm/helper.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index d2ec2c53510..b7b6887241d 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.
--
2.20.1
- [PULL 0/5] target-arm queue, Peter Maydell, 2020/03/23
- [PULL 4/5] target/arm: Assert immh != 0 in disas_simd_shift_imm, Peter Maydell, 2020/03/23
- [PULL 3/5] target/arm: Rearrange disabled check for watchpoints,
Peter Maydell <=
- [PULL 5/5] target/arm: Move computation of index in handle_simd_dupe, Peter Maydell, 2020/03/23
- [PULL 2/5] aspeed/smc: Fix DMA support for AST2600, Peter Maydell, 2020/03/23
- [PULL 1/5] hw/arm/bcm283x: Correct the license text, Peter Maydell, 2020/03/23
- Re: [PULL 0/5] target-arm queue, Peter Maydell, 2020/03/23