diff mbox

[09/11] memory: Add iova to IOMMUTLBEntry

Message ID 1368522837-20747-10-git-send-email-david@gibson.dropbear.id.au
State New
Headers show

Commit Message

David Gibson May 14, 2013, 9:13 a.m. UTC
Currently, the IOMMUTLBEntry structure contains the translated address,
but not the IOVA (original untranslated address).  We're going to need it
for upcoming changes, so add it in here, and populate it correctly in our
one existing iommu implementation.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr_iommu.c  |    2 ++
 include/exec/memory.h |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Alex Williamson May 14, 2013, 4:53 p.m. UTC | #1
On Tue, 2013-05-14 at 19:13 +1000, David Gibson wrote:
> Currently, the IOMMUTLBEntry structure contains the translated address,
> but not the IOVA (original untranslated address).  We're going to need it
> for upcoming changes, so add it in here, and populate it correctly in our
> one existing iommu implementation.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/ppc/spapr_iommu.c  |    2 ++
>  include/exec/memory.h |    2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
> index 90469b3..07a6307 100644
> --- a/hw/ppc/spapr_iommu.c
> +++ b/hw/ppc/spapr_iommu.c
> @@ -80,6 +80,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
>  
>      if (tcet->bypass) {
>          return (IOMMUTLBEntry) {
> +            .iova = 0,
>              .translated_addr = 0,
>              .addr_mask = ~(hwaddr)0,
>              .perm = { true, true },
> @@ -102,6 +103,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
>  #endif
>  
>      return (IOMMUTLBEntry) {
> +        .iova = addr & ~SPAPR_TCE_PAGE_MASK,
>          .translated_addr = tce & ~SPAPR_TCE_PAGE_MASK,
>          .addr_mask = SPAPR_TCE_PAGE_MASK,
>          .perm = { [0] = tce & SPAPR_TCE_RO, [1] = tce & SPAPR_TCE_WO },
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index b97ace7..cd33439 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -116,7 +116,7 @@ typedef struct IOMMUTLBEntry IOMMUTLBEntry;
>  typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
>  
>  struct IOMMUTLBEntry {
> -    hwaddr translated_addr;
> +    hwaddr iova, translated_addr;

Being a struct definition, I assume we'd want to keep these on separate
lines for clarity (and preferably comments).

>      hwaddr addr_mask;  /* 0xfff = 4k translation */
>      bool perm[2]; /* permissions, [0] for read, [1] for write */
>  };
Paolo Bonzini May 14, 2013, 9:22 p.m. UTC | #2
Il 14/05/2013 11:13, David Gibson ha scritto:
> Currently, the IOMMUTLBEntry structure contains the translated address,
> but not the IOVA (original untranslated address).  We're going to need it
> for upcoming changes, so add it in here, and populate it correctly in our
> one existing iommu implementation.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/ppc/spapr_iommu.c  |    2 ++
>  include/exec/memory.h |    2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
> index 90469b3..07a6307 100644
> --- a/hw/ppc/spapr_iommu.c
> +++ b/hw/ppc/spapr_iommu.c
> @@ -80,6 +80,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
>  
>      if (tcet->bypass) {
>          return (IOMMUTLBEntry) {
> +            .iova = 0,
>              .translated_addr = 0,
>              .addr_mask = ~(hwaddr)0,
>              .perm = { true, true },
> @@ -102,6 +103,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
>  #endif
>  
>      return (IOMMUTLBEntry) {
> +        .iova = addr & ~SPAPR_TCE_PAGE_MASK,
>          .translated_addr = tce & ~SPAPR_TCE_PAGE_MASK,
>          .addr_mask = SPAPR_TCE_PAGE_MASK,
>          .perm = { [0] = tce & SPAPR_TCE_RO, [1] = tce & SPAPR_TCE_WO },
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index b97ace7..cd33439 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -116,7 +116,7 @@ typedef struct IOMMUTLBEntry IOMMUTLBEntry;
>  typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
>  
>  struct IOMMUTLBEntry {
> -    hwaddr translated_addr;
> +    hwaddr iova, translated_addr;
>      hwaddr addr_mask;  /* 0xfff = 4k translation */
>      bool perm[2]; /* permissions, [0] for read, [1] for write */
>  };
> 

Split and squashed into various patches of my iommu tree.

Paolo
David Gibson May 15, 2013, 3:51 a.m. UTC | #3
On Tue, May 14, 2013 at 10:53:35AM -0600, Alex Williamson wrote:
> On Tue, 2013-05-14 at 19:13 +1000, David Gibson wrote:
> > Currently, the IOMMUTLBEntry structure contains the translated address,
> > but not the IOVA (original untranslated address).  We're going to need it
> > for upcoming changes, so add it in here, and populate it correctly in our
> > one existing iommu implementation.
> > 
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  hw/ppc/spapr_iommu.c  |    2 ++
> >  include/exec/memory.h |    2 +-
> >  2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
> > index 90469b3..07a6307 100644
> > --- a/hw/ppc/spapr_iommu.c
> > +++ b/hw/ppc/spapr_iommu.c
> > @@ -80,6 +80,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
> >  
> >      if (tcet->bypass) {
> >          return (IOMMUTLBEntry) {
> > +            .iova = 0,
> >              .translated_addr = 0,
> >              .addr_mask = ~(hwaddr)0,
> >              .perm = { true, true },
> > @@ -102,6 +103,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
> >  #endif
> >  
> >      return (IOMMUTLBEntry) {
> > +        .iova = addr & ~SPAPR_TCE_PAGE_MASK,
> >          .translated_addr = tce & ~SPAPR_TCE_PAGE_MASK,
> >          .addr_mask = SPAPR_TCE_PAGE_MASK,
> >          .perm = { [0] = tce & SPAPR_TCE_RO, [1] = tce & SPAPR_TCE_WO },
> > diff --git a/include/exec/memory.h b/include/exec/memory.h
> > index b97ace7..cd33439 100644
> > --- a/include/exec/memory.h
> > +++ b/include/exec/memory.h
> > @@ -116,7 +116,7 @@ typedef struct IOMMUTLBEntry IOMMUTLBEntry;
> >  typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
> >  
> >  struct IOMMUTLBEntry {
> > -    hwaddr translated_addr;
> > +    hwaddr iova, translated_addr;
> 
> Being a struct definition, I assume we'd want to keep these on separate
> lines for clarity (and preferably comments).

Good idea, adjusted accordingly.
diff mbox

Patch

diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index 90469b3..07a6307 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -80,6 +80,7 @@  static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
 
     if (tcet->bypass) {
         return (IOMMUTLBEntry) {
+            .iova = 0,
             .translated_addr = 0,
             .addr_mask = ~(hwaddr)0,
             .perm = { true, true },
@@ -102,6 +103,7 @@  static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
 #endif
 
     return (IOMMUTLBEntry) {
+        .iova = addr & ~SPAPR_TCE_PAGE_MASK,
         .translated_addr = tce & ~SPAPR_TCE_PAGE_MASK,
         .addr_mask = SPAPR_TCE_PAGE_MASK,
         .perm = { [0] = tce & SPAPR_TCE_RO, [1] = tce & SPAPR_TCE_WO },
diff --git a/include/exec/memory.h b/include/exec/memory.h
index b97ace7..cd33439 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -116,7 +116,7 @@  typedef struct IOMMUTLBEntry IOMMUTLBEntry;
 typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps;
 
 struct IOMMUTLBEntry {
-    hwaddr translated_addr;
+    hwaddr iova, translated_addr;
     hwaddr addr_mask;  /* 0xfff = 4k translation */
     bool perm[2]; /* permissions, [0] for read, [1] for write */
 };