Skip to content

Commit 6ae1477

Browse files
committed
Merge branch 'amd/amd-vi' into next
* amd/amd-vi: iommu/amd: Fix geometry.aperture_end for V2 tables iommu/amd: Wrap debugfs ABI testing symbols snippets in literal code blocks iommu/amd: Add documentation for AMD IOMMU debugfs support iommu/amd: Add debugfs support to dump IRT Table iommu/amd: Add debugfs support to dump device table iommu/amd: Add support for device id user input iommu/amd: Add debugfs support to dump IOMMU command buffer iommu/amd: Add debugfs support to dump IOMMU Capability registers iommu/amd: Add debugfs support to dump IOMMU MMIO registers iommu/amd: Refactor AMD IOMMU debugfs initial setup iommu/amd: Enable PASID and ATS capabilities in the correct order iommu/amd: Add efr[HATS] max v1 page table level iommu/amd: Add HATDis feature support
2 parents 9f341a2 + 8637afa commit 6ae1477

File tree

7 files changed

+598
-30
lines changed

7 files changed

+598
-30
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
What: /sys/kernel/debug/iommu/amd/iommu<x>/mmio
2+
Date: January 2025
3+
Contact: Dheeraj Kumar Srivastava <[email protected]>
4+
Description:
5+
This file provides read/write access for user input. Users specify the
6+
MMIO register offset for iommu<x>, and the file outputs the corresponding
7+
MMIO register value of iommu<x>
8+
9+
Example::
10+
11+
$ echo "0x18" > /sys/kernel/debug/iommu/amd/iommu00/mmio
12+
$ cat /sys/kernel/debug/iommu/amd/iommu00/mmio
13+
14+
Output::
15+
16+
Offset:0x18 Value:0x000c22000003f48d
17+
18+
What: /sys/kernel/debug/iommu/amd/iommu<x>/capability
19+
Date: January 2025
20+
Contact: Dheeraj Kumar Srivastava <[email protected]>
21+
Description:
22+
This file provides read/write access for user input. Users specify the
23+
capability register offset for iommu<x>, and the file outputs the
24+
corresponding capability register value of iommu<x>.
25+
26+
Example::
27+
28+
$ echo "0x10" > /sys/kernel/debug/iommu/amd/iommu00/capability
29+
$ cat /sys/kernel/debug/iommu/amd/iommu00/capability
30+
31+
Output::
32+
33+
Offset:0x10 Value:0x00203040
34+
35+
What: /sys/kernel/debug/iommu/amd/iommu<x>/cmdbuf
36+
Date: January 2025
37+
Contact: Dheeraj Kumar Srivastava <[email protected]>
38+
Description:
39+
This file is a read-only output file containing iommu<x> command
40+
buffer entries.
41+
42+
Examples::
43+
44+
$ cat /sys/kernel/debug/iommu/amd/iommu<x>/cmdbuf
45+
46+
Output::
47+
48+
CMD Buffer Head Offset:339 Tail Offset:339
49+
0: 00835001 10000001 00003c00 00000000
50+
1: 00000000 30000005 fffff003 7fffffff
51+
2: 00835001 10000001 00003c01 00000000
52+
3: 00000000 30000005 fffff003 7fffffff
53+
4: 00835001 10000001 00003c02 00000000
54+
5: 00000000 30000005 fffff003 7fffffff
55+
6: 00835001 10000001 00003c03 00000000
56+
7: 00000000 30000005 fffff003 7fffffff
57+
8: 00835001 10000001 00003c04 00000000
58+
9: 00000000 30000005 fffff003 7fffffff
59+
10: 00835001 10000001 00003c05 00000000
60+
11: 00000000 30000005 fffff003 7fffffff
61+
[...]
62+
63+
What: /sys/kernel/debug/iommu/amd/devid
64+
Date: January 2025
65+
Contact: Dheeraj Kumar Srivastava <[email protected]>
66+
Description:
67+
This file provides read/write access for user input. Users specify the
68+
device ID, which can be used to dump IOMMU data structures such as the
69+
interrupt remapping table and device table.
70+
71+
Example:
72+
73+
1.
74+
::
75+
76+
$ echo 0000:01:00.0 > /sys/kernel/debug/iommu/amd/devid
77+
$ cat /sys/kernel/debug/iommu/amd/devid
78+
79+
Output::
80+
81+
0000:01:00.0
82+
83+
2.
84+
::
85+
86+
$ echo 01:00.0 > /sys/kernel/debug/iommu/amd/devid
87+
$ cat /sys/kernel/debug/iommu/amd/devid
88+
89+
Output::
90+
91+
0000:01:00.0
92+
93+
What: /sys/kernel/debug/iommu/amd/devtbl
94+
Date: January 2025
95+
Contact: Dheeraj Kumar Srivastava <[email protected]>
96+
Description:
97+
This file is a read-only output file containing the device table entry
98+
for the device ID provided in /sys/kernel/debug/iommu/amd/devid.
99+
100+
Example::
101+
102+
$ cat /sys/kernel/debug/iommu/amd/devtbl
103+
104+
Output::
105+
106+
DeviceId QWORD[3] QWORD[2] QWORD[1] QWORD[0] iommu
107+
0000:01:00.0 0000000000000000 20000001373b8013 0000000000000038 6000000114d7b603 iommu3
108+
109+
What: /sys/kernel/debug/iommu/amd/irqtbl
110+
Date: January 2025
111+
Contact: Dheeraj Kumar Srivastava <[email protected]>
112+
Description:
113+
This file is a read-only output file containing valid IRT table entries
114+
for the device ID provided in /sys/kernel/debug/iommu/amd/devid.
115+
116+
Example::
117+
118+
$ cat /sys/kernel/debug/iommu/amd/irqtbl
119+
120+
Output::
121+
122+
DeviceId 0000:01:00.0
123+
IRT[0000] 0000000000000020 0000000000000241
124+
IRT[0001] 0000000000000020 0000000000000841
125+
IRT[0002] 0000000000000020 0000000000002041
126+
IRT[0003] 0000000000000020 0000000000008041
127+
IRT[0004] 0000000000000020 0000000000020041
128+
IRT[0005] 0000000000000020 0000000000080041
129+
IRT[0006] 0000000000000020 0000000000200041
130+
IRT[0007] 0000000000000020 0000000000800041
131+
[...]

