lib/logic_pio: Fix overlap check for pio registery
PATCH 1/1 lib/logic_pio: Fix overlap check for pio registery
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
--- lib/logic_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/logic_pio.c +1 -1
@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) {/* for MMIO ranges we need to check for overlap */ if (start >= range->hw_start + range->size || - end < range->hw_start) { + end <= range->hw_start) { mmio_end = range->io_start + range->size; }else { ret = -EFAULT ;
Signature · 1 line
2.28.0
Quoted 13 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen <[email protected]>--- lib/logic_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0
lib/logic_pio.c int logic_pio_register_range(struct logic_pio_hwaddr *new_range) · line 60
Quoted 5 lines
lib/logic_pio.c +1
-1@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) {/* for MMIO ranges we need to check for overlap */ if (start >= range->hw_start + range->size || - end < range->hw_start) { + end <= range->hw_start) {
It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regions
Have you seen a problem here?
Thanks,
John
Hi John,
Quoted 24 lines · John Garry
Quoted 15 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen <[email protected]>---
lib/logic_pio.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) { /* for MMIO ranges we need to check for overlap */Quoted 3 lines
if (start >=
range->hw_start+range->size|| - end <range->hw_start) {
+ end <=range->hw_start) {It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regions
Quoted 2 lines
Have you seen a problem here?
No serious problem. I found it just when I was working on adding support of pci expander bridge for Arm in QEMU. I found the IO window of some extended root bus could not be registered when I inserted the extended buses' _CRS info into DSDT table in the x86 way, which does not sort the buses.
Though root buses should be sorted in QEMU, would it be better to accept those non-ascending IO windows?
BTW, for b, it seems to be no space between IO windows of different root buses generated by EDK2. Or maybe I missed something obvious.
Thanks,
Jiahui
John Garry
Reviewed-byQuoted 28 lines · Jiahui Cen
Hi John,
Quoted 23 lines · John Garry
Quoted 13 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen<[email protected]>--- lib/logic_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0lib/logic_pio.c int logic_pio_register_range(struct logic_pio_hwaddr *new_range) · line 60
Quoted 5 lines
lib/logic_pio.c +1
-1@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) { /* for MMIO ranges we need to check for overlap */ if (start >= range->hw_start + range->size || - end < range->hw_start) { + end <= range->hw_start) {It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regionsQuoted 2 lines
Have you seen a problem here?
Quoted 8 lines
No serious problem. I found it just when I was working on adding support of pci expander bridge for Arm in QEMU. I found the IO window of some extended root bus could not be registered when I inserted the extended buses'
_CRSinfo into DSDT table in the x86 way, which does not sort the buses.Though root buses should be sorted in QEMU, would it be better to accept those non-ascending IO windows?
ok, so it seems that you have seen a real problem, and this issue is not just detected by code analysis.
Quoted 2 lines
BTW, for b, it seems to be no space between IO windows of different root buses generated by EDK2. Or maybe I missed something obvious.
I don't know about that. Anyway, your change looks ok.
BTW, for your virt env, will there be requirement to unregister PCI MMIO ranges? Currently we don't see that in non-virt world.
Thanks,
John
Hi John,
Quoted 40 lines · John Garry
Quoted 28 lines · Jiahui Cen
Hi John,
Quoted 23 lines · John Garry
Quoted 15 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen<[email protected]>---
lib/logic_pio.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) { /* for MMIO ranges we need to check for overlap */Quoted 3 lines
if (start >=
range->hw_start+range->size|| - end <range->hw_start) {
+ end <=range->hw_start) {It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regionsQuoted 2 lines
Have you seen a problem here?
Quoted 8 lines
No serious problem. I found it just when I was working on adding support of pci expander bridge for Arm in QEMU. I found the IO window of some extended root bus could not be registered when I inserted the extended buses'
_CRSinfo into DSDT table in the x86 way, which does not sort the buses.Though root buses should be sorted in QEMU, would it be better to accept those non-ascending IO windows?
ok, so it seems that you have seen a real problem, and this issue is not just detected by code analysis.
Quoted 9 lines
Quoted 2 lines
BTW, for b, it seems to be no space between IO windows of different root buses generated by EDK2. Or maybe I missed something obvious.
I don't know about that. Anyway, your change looks ok.
Reviewed-by John Garry <[email protected]>BTW, for your virt env, will there be requirement to unregister PCI MMIO ranges? Currently we don't see that in non-virt world.
Thanks for your review.
And currently there is no such a requirement in my virt env.
Thanks,
Jiahui
Quoted 43 lines · Jiahui Cen
Quoted 43 lines · Jiahui Cen
Quoted 28 lines
Hi John,
Quoted 23 lines · John Garry
Quoted 13 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen<[email protected]>--- lib/logic_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0lib/logic_pio.c int logic_pio_register_range(struct logic_pio_hwaddr *new_range) · line 60
Quoted 5 lines
lib/logic_pio.c +1
-1@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) { /* for MMIO ranges we need to check for overlap */ if (start >= range->hw_start + range->size || - end < range->hw_start) { + end <= range->hw_start) {It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regionsQuoted 2 lines
Have you seen a problem here?
Quoted 8 lines
No serious problem. I found it just when I was working on adding support of pci expander bridge for Arm in QEMU. I found the IO window of some extended root bus could not be registered when I inserted the extended buses'
_CRSinfo into DSDT table in the x86 way, which does not sort the buses.Though root buses should be sorted in QEMU, would it be better to accept those non-ascending IO windows?
ok, so it seems that you have seen a real problem, and this issue is not just detected by code analysis.
Quoted 2 lines
BTW, for b, it seems to be no space between IO windows of different root buses generated by EDK2. Or maybe I missed something obvious.
I don't know about that. Anyway, your change looks ok.
Quoted 8 lines
Quoted 4 lines
Reviewed-by John Garry<[email protected]>BTW, for your virt env, will there be requirement to unregister PCI MMIO ranges? Currently we don't see that in non-virt world.
Thanks for your review.
And currently there is no such a requirement in my virt env.
I am not sure what happened to this patch, but I plan on sending some patches in this area soon - do you want me to include this one?
Thanks,
John
Hi John,
Quoted 46 lines · John Garry
Quoted 45 lines · Jiahui Cen
Quoted 45 lines · Jiahui Cen
Quoted 28 lines
Hi John,
Quoted 23 lines · John Garry
Quoted 15 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen<[email protected]>---
lib/logic_pio.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) { /* for MMIO ranges we need to check for overlap */Quoted 3 lines
if (start >=
range->hw_start+range->size|| - end <range->hw_start) {
+ end <=range->hw_start) {It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regionsQuoted 2 lines
Have you seen a problem here?
Quoted 8 lines
No serious problem. I found it just when I was working on adding support of pci expander bridge for Arm in QEMU. I found the IO window of some extended root bus could not be registered when I inserted the extended buses'
_CRSinfo into DSDT table in the x86 way, which does not sort the buses.Though root buses should be sorted in QEMU, would it be better to accept those non-ascending IO windows?
ok, so it seems that you have seen a real problem, and this issue is not just detected by code analysis.
Quoted 2 lines
BTW, for b, it seems to be no space between IO windows of different root buses generated by EDK2. Or maybe I missed something obvious.
I don't know about that. Anyway, your change looks ok.
Reviewed-by John Garry<[email protected]>
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
BTW, for your virt env, will there be requirement to unregister PCI MMIO ranges? Currently we don't see that in non-virt world.
Thanks for your review.
And currently there is no such a requirement in my virt env.
I am not sure what happened to this patch, but I plan on sending some patches in this area soon - do you want me to include this one?
Sorry for replying late. It's appreciated if you can include this patch.
Thanks!
Jiahui
Quoted 4 lines
Thanks,
John.
On 18/01/2021 01:27, Jiahui Cen wrote:
+
Hi Arnd, xu wei,
Any chance we could pick up this patch via arm-soc tree?
The series which I originally included in, below, is stalled a bit.
Thanks,
John
https://lore.kernel.org/lkml/[email protected]/
Quoted 70 lines
Hi John,
Quoted 46 lines · John Garry
Quoted 45 lines · Jiahui Cen
Quoted 45 lines · Jiahui Cen
Quoted 28 lines
Hi John,
Quoted 23 lines · John Garry
Quoted 13 lines · Jiahui Cen
Since the [start, end) is a half-open interval, a range with the end equal to the start of another range should not be considered as overlapped.
Signed-off-by Jiahui Cen<[email protected]>--- lib/logic_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/logic_pio.c +0
-0lib/logic_pio.c int logic_pio_register_range(struct logic_pio_hwaddr *new_range) · line 60
Quoted 5 lines
lib/logic_pio.c +1
-1@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) new_range->flags == LOGIC_PIO_CPU_MMIO) { /* for MMIO ranges we need to check for overlap */ if (start >= range->hw_start + range->size || - end < range->hw_start) { + end <= range->hw_start) {It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regionsQuoted 2 lines
Have you seen a problem here?
Quoted 8 lines
No serious problem. I found it just when I was working on adding support of pci expander bridge for Arm in QEMU. I found the IO window of some extended root bus could not be registered when I inserted the extended buses'
_CRSinfo into DSDT table in the x86 way, which does not sort the buses.Though root buses should be sorted in QEMU, would it be better to accept those non-ascending IO windows?
ok, so it seems that you have seen a real problem, and this issue is not just detected by code analysis.
Quoted 2 lines
BTW, for b, it seems to be no space between IO windows of different root buses generated by EDK2. Or maybe I missed something obvious.
I don't know about that. Anyway, your change looks ok.
Reviewed-by John Garry<[email protected]>Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
BTW, for your virt env, will there be requirement to unregister PCI MMIO ranges? Currently we don't see that in non-virt world.
Thanks for your review.
And currently there is no such a requirement in my virt env.
I am not sure what happened to this patch, but I plan on sending some patches in this area soon - do you want me to include this one?
Sorry for replying late. It's appreciated if you can include this patch.
Thanks!
JiahuiQuoted 4 lines
Thanks,
John.
.