13 Jan, 2012

1 commit


11 Jan, 2012

1 commit

  • * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (53 commits)
    iommu/amd: Set IOTLB invalidation timeout
    iommu/amd: Init stats for iommu=pt
    iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume
    iommu/amd: Add invalidate-context call-back
    iommu/amd: Add amd_iommu_device_info() function
    iommu/amd: Adapt IOMMU driver to PCI register name changes
    iommu/amd: Add invalid_ppr callback
    iommu/amd: Implement notifiers for IOMMUv2
    iommu/amd: Implement IO page-fault handler
    iommu/amd: Add routines to bind/unbind a pasid
    iommu/amd: Implement device aquisition code for IOMMUv2
    iommu/amd: Add driver stub for AMD IOMMUv2 support
    iommu/amd: Add stat counter for IOMMUv2 events
    iommu/amd: Add device errata handling
    iommu/amd: Add function to get IOMMUv2 domain for pdev
    iommu/amd: Implement function to send PPR completions
    iommu/amd: Implement functions to manage GCR3 table
    iommu/amd: Implement IOMMUv2 TLB flushing routines
    iommu/amd: Add support for IOMMUv2 domain mode
    iommu/amd: Add amd_iommu_domain_direct_map function
    ...

    Linus Torvalds
     

09 Jan, 2012

1 commit


27 Dec, 2011

14 commits


26 Dec, 2011

1 commit

  • Only allow KVM device assignment to attach to devices which:

    - Are not bridges
    - Have BAR resources (assume others are special devices)
    - The user has permissions to use

    Assigning a bridge is a configuration error, it's not supported, and
    typically doesn't result in the behavior the user is expecting anyway.
    Devices without BAR resources are typically chipset components that
    also don't have host drivers. We don't want users to hold such devices
    captive or cause system problems by fencing them off into an iommu
    domain. We determine "permission to use" by testing whether the user
    has access to the PCI sysfs resource files. By default a normal user
    will not have access to these files, so it provides a good indication
    that an administration agent has granted the user access to the device.

    [Yang Bai: add missing #include]
    [avi: fix comment style]

    Signed-off-by: Alex Williamson
    Signed-off-by: Yang Bai
    Signed-off-by: Marcelo Tosatti

    Alex Williamson
     

25 Dec, 2011

1 commit


10 Nov, 2011

1 commit

  • When mapping a memory region, split it to page sizes as supported
    by the iommu hardware. Always prefer bigger pages, when possible,
    in order to reduce the TLB pressure.

    The logic to do that is now added to the IOMMU core, so neither the iommu
    drivers themselves nor users of the IOMMU API have to duplicate it.

    This allows a more lenient granularity of mappings; traditionally the
    IOMMU API took 'order' (of a page) as a mapping size, and directly let
    the low level iommu drivers handle the mapping, but now that the IOMMU
    core can split arbitrary memory regions into pages, we can remove this
    limitation, so users don't have to split those regions by themselves.

    Currently the supported page sizes are advertised once and they then
    remain static. That works well for OMAP and MSM but it would probably
    not fly well with intel's hardware, where the page size capabilities
    seem to have the potential to be different between several DMA
    remapping devices.

    register_iommu() currently sets a default pgsize behavior, so we can convert
    the IOMMU drivers in subsequent patches. After all the drivers
    are converted, the temporary default settings will be removed.

    Mainline users of the IOMMU API (kvm and omap-iovmm) are adopted
    to deal with bytes instead of page order.

    Many thanks to Joerg Roedel for significant review!

    Signed-off-by: Ohad Ben-Cohen
    Cc: David Brown
    Cc: David Woodhouse
    Cc: Joerg Roedel
    Cc: Stepan Moskovchenko
    Cc: KyongHo Cho
    Cc: Hiroshi DOYU
    Cc: Laurent Pinchart
    Cc: kvm@vger.kernel.org
    Signed-off-by: Joerg Roedel

    Ohad Ben-Cohen
     

01 Nov, 2011

2 commits

  • This file has things like module_param_named() and MODULE_PARM_DESC()
    so it needs the full module.h header present. Without it, you'll get:

    CC arch/x86/kvm/../../../virt/kvm/iommu.o
    virt/kvm/iommu.c:37: error: expected ‘)’ before ‘bool’
    virt/kvm/iommu.c:39: error: expected ‘)’ before string constant
    make[3]: *** [arch/x86/kvm/../../../virt/kvm/iommu.o] Error 1
    make[2]: *** [arch/x86/kvm] Error 2

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     
  • This was coming in via an implicit module.h (and its sub-includes)
    before, but we'll be cleaning that up shortly. Call out the stat.h
    include requirement in advance.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

31 Oct, 2011

