nand: fix address overflow
PATCH 1/1 nand: fix address overflow
The shifts of the address mask and value shift beyond 32 bits when there are 5 address cycles.
--- hw/block/nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/block/nand.c +2 -2
@@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)if (s->ale) {unsigned int shift = s->addrlen *8 ; -unsigned int mask = ~(0xff << shift); -unsigned int v = value << shift; +uint64_t mask = ~(0xffull << shift); +uint64_t v = (uint64_t )value << shift; s->addr = (s->addr & mask) | v; s->addrlen ++;
Signature · 1 line
1.7.10.4
Quoted 14 lines · Rabin Vincent
The shifts of the address mask and value shift beyond 32 bits when there are 5 address cycles.
Signed-off-by Rabin Vincent <[email protected]>--- hw/block/nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/block/nand.c +0
-0
hw/block/nand.c void nand_setio(DeviceState *dev, uint32_t value) · line 529
Quoted 10 lines
hw/block/nand.c +2
-2@@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)if (s->ale) {unsigned int shift = s->addrlen *8 ; -unsigned int mask = ~(0xff << shift); -unsigned int v = value << shift; +uint64_t mask = ~(0xffull << shift); +uint64_t v = (uint64_t )value << shift; s->addr = (s->addr & mask) | v; s->addrlen ++;
Peter Crosthwaite
Reviewed-byQuoted 24 lines · Paolo Bonzini
Quoted 21 lines · Rabin Vincent
The shifts of the address mask and value shift beyond 32 bits when there are 5 address cycles.
Signed-off-by Rabin Vincent <[email protected]>--- hw/block/nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/block/nand.c +2
-2@@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)if (s->ale) {unsigned int shift = s->addrlen *8 ; -unsigned int mask = ~(0xff << shift); -unsigned int v = value << shift; +uint64_t mask = ~(0xffull << shift); +uint64_t v = (uint64_t )value << shift;
Quoted 6 lines
hw/block/nand.c void nand_setio(DeviceState *dev, uint32_t value) · line 529
Quoted 3 lines
hw/block/nand.c +0
-0s->addr = (s->addr & mask) | v; s->addrlen ++;Reviewed-by Paolo Bonzini <[email protected]>
This is a bugfix right? IIUC This would not have worked for accesses to devices above column address 255 at all. Should this go to stable/2.5?
Regards,
Peter
Quoted 1 line
Quoted 29 lines
Quoted 22 lines · Rabin Vincent
Quoted 21 lines
The shifts of the address mask and value shift beyond 32 bits when there are 5 address cycles.
Signed-off-by Rabin Vincent <[email protected]>--- hw/block/nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/block/nand.c +2
-2@@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)if (s->ale) {unsigned int shift = s->addrlen *8 ; -unsigned int mask = ~(0xff << shift); -unsigned int v = value << shift; +uint64_t mask = ~(0xffull << shift); +uint64_t v = (uint64_t )value << shift;Quoted 6 lines
hw/block/nand.c void nand_setio(DeviceState *dev, uint32_t value) · line 529
Quoted 3 lines
hw/block/nand.c +0
-0s->addr = (s->addr & mask) | v; s->addrlen ++;Reviewed-by Paolo Bonzini <[email protected]>
Quoted 5 lines
Reviewed-by Peter Crosthwaite <[email protected]>This is a bugfix right? IIUC This would not have worked for accesses to devices above column address 255 at all. Should this go to stable/2.5?
Yes, it should. Michael, are you planning to send another pull request during hard freeze?
Paolo
Am 13.11.2015 um 10:32 hat Paolo Bonzini geschrieben:
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines · Rabin Vincent
Quoted 14 lines
The shifts of the address mask and value shift beyond 32 bits when there are 5 address cycles.
Signed-off-by Rabin Vincent <[email protected]>--- hw/block/nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/block/nand.c +0
-0hw/block/nand.c void nand_setio(DeviceState *dev, uint32_t value) · line 529
Quoted 10 lines
hw/block/nand.c +2
-2@@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)if (s->ale) {unsigned int shift = s->addrlen *8 ; -unsigned int mask = ~(0xff << shift); -unsigned int v = value << shift; +uint64_t mask = ~(0xffull << shift); +uint64_t v = (uint64_t )value << shift; s->addr = (s->addr & mask) | v; s->addrlen ++;Reviewed-by Paolo Bonzini <[email protected]>
Quoted 8 lines
Quoted 5 lines
Reviewed-by Peter Crosthwaite <[email protected]>This is a bugfix right? IIUC This would not have worked for accesses to devices above column address 255 at all. Should this go to stable/2.5?
Yes, it should. Michael, are you planning to send another pull request during hard freeze?
The block layer catch-all entry in MAINTAINERS says that it's mine, so I'll just take it through my block tree.
Kevin