Skip to content
  • Alexey Kardashevskiy's avatar
    powerpc: Prepare to support kernel handling of IOMMU map/unmap · 8e0861fa
    Alexey Kardashevskiy authored
    
    
    The current VFIO-on-POWER implementation supports only user mode
    driven mapping, i.e. QEMU is sending requests to map/unmap pages.
    However this approach is really slow, so we want to move that to KVM.
    Since H_PUT_TCE can be extremely performance sensitive (especially with
    network adapters where each packet needs to be mapped/unmapped) we chose
    to implement that as a "fast" hypercall directly in "real
    mode" (processor still in the guest context but MMU off).
    
    To be able to do that, we need to provide some facilities to
    access the struct page count within that real mode environment as things
    like the sparsemem vmemmap mappings aren't accessible.
    
    This adds an API function realmode_pfn_to_page() to get page struct when
    MMU is off.
    
    This adds to MM a new function put_page_unless_one() which drops a page
    if counter is bigger than 1. It is going to be used when MMU is off
    (for example, real mode on PPC64) and we want to make sure that page
    release will not happen in real mode as it may crash the kernel in
    a horrible way.
    
    CONFIG_SPARSEMEM_VMEMMAP and CONFIG_FLATMEM are supported.
    
    Cc: linux-mm@kvack.org
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Reviewed-by: default avatarPaul Mackerras <paulus@samba.org>
    Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
    Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
    Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
    8e0861fa