2 commits

  • * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (33 commits)
    iommu/core: Remove global iommu_ops and register_iommu
    iommu/msm: Use bus_set_iommu instead of register_iommu
    iommu/omap: Use bus_set_iommu instead of register_iommu
    iommu/vt-d: Use bus_set_iommu instead of register_iommu
    iommu/amd: Use bus_set_iommu instead of register_iommu
    iommu/core: Use bus->iommu_ops in the iommu-api
    iommu/core: Convert iommu_found to iommu_present
    iommu/core: Add bus_type parameter to iommu_domain_alloc
    Driver core: Add iommu_ops to bus_type
    iommu/core: Define iommu_ops and register_iommu only with CONFIG_IOMMU_API
    iommu/amd: Fix wrong shift direction
    iommu/omap: always provide iommu debug code
    iommu/core: let drivers know if an iommu fault handler isn't installed
    iommu/core: export iommu_set_fault_handler()
    iommu/omap: Fix build error with !IOMMU_SUPPORT
    iommu/omap: Migrate to the generic fault report mechanism
    iommu/core: Add fault reporting mechanism
    iommu/core: Use PAGE_SIZE instead of hard-coded value
    iommu/core: use the existing IS_ALIGNED macro
    iommu/msm: ->unmap() should return order of unmapped page
    ...

    Fixup trivial conflicts in drivers/iommu/Makefile: "move omap iommu to
    dedicated iommu folder" vs "Rename the DMAR and INTR_REMAP config
    options" just happened to touch lines next to each other.

    Linus Torvalds
     
  • * 'kvm-updates/3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm: (75 commits)
    KVM: SVM: Keep intercepting task switching with NPT enabled
    KVM: s390: implement sigp external call
    KVM: s390: fix register setting
    KVM: s390: fix return value of kvm_arch_init_vm
    KVM: s390: check cpu_id prior to using it
    KVM: emulate lapic tsc deadline timer for guest
    x86: TSC deadline definitions
    KVM: Fix simultaneous NMIs
    KVM: x86 emulator: convert push %sreg/pop %sreg to direct decode
    KVM: x86 emulator: switch lds/les/lss/lfs/lgs to direct decode
    KVM: x86 emulator: streamline decode of segment registers
    KVM: x86 emulator: simplify OpMem64 decode
    KVM: x86 emulator: switch src decode to decode_operand()
    KVM: x86 emulator: qualify OpReg inhibit_byte_regs hack
    KVM: x86 emulator: switch OpImmUByte decode to decode_imm()
    KVM: x86 emulator: free up some flag bits near src, dst
    KVM: x86 emulator: switch src2 to generic decode_operand()
    KVM: x86 emulator: expand decode flags to 64 bits
    KVM: x86 emulator: split dst decode to a generic decode_operand()
    KVM: x86 emulator: move memop, memopp into emulation context
    ...

    Linus Torvalds
     

21 Oct, 2011

2 commits


26 Sep, 2011

6 commits

  • The threaded IRQ handler for MSI-X has almost nothing in common with the
    INTx/MSI handler. Move its code into a dedicated handler.

    Signed-off-by: Jan Kiszka
    Signed-off-by: Marcelo Tosatti

    Jan Kiszka
     
  • We only perform work in kvm_assigned_dev_ack_irq if the guest IRQ is of
    INTx type. This completely avoids the callback invocation in non-INTx
    cases by registering the IRQ ack notifier only for INTx.

    Signed-off-by: Jan Kiszka
    Signed-off-by: Marcelo Tosatti

    Jan Kiszka
     
  • Signed-off-by: Jan Kiszka
    Signed-off-by: Marcelo Tosatti

    Jan Kiszka
     
  • Currently the method of dealing with an IO operation on a bus (PIO/MMIO)
    is to call the read or write callback for each device registered
    on the bus until we find a device which handles it.

    Since the number of devices on a bus can be significant due to ioeventfds
    and coalesced MMIO zones, this leads to a lot of overhead on each IO
    operation.

    Instead of registering devices, we now register ranges which points to
    a device. Lookup is done using an efficient bsearch instead of a linear
    search.

    Performance test was conducted by comparing exit count per second with
    200 ioeventfds created on one byte and the guest is trying to access a
    different byte continuously (triggering usermode exits).
    Before the patch the guest has achieved 259k exits per second, after the
    patch the guest does 274k exits per second.

    Cc: Avi Kivity
    Cc: Marcelo Tosatti
    Signed-off-by: Sasha Levin
    Signed-off-by: Avi Kivity

    Sasha Levin
     
  • This patch changes coalesced mmio to create one mmio device per
    zone instead of handling all zones in one device.

    Doing so enables us to take advantage of existing locking and prevents
    a race condition between coalesced mmio registration/unregistration
    and lookups.

    Suggested-by: Avi Kivity
    Signed-off-by: Sasha Levin
    Signed-off-by: Marcelo Tosatti

    Sasha Levin
     
  • Move the check whether there are available entries to within the spinlock.
    This allows working with larger amount of VCPUs and reduces premature
    exits when using a large number of VCPUs.

    Cc: Avi Kivity
    Cc: Ingo Molnar
    Cc: Marcelo Tosatti
    Cc: Pekka Enberg
    Signed-off-by: Sasha Levin
    Signed-off-by: Marcelo Tosatti

    Sasha Levin
     

