pseries: Don't allow TCE (iommu) tables to be registered with duplicate LIOBNs
authorDavid Gibson <david@gibson.dropbear.id.au>
Mon, 3 Dec 2012 16:42:13 +0000 (16:42 +0000)
committerAlexander Graf <agraf@suse.de>
Fri, 14 Dec 2012 12:12:55 +0000 (13:12 +0100)
The PAPR specification requires that every bus or device mediated by the
IOMMU have a unique Logical IO Bus Number (LIOBN).  This patch adds a check
to enforce this, which will help catch errors in configuration earlier.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
hw/spapr_iommu.c

index 02d78ccf28a02d80cb1dde7aae608aa17f8510d1..3011b251d3dcc0193ce12e3d9277f75be4560b4c 100644 (file)
@@ -120,6 +120,12 @@ DMAContext *spapr_tce_new_dma_context(uint32_t liobn, size_t window_size)
 {
     sPAPRTCETable *tcet;
 
+    if (spapr_tce_find_by_liobn(liobn)) {
+        fprintf(stderr, "Attempted to create TCE table with duplicate"
+                " LIOBN 0x%x\n", liobn);
+        return NULL;
+    }
+
     if (!window_size) {
         return NULL;
     }