x86/amd-iommu: Introduce increase_address_space function
authorJoerg Roedel <joerg.roedel@amd.com>
Wed, 2 Sep 2009 13:38:40 +0000 (15:38 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 3 Sep 2009 14:03:46 +0000 (16:03 +0200)
This function will be used to increase the address space
size of a protection domain.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
arch/x86/include/asm/amd_iommu_types.h
arch/x86/kernel/amd_iommu.c

index 97f3d09d3be5902cdf45a4c7ed0928cbbb6878b6..1b4b3d6c9f04d22aa4211670864a4d33e3b75368 100644 (file)
                                  ((1ULL << PM_LEVEL_SHIFT((x))) - 1): \
                                   (0xffffffffffffffffULL))
 #define PM_LEVEL_INDEX(x, a)   (((a) >> PM_LEVEL_SHIFT((x))) & 0x1ffULL)
+#define PM_LEVEL_ENC(x)                (((x) << 9) & 0xe00ULL)
+#define PM_LEVEL_PDE(x, a)     ((a) | PM_LEVEL_ENC((x)) | \
+                                IOMMU_PTE_P | IOMMU_PTE_IR | IOMMU_PTE_IW)
+
 
 #define IOMMU_PTE_L2_INDEX(address) (((address) >> 30) & 0x1ffULL)
 #define IOMMU_PTE_L1_INDEX(address) (((address) >> 21) & 0x1ffULL)
index 5eab6a84b9ccea36ea954014b172853a7425b6d6..fc97b51f0287f3cfc8bd187eee00eb45ca064ed1 100644 (file)
@@ -1324,6 +1324,33 @@ static void update_domain(struct protection_domain *domain)
        domain->updated = false;
 }
 
+/*
+ * This function is used to add another level to an IO page table. Adding
+ * another level increases the size of the address space by 9 bits to a size up
+ * to 64 bits.
+ */
+static bool increase_address_space(struct protection_domain *domain,
+                                  gfp_t gfp)
+{
+       u64 *pte;
+
+       if (domain->mode == PAGE_MODE_6_LEVEL)
+               /* address space already 64 bit large */
+               return false;
+
+       pte = (void *)get_zeroed_page(gfp);
+       if (!pte)
+               return false;
+
+       *pte             = PM_LEVEL_PDE(domain->mode,
+                                       virt_to_phys(domain->pt_root));
+       domain->pt_root  = pte;
+       domain->mode    += 1;
+       domain->updated  = true;
+
+       return true;
+}
+
 /*
  * If the pte_page is not yet allocated this function is called
  */
This page took 0.028216 seconds and 5 git commands to generate.