Patchwork [1/2] pseries: Don't allow TCE (iommu) tables to be registered with duplicate LIOBNs

login
register
mail settings
Submitter David Gibson
Date Nov. 27, 2012, 6:07 a.m.
Message ID <1353996453-24262-2-git-send-email-david@gibson.dropbear.id.au>
Download mbox | patch
Permalink /patch/202099/
State New
Headers show

Comments

David Gibson - Nov. 27, 2012, 6:07 a.m.
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>
---
 hw/spapr_iommu.c |    6 ++++++
 1 file changed, 6 insertions(+)
Michael S. Tsirkin - Dec. 10, 2012, 1 p.m.
On Tue, Nov 27, 2012 at 05:07:32PM +1100, David Gibson wrote:
> 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>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/spapr_iommu.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c
> index 02d78cc..3011b25 100644
> --- a/hw/spapr_iommu.c
> +++ b/hw/spapr_iommu.c
> @@ -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;
>      }
> -- 
> 1.7.10.4
Alexander Graf - Dec. 11, 2012, 9:59 a.m.
On 10.12.2012, at 14:00, Michael S. Tsirkin wrote:

> On Tue, Nov 27, 2012 at 05:07:32PM +1100, David Gibson wrote:
>> 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>
> 
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Thanks, applied to ppc-next.


Alex

> 
>> ---
>> hw/spapr_iommu.c |    6 ++++++
>> 1 file changed, 6 insertions(+)
>> 
>> diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c
>> index 02d78cc..3011b25 100644
>> --- a/hw/spapr_iommu.c
>> +++ b/hw/spapr_iommu.c
>> @@ -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;
>>     }
>> -- 
>> 1.7.10.4

Patch

diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c
index 02d78cc..3011b25 100644
--- a/hw/spapr_iommu.c
+++ b/hw/spapr_iommu.c
@@ -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;
     }