aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/amd_iommu_types.h4
-rw-r--r--arch/x86/kernel/amd_iommu.c27
2 files changed, 31 insertions, 0 deletions
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index 97f3d09d3be5..1b4b3d6c9f04 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -160,6 +160,10 @@
160 ((1ULL << PM_LEVEL_SHIFT((x))) - 1): \ 160 ((1ULL << PM_LEVEL_SHIFT((x))) - 1): \
161 (0xffffffffffffffffULL)) 161 (0xffffffffffffffffULL))
162#define PM_LEVEL_INDEX(x, a) (((a) >> PM_LEVEL_SHIFT((x))) & 0x1ffULL) 162#define PM_LEVEL_INDEX(x, a) (((a) >> PM_LEVEL_SHIFT((x))) & 0x1ffULL)
163#define PM_LEVEL_ENC(x) (((x) << 9) & 0xe00ULL)
164#define PM_LEVEL_PDE(x, a) ((a) | PM_LEVEL_ENC((x)) | \
165 IOMMU_PTE_P | IOMMU_PTE_IR | IOMMU_PTE_IW)
166
163 167
164#define IOMMU_PTE_L2_INDEX(address) (((address) >> 30) & 0x1ffULL) 168#define IOMMU_PTE_L2_INDEX(address) (((address) >> 30) & 0x1ffULL)
165#define IOMMU_PTE_L1_INDEX(address) (((address) >> 21) & 0x1ffULL) 169#define IOMMU_PTE_L1_INDEX(address) (((address) >> 21) & 0x1ffULL)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 5eab6a84b9cc..fc97b51f0287 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1325,6 +1325,33 @@ static void update_domain(struct protection_domain *domain)
1325} 1325}
1326 1326
1327/* 1327/*
1328 * This function is used to add another level to an IO page table. Adding
1329 * another level increases the size of the address space by 9 bits to a size up
1330 * to 64 bits.
1331 */
1332static bool increase_address_space(struct protection_domain *domain,
1333 gfp_t gfp)
1334{
1335 u64 *pte;
1336
1337 if (domain->mode == PAGE_MODE_6_LEVEL)
1338 /* address space already 64 bit large */
1339 return false;
1340
1341 pte = (void *)get_zeroed_page(gfp);
1342 if (!pte)
1343 return false;
1344
1345 *pte = PM_LEVEL_PDE(domain->mode,
1346 virt_to_phys(domain->pt_root));
1347 domain->pt_root = pte;
1348 domain->mode += 1;
1349 domain->updated = true;
1350
1351 return true;
1352}
1353
1354/*
1328 * If the pte_page is not yet allocated this function is called 1355 * If the pte_page is not yet allocated this function is called
1329 */ 1356 */
1330static u64* alloc_pte(struct protection_domain *dom, 1357static u64* alloc_pte(struct protection_domain *dom,