drivers/iommu/amd/amd_iommu.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu,
2828
gfp_t gfp, size_t size);
2929

3030
#ifdef CONFIG_AMD_IOMMU_DEBUGFS
31-
void amd_iommu_debugfs_setup(struct amd_iommu *iommu);
31+
void amd_iommu_debugfs_setup(void);
3232
#else
33-
static inline void amd_iommu_debugfs_setup(struct amd_iommu *iommu) {}
33+
static inline void amd_iommu_debugfs_setup(void) {}
3434
#endif
3535

3636
/* Needed for interrupt remapping */
@@ -42,7 +42,9 @@ int amd_iommu_enable_faulting(unsigned int cpu);
4242
extern int amd_iommu_guest_ir;
4343
extern enum protection_domain_mode amd_iommu_pgtable;
4444
extern int amd_iommu_gpt_level;
45+
extern u8 amd_iommu_hpt_level;
4546
extern unsigned long amd_iommu_pgsize_bitmap;
47+
extern bool amd_iommu_hatdis;
4648

4749
/* Protection domain ops */
4850
void amd_iommu_init_identity_domain(void);

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
#define FEATURE_GA BIT_ULL(7)
9595
#define FEATURE_HE BIT_ULL(8)
9696
#define FEATURE_PC BIT_ULL(9)
97+
#define FEATURE_HATS GENMASK_ULL(11, 10)
9798
#define FEATURE_GATS GENMASK_ULL(13, 12)
9899
#define FEATURE_GLX GENMASK_ULL(15, 14)
99100
#define FEATURE_GAM_VAPIC BIT_ULL(21)
@@ -460,6 +461,9 @@
460461
/* IOMMU Feature Reporting Field (for IVHD type 10h */
461462
#define IOMMU_FEAT_GASUP_SHIFT 6
462463

464+
/* IOMMU HATDIS for IVHD type 11h and 40h */
465+
#define IOMMU_IVHD_ATTR_HATDIS_SHIFT 0
466+
463467
/* IOMMU Extended Feature Register (EFR) */
464468
#define IOMMU_EFR_XTSUP_SHIFT 2
465469
#define IOMMU_EFR_GASUP_SHIFT 7
@@ -558,7 +562,8 @@ struct amd_io_pgtable {
558562
};
559563

560564
enum protection_domain_mode {
561-
PD_MODE_V1 = 1,
565+
PD_MODE_NONE,
566+
PD_MODE_V1,
562567
PD_MODE_V2,
563568
};
564569

@@ -790,6 +795,8 @@ struct amd_iommu {
790795
#ifdef CONFIG_AMD_IOMMU_DEBUGFS
791796
/* DebugFS Info */
792797
struct dentry *debugfs;
798+
int dbg_mmio_offset;
799+
int dbg_cap_offset;
793800
#endif
794801

795802
/* IOPF support */
@@ -890,6 +897,13 @@ struct dev_table_entry {
890897
};
891898
};
892899

900+
/*
901+
* Structure defining one entry in the command buffer
902+
*/
903+
struct iommu_cmd {
904+
u32 data[4];
905+
};
906+
893907
/*
894908
* Structure to sture persistent DTE flags from IVHD
895909
*/

0 commit comments

Comments
 (0)