From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHxhQ-0006y8-Py for qemu-devel@nongnu.org; Tue, 28 Jun 2016 14:25:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHxhN-0002Re-G8 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 14:25:28 -0400 Received: from mo3.mail-out.ovh.net ([178.32.228.3]:60275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHxhN-0002RQ-5g for qemu-devel@nongnu.org; Tue, 28 Jun 2016 14:25:25 -0400 Received: from player772.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 47C1FFF8E86 for ; Tue, 28 Jun 2016 20:25:20 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 28 Jun 2016 20:24:25 +0200 Message-Id: <1467138270-32481-5-git-send-email-clg@kaod.org> In-Reply-To: <1467138270-32481-1-git-send-email-clg@kaod.org> References: <1467138270-32481-1-git-send-email-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v5 4/9] m25p80: change cur_addr to 32 bit integer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Peter Crosthwaite Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, kwolf@redhat.com, armbru@redhat.com, Andrew Jeffery , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= From: Paolo Bonzini The maximum amount of storage that can be addressed by the m25p80 command set is 4 GiB. However, cur_addr is currently a 64-bit integer. To avoid further problems related to sign extension of signed 32-bit integer expressions, change cur_addr to a 32 bit integer. Preserve migration format by adding a dummy 4-byte field in place of the (big-endian) high four bytes in the formerly 64-bit cur_addr field. Signed-off-by: Paolo Bonzini Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater --- hw/block/m25p80.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 4836b4eb9666..80e60c23e009 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -390,7 +390,7 @@ typedef struct Flash { uint32_t pos; uint8_t needed_bytes; uint8_t cmd_in_progress; - uint64_t cur_addr; + uint32_t cur_addr; uint32_t nonvolatile_cfg; /* Configuration register for Macronix */ uint32_t volatile_cfg; @@ -536,9 +536,9 @@ static inline void flash_sync_dirty(Flash *s, int64_t= newpage) } =20 static inline -void flash_write8(Flash *s, uint64_t addr, uint8_t data) +void flash_write8(Flash *s, uint32_t addr, uint8_t data) { - int64_t page =3D addr / s->pi->page_size; + uint32_t page =3D addr / s->pi->page_size; uint8_t prev =3D s->storage[s->cur_addr]; =20 if (!s->write_enable) { @@ -546,7 +546,7 @@ void flash_write8(Flash *s, uint64_t addr, uint8_t da= ta) } =20 if ((prev ^ data) & data) { - DB_PRINT_L(1, "programming zero to one! addr=3D%" PRIx64 " %" P= RIx8 + DB_PRINT_L(1, "programming zero to one! addr=3D%" PRIx32 " %" P= RIx8 " -> %" PRIx8 "\n", addr, prev, data); } =20 @@ -1095,7 +1095,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint= 32_t tx) switch (s->state) { =20 case STATE_PAGE_PROGRAM: - DB_PRINT_L(1, "page program cur_addr=3D%#" PRIx64 " data=3D%" PR= Ix8 "\n", + DB_PRINT_L(1, "page program cur_addr=3D%#" PRIx32 " data=3D%" PR= Ix8 "\n", s->cur_addr, (uint8_t)tx); flash_write8(s, s->cur_addr, (uint8_t)tx); s->cur_addr =3D (s->cur_addr + 1) & (s->size - 1); @@ -1103,7 +1103,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint= 32_t tx) =20 case STATE_READ: r =3D s->storage[s->cur_addr]; - DB_PRINT_L(1, "READ 0x%" PRIx64 "=3D%" PRIx8 "\n", s->cur_addr, + DB_PRINT_L(1, "READ 0x%" PRIx32 "=3D%" PRIx8 "\n", s->cur_addr, (uint8_t)r); s->cur_addr =3D (s->cur_addr + 1) & (s->size - 1); break; @@ -1202,7 +1202,8 @@ static const VMStateDescription vmstate_m25p80 =3D = { VMSTATE_UINT32(pos, Flash), VMSTATE_UINT8(needed_bytes, Flash), VMSTATE_UINT8(cmd_in_progress, Flash), - VMSTATE_UINT64(cur_addr, Flash), + VMSTATE_UNUSED(4), + VMSTATE_UINT32(cur_addr, Flash), VMSTATE_BOOL(write_enable, Flash), VMSTATE_BOOL_V(reset_enable, Flash, 2), VMSTATE_UINT8_V(ear, Flash, 2), --=20 2.1.4