diff options
author | Cédric Le Goater | 2017-02-10 18:40:30 +0100 |
---|---|---|
committer | Peter Maydell | 2017-02-10 18:40:30 +0100 |
commit | b4cc583f0285a2e1e78621dfba142f00ca47414a (patch) | |
tree | 298e783ef635a9514a758659586c3dbd773c792b /hw/ssi | |
parent | aspeed/smc: handle dummies only in fast read mode (diff) | |
download | qemu-b4cc583f0285a2e1e78621dfba142f00ca47414a.tar.gz qemu-b4cc583f0285a2e1e78621dfba142f00ca47414a.tar.xz qemu-b4cc583f0285a2e1e78621dfba142f00ca47414a.zip |
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')
-rw-r--r-- | hw/ssi/aspeed_smc.c | 4 |
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; } |