aboutsummaryrefslogtreecommitdiff
path: root/hw/ssi/aspeed_smc.c
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2017-02-10 17:40:30 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-02-10 17:40:30 +0000
commitb4cc583f0285a2e1e78621dfba142f00ca47414a (patch)
tree298e783ef635a9514a758659586c3dbd773c792b /hw/ssi/aspeed_smc.c
parent1a6d4fc27d75839b6a0325ef258560fded6ec7d9 (diff)
aspeed/smc: use a modulo to check segment limits
The size of a segment is not necessarily a power of 2. Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 1486648058-520-5-git-send-email-clg@kaod.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/ssi/aspeed_smc.c')
-rw-r--r--hw/ssi/aspeed_smc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 70177078a8..cb515730c5 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -475,15 +475,15 @@ static uint32_t aspeed_smc_check_segment_addr(const AspeedSMCFlash *fl,
AspeedSegments seg;
aspeed_smc_reg_to_segment(s->regs[R_SEG_ADDR0 + fl->id], &seg);
- if ((addr & (seg.size - 1)) != addr) {
+ if ((addr % seg.size) != addr) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: invalid address 0x%08x for CS%d segment : "
"[ 0x%"HWADDR_PRIx" - 0x%"HWADDR_PRIx" ]\n",
s->ctrl->name, addr, fl->id, seg.addr,
seg.addr + seg.size);
+ addr %= seg.size;
}
- addr &= seg.size - 1;
return addr;
}