gt64xxx: fix decoding of ISD register
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 6 Nov 2015 15:34:06 +0000 (16:34 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 4 Dec 2015 06:39:55 +0000 (09:39 +0300)
The GT64xxx's internal registers can be placed above the first 4 GiB
in the address space, but not above the first 64 GiB.  Correctly cast
the register to a 64-bit integer, and mask away bits above bit 35.

Datasheet at http://pdf.datasheetarchive.com/datasheetsmain/Datasheets-33/DSA-655889.pdf
(bug reported by Coverity).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/mips/gt64xxx_pci.c

index 10fcca33f86053b0a7a7fb8348a4030674b53a43..f76a9fd36b31195f661d8cd569742a71b12bc262 100644 (file)
@@ -275,7 +275,8 @@ static void check_reserved_space (hwaddr *start,
 
 static void gt64120_isd_mapping(GT64120State *s)
 {
-    hwaddr start = s->regs[GT_ISD] << 21;
+    /* Bits 14:0 of ISD map to bits 35:21 of the start address.  */
+    hwaddr start = ((hwaddr)s->regs[GT_ISD] << 21) & 0xFFFE00000ull;
     hwaddr length = 0x1000;
 
     if (s->ISD_length) {