pcnet: Fix sign extension: make ipxe work with >2G RAM
authorMichael Brown <mcb30@ipxe.org>
Tue, 15 Mar 2011 16:47:22 +0000 (10:47 -0600)
committerAurelien Jarno <aurelien@aurel32.net>
Fri, 1 Apr 2011 20:35:25 +0000 (22:35 +0200)
commitcdf70cfec0282629d8d21bdb3646b9b9ef4a8729
tree1f852cf550f22eff813c385597299fc1b3903146
parent315fa7f3d3d291556596ebc69908f08271565092
pcnet: Fix sign extension: make ipxe work with >2G RAM

The problem is with definitions in hw/pcnet.c such as:

  #define CSR_CRDA(S)      ((S)->csr[28] | ((S)->csr[29] << 16))

"(S)->csr[29]" is a uint16_t, but "(S)->csr[29] << 16" gets promoted to
int, so the overall CSR_CRDA(s) is a (signed) int rather than a uint32_t.

This then gets assigned to a uint64_t using

  target_phys_addr_t crda = CSR_CRDA(s);

so when (S)->csr[29] has the high bit set, we end up with
crda=0xffffffffxxxxxxxx.

From: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
hw/pcnet.c