88#ifndef _ASM_X86_AMD_IOMMU_TYPES_H
99#define _ASM_X86_AMD_IOMMU_TYPES_H
1010
11+ #include <linux/bitfield.h>
1112#include <linux/iommu.h>
1213#include <linux/types.h>
1314#include <linux/mmu_notifier.h>
9596#define FEATURE_GA BIT_ULL(7)
9697#define FEATURE_HE BIT_ULL(8)
9798#define FEATURE_PC BIT_ULL(9)
98- #define FEATURE_GATS_SHIFT ( 12)
99- #define FEATURE_GATS_MASK (3ULL )
99+ #define FEATURE_GATS GENMASK_ULL(13, 12)
100+ #define FEATURE_GLX GENMASK_ULL(15, 14 )
100101#define FEATURE_GAM_VAPIC BIT_ULL(21)
102+ #define FEATURE_PASMAX GENMASK_ULL(36, 32)
101103#define FEATURE_GIOSUP BIT_ULL(48)
102104#define FEATURE_HASUP BIT_ULL(49)
103105#define FEATURE_EPHSUP BIT_ULL(50)
104106#define FEATURE_HDSUP BIT_ULL(52)
105107#define FEATURE_SNP BIT_ULL(63)
106108
107- #define FEATURE_PASID_SHIFT 32
108- #define FEATURE_PASID_MASK (0x1fULL << FEATURE_PASID_SHIFT)
109-
110- #define FEATURE_GLXVAL_SHIFT 14
111- #define FEATURE_GLXVAL_MASK (0x03ULL << FEATURE_GLXVAL_SHIFT)
112109
113110/* Extended Feature 2 Bits */
114- #define FEATURE_SNPAVICSUP_SHIFT 5
115- #define FEATURE_SNPAVICSUP_MASK (0x07ULL << FEATURE_SNPAVICSUP_SHIFT)
111+ #define FEATURE_SNPAVICSUP GENMASK_ULL(7, 5)
116112#define FEATURE_SNPAVICSUP_GAM (x ) \
117- ((x & FEATURE_SNPAVICSUP_MASK) >> FEATURE_SNPAVICSUP_SHIFT == 0x1)
113+ (FIELD_GET(FEATURE_SNPAVICSUP, x) == 0x1)
118114
119115/* Note:
120116 * The current driver only support 16-bit PASID.
294290 * that we support.
295291 *
296292 * 512GB Pages are not supported due to a hardware bug
293+ * Page sizes >= the 52 bit max physical address of the CPU are not supported.
297294 */
298- #define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38))
295+ #define AMD_IOMMU_PGSIZES (GENMASK_ULL(51, 12) ^ SZ_512G)
296+
297+ /* Special mode where page-sizes are limited to 4 KiB */
298+ #define AMD_IOMMU_PGSIZES_4K (PAGE_SIZE)
299+
299300/* 4K, 2MB, 1G page sizes are supported */
300301#define AMD_IOMMU_PGSIZES_V2 (PAGE_SIZE | (1ULL << 21) | (1ULL << 30))
301302
419420#define DTE_GCR3_VAL_B (x ) (((x) >> 15) & 0x0ffffULL)
420421#define DTE_GCR3_VAL_C (x ) (((x) >> 31) & 0x1fffffULL)
421422
422- #define DTE_GCR3_INDEX_A 0
423- #define DTE_GCR3_INDEX_B 1
424- #define DTE_GCR3_INDEX_C 1
425-
426423#define DTE_GCR3_SHIFT_A 58
427424#define DTE_GCR3_SHIFT_B 16
428425#define DTE_GCR3_SHIFT_C 43
@@ -527,7 +524,7 @@ struct amd_irte_ops;
527524#define AMD_IOMMU_FLAG_TRANS_PRE_ENABLED (1 << 0)
528525
529526#define io_pgtable_to_data (x ) \
530- container_of((x), struct amd_io_pgtable, iop )
527+ container_of((x), struct amd_io_pgtable, pgtbl )
531528
532529#define io_pgtable_ops_to_data (x ) \
533530 io_pgtable_to_data(io_pgtable_ops_to_pgtable(x))
@@ -537,7 +534,7 @@ struct amd_irte_ops;
537534 struct protection_domain, iop)
538535
539536#define io_pgtable_cfg_to_data (x ) \
540- container_of((x), struct amd_io_pgtable, pgtbl_cfg )
537+ container_of((x), struct amd_io_pgtable, pgtbl.cfg )
541538
542539struct gcr3_tbl_info {
543540 u64 * gcr3_tbl ; /* Guest CR3 table */
@@ -547,8 +544,7 @@ struct gcr3_tbl_info {
547544};
548545
549546struct amd_io_pgtable {
550- struct io_pgtable_cfg pgtbl_cfg ;
551- struct io_pgtable iop ;
547+ struct io_pgtable pgtbl ;
552548 int mode ;
553549 u64 * root ;
554550 u64 * pgd ; /* v2 pgtable pgd pointer */
@@ -580,7 +576,6 @@ struct protection_domain {
580576 struct amd_io_pgtable iop ;
581577 spinlock_t lock ; /* mostly used to lock the page table*/
582578 u16 id ; /* the domain id written to the device table */
583- int nid ; /* Node ID */
584579 enum protection_domain_mode pd_mode ; /* Track page table type */
585580 bool dirty_tracking ; /* dirty tracking is enabled in the domain */
586581 unsigned dev_cnt ; /* devices assigned to this domain */
0 commit comments