mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
KVM: Device Assignment with VT-d
Based on a patch by: Kay, Allen M <[email protected]> This patch enables PCI device assignment based on VT-d support. When a device is assigned to the guest, the guest memory is pinned and the mapping is updated in the VT-d IOMMU. [Amit: Expose KVM_CAP_IOMMU so we can check if an IOMMU is present and also control enable/disable from userspace] Signed-off-by: Kay, Allen M <[email protected]> Signed-off-by: Weidong Han <[email protected]> Signed-off-by: Ben-Ami Yassour <[email protected]> Signed-off-by: Amit Shah <[email protected]> Acked-by: Mark Gross <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
This commit is contained in:
parent
3871794642
commit
62c476c7c7
7 changed files with 281 additions and 21 deletions
|
|
@ -41,6 +41,7 @@
|
|||
#include <linux/pagemap.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/intel-iommu.h>
|
||||
|
||||
#include <asm/processor.h>
|
||||
#include <asm/io.h>
|
||||
|
|
@ -76,7 +77,7 @@ static inline int valid_vcpu(int n)
|
|||
return likely(n >= 0 && n < KVM_MAX_VCPUS);
|
||||
}
|
||||
|
||||
static inline int is_mmio_pfn(pfn_t pfn)
|
||||
inline int is_mmio_pfn(pfn_t pfn)
|
||||
{
|
||||
if (pfn_valid(pfn))
|
||||
return PageReserved(pfn_to_page(pfn));
|
||||
|
|
@ -578,6 +579,12 @@ int __kvm_set_memory_region(struct kvm *kvm,
|
|||
}
|
||||
|
||||
kvm_free_physmem_slot(&old, &new);
|
||||
|
||||
/* map the pages in iommu page table */
|
||||
r = kvm_iommu_map_pages(kvm, base_gfn, npages);
|
||||
if (r)
|
||||
goto out;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free:
|
||||
|
|
|
|||
Loading…
Reference in a new issue