* [PATCH v2] xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler
@ 2017-09-29 0:33 Bhupinder Thakur
2017-09-29 0:43 ` Julien Grall
0 siblings, 1 reply; 2+ messages in thread
From: Bhupinder Thakur @ 2017-09-29 0:33 UTC (permalink / raw)
To: xen-devel; +Cc: Julien Grall, Stefano Stabellini
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.
Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
xen/arch/arm/io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
index e216128..c748d8f 100644
--- a/xen/arch/arm/io.c
+++ b/xen/arch/arm/io.c
@@ -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;
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler
2017-09-29 0:33 [PATCH v2] xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler Bhupinder Thakur
@ 2017-09-29 0:43 ` Julien Grall
0 siblings, 0 replies; 2+ messages in thread
From: Julien Grall @ 2017-09-29 0:43 UTC (permalink / raw)
To: Bhupinder Thakur, xen-devel; +Cc: Stefano Stabellini
Hi Bhupinder,
On 09/29/2017 01:33 AM, Bhupinder Thakur wrote:
> 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.
> 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.
FIY, this does not need to be in the commit message. You could add after
"---". When committed, it will get removed.
>
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
>
> xen/arch/arm/io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
> index e216128..c748d8f 100644
> --- a/xen/arch/arm/io.c
> +++ b/xen/arch/arm/io.c
> @@ -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,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-29 0:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 0:33 [PATCH v2] xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler Bhupinder Thakur
2017-09-29 0:43 ` Julien Grall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.