]> git.proxmox.com Git - qemu.git/commit - hw/pcnet.c
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)
commit366c9332450caace5843c17806ba4879bf2d005c
tree1f852cf550f22eff813c385597299fc1b3903146
parente318a60b94b152c1e80125861a8917ae177d845e
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