1 // SPDX-License-Identifier: GPL-2.0
3 * intel-pasid.c - PASID idr, table and entry manipulation
5 * Copyright (C) 2018 Intel Corporation
7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
10 #define pr_fmt(fmt) "DMAR: " fmt
12 #include <linux/bitops.h>
13 #include <linux/cpufeature.h>
14 #include <linux/dmar.h>
15 #include <linux/intel-iommu.h>
16 #include <linux/iommu.h>
17 #include <linux/memory.h>
18 #include <linux/pci.h>
19 #include <linux/pci-ats.h>
20 #include <linux/spinlock.h>
25 * Intel IOMMU system wide PASID name space:
27 u32 intel_pasid_max_id = PASID_MAX;
29 int vcmd_alloc_pasid(struct intel_iommu *iommu, u32 *pasid)
36 raw_spin_lock_irqsave(&iommu->register_lock, flags);
37 dmar_writeq(iommu->reg + DMAR_VCMD_REG, VCMD_CMD_ALLOC);
38 IOMMU_WAIT_OP(iommu, DMAR_VCRSP_REG, dmar_readq,
39 !(res & VCMD_VRSP_IP), res);
40 raw_spin_unlock_irqrestore(&iommu->register_lock, flags);
42 status_code = VCMD_VRSP_SC(res);
43 switch (status_code) {
44 case VCMD_VRSP_SC_SUCCESS:
45 *pasid = VCMD_VRSP_RESULT_PASID(res);
47 case VCMD_VRSP_SC_NO_PASID_AVAIL:
48 pr_info("IOMMU: %s: No PASID available\n", iommu->name);
53 pr_warn("IOMMU: %s: Unexpected error code %d\n",
54 iommu->name, status_code);
60 void vcmd_free_pasid(struct intel_iommu *iommu, u32 pasid)
66 raw_spin_lock_irqsave(&iommu->register_lock, flags);
67 dmar_writeq(iommu->reg + DMAR_VCMD_REG,
68 VCMD_CMD_OPERAND(pasid) | VCMD_CMD_FREE);
69 IOMMU_WAIT_OP(iommu, DMAR_VCRSP_REG, dmar_readq,
70 !(res & VCMD_VRSP_IP), res);
71 raw_spin_unlock_irqrestore(&iommu->register_lock, flags);
73 status_code = VCMD_VRSP_SC(res);
74 switch (status_code) {
75 case VCMD_VRSP_SC_SUCCESS:
77 case VCMD_VRSP_SC_INVALID_PASID:
78 pr_info("IOMMU: %s: Invalid PASID\n", iommu->name);
81 pr_warn("IOMMU: %s: Unexpected error code %d\n",
82 iommu->name, status_code);
87 * Per device pasid table management:
90 device_attach_pasid_table(struct device_domain_info *info,
91 struct pasid_table *pasid_table)
93 info->pasid_table = pasid_table;
94 list_add(&info->table, &pasid_table->dev);
98 device_detach_pasid_table(struct device_domain_info *info,
99 struct pasid_table *pasid_table)
101 info->pasid_table = NULL;
102 list_del(&info->table);
105 struct pasid_table_opaque {
106 struct pasid_table **pasid_table;
112 static int search_pasid_table(struct device_domain_info *info, void *opaque)
114 struct pasid_table_opaque *data = opaque;
116 if (info->iommu->segment == data->segment &&
117 info->bus == data->bus &&
118 info->devfn == data->devfn &&
120 *data->pasid_table = info->pasid_table;
127 static int get_alias_pasid_table(struct pci_dev *pdev, u16 alias, void *opaque)
129 struct pasid_table_opaque *data = opaque;
131 data->segment = pci_domain_nr(pdev->bus);
132 data->bus = PCI_BUS_NUM(alias);
133 data->devfn = alias & 0xff;
135 return for_each_device_domain(&search_pasid_table, data);
139 * Allocate a pasid table for @dev. It should be called in a
140 * single-thread context.
142 int intel_pasid_alloc_table(struct device *dev)
144 struct device_domain_info *info;
145 struct pasid_table *pasid_table;
146 struct pasid_table_opaque data;
153 info = get_domain_info(dev);
154 if (WARN_ON(!info || !dev_is_pci(dev) || info->pasid_table))
157 /* DMA alias device already has a pasid table, use it: */
158 data.pasid_table = &pasid_table;
159 ret = pci_for_each_dma_alias(to_pci_dev(dev),
160 &get_alias_pasid_table, &data);
164 pasid_table = kzalloc(sizeof(*pasid_table), GFP_KERNEL);
167 INIT_LIST_HEAD(&pasid_table->dev);
169 if (info->pasid_supported)
170 max_pasid = min_t(u32, pci_max_pasids(to_pci_dev(dev)),
173 size = max_pasid >> (PASID_PDE_SHIFT - 3);
174 order = size ? get_order(size) : 0;
175 pages = alloc_pages_node(info->iommu->node,
176 GFP_KERNEL | __GFP_ZERO, order);
182 pasid_table->table = page_address(pages);
183 pasid_table->order = order;
184 pasid_table->max_pasid = 1 << (order + PAGE_SHIFT + 3);
187 device_attach_pasid_table(info, pasid_table);
189 if (!ecap_coherent(info->iommu->ecap))
190 clflush_cache_range(pasid_table->table, (1 << order) * PAGE_SIZE);
195 void intel_pasid_free_table(struct device *dev)
197 struct device_domain_info *info;
198 struct pasid_table *pasid_table;
199 struct pasid_dir_entry *dir;
200 struct pasid_entry *table;
203 info = get_domain_info(dev);
204 if (!info || !dev_is_pci(dev) || !info->pasid_table)
207 pasid_table = info->pasid_table;
208 device_detach_pasid_table(info, pasid_table);
210 if (!list_empty(&pasid_table->dev))
213 /* Free scalable mode PASID directory tables: */
214 dir = pasid_table->table;
215 max_pde = pasid_table->max_pasid >> PASID_PDE_SHIFT;
216 for (i = 0; i < max_pde; i++) {
217 table = get_pasid_table_from_pde(&dir[i]);
218 free_pgtable_page(table);
221 free_pages((unsigned long)pasid_table->table, pasid_table->order);
225 struct pasid_table *intel_pasid_get_table(struct device *dev)
227 struct device_domain_info *info;
229 info = get_domain_info(dev);
233 return info->pasid_table;
236 int intel_pasid_get_dev_max_id(struct device *dev)
238 struct device_domain_info *info;
240 info = get_domain_info(dev);
241 if (!info || !info->pasid_table)
244 return info->pasid_table->max_pasid;
247 struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid)
249 struct device_domain_info *info;
250 struct pasid_table *pasid_table;
251 struct pasid_dir_entry *dir;
252 struct pasid_entry *entries;
253 int dir_index, index;
255 pasid_table = intel_pasid_get_table(dev);
256 if (WARN_ON(!pasid_table || pasid >= intel_pasid_get_dev_max_id(dev)))
259 dir = pasid_table->table;
260 info = get_domain_info(dev);
261 dir_index = pasid >> PASID_PDE_SHIFT;
262 index = pasid & PASID_PTE_MASK;
265 entries = get_pasid_table_from_pde(&dir[dir_index]);
267 entries = alloc_pgtable_page(info->iommu->node);
272 * The pasid directory table entry won't be freed after
273 * allocation. No worry about the race with free and
274 * clear. However, this entry might be populated by others
275 * while we are preparing it. Use theirs with a retry.
277 if (cmpxchg64(&dir[dir_index].val, 0ULL,
278 (u64)virt_to_phys(entries) | PASID_PTE_PRESENT)) {
279 free_pgtable_page(entries);
282 if (!ecap_coherent(info->iommu->ecap)) {
283 clflush_cache_range(entries, VTD_PAGE_SIZE);
284 clflush_cache_range(&dir[dir_index].val, sizeof(*dir));
288 return &entries[index];
292 * Interfaces for PASID table entry manipulation:
294 static inline void pasid_clear_entry(struct pasid_entry *pe)
296 WRITE_ONCE(pe->val[0], 0);
297 WRITE_ONCE(pe->val[1], 0);
298 WRITE_ONCE(pe->val[2], 0);
299 WRITE_ONCE(pe->val[3], 0);
300 WRITE_ONCE(pe->val[4], 0);
301 WRITE_ONCE(pe->val[5], 0);
302 WRITE_ONCE(pe->val[6], 0);
303 WRITE_ONCE(pe->val[7], 0);
306 static inline void pasid_clear_entry_with_fpd(struct pasid_entry *pe)
308 WRITE_ONCE(pe->val[0], PASID_PTE_FPD);
309 WRITE_ONCE(pe->val[1], 0);
310 WRITE_ONCE(pe->val[2], 0);
311 WRITE_ONCE(pe->val[3], 0);
312 WRITE_ONCE(pe->val[4], 0);
313 WRITE_ONCE(pe->val[5], 0);
314 WRITE_ONCE(pe->val[6], 0);
315 WRITE_ONCE(pe->val[7], 0);
319 intel_pasid_clear_entry(struct device *dev, u32 pasid, bool fault_ignore)
321 struct pasid_entry *pe;
323 pe = intel_pasid_get_entry(dev, pasid);
327 if (fault_ignore && pasid_pte_is_present(pe))
328 pasid_clear_entry_with_fpd(pe);
330 pasid_clear_entry(pe);
333 static inline void pasid_set_bits(u64 *ptr, u64 mask, u64 bits)
337 old = READ_ONCE(*ptr);
338 WRITE_ONCE(*ptr, (old & ~mask) | bits);
342 * Setup the DID(Domain Identifier) field (Bit 64~79) of scalable mode
346 pasid_set_domain_id(struct pasid_entry *pe, u64 value)
348 pasid_set_bits(&pe->val[1], GENMASK_ULL(15, 0), value);
352 * Get domain ID value of a scalable mode PASID entry.
355 pasid_get_domain_id(struct pasid_entry *pe)
357 return (u16)(READ_ONCE(pe->val[1]) & GENMASK_ULL(15, 0));
361 * Setup the SLPTPTR(Second Level Page Table Pointer) field (Bit 12~63)
362 * of a scalable mode PASID entry.
365 pasid_set_slptr(struct pasid_entry *pe, u64 value)
367 pasid_set_bits(&pe->val[0], VTD_PAGE_MASK, value);
371 * Setup the AW(Address Width) field (Bit 2~4) of a scalable mode PASID
375 pasid_set_address_width(struct pasid_entry *pe, u64 value)
377 pasid_set_bits(&pe->val[0], GENMASK_ULL(4, 2), value << 2);
381 * Setup the PGTT(PASID Granular Translation Type) field (Bit 6~8)
382 * of a scalable mode PASID entry.
385 pasid_set_translation_type(struct pasid_entry *pe, u64 value)
387 pasid_set_bits(&pe->val[0], GENMASK_ULL(8, 6), value << 6);
391 * Enable fault processing by clearing the FPD(Fault Processing
392 * Disable) field (Bit 1) of a scalable mode PASID entry.
394 static inline void pasid_set_fault_enable(struct pasid_entry *pe)
396 pasid_set_bits(&pe->val[0], 1 << 1, 0);
400 * Setup the SRE(Supervisor Request Enable) field (Bit 128) of a
401 * scalable mode PASID entry.
403 static inline void pasid_set_sre(struct pasid_entry *pe)
405 pasid_set_bits(&pe->val[2], 1 << 0, 1);
409 * Setup the P(Present) field (Bit 0) of a scalable mode PASID
412 static inline void pasid_set_present(struct pasid_entry *pe)
414 pasid_set_bits(&pe->val[0], 1 << 0, 1);
418 * Setup Page Walk Snoop bit (Bit 87) of a scalable mode PASID
421 static inline void pasid_set_page_snoop(struct pasid_entry *pe, bool value)
423 pasid_set_bits(&pe->val[1], 1 << 23, value << 23);
427 * Setup the Page Snoop (PGSNP) field (Bit 88) of a scalable mode
431 pasid_set_pgsnp(struct pasid_entry *pe)
433 pasid_set_bits(&pe->val[1], 1ULL << 24, 1ULL << 24);
437 * Setup the First Level Page table Pointer field (Bit 140~191)
438 * of a scalable mode PASID entry.
441 pasid_set_flptr(struct pasid_entry *pe, u64 value)
443 pasid_set_bits(&pe->val[2], VTD_PAGE_MASK, value);
447 * Setup the First Level Paging Mode field (Bit 130~131) of a
448 * scalable mode PASID entry.
451 pasid_set_flpm(struct pasid_entry *pe, u64 value)
453 pasid_set_bits(&pe->val[2], GENMASK_ULL(3, 2), value << 2);
457 * Setup the Extended Access Flag Enable (EAFE) field (Bit 135)
458 * of a scalable mode PASID entry.
461 pasid_set_eafe(struct pasid_entry *pe)
463 pasid_set_bits(&pe->val[2], 1 << 7, 1 << 7);
467 pasid_cache_invalidation_with_pasid(struct intel_iommu *iommu,
472 desc.qw0 = QI_PC_DID(did) | QI_PC_GRAN(QI_PC_PASID_SEL) |
473 QI_PC_PASID(pasid) | QI_PC_TYPE;
478 qi_submit_sync(iommu, &desc, 1, 0);
482 devtlb_invalidation_with_pasid(struct intel_iommu *iommu,
483 struct device *dev, u32 pasid)
485 struct device_domain_info *info;
486 u16 sid, qdep, pfsid;
488 info = get_domain_info(dev);
489 if (!info || !info->ats_enabled)
492 if (pci_dev_is_disconnected(to_pci_dev(dev)))
495 sid = info->bus << 8 | info->devfn;
496 qdep = info->ats_qdep;
500 * When PASID 0 is used, it indicates RID2PASID(DMA request w/o PASID),
501 * devTLB flush w/o PASID should be used. For non-zero PASID under
502 * SVA usage, device could do DMA with multiple PASIDs. It is more
503 * efficient to flush devTLB specific to the PASID.
505 if (pasid == PASID_RID2PASID)
506 qi_flush_dev_iotlb(iommu, sid, pfsid, qdep, 0, 64 - VTD_PAGE_SHIFT);
508 qi_flush_dev_iotlb_pasid(iommu, sid, pfsid, pasid, qdep, 0, 64 - VTD_PAGE_SHIFT);
511 void intel_pasid_tear_down_entry(struct intel_iommu *iommu, struct device *dev,
512 u32 pasid, bool fault_ignore)
514 struct pasid_entry *pte;
517 pte = intel_pasid_get_entry(dev, pasid);
521 did = pasid_get_domain_id(pte);
522 pgtt = pasid_pte_get_pgtt(pte);
524 intel_pasid_clear_entry(dev, pasid, fault_ignore);
526 if (!ecap_coherent(iommu->ecap))
527 clflush_cache_range(pte, sizeof(*pte));
529 pasid_cache_invalidation_with_pasid(iommu, did, pasid);
531 if (pgtt == PASID_ENTRY_PGTT_PT || pgtt == PASID_ENTRY_PGTT_FL_ONLY)
532 qi_flush_piotlb(iommu, did, pasid, 0, -1, 0);
534 iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH);
536 /* Device IOTLB doesn't need to be flushed in caching mode. */
537 if (!cap_caching_mode(iommu->cap))
538 devtlb_invalidation_with_pasid(iommu, dev, pasid);
541 static void pasid_flush_caches(struct intel_iommu *iommu,
542 struct pasid_entry *pte,
545 if (!ecap_coherent(iommu->ecap))
546 clflush_cache_range(pte, sizeof(*pte));
548 if (cap_caching_mode(iommu->cap)) {
549 pasid_cache_invalidation_with_pasid(iommu, did, pasid);
550 qi_flush_piotlb(iommu, did, pasid, 0, -1, 0);
552 iommu_flush_write_buffer(iommu);
557 * Set up the scalable mode pasid table entry for first only
560 int intel_pasid_setup_first_level(struct intel_iommu *iommu,
561 struct device *dev, pgd_t *pgd,
562 u32 pasid, u16 did, int flags)
564 struct pasid_entry *pte;
566 if (!ecap_flts(iommu->ecap)) {
567 pr_err("No first level translation support on %s\n",
572 pte = intel_pasid_get_entry(dev, pasid);
576 pasid_clear_entry(pte);
578 /* Setup the first level page table pointer: */
579 pasid_set_flptr(pte, (u64)__pa(pgd));
580 if (flags & PASID_FLAG_SUPERVISOR_MODE) {
581 if (!ecap_srs(iommu->ecap)) {
582 pr_err("No supervisor request support on %s\n",
589 if (flags & PASID_FLAG_FL5LP) {
590 if (cap_5lp_support(iommu->cap)) {
591 pasid_set_flpm(pte, 1);
593 pr_err("No 5-level paging support for first-level\n");
594 pasid_clear_entry(pte);
599 if (flags & PASID_FLAG_PAGE_SNOOP)
600 pasid_set_pgsnp(pte);
602 pasid_set_domain_id(pte, did);
603 pasid_set_address_width(pte, iommu->agaw);
604 pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
606 /* Setup Present and PASID Granular Transfer Type: */
607 pasid_set_translation_type(pte, PASID_ENTRY_PGTT_FL_ONLY);
608 pasid_set_present(pte);
609 pasid_flush_caches(iommu, pte, pasid, did);
615 * Skip top levels of page tables for iommu which has less agaw
616 * than default. Unnecessary for PT mode.
618 static inline int iommu_skip_agaw(struct dmar_domain *domain,
619 struct intel_iommu *iommu,
620 struct dma_pte **pgd)
624 for (agaw = domain->agaw; agaw > iommu->agaw; agaw--) {
625 *pgd = phys_to_virt(dma_pte_addr(*pgd));
626 if (!dma_pte_present(*pgd))
634 * Set up the scalable mode pasid entry for second only translation type.
636 int intel_pasid_setup_second_level(struct intel_iommu *iommu,
637 struct dmar_domain *domain,
638 struct device *dev, u32 pasid)
640 struct pasid_entry *pte;
647 * If hardware advertises no support for second level
648 * translation, return directly.
650 if (!ecap_slts(iommu->ecap)) {
651 pr_err("No second level translation support on %s\n",
657 agaw = iommu_skip_agaw(domain, iommu, &pgd);
659 dev_err(dev, "Invalid domain page table\n");
663 pgd_val = virt_to_phys(pgd);
664 did = domain->iommu_did[iommu->seq_id];
666 pte = intel_pasid_get_entry(dev, pasid);
668 dev_err(dev, "Failed to get pasid entry of PASID %d\n", pasid);
672 pasid_clear_entry(pte);
673 pasid_set_domain_id(pte, did);
674 pasid_set_slptr(pte, pgd_val);
675 pasid_set_address_width(pte, agaw);
676 pasid_set_translation_type(pte, PASID_ENTRY_PGTT_SL_ONLY);
677 pasid_set_fault_enable(pte);
678 pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
680 if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
681 pasid_set_pgsnp(pte);
684 * Since it is a second level only translation setup, we should
685 * set SRE bit as well (addresses are expected to be GPAs).
687 if (pasid != PASID_RID2PASID && ecap_srs(iommu->ecap))
689 pasid_set_present(pte);
690 pasid_flush_caches(iommu, pte, pasid, did);
696 * Set up the scalable mode pasid entry for passthrough translation type.
698 int intel_pasid_setup_pass_through(struct intel_iommu *iommu,
699 struct dmar_domain *domain,
700 struct device *dev, u32 pasid)
702 u16 did = FLPT_DEFAULT_DID;
703 struct pasid_entry *pte;
705 pte = intel_pasid_get_entry(dev, pasid);
707 dev_err(dev, "Failed to get pasid entry of PASID %d\n", pasid);
711 pasid_clear_entry(pte);
712 pasid_set_domain_id(pte, did);
713 pasid_set_address_width(pte, iommu->agaw);
714 pasid_set_translation_type(pte, PASID_ENTRY_PGTT_PT);
715 pasid_set_fault_enable(pte);
716 pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
719 * We should set SRE bit as well since the addresses are expected
722 if (ecap_srs(iommu->ecap))
724 pasid_set_present(pte);
725 pasid_flush_caches(iommu, pte, pasid, did);
731 intel_pasid_setup_bind_data(struct intel_iommu *iommu, struct pasid_entry *pte,
732 struct iommu_gpasid_bind_data_vtd *pasid_data)
735 * Not all guest PASID table entry fields are passed down during bind,
736 * here we only set up the ones that are dependent on guest settings.
737 * Execution related bits such as NXE, SMEP are not supported.
738 * Other fields, such as snoop related, are set based on host needs
739 * regardless of guest settings.
741 if (pasid_data->flags & IOMMU_SVA_VTD_GPASID_SRE) {
742 if (!ecap_srs(iommu->ecap)) {
743 pr_err_ratelimited("No supervisor request support on %s\n",
750 if (pasid_data->flags & IOMMU_SVA_VTD_GPASID_EAFE) {
751 if (!ecap_eafs(iommu->ecap)) {
752 pr_err_ratelimited("No extended access flag support on %s\n",
760 * Memory type is only applicable to devices inside processor coherent
761 * domain. Will add MTS support once coherent devices are available.
763 if (pasid_data->flags & IOMMU_SVA_VTD_GPASID_MTS_MASK) {
764 pr_warn_ratelimited("No memory type support %s\n",
773 * intel_pasid_setup_nested() - Set up PASID entry for nested translation.
774 * This could be used for guest shared virtual address. In this case, the
775 * first level page tables are used for GVA-GPA translation in the guest,
776 * second level page tables are used for GPA-HPA translation.
778 * @iommu: IOMMU which the device belong to
779 * @dev: Device to be set up for translation
780 * @gpgd: FLPTPTR: First Level Page translation pointer in GPA
781 * @pasid: PASID to be programmed in the device PASID table
782 * @pasid_data: Additional PASID info from the guest bind request
783 * @domain: Domain info for setting up second level page tables
784 * @addr_width: Address width of the first level (guest)
786 int intel_pasid_setup_nested(struct intel_iommu *iommu, struct device *dev,
787 pgd_t *gpgd, u32 pasid,
788 struct iommu_gpasid_bind_data_vtd *pasid_data,
789 struct dmar_domain *domain, int addr_width)
791 struct pasid_entry *pte;
798 if (!ecap_nest(iommu->ecap)) {
799 pr_err_ratelimited("IOMMU: %s: No nested translation support\n",
804 if (!(domain->flags & DOMAIN_FLAG_NESTING_MODE)) {
805 pr_err_ratelimited("Domain is not in nesting mode, %x\n",
810 pte = intel_pasid_get_entry(dev, pasid);
815 * Caller must ensure PASID entry is not in use, i.e. not bind the
816 * same PASID to the same device twice.
818 if (pasid_pte_is_present(pte))
821 pasid_clear_entry(pte);
823 /* Sanity checking performed by caller to make sure address
824 * width matching in two dimensions:
828 switch (addr_width) {
830 case ADDR_WIDTH_5LEVEL:
831 if (!cpu_feature_enabled(X86_FEATURE_LA57) ||
832 !cap_5lp_support(iommu->cap)) {
833 dev_err_ratelimited(dev,
834 "5-level paging not supported\n");
838 pasid_set_flpm(pte, 1);
841 case ADDR_WIDTH_4LEVEL:
842 pasid_set_flpm(pte, 0);
845 dev_err_ratelimited(dev, "Invalid guest address width %d\n",
850 /* First level PGD is in GPA, must be supported by the second level */
851 if ((uintptr_t)gpgd > domain->max_addr) {
852 dev_err_ratelimited(dev,
853 "Guest PGD %lx not supported, max %llx\n",
854 (uintptr_t)gpgd, domain->max_addr);
857 pasid_set_flptr(pte, (uintptr_t)gpgd);
859 ret = intel_pasid_setup_bind_data(iommu, pte, pasid_data);
863 /* Setup the second level based on the given domain */
866 agaw = iommu_skip_agaw(domain, iommu, &pgd);
868 dev_err_ratelimited(dev, "Invalid domain page table\n");
871 pgd_val = virt_to_phys(pgd);
872 pasid_set_slptr(pte, pgd_val);
873 pasid_set_fault_enable(pte);
875 did = domain->iommu_did[iommu->seq_id];
876 pasid_set_domain_id(pte, did);
878 pasid_set_address_width(pte, agaw);
879 pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
881 pasid_set_translation_type(pte, PASID_ENTRY_PGTT_NESTED);
882 pasid_set_present(pte);
883 pasid_flush_caches(iommu, pte, pasid, did);