24 Sep, 2011

1 commit

  • Device drivers that create and destroy SR-IOV virtual functions via
    calls to pci_enable_sriov() and pci_disable_sriov can cause catastrophic
    failures if they attempt to destroy VFs while they are assigned to
    guest virtual machines. By adding a flag for use by the KVM module
    to indicate that a device is assigned a device driver can check that
    flag and avoid destroying VFs while they are assigned and avoid system
    failures.

    CC: Ian Campbell
    CC: Konrad Wilk
    Signed-off-by: Greg Rose
    Acked-by: Jesse Barnes
    Signed-off-by: Jeff Kirsher

    Greg Rose
     

24 Jul, 2011

3 commits

  • IOMMU interrupt remapping support provides a further layer of
    isolation for device assignment by preventing arbitrary interrupt
    block DMA writes by a malicious guest from reaching the host. By
    default, we should require that the platform provides interrupt
    remapping support, with an opt-in mechanism for existing behavior.

    Both AMD IOMMU and Intel VT-d2 hardware support interrupt
    remapping, however we currently only have software support on
    the Intel side. Users wishing to re-enable device assignment
    when interrupt remapping is not supported on the platform can
    use the "allow_unsafe_assigned_interrupts=1" module option.

    [avi: break long lines]

    Signed-off-by: Alex Williamson
    Signed-off-by: Marcelo Tosatti
    Signed-off-by: Avi Kivity

    Alex Williamson
     
  • The idea is from Avi:

    | We could cache the result of a miss in an spte by using a reserved bit, and
    | checking the page fault error code (or seeing if we get an ept violation or
    | ept misconfiguration), so if we get repeated mmio on a page, we don't need to
    | search the slot list/tree.
    | (https://lkml.org/lkml/2011/2/22/221)

    When the page fault is caused by mmio, we cache the info in the shadow page
    table, and also set the reserved bits in the shadow page table, so if the mmio
    is caused again, we can quickly identify it and emulate it directly

    Searching mmio gfn in memslots is heavy since we need to walk all memeslots, it
    can be reduced by this feature, and also avoid walking guest page table for
    soft mmu.

    [jan: fix operator precedence issue]

    Signed-off-by: Xiao Guangrong
    Signed-off-by: Jan Kiszka
    Signed-off-by: Avi Kivity

    Xiao Guangrong
     
  • If the page fault is caused by mmio, the gfn can not be found in memslots, and
    'bad_pfn' is returned on gfn_to_hva path, so we can use 'bad_pfn' to identify
    the mmio page fault.
    And, to clarify the meaning of mmio pfn, we return fault page instead of bad
    page when the gfn is not allowd to prefetch

    Signed-off-by: Xiao Guangrong
    Signed-off-by: Avi Kivity

    Xiao Guangrong
     

12 Jul, 2011

4 commits

  • Introduce kvm_read_guest_cached() function in addition to write one we
    already have.

    [ by glauber: export function signature in kvm header ]

    Signed-off-by: Gleb Natapov
    Signed-off-by: Glauber Costa
    Acked-by: Rik van Riel
    Tested-by: Eric Munson
    Signed-off-by: Avi Kivity

    Gleb Natapov
     
  • KVM_MAX_MSIX_PER_DEV implies that up to that many MSI-X entries can be
    requested. But the kernel so far rejected already the upper limit.

    Signed-off-by: Jan Kiszka
    Signed-off-by: Avi Kivity

    Jan Kiszka
     
  • KVM has an ioctl to define which signal mask should be used while running
    inside VCPU_RUN. At least for big endian systems, this mask is different
    on 32-bit and 64-bit systems (though the size is identical).

    Add a compat wrapper that converts the mask to whatever the kernel accepts,
    allowing 32-bit kvm user space to set signal masks.

    This patch fixes qemu with --enable-io-thread on ppc64 hosts when running
    32-bit user land.

    Signed-off-by: Alexander Graf
    Signed-off-by: Avi Kivity

    Alexander Graf
     
  • So far kvm_arch_vcpu_setup is responsible for freeing the vcpu struct if
    it fails. Move this confusing resonsibility back into the hands of
    kvm_vm_ioctl_create_vcpu. Only kvm_arch_vcpu_setup of x86 is affected,
    all other archs cannot fail.

    Signed-off-by: Jan Kiszka
    Signed-off-by: Avi Kivity

    Jan Kiszka