linux_dsm_epyc7002/arch/powerpc/include/asm
Alexey Kardashevskiy 2157e7b82f vfio: powerpc/spapr: Register memory and define IOMMU v2
The existing implementation accounts the whole DMA window in
the locked_vm counter. This is going to be worse with multiple
containers and huge DMA windows. Also, real-time accounting would requite
additional tracking of accounted pages due to the page size difference -
IOMMU uses 4K pages and system uses 4K or 64K pages.

Another issue is that actual pages pinning/unpinning happens on every
DMA map/unmap request. This does not affect the performance much now as
we spend way too much time now on switching context between
guest/userspace/host but this will start to matter when we add in-kernel
DMA map/unmap acceleration.

This introduces a new IOMMU type for SPAPR - VFIO_SPAPR_TCE_v2_IOMMU.
New IOMMU deprecates VFIO_IOMMU_ENABLE/VFIO_IOMMU_DISABLE and introduces
2 new ioctls to register/unregister DMA memory -
VFIO_IOMMU_SPAPR_REGISTER_MEMORY and VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY -
which receive user space address and size of a memory region which
needs to be pinned/unpinned and counted in locked_vm.
New IOMMU splits physical pages pinning and TCE table update
into 2 different operations. It requires:
1) guest pages to be registered first
2) consequent map/unmap requests to work only with pre-registered memory.
For the default single window case this means that the entire guest
(instead of 2GB) needs to be pinned before using VFIO.
When a huge DMA window is added, no additional pinning will be
required, otherwise it would be guest RAM + 2GB.

The new memory registration ioctls are not supported by
VFIO_SPAPR_TCE_IOMMU. Dynamic DMA window and in-kernel acceleration
will require memory to be preregistered in order to work.

The accounting is done per the user process.

This advertises v2 SPAPR TCE IOMMU and restricts what the userspace
can do with v1 or v2 IOMMUs.

In order to support memory pre-registration, we need a way to track
the use of every registered memory region and only allow unregistration
if a region is not in use anymore. So we need a way to tell from what
region the just cleared TCE was from.

This adds a userspace view of the TCE table into iommu_table struct.
It contains userspace address, one per TCE entry. The table is only
allocated when the ownership over an IOMMU group is taken which means
it is only used from outside of the powernv code (such as VFIO).

