[PATCH] hw/core/qdev-properties-system: allow bus addresses > 0x1f

Geoffrey McRae posted 1 patch 3 years, 5 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201106234510.2101-1-geoff@hostfission.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>
hw/core/qdev-properties-system.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/core/qdev-properties-system: allow bus addresses > 0x1f
Posted by Geoffrey McRae 3 years, 5 months ago
The commit bccb20c49df1bd683248a366021973901c11982f introduced an error
in the checking logic that validates the bus addresses for PCI device
addresses preventing usage of devices via vfio-pci that sit at a bus
address of 0x20 or higher. This patch resolves this by reverting the
checking logic to the original maximum value of 0xff

Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
---
 hw/core/qdev-properties-system.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index b81a4e8d14..e62644bc69 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -882,7 +882,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
     bus = val;
 
     p = (char *)e + 1;
-    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
+    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xff || e == p) {
         goto inval;
     }
     if (*e == ':') {
-- 
2.20.1


Re: [PATCH] hw/core/qdev-properties-system: allow bus addresses > 0x1f
Posted by Philippe Mathieu-Daudé 3 years, 5 months ago
Hi Geoffrey,

Cc'ing the QOM maintainers.

On 11/7/20 12:45 AM, Geoffrey McRae wrote:
> The commit bccb20c49df1bd683248a366021973901c11982f introduced an error
> in the checking logic that validates the bus addresses for PCI device
> addresses preventing usage of devices via vfio-pci that sit at a bus
> address of 0x20 or higher. This patch resolves this by reverting the
> checking logic to the original maximum value of 0xff
> 
> Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
> ---
>  hw/core/qdev-properties-system.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index b81a4e8d14..e62644bc69 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -882,7 +882,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
>      bus = val;
>  
>      p = (char *)e + 1;
> -    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
> +    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xff || e == p) {

The fix has already been suggested last month ...:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg750122.html

... then reworked:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg750121.html

You could help to get it merged by reviewing it ;)

Thanks,

Phil.

>          goto inval;
>      }
>      if (*e == ':') {
>