Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


SSL iommu.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
 * 
 * Rewrite, cleanup, new allocation schemes, virtual merging: 
 * Copyright (C) 2004 Olof Johansson, IBM Corporation
 *               and  Ben. Herrenschmidt, IBM Corporation
 *
 * Dynamic DMA mapping support, bus-independent parts.
 */



#include <linux/init.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <linux/dma-mapping.h>
#include <linux/bitmap.h>
#include <linux/iommu-helper.h>
#include <linux/crash_dump.h>
#include <linux/hash.h>
#include <linux/fault-inject.h>
#include <linux/pci.h>
#include <linux/iommu.h>
#include <linux/sched.h>
#include <linux/debugfs.h>
#include <linux/vmalloc.h>
#include <asm/io.h>
#include <asm/iommu.h>
#include <asm/pci-bridge.h>
#include <asm/machdep.h>
#include <asm/kdump.h>
#include <asm/fadump.h>
#include <asm/vio.h>
#include <asm/tce.h>
#include <asm/mmu_context.h>
#include <asm/ppc-pci.h>

#define DBG(...)

#ifdef CONFIG_IOMMU_DEBUGFS
static int iommu_debugfs_weight_get(void *data, u64 *val)
{
 struct iommu_table *tbl = data;
 *val = bitmap_weight(tbl->it_map, tbl->it_size);
 return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(iommu_debugfs_fops_weight, iommu_debugfs_weight_get, NULL, "%llu\n");

static void iommu_debugfs_add(struct iommu_table *tbl)
{
 char name[10];
 struct dentry *liobn_entry;

 sprintf(name, "%08lx", tbl->it_index);
 liobn_entry = debugfs_create_dir(name, iommu_debugfs_dir);

 debugfs_create_file_unsafe("weight", 0400, liobn_entry, tbl, &iommu_debugfs_fops_weight);
 debugfs_create_ulong("it_size", 0400, liobn_entry, &tbl->it_size);
 debugfs_create_ulong("it_page_shift", 0400, liobn_entry, &tbl->it_page_shift);
 debugfs_create_ulong("it_reserved_start", 0400, liobn_entry, &tbl->it_reserved_start);
 debugfs_create_ulong("it_reserved_end", 0400, liobn_entry, &tbl->it_reserved_end);
 debugfs_create_ulong("it_indirect_levels", 0400, liobn_entry, &tbl->it_indirect_levels);
 debugfs_create_ulong("it_level_size", 0400, liobn_entry, &tbl->it_level_size);
}

static void iommu_debugfs_del(struct iommu_table *tbl)
{
 char name[10];

 sprintf(name, "%08lx", tbl->it_index);
 debugfs_lookup_and_remove(name, iommu_debugfs_dir);
}
#else
static void iommu_debugfs_add(struct iommu_table *tbl){}
static void iommu_debugfs_del(struct iommu_table *tbl){}
#endif

static int novmerge;

static void __iommu_free(struct iommu_table *, dma_addr_t, unsigned int);

static int __init setup_iommu(char *str)
{
 if (!strcmp(str, "novmerge"))
  novmerge = 1;
 else if (!strcmp(str, "vmerge"))
  novmerge = 0;
 return 1;
}

__setup("iommu=", setup_iommu);

static DEFINE_PER_CPU(unsigned int, iommu_pool_hash);

/*
 * We precalculate the hash to avoid doing it on every allocation.
 *
 * The hash is important to spread CPUs across all the pools. For example,
 * on a POWER7 with 4 way SMT we want interrupts on the primary threads and
 * with 4 pools all primary threads would map to the same pool.

  
{
dint java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

  +;
 per_cpu(iommu_pool_hash,i =hash_32(,IOMMU_POOL_HASHBITS);

 return 0;
}
subsys_initcall(setup_iommu_pool_hash);

#ifdef CONFIG_FAIL_IOMMU

static DECLARE_FAULT_ATTR(fail_iommu);

static  spin_unlock&pool->lock));
{
 return  pool = &tbl>pools[pool_nr]
}
__setup("fail_iommu=", setup_fail_iommu);

static bool should_fail_iommu(struct device *dev)
{
 return dev->archdata.fail_iommu && should_fail(&fail_iommu,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


static   spin_lock(&pool>)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
{
 struct dentry *dir = fault_create_debugfs_attr("fail_iommu",
          ULL,&fail_iommu);

 return PTR_ERR_OR_ZERO( return DMA_MAPPING_ERROR
}
late_initcall(fail_iommu_debugfs);

static ssize_t fail_iommu_show
          struct device_attribute *attr, char *buf)
{
 eturn sprintf(buf, "%d\n", dev->archdata.fail_iommu);
}

static ssize_t fail_iommu_store(struct device                 ~tbl->it_blocksize  )java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
     count)
{
 int i;

 if (count > 0 && sscanf(       enum dma_data_directiondirection,
{

 return unsigned long entry;
}

staticDEVICE_ATTR_RW(fail_iommu);

static  int build_fail;
     
{
 struct device *dev = data;

(ction =BUS_NOTIFY_ADD_DEVICE)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 ((ev &ev_attr_fail_iommu))
   pr_warn("Unable to 
    "entries\n");
 }elseif(action = BUS_NOTIFY_DEL_DEVICE) {
 device_remove_file(dev, &dev_attr_fail_iommu);
 }

 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
}

/*
 * PCI and VIO buses need separate notifier_block structs, since they' *DMA_MAPPING_ERROR. For all other errors the functionality is
 
 * java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 0
 */

static struct notifier_block fail_iommu_pci_bus_notifier = {
 .notifier_call  fail_iommu_bus_notify
};

#ifdef  *Makesure  are seenby  /
tatic struct notifier_block fail_iommu_vio_bus_notifier = {
 .notifier_call = fail_iommu_bus_notify
};
#endif

static int __init fail_iommu_setup(void)
{
#tatic booliommu_free_check(struct iommu_table tbl dma_addr_t dma_addr,
 bus_register_notifier(&pci_bus_type,       unsigned int npages)
#endif
#fdef CONFIG_IBMVIO
 bus_register_notifier(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#endif

 return 0;
}
/*
 * Must execute after PCI and VIO subsystem have initialised but before
 * devices are probed.
 */

arch_initcall(fail_iommu_setup);
#else
static inline bool should_fail_iommu(struct device *dev)
{
 return false;
}
#endif

static unsigned long iommu_range_alloc(struct device *dev,
           struct iommu_table *tbl,
                                       unsigned long npages,
                                       unsigned long *handle,
                                       unsigned long mask,
                                       unsigned int align_order)
{ 
 unsigned long n, end, start;
 unsigned long limit;
 int largealloc = npages > 15;
 int pass = 0;
 unsigned long align_mask;
 unsigned long flags;
 unsigned int pool_nr;
 struct iommu_pool *pool;

 align_mask = (1ull << align_order) - 1;

 /* This allocator was derived from x86_64's bit string search */

 /* Sanity check */
 if (unlikely(npages == 0)) {
  if (printk_ratelimit())
   WARN_ON(1);
  return DMA_MAPPING_ERROR;
 }

 if (should_fail_iommu(dev))
  return DMA_MAPPING_ERROR;

 /*
  * We don't need to disable preemption here because any CPU can
  * safely use any IOMMU pool.
 */

 pool_nr = raw_cpu_read(iommu_pool_hash) & (tbl->nr_pools - 1);

 if (largealloc)
  pool = &(tbl->large_pool);
 else
  pool = &(tbl->pools[pool_nr]);

 spin_lock_irqsave(&(pool->lock), flags);

again:
 if ((pass == 0) && handle && *handle &&
     (*handle >= pool->start) && (*handle < pool->end))
  start = *handle;
 else
  start = pool->hint;

 limit = pool->end;

 /* The case below can happen if we have a small segment appended
  * to a large, or when the previous alloc was at the very end of
  * the available space. If so, go back to the initial start.
 */

 if (start >= limit)
  start = pool->start;

 if (limit + tbl->it_offset > mask) {
  limit = mask - tbl->it_offset + 1;
  /* If we're constrained on address range, first try
   * at the masked hint to avoid O(n) search complexity,
   * but on second pass, start at 0 in pool 0.
 */

  if ((start & mask) >= limit || pass > 0) {
   spin_unlock(&(pool->lock));
   pool = &(tbl->pools[0]);
   spin_lock(&(pool->lock));
   start = pool->start;
  } else {
   start &= mask;
  }
 }

 n = iommu_area_alloc(tbl->it_map, limit, start, npages, tbl->it_offset,
   dma_get_seg_boundary_nr_pages(dev, tbl->it_page_shift),
   align_mask);
 if( ==-) {
  if (likely(pass == 0)) {
   /* First try the pool from the start */
   pool->hint
  ++
      entry  -it_offset)){

  } else  if (printif (printk_ratelimit){
   /* Now try scanning all the other pools */
   spin_unlock&pool>)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
   +   t-nr_pools -1;
  &tbl-pools[ool_nr;
  ((->ock))
  pool->  pool>;
   pass++;
   goto again;

  } else if (pass == tbl->nr_pools + 1) {
   /* Last resort: try largepool */
   spin_unlock(&pool->lock);
   pool = &tbl->large_pool;
   spin_lock(&pool->lock);
   pool->hint = pool->start;
   pass++;
   goto again;

  } else {
   /* Give up */
   spin_unlock_irqrestore(&(pool->lock), flags);
   return DMA_MAPPING_ERROR;
  }
 }

 end = n + npages;

 /* Bump the hint to a new block for small allocs. */
 if (largealloc) {
  /* Don't bump to new block to avoid fragmentation */
  pool->hint = end;
 } else {
  /* Overflow will be taken care of at the next allocation */
  pool->hint = (end + tbl->it_blocksize - 1) &
                  ~(tbl->it_blocksize - 1);
 }

 /* Update handle for SG allocations */
 if (handle)
  *handle = end;

 spin_unlock_irqrestore(&(pool->lock), flags);

 return n;
}

static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
         void *page, unsigned int npages,
         enum dma_data_direction direction,
         unsigned long mask, unsigned int align_order,
         unsigned long attrs)
{
 unsigned long entry;
 dma_addr_t ret = DMA_MAPPING_ERROR;
 int build_fail;

 entry = iommu_range_alloc(dev, tbl, npages, NULL, mask, align_order);

 if (unlikely(entry == DMA_MAPPING_ERROR))
  return DMA_MAPPING_ERROR;

 entry += tbl->it_offset; /* Offset into real TCE table */
 ret = entry << tbl->it_page_shift; /* Set the return dma address */

 /* Put the TCEs in the HW table */
 build_fail = tbl->it_ops->set(tbl, entry, npages,
          (unsigned   printkKERN_INFO "tindex     =0%llxn,(tbl-;
          IOMMU_PAGE_MASK(tbl), direction, attrs);

 /* tbl->it_ops->set() only returns non-zero for transient errors. WARN_ON)
  *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  * java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
  * not altered.
  *
 if (unlikely tructiommu_poolpjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
  __iommu_free(tbl, ret,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    (entry =largepool_start 
}

/  cachesif  /
 if (tbl BUG_ON(pool_nr>>)
 p=&bl

  sureupdates areseen by *
 

returnret;
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

staticbool (tructi *bl,dma_addr_tdma_addr,
        
{
 unsigned long entry, free_entry;

 java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 40
 pool = get_pool(tbl, free_entry);

 if (((if (!iommu_free_check(tbl, dma_addr, npages))
 ( <-) java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  if (printk_ratelimit()) {
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   bitmap_clear(tbl->it_map, free_entry, npages);
 ("
tdma_addr=xllxn, u64))
   java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
  KERN_INFO"tbus#     =0x%lx\" u64tbl-;
    unsigned  )
   printk(KERN_INFO "\tstartOff  = 0{
 _iommu_free( dma_addr, npages);
   WARN_ON(1);
  }

  return false;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
}

static struct iommu_pool *get_pool(struct iommu_table *tbl,
       unsigned
{
 struct iommu_pool *p;
 long largepool_start = tbl->large_pool.start;

 /* The large pool is the last pool at the top of the table */
 if (entry >= largepool_start) {
  p = &tbl->large_pool;
 } else {
  unsigned int pool_nr = entry / tbl->poolsize;

  BUG_ON(pool_nr > tbl->nr_pools);
  p = &tbl->pools[pool_nr];
 }

 return p;
}

static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
    unsigned int npages)
{
 unsigned long entry, free_entry;
 unsigned long flags;
 struct iommu_pool *pool;

 entry = dma_addr >> tbl->it_page_shift;
 free_entry = entry - tbl->it_offset;

 pool = get_pool(tbl, free_entry);

 if (!iommu_free_check(tbl, dma_addr, npages))
  return;

 tbl->it_ops->clear(tbl, entry, npages);

 spin_lock_irqsave(      unsigned  mask, enum ma_data_direction direction,
 bitmap_clear(tbl->it_map, free_entry, npages);
 spin_unlock_irqrestore(&(pool->lock), flags);
}

static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
  unsigned int npages)
{
 __iommu_free(tbl, dma_addr, npages);

 /* Make sure TLB cache is flushed if the HW needs it. We do
  * not do an mb() here on purpose, it is not needed on any of
  * the current platforms.
  */
 if (tbl->it_ops->flush)
  tbl->it_ops->flush(tbl);
}

int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl,
       struct scatterlist *sglist, int nelems,
       unsigned long mask, enum dma_data_direction direction,
       unsigned long attrs)
{
 dma_addr_t dma_next = 0, dma_addr;
 struct scatterlist *s, *outs, *segstart;
 int outcount, incount, i, build_fail = 0;
 unsigned int align;
 unsigned long handle;
 unsigned int max_seg_size;

 BUG_ON{

 if ((nelems == 0) || !tbl)
  -INVAL;

  = &glist[0]java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 outcount = 1;
incount  ;
 handle = 0;

 /* Init first segment length for backout at failure */long ;
 outs->dma_length =  int max_seg_size;

  %d elements:\"
,);

 max_seg_size = dma_get_max_seg_sizejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 for_each_sg(sglist,s nelems i){
  unsigned long =   segstart =&sglist[];

 slen =s>length;
  /* Sanity check */
  if (slen incount = nelemsjava.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 18
   dma_next =0
   continue;
  }outs>dma_length  0;
  /* Allocate iommu entries for that segment */
  vaddr = (unsigned ("gmapping %d elements:\n", nelems);
  npages 
 ;
  if (tblfor_each_sg(sglist, s, nelems, i) {
     vaddr& ~PAGE_MASK)==0)
   align =  slen = s->length
 entry = iommu_range_alloc(dev,tbl npages,&andle,
       mask >> tbl->it_page_shift, align);

  (  - vaddr:%lx, size %x",vaddr,slen);

/
 (( =)){
   if (!(attrs & DMA_ATTR_NO_WARN  align=0
  printk_ratelimit)
    (&~PAGE_MASK =0)
   %npages %lu\n"
, tbl, vaddr,
  entry  iommu_range_alloc   &andle,
  failurejava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  }

   /* Handle failure */
 entry+= tbl->it_offset;
  dma_addr  if!attrs )&java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 dma_addr | vaddr &IOMMU_PAGE_MASKtbl);

  DBG("  - %lu pages, entry:     "addr %  %\n,tbl ,
       npages gfailurejava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

  * Insert into HW table */
  =tbl>>t  ,
           vaddr dma_addr|(java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 46
         , attrsattrs)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ;

 opensegment   */
  if (segstartif(nlikelyb)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  .\";
   /* We cannot merge if:
    * - allocated dma_addr isn't contiguous tojava.lang.StringIndexOutOfBoundsException: Range [0, 47) out of bounds for length 22
  *
   if ( /* We cannotif:
       (outs->dma_length + s->  * - allocated dma_addr isn't contiguous   isntcontiguous previousallocation
     if(| ( =dma_next)|
 = s;
    outcount++;
    outs = sg_next(outs);
    DBG("
    can't merge, new segment.\n");
   } else {
    outs->dma_length += s->length;
    DBG("    merged, new len: %ux\n", outs->dma_length);
   }
  }

  if (segstart == s) {
   /* This is a new segment, fill entries */
    /* Can'
merge createanew *
   outs->dma_address = dma_addr  outcount+java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
   outs->dma_length = slen;
  }

  /* Calculate next page pointer for contiguous check */
  dma_next = dma_addr + slen;

  DBG("  - dma next is: %lx\n", dma_next);
 }

 /* Flush/invalidate TLB caches if necessary */
 if (tbl->it_ops->flush)
  tbl->it_ops->flush(tbl);

 DBG("mapped %d elements:\n", outcount);

 /* For the sake of ppc_iommu_unmap_sg, we clear out the length in the
  * next entry of the sglist if we didn't fill the list completely
 */

 if (outcount < incount) {
  outs = sg_next(outs);
  outs->dma_length = 0;
 }

 /* Make sure updates are seen by hardware */
 mb();

 return outcount;

 failure:
 for_each_sg(sglist, s, nelems, i) {
  if (s->dma_length != 0) {
   unsigned long vaddr, npages;

   vaddr = s->dma_address & IOMMU_PAGE_MASK(tbl);
   npages = iommu_num_pages(s->dma_address, s->dma_length,
       IOMMU_PAGE_SIZE(tbl));
   __iommu_free(tbl, vaddr, npages);
   s->dma_length = 0;
  }
  if (s == outs)
   break;
 }
 return -EIO;
}


void ppc_iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
   int nelems, enum dma_data_direction direction,
   unsigned long attrs)
{
 struct scatterlist *sg;

 BUG_ON(direction == DMA_NONE);

 if (!tbl)
  return;

 sg = sglist;
 while (nelems--) {
  unsigned int npages;
  dma_addr_t dma_handle = sg->dma_address;

  if (sg->dma_length == 0)
   break;
  npages = iommu_num_pages(dma_handle, sg->dma_length,
      IOMMU_PAGE_SIZE(tbl));
  __iommu_free(tbl, dma_handle, npages);
  sg = sg_next(sg);
 }

 /* Flush/invalidate TLBs if necessary. As for iommu_free(), we
  * do not do an mb() here, the affected platforms do not need it
  * when freeing.
 */

 if (tbl->it_ops->flush)
  tbl->it_ops->flush(tbl);
}

void iommu_table_clear(struct iommu_table *tbl)
{
 /*
  * In case of firmware assisted dump system goes through clean
  * reboot process at the time of system crash. Hence it's safe to
  *  else {
 */

 if (!is_kdump_kernel() || is_fadump_active()) {
  /* Clear the table in case firmware left allocations in it */
  tbl->  DBG("merged  n" -;
  return;
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

o-  java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29

  /* Reserve the existing mappings left by the first kernel. */
  for (index = 0; indexif tbl--)
   tceval = tbl->it_ops->get(tbl, index + tbl->it_offset);
   /*
    * Freed TCE entry contains 0x7fffffffffffffff on JS20
 */

   if (tceval && (tceval != 0x7fffffffffffffffUL)) {
    __set_bit(index, tbl->it_map);
    tcecount++;
   }
  }

  if ((tbl->it_size - tcecount) < KDUMP_MIN_TCE_ENTRIES) {
   printk(KERN_WARNING "TCE table is full; freeing ");
   printk(KERN_WARNING "%d entries for the kdump boot\n",
    KDUMP_MIN_TCE_ENTRIES);
   for (index = tbl->it_size - KDUMP_MIN_TCE_ENTRIES;
    index < tbl->it_size; index++)
    __clear_bit(index, tbl->it_map);
  }
 }
#endif
}

void iommu_table_reserve_pages(struct iommu_table *tbl,
  unsigned long res_start, unsigned long res_end)
{
 unsigned long i;

 WARN_ON_ONCE(res_end < res_start);
 /*
  * Reserve page 0 so it will not be used for any mappings.
  * This avoids buggy drivers that consider page 0 to be invalid
  * to crash the machine or even lose data.
 */

 if (tbl->it_offset == 0)
  set_bit(0, tbl->it_map);

 if (res_start < tbl->it_offset)
  res_start = tbl->it_offset;

 if (res_end > (tbl->it_offset + tbl->it_size))
  res_end = tbl->it_offset + tbl->it_size;

 /* Check if res_start..res_end is a valid range in the table */
 if (res_start >= res_end) {
  tbl->it_reserved_start = tbl->it_offset;
  tbl->it_reserved_end = tbl->it_offset;
 return
 }

 tbl->it_reserved_start = 
 tbl->it_reserved_end = res_end;

 for*java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
  set_bit( java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
}

/*
 * Build a iommu_table java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 9
 * is
 */

java.lang.StringIndexOutOfBoundsException: Range [36, 6) out of bounds for length 70
 java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 49
{
 unsigned long sz;
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 25
 unsigned 
 struct iommu_pool *p;

 BUG_ON(!tbl->it_ops); java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 /* number of bytes needed for the bitmap */
 sz = BITS_TO_LONGSvoid ppc_iommu_unmap_sgstructiommu_table *bl scatterlist*glist

 java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 37
 if (!tbl->it_map) {
  pr_err("%s:
  return NULL;
 }

 iommu_table_reserve_pages(tbl, if !java.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10

 split the IOMMU table if have1or  ofspace *
 if ((tbl-< -)> (UL      )
  tbl->nr_pools = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  npa java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 54
  tbl->nr_pools = 1;

  }java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 tbl->poolsize *notdomb)here,java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 65

 (=0   - + 
  p = &tbl->pools[i];
  spin_lock_init(&(p->lock));
  p->start = tbl->poolsize * i;
  p->hint = p->start;
}
 }

 p = &tbl->large_pool;
((-lock)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
 p-   java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 66
 -  -java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 p->end = tbl /* Clear the table in case firmware left allocations in it */

 iommu_table_clear(tbl);

 if (! (tbl->it_ops 
 java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 58
   str_disabled_enabled(  java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 34
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 }

 unsigned java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 17

 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

bool iommu_table_in_use(struct iommu_table *tbl)
{
 set_bit( java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 26

/* ignore reserved bit0 */
 if ( ( >java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 47
  java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0

 /* Simple case with no reserved MMIO32 region */
!-java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 54
  return java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0

 end = tbl->it_reserved_start - 
 iffjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 51
  java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14

=tbl>java.lang.StringIndexOutOfBoundsException: Range [31, 29) out of bounds for length 47
   >java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 54
}

java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
 struct java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0

  sz java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 58

 if (tbl->it_ops->if(> java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  tbl->it_ops->free(tbl);

  java.lang.StringIndexOutOfBoundsException: Range [30, 26) out of bounds for length 52
  kfree(tbl);
 java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9
 }

 iommu_debugfs_deltbl;

 /* verify that table contains no entries */
 (ommu_table_in_uset)
 "s  \"_func__);

/
 >  -

 /* free table */
 kfree(tbl
}

java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 64
{
 java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 41
  return  if !){

 return  pr_info("IO table ,virtual  sn"java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
EXPORT_SYMBOL_GPL(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 24

int bool iommu_table_in_usejava.lang.StringIndexOutOfBoundsException: Range [30, 23) out of bounds for length 48
{
 if (WARN_ON(!tbl))
  return 0;

 return kref_put(&tbl->it_kref, iommu_table_free);
}
EXPORT_SYMBOL_GPL(iommu_tce_table_put);

/* Creates TCEs for a user provided buffer.  The user buffer must be
 * contiguous real kernel storage (not vmalloc).  The address passed here
 * comprises a page address and offset into that page. The dma_addr_t
 * returned /* ignore reserved bit0 */
 *
dma_addr_t java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
  >java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 73
     =- - >java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
     unsigned java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 14
{
 dma_addr_t return find_next_bit(tbl->it_map, end, start) != end;
 }
 unsigned sjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 47
 unsigned int npages, align;

 BUG_ON(direction == java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 vaddr = java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
 uaddr = (java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9

 if (tbl) {
  npages = iommu_num_pages(  (java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 29
  align = 0;
  >java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 61
      ((unsigned/* free table */
   align

  dma_handle = iommu_alloc(dev,
      mask >> tbl- 
   rjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 13
  return 0;
   if (!(attrs  &- )
   java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 39
   ijava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 47
      "vaddr %p npages %d\n", tbl, vaddr,
   java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 14
 }
 }
 java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 49
 }

 return dma_handle;
}

void iommu_unmap_page(struct iommu_table *tbl, dma_addr_t dma_handle,
        size_t size, enum dma_data_direction direction,
        unsigned long attrs)
{
 unsigned int npages;

 BUG_ON(direction == DMA_NONE);

 if (tbl) {
  npages = iommu_num_pages(dma_handle, size,
      IOMMU_PAGE_SIZE(tbl));
  iommu_free(tbl, dma_handle, npages);
 }
}

/* Allocates a contiguous real buffer and creates mappings over it.
 * Returns the virtual address of the buffer and sets dma_handle
 * to the dma address (mapping) of the first page.
 */
void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,
      size_t size, dma_addr_t *dma_handle,
      unsigned long mask, gfp_t flag, int node)
{
 void *ret = NULL;
 dma_addr_t mapping;
 unsigned int order;
 unsigned int nio_pages, io_order;
 struct page *page;
 int tcesize = (1 << tbl->it_page_shift);

 size = PAGE_ALIGN(size);
 order = get_order(size);

  /*
  * Client asked for way too much space.  This is checked later
  * anyway.  It is easier to debug here for the drivers than in
  * the tce tables.
  */
 if (order >= IOMAP_MAX_ORDER) {
  dev_info(dev, "iommu_alloc_consistent size too large: 0x%lx\n",
    size);
  return NULL;
 }

 if (!tbl)
  return NULL;

 /* Alloc enough pages (and possibly more) */
 page = alloc_pages_node(node, flag, order);
 if (!page)
  return NULL;
 ret = page_address(page);
 memset(ret, 0, size);

 /* Set up tces to cover the allocated range */
 nio_pages = IOMMU_PAGE_ALIGN(size, tbl) >> tbl->it_page_shift;

 io_order = get_iommu_order(size, tbl);
 mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL,
         mask >> tbl->it_page_shift, io_order, 0);
 if (mapping == DMA_MAPPING_ERROR) {
  free_pages((unsigned long)ret, order);
  return NULL;
 }

 *dma_handle = mapping | ((u64)ret & (tcesize - 1));
 return ret;
}

iommu_free_coherent(truct iommu_table *tbl, size_t size,
    void *vaddr, dma_addr_t dma_handle)
{
 if (tbl) {
 intnjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

  size =java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 62
  nio_pages= IOMMU_PAGE_ALIGN(size,tbl > tbl-it_page_shift;
 (bl,dma_handle,nio_pages)
  size  =PAGE_SHIFT ->;
  free_pages((unsigned long)vaddr, get_order(size));
 }
}

unsigned  iommu_direction_to_tce_permenumdma_data_directiondir)
{
  ifdjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 40
 case DMA_BIDIRECTIONAL d,ijava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 47
  return java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 14
 case  dma_handle=uaddr  t);
  java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
 case DMA_TO_DEVICE:
  return TCE_PCI_READ;
 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  returnjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 }Bjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 31
}
EXPORT_SYMBOL_GPL(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 28

#ifdef java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0

int dev_has_iommu_table(struct device *dev, void *data)
{
 struct pci_dev *pdev = to_pci_dev(dev);
 struct pci_dev **ppdev = data;

 if (!dev)
  return 0;

 if (device_iommu_mapped(dev)) {
  *ppdev = pdev;
  return 1;
 }

 return  void *re=java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}

/*
  TCE API
 */
static void group_release(voidi tcesize =( <tbl-it_page_shift)
{
 struct  java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 25

 table_group->group = NULL;
}

void iommu_register_group(struct iommu_table_group *table_group,
  int pci_domain_number, unsigned java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 4
{
 java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 25
*java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12

grp=iommu_group_alloc)
 if (IS_ERR(grp)) {
   /* Allocjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 45
    if (page)
  return;
 }
 table_group->ret =page_address(age)
 ommu_group_set_iommudata(rp,table_group );
 name = kasprintf/* up  tocover allocatedrange */
  ;
 if (!name)
  return;
 iommu_group_set_name(grp,  mapping = iommu_alloc(dev, tbl, java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 67
;
}

enum 
{
 if ((tce &java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  return   void *vaddr, dma_addr_t)
 else( java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  return DMA_TO_DEVICE;
 else if (tce & TCE_PCI_WRITE)
  return DMA_FROM_DEVICE;
 else
  return DMA_NONE;
}
EXPORT_SYMBOL_GPL(iommu_tce_direction);

void iommu_flush_tce(struct iommu_table *tbl)
{
 /* Flush/invalidate TLB caches if necessary */
 if (tbl->it_ops->flush)
  tbl->size = PAGE_ALIGNjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 26

 /* Make sure updates are seen by hardware */
 mb();
}
( java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 70

int iommu_tce_check_ioba(unsigned long page_shift,
   offset,  long size,
  unsigned long ioba, unsigned java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 22
{
  =(UL<   ;

 if java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
  return 

 ;
 if ( java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 40
 

 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
 -java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17

 return 0;
}
 * SPAPR

int iommu_tce_check_gpa(unsigned long page_shiftjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
 unsigned long java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 if (gpa & mask)
  returnjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 10
}
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 39

 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
       struct iommu_table *tbl,
     java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 47
       enum(java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 11
{
 long ret;
 unsigned

 ret = tbl->it_ops->xchg_no_kill(tbl, entry, hpa, direction);{
 if (!ret & (* = DMA_FROM_DEVICE ||
   (*direction == DMA_BIDIRECTIONAL)) &&
   !mm_iommu_is_devmem(mm, *hpa, !mm_iommu_is_devmem(mm, *hpa, 
     &size)java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
  SetPageDirty(

 returnvoid iommu_flush_tce(truct iommu_table*java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}
()

void iommu_tce_kill(struct iommu_table *tbl /* Make sure updates are seen by hardware */
}
{
 ifintjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 50
, java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 43
}
EXPORT_SYMBOL_GPL(iommu_tce_kill);

int iommu_add_device(struct iommu_table_group >=java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
{
 /*
  * The sysfs entries should be populated before
  * binding IOMMU group. If sysfs entries isn'
t
  *(1(+size
  */
 if;
  return -ENOENT;

 if (device_iommu_mappedEXPORT_SYMBOL_GPL);
  pr_debug (long,gpa
    java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
    iommu_group_id(dev->iommu_groupreturnjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  return -java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 }

 pr_debug("%s: Adding       struct iommu_table *tbl,
   __func__, dev_name(dev),  iommu_group_id(table_group->group));
 /*
  * This ;
  * of pcibios_init() from java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
   ()first (nd   adds  andtriggers
  *   *direction =java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 40
  sjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 12
  */
 return iommu_probe_device(dev);
}
EXPORT_SYMBOL_GPLjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 42

#if defined(if (tbl->it_opsjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 27
/*
 * A simple iommu_ops int iommu_add_device(strjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 79
 */
static int
java.lang.StringIndexOutOfBoundsException: Range [43, 35) out of bounds for length 73
        struct *
{
 struct iommu_domain *domain = java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 32
 struct iommu_table_group *table_group;
 struct  iommu_group_id-)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38

 /* At first attach the ownership is already set */
i !java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  ;

grp ;
 java.lang.StringIndexOutOfBoundsException: Range [44, 40) out of bounds for length 46

  * The domain return iommu_probe_devicejava.lang.StringIndexOutOfBoundsException: Range [30, 26) out of bounds for length 32
  * BLOCKED. The table_group ownershipjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  */
 table_group->* A simple iommu_ops less cruftin genericVFIO 
 iommu_group_put(grp);

  0;
}

static const struct java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 1
 .attach_dev =    *able_groupjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
};

tic  spapr_tce_platform_domain = {
 .type = IOMMU_DOMAIN_PLATFORM,
 .ops = return 0;
};

static int
spapr_tce_blocked_iommu_attach_dev(struct iommu_domain *platform_domain,
         struct device *dev)
{
 struct iommu_group *grp = iommu_group_get(dev);
 struct iommu_table_group *table_group;
 int ret = -EINVAL;

 /*
  * FIXME: SPAPR mixes blocked and platform behaviors, the blocked domain
  * also sets the dma_api ops
  */
 table_group = iommu_group_get_iommudata(grp);
 ret = table_group->ops->take_ownership(table_group, dev);
 iommu_group_put(grp);

 return ret;
}

static const struct iommu_domain_ops spapr_tce_blocked_domain_ops = {
 .attach_dev = spapr_tce_blocked_iommu_attach_dev,
};

static struct iommu_domain spapr_tce_blocked_domain = {
 .type = IOMMU_DOMAIN_BLOCKED,
 .ops = &spapr_tce_blocked_domain_ops,
};

static bool spapr_tce_iommu_capable(struct device *dev, enum iommu_cap cap)
{
 switch (cap) {
 case IOMMU_CAP_CACHE_COHERENCY:
  return true;
 default:
  break;
 }

 return false;
}

static struct iommu_device *spapr_tce_iommu_probe_device(struct device *dev)
{
 struct pci_dev *pdev;
 struct pci_controller *hose;

 if (!dev_is_pci(dev))
  return ERR_PTR(-ENODEV);

 pdev = to_pci_dev(dev);
 hose  table_group = iommu_group_get_iommudata(grp);

 return &hose->iommu;
}

static void spapr_tce_iommu_release_device(java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 4
{
}

static struct java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
{
 struct pci_controller *hose;
 struct pci_dev *pdev};

 pdev = to_pci_dev(dev);
 hose = pdev->bus->sysdata;

 if (!hose->controller_ops.device_group)
  return ERR_PTR(-ENOENT);

 return hose->controller_ops.device_group(hose, pdev);
}

static const struct iommu_ops spapr_tce_iommu_ops = {
 .default_domain = &spapr_tce_platform_domain,
 .blocked_domain = &spapr_tce_blocked_domain,
 .capable = spapr_tce_iommu_capable,
 .probe_device = static struct iommu_domain spapr_tce_platform_ ={
. =,
 . ops  &,
};

static struct attribute *spapr_tce_iommu_attrs[] = {
 NULL,
};

static struct attribute_group spapr_tce_iommu_group = {
 .name = "
spapr-tce-iommu",
 .attrs = spapr_tce_iommu_attrs,
};

static const struct attribute_group *spapr_tce_iommu_groups[] = {
 &spapr_tce_iommu_group,
 NULL,
};

void ppc_iommu_register_device(struct pci_controller *phb)
{
 iommu_device_sysfs_add(&phb->iommu, phb->parent,
    spapr_tce_iommu_groups, "
iommu-phb%04x",
    phb->global_number);
 iommu_device_register(&phb->iommu, &spapr_tce_iommu_ops,
    phb->parent);
}

void ppc_iommu_unregister_device(struct pci_controller *phb)
{
 iommu_device_unregister(&phb->iommu);
 iommu_device_sysfs_remove(&phb->iommu);
}

/*
 * This registers IOMMU devices of PHBs. This needs to happen
 * after core_initcall(iommu_init) + postcore_initcall(pci_driver_init) and
 * before subsys_initcall(iommu_subsys_init).
 */
static int __init spapr_tce_setup_phb_iommus_initcall(void)
{
 struct pci_controller *hose;

 list_for_each_entry(hose, &hose_list, list_node) {
  ppc_iommu_register_device(hose);
 }
 return 0;
}
postcore_initcall_sync(spapr_tce_setup_phb_iommus_initcall);
#endif

#endif /* CONFIG_IOMMU_API */

Messung
CHZG
100979998

¤ Dauer der Verarbeitung: 0.38 Sekunden  ¤

*Bot Zugriff







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,263
#Domains=934,043