xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler
PATCH v2 1/1 xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler
This function returns true/false based on whether the key value is in the range (start, start+size). However, it should check against (start, start+size-1) because start+size falls outside the range.
This resulted in returning a wrong mmio_handler for a given mmio address which happened to be start+size.
This bug was introduced when the mmio region search was switched from linear search to binary search in the following commit:
8047e09 "xen/arm: io: Use binary search for mmio handler lookup".
This change may have to be back-ported to 4.8 also.
---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
xen/arch/arm/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/io.c +1 -1
@@ -79,7 +79,7 @@ static int cmp_mmio_handler(const void *key, const void *elem)if ( handler0->addr < handler1->addr )return -1 ; -if ( handler0->addr > (handler1->addr + handler1->size) ) +if ( handler0->addr >= (handler1->addr + handler1->size) )return 1 ;return 0 ;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Hi Bhupinder,
Quoted 1 line · Bhupinder Thakur
This function returns true/false based on whether the key value
Technically, this function returns 3 values: -1/0/1. The commit message should be updated to reflect that.
Quoted 6 lines
is in the range (start, start+size). However, it should check against (start, start+size-1) because start+size falls outside the range.
This resulted in returning a wrong
mmio_handlerfor a given mmio address which happened to be start+size.
Quoted 6 lines
This bug was introduced when the mmio region search was switched from linear search to binary search in the following commit:
8047e09 "xen/arm: io: Use binary search for mmio handler lookup".
This change may have to be back-ported to 4.8 also.
FIY, this does not need to be in the commit message. You could add after "---". When committed, it will get removed.
Quoted 15 lines
Signed-off-by Bhupinder Thakur <[email protected]>---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>xen/arch/arm/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/io.c +0
-0
xen/arch/arm/io.c static int cmp_mmio_handler(const void *key, const void *elem) · line 85
Quoted 8 lines
xen/arch/arm/io.c +1
-1@@ -79,7 +79,7 @@ static int cmp_mmio_handler(const void *key, const void *elem)if ( handler0->addr < handler1->addr )return -1 ; -if ( handler0->addr > (handler1->addr + handler1->size) ) +if ( handler0->addr >= (handler1->addr + handler1->size) )return 1 ;return 0 ;
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel