Skip to contentSkip to conversation

libxl: Don't ignore error when we fail to give access to ioport/irq

PATCH Superseded Julien Grall 2 participants 3 messages Jan 9, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: Don't ignore error when we fail to give access to ioport/irq

If we fail to give the access, the domain will unlikely work correctly. So we should bail out at the first error.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

---
This patch is candidate for a backport for at least Xen 4.4 and Xen 4.5.

---
 tools/libxl/libxl_create.c | 2 ++
 1 file changed, 2 insertions(+)
tools/libxl/libxl_create.c +2 -0
index 1198225..09d481a 100644
@@ -1167,6 +1167,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
                  "failed give dom%d access to ioports %"PRIx32"-%"PRIx32,
                  domid, io->first, io->first + io->number - 1);
             ret = ERROR_FAIL;
+            goto error_out;
         }
     }
 
@@ -1182,6 +1183,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         if (ret < 0) {
             LOGE(ERROR, "failed give dom%d access to irq %d", domid, irq);
             ret = ERROR_FAIL;
+            goto error_out;
         }
     }
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 11 lines · Julien Grall

If we fail to give the access, the domain will unlikely work correctly. So we should bail out at the first error.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

---
This patch is candidate for a backport for at least Xen 4.4 and Xen 4.5.

The handling of io mem has same issue. You may also want to fix that?

Also do you need to clean up (revoke permission) the ports, irqs and io mems that have already been assigned? I presume that's done when domain is destroyed?

Wei.

Quoted 26 lines
---
 tools/libxl/libxl_create.c | 2 ++
 1 file changed, 2 insertions(+)
tools/libxl/libxl_create.c +2 -0
index 1198225..09d481a 100644
@@ -1167,6 +1167,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
                  "failed give dom%d access to ioports %"PRIx32"-%"PRIx32,
                  domid, io->first, io->first + io->number - 1);
             ret = ERROR_FAIL;
+            goto error_out;
         }
     }
 
@@ -1182,6 +1183,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         if (ret < 0) {
             LOGE(ERROR, "failed give dom%d access to irq %d", domid, irq);
             ret = ERROR_FAIL;
+            goto error_out;
         }
     }
 
Signature · 1 line
2.1.4
#2 lore raw

Hi Wei,

Quoted 10 lines · Wei Liu
Quoted 9 lines · Julien Grall

If we fail to give the access, the domain will unlikely work correctly. So we should bail out at the first error.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
Quoted 4 lines
Quoted 2 lines

---
This patch is candidate for a backport for at least Xen 4.4 and Xen 4.5.

The handling of io mem has same issue. You may also want to fix that?

I forgot this one. I will fix in the next version.

Quoted 2 lines

Also do you need to clean up (revoke permission) the ports, irqs and io mems that have already been assigned?

We don't need to clean up ioport/irqs/iomems. It's already done implicitly when the domain is destroyed.

Quoted 2 lines

I presume that's done when domain
is destroyed?

If domain destroyed doesn't correctly revoke the permission that would mean the code is buggy in the normal behavior.

Regards,

Signature · 1 line
Julien Grall