diff options
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 2280ef86651f..fee16fbf2f33 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -286,6 +286,21 @@ static int iommu_queue_inv_dev_entry(struct amd_iommu *iommu, u16 devid) | |||
286 | return ret; | 286 | return ret; |
287 | } | 287 | } |
288 | 288 | ||
289 | static void __iommu_build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address, | ||
290 | u16 domid, int pde, int s) | ||
291 | { | ||
292 | memset(cmd, 0, sizeof(*cmd)); | ||
293 | address &= PAGE_MASK; | ||
294 | CMD_SET_TYPE(cmd, CMD_INV_IOMMU_PAGES); | ||
295 | cmd->data[1] |= domid; | ||
296 | cmd->data[2] = lower_32_bits(address); | ||
297 | cmd->data[3] = upper_32_bits(address); | ||
298 | if (s) /* size bit - we flush more than one 4kb page */ | ||
299 | cmd->data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK; | ||
300 | if (pde) /* PDE bit - we wan't flush everything not only the PTEs */ | ||
301 | cmd->data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK; | ||
302 | } | ||
303 | |||
289 | /* | 304 | /* |
290 | * Generic command send function for invalidaing TLB entries | 305 | * Generic command send function for invalidaing TLB entries |
291 | */ | 306 | */ |
@@ -295,16 +310,7 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu, | |||
295 | struct iommu_cmd cmd; | 310 | struct iommu_cmd cmd; |
296 | int ret; | 311 | int ret; |
297 | 312 | ||
298 | memset(&cmd, 0, sizeof(cmd)); | 313 | __iommu_build_inv_iommu_pages(&cmd, address, domid, pde, s); |
299 | address &= PAGE_MASK; | ||
300 | CMD_SET_TYPE(&cmd, CMD_INV_IOMMU_PAGES); | ||
301 | cmd.data[1] |= domid; | ||
302 | cmd.data[2] = lower_32_bits(address); | ||
303 | cmd.data[3] = upper_32_bits(address); | ||
304 | if (s) /* size bit - we flush more than one 4kb page */ | ||
305 | cmd.data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK; | ||
306 | if (pde) /* PDE bit - we wan't flush everything not only the PTEs */ | ||
307 | cmd.data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK; | ||
308 | 314 | ||
309 | ret = iommu_queue_command(iommu, &cmd); | 315 | ret = iommu_queue_command(iommu, &cmd); |
310 | 316 | ||