mirror of
https://github.com/qemu/qemu.git
synced 2024-11-28 06:13:46 +08:00
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>
This commit is contained in:
parent
1a6d4fc27d
commit
b4cc583f02
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user