As v2 IOMMU supports IODA2 and pre-IODA2 IOMMUs (which do not support
DDW API), this creates a default DMA window for IODA2 for consistency.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[aw: for the vfio related changes]
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2015-06-11 15:16:55 +10:00
..
8xx_immap.h
agp.h
archrandom.h KVM: PPC: Book3S HV: Add fast real-mode H_RANDOM implementation. 2015-04-21 15:21:29 +02:00
asm-compat.h ppc: bpf: add required compatibility macros for jit 2015-02-20 15:19:43 -05:00
asm-offsets.h
async_tx.h
atomic.h
backlight.h
barrier.h arch: Add lightweight memory barriers dma_rmb() and dma_wmb() 2014-12-11 21:15:06 -05:00
bitops.h powerpc: Fix comment typos in arch/powerpc/include/asm/bitops.h 2014-11-12 16:31:46 +11:00
bootx.h
btext.h
bug.h
bugs.h
cache.h powerpc: Remove duplicate cacheable_memcpy/memzero functions 2015-03-17 11:25:50 +11:00
cacheflush.h mm/debug_pagealloc: fix build failure on ppc and some other archs 2015-02-05 13:35:30 -08:00
cell-pmu.h
cell-regs.h
checksum.h
cmpxchg.h
code-patching.h
compat.h
context_tracking.h
copro.h
cpm1.h
cpm2.h
cpm.h
cpuidle.h powernv/cpuidle: Redesign idle states management 2014-12-15 10:46:40 +11:00
cputable.h powerpc/book3s: Fix flush_tlb cpu_spec hook to take a generic argument. 2015-03-17 07:52:48 +11:00
cputhreads.h powerpc: Fix cpu_online_cores_map to return only online threads mask 2015-05-22 15:12:30 +10:00
cputime.h Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu 2014-10-15 07:48:18 +02:00
current.h
dbdma.h powerpc: Move Power Macintosh drivers to generic byteswappers 2015-03-23 14:29:40 +11:00
dbell.h
dcr-generic.h
dcr-mmio.h
dcr-native.h powerpc: Use bool function return values of true/false not 1/0 2015-03-31 14:19:47 +11:00
dcr-regs.h
dcr.h
debug.h
delay.h
device.h powerpc: Add cxl context to device archdata 2015-06-03 13:27:16 +10:00
disassemble.h
dma-mapping.h powerpc: Use bool function return values of true/false not 1/0 2015-03-31 14:19:47 +11:00
dma.h
edac.h
eeh_event.h
eeh.h powerpc/eeh: Introduce eeh_pe_inject_err() 2015-05-12 20:33:35 +10:00
ehv_pic.h
elf.h mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE 2015-04-14 16:49:05 -07:00
emergency-restart.h
emulated_ops.h
epapr_hcalls.h
exception-64e.h
exception-64s.h
exec.h
fadump.h powerpc/fadump: Fix endianess issues in firmware assisted dump handling 2014-10-30 16:52:46 +11:00
fb.h
feature-fixups.h
firmware.h powerpc: Remove the celleb support 2015-04-07 17:15:13 +10:00
fixmap.h
floppy.h
fs_pd.h
fsl_85xx_cache_sram.h
fsl_gtm.h
fsl_guts.h powerpc/fsl: Added rcw registers to global utility registers 2014-11-07 18:10:47 -06:00
fsl_hcalls.h
fsl_lbc.h uio: uio_fsl_elbc_gpcm: new driver 2015-01-12 05:04:13 -08:00
fsl_pamu_stash.h iommu/fsl: Various cleanups 2015-02-03 18:47:18 +01:00
ftrace.h
futex.h
gpio.h
grackle.h
hardirq.h powerpc: Replace __get_cpu_var uses 2014-11-03 12:12:32 +11:00
heathrow.h
highmem.h
hugetlb.h powerpc/mm: Switch to generic RCU get_user_pages_fast 2014-11-14 17:24:21 +11:00
hvcall.h
hvconsole.h
hvcserver.h
hvsi.h
hw_breakpoint.h
hw_irq.h
hydra.h
i8259.h
ibmebus.h
ide.h
immap_cpm2.h
immap_qe.h
io_event_irq.h
io-defs.h
io-workarounds.h
io.h powerpc updates for 3.19 2014-12-11 17:48:14 -08:00
iommu.h vfio: powerpc/spapr: Register memory and define IOMMU v2 2015-06-11 15:16:55 +10:00
ipic.h
irq_work.h powerpc: Re-enable dynticks 2015-02-23 14:52:04 +11:00
irq.h
irqflags.h
jump_label.h
Kbuild powerpc: use kbuild generic-y where possible 2015-03-23 15:09:44 +11:00
kdebug.h
kdump.h
kexec.h powerpc/kdump: Ignore failure in enabling big endian exception during crash 2014-12-29 15:44:53 +11:00
keylargo.h
kgdb.h
kmap_types.h
kprobes.h powerpc/kprobes: Fix kallsyms lookup across powerpc ABIv1 and ABIv2 2015-01-23 14:02:51 +11:00
kvm_asm.h
kvm_book3s_32.h
kvm_book3s_64.h powerpc fixes for 4.1 2015-04-26 13:23:15 -07:00
kvm_book3s_asm.h
kvm_book3s.h This mostly includes the PPC changes for 4.1, which this time cover 2015-04-26 13:06:22 -07:00
kvm_booke_hv_asm.h
kvm_booke.h
kvm_fpu.h
kvm_host.h This mostly includes the PPC changes for 4.1, which this time cover 2015-04-26 13:06:22 -07:00
kvm_para.h
kvm_ppc.h KVM: PPC: Book3S HV: Add fast real-mode H_RANDOM implementation. 2015-04-21 15:21:29 +02:00
libata-portmap.h
linkage.h
local.h
lppaca.h
lv1call.h
machdep.h powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table 2015-06-11 15:14:56 +10:00
macio.h
mc146818rtc.h
mce.h
mediabay.h
mman.h
mmu_context.h powerpc/mmu: Add userspace-to-physical addresses translation cache 2015-06-11 15:16:54 +10:00
mmu-8xx.h powerpc/8xx: Implement 16k pages 2014-11-07 18:10:42 -06:00
mmu-40x.h
mmu-44x.h
mmu-book3e.h
mmu-hash32.h
mmu-hash64.h powerpc/mmu: Add userspace-to-physical addresses translation cache 2015-06-11 15:16:54 +10:00
mmu.h
mmzone.h
module.h
mpc5xxx.h
mpc6xx.h
mpc52xx_psc.h
mpc52xx.h
mpc85xx.h powerpc/fsl-booke: Add T4080 SVR value 2015-03-31 22:23:17 -05:00
mpc5121.h
mpc8260.h
mpic_msgr.h
mpic_timer.h
mpic.h powerpc/mpic: Add get_version API both for internal and external use 2015-03-23 19:51:17 -05:00
msi_bitmap.h
mutex.h
nmi.h powerpc: Add ppc64 hard lockup detector support 2015-04-11 20:49:27 +10:00
nvram.h powerpc/nvram: Move generic code for nvram and pstore 2015-03-23 14:05:49 +11:00
ohare.h
opal-api.h powerpc/powernv: Add opal-prd channel 2015-06-05 08:32:21 +10:00
opal.h powerpc/powernv: Add opal-prd channel 2015-06-05 08:32:21 +10:00
oprofile_impl.h
paca.h powerpc: book3e_64: fix the align size for paca_struct 2015-03-31 22:23:17 -05:00
page_32.h
page_64.h
page.h powerpc: Make STRICT_MM_TYPECHECKS a config option 2015-05-11 19:53:59 +10:00
parport.h
pasemi_dma.h
pci-bridge.h powerpc/spapr: vfio: Replace iommu_table with iommu_table_group 2015-06-11 15:14:57 +10:00
pci.h powerpc: Remove shims for pci_controller_ops operations 2015-04-11 20:49:18 +10:00
percpu.h
perf_event_fsl_emb.h
perf_event_server.h
perf_event.h powerpc: Rename __get_SP() to current_stack_pointer() 2014-10-15 11:23:20 +11:00
pgalloc-32.h
pgalloc-64.h
pgalloc.h mmu_gather: move minimal range calculations into generic code 2014-11-17 10:12:42 +00:00
pgtable-ppc32.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pgtable-ppc64-4k.h powerpc/mm: Add missing pmd accessors 2014-11-14 17:24:21 +11:00
pgtable-ppc64-64k.h powerpc/mm: Add missing pmd accessors 2014-11-14 17:24:21 +11:00
pgtable-ppc64.h powerpc: Make STRICT_MM_TYPECHECKS a config option 2015-05-11 19:53:59 +10:00
pgtable.h powerpc/mm/thp: Make page table walk safe against thp split/collapse 2015-04-17 11:23:39 +10:00
plpar_wrappers.h
pmac_feature.h
pmac_low_i2c.h
pmac_pfunc.h
pmc.h
pmi.h
pnv-pci.h cxl: Move include file cxl.h -> cxl-base.h 2015-06-03 13:27:19 +10:00
ppc4xx_ocm.h
ppc4xx.h
ppc_asm.h powerpc: Change vsrX register defines to vsX to match gcc and glibc 2015-03-16 18:32:11 +11:00
ppc-opcode.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-04-02 16:16:53 -04:00
ppc-pci.h powerpc: move find_and_init_phbs() to pSeries specific code 2015-04-11 20:49:09 +10:00
probes.h
processor.h powerpc/dscr: Add some in-code documentation 2015-06-07 19:29:15 +10:00
prom.h
ps3.h
ps3av.h
ps3gpu.h
ps3stor.h
pte-8xx.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pte-40x.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pte-44x.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pte-book3e.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pte-common.h mm: remove remaining references to NUMA hinting bits and helpers 2015-02-12 18:54:08 -08:00
pte-fsl-booke.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pte-hash32.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
pte-hash64-4k.h
pte-hash64-64k.h
pte-hash64.h powerpc: drop _PAGE_FILE and pte_file()-related helpers 2015-02-16 17:56:05 -08:00
ptrace.h
qe_ic.h
qe.h
reg_8xx.h
reg_a2.h
reg_booke.h
reg_fsl_emb.h
reg.h powerpc/powernv: Fixes for hypervisor doorbell handling 2015-03-20 14:51:53 +11:00
rheap.h
rio.h
rtas.h Merge branch 'next-dlpar' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc into next 2015-04-13 15:30:21 +10:00
rtc.h
runlatch.h
scom.h
seccomp.h powerpc: switch to using asm-generic for seccomp.h 2015-04-17 09:04:10 -04:00
sections.h
serial.h
setjmp.h
setup.h powerpc: Replace mem_init_done with slab_is_available() 2015-04-10 20:02:48 +10:00
sfp-machine.h
shmparam.h
signal.h
smp.h powerpc: Drop return value of smp_ops->probe() 2015-04-10 20:02:49 +10:00
smu.h powerpc: Fix comment in smu.h 2015-03-06 23:21:07 +01:00
sparsemem.h
spinlock_types.h
spinlock.h
spu_csa.h
spu_info.h
spu_priv1.h
spu.h
sstep.h
string.h
swab.h powerpc: Remove unused st_le*() and ld_le* functions 2015-03-24 13:33:52 +11:00
swiotlb.h
switch_to.h
synch.h
syscall.h powerpc: add little endian flag to syscall_get_arch() 2014-12-12 20:14:08 +11:00
syscalls.h
systbl.h powerpc: Enable sys_kcmp() for CRIU 2015-05-20 10:42:05 +10:00
tce.h
termios.h
thread_info.h arch: Remove exec_domain from remaining archs 2015-04-12 21:03:30 +02:00
time.h KVM: PPC: Book3S HV: Accumulate timing information for real-mode code 2015-04-21 15:21:31 +02:00
timex.h
tlb.h mmu_gather: move minimal range calculations into generic code 2014-11-17 10:12:42 +00:00
tlbflush.h powerpc/mm: don't do tlbie for updatepp request with NO HPTE fault 2014-12-05 16:26:15 +11:00
tm.h
topology.h
trace.h powerpc/mm: Add trace point for tracking hash pte fault 2015-06-10 14:06:29 +10:00
tsi108_irq.h
tsi108_pci.h
tsi108.h
types.h
uaccess.h powerpc/uaccess: Allow get_user() with bitwise types 2014-12-18 19:11:09 +11:00
ucc_fast.h
ucc_slow.h powerpc/qe: drop unused ucc_slow_poll_transmitter_now 2015-03-16 18:50:17 +11:00
ucc.h
udbg.h
uic.h
unaligned.h
uninorth.h
unistd.h powerpc: Add a proper syscall for switching endianness 2015-03-28 22:03:40 +11:00
uprobes.h
user.h
vdso_datapage.h
vdso.h
vga.h powerpc: Move Power Macintosh drivers to generic byteswappers 2015-03-23 14:29:40 +11:00
vio.h
word-at-a-time.h
xics.h powerpc: Drop return value of smp_ops->probe() 2015-04-10 20:02:49 +10:00
xilinx_intc.h
xilinx_pci.h
xmon.h
xor.h