iommu/vt-d: Add support for ACPI/SATC table
Subsystems (4)
Lu Baolu
maintainercover iommu/vt-d: Add support for ACPI/SATC table
Intel platform VT-d (v3.2) comes with a new type of DMAR subtable SATC. The SATC table includes a list of SoC integrated devices that require SATC. OS software can use this table to enable ATS only for the devices in the list.
Yian Chen (3):
iommu/vt-d: Add new enum value and structure for SATC iommu/vt-d: Parse SATC reporting structure iommu/vt-d: Apply SATC policy
drivers/iommu/intel/dmar.c | 9 ++ drivers/iommu/intel/iommu.c | 161 +++++++++++++++++++++++++++++++++++- include/acpi/actbl1.h | 11 ++- include/linux/dmar.h | 2 + 4 files changed, 178 insertions(+), 5 deletions(-)
Signature · 6 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerPATCH 1/3 iommu/vt-d: Add new enum value and structure for SATC
From: Yian Chen <[email protected]>
Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping structure SATC for SOC integrated devices, according to section 8.8 of Intel VT-d architecture specification v3.2. The SATC structure reports a list of the devices that require SATC enabling via ATS capacity.
This patch introduces the new enum value and structure to represent the remapping information. Kernel should parse the information from the reporting structure and enable ATC for the devices as needed.
--- include/acpi/actbl1.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
include/acpi/actbl1.h +10 -1
@@ -514,7 +514,8 @@ enum acpi_dmar_type {ACPI_DMAR_TYPE_ROOT_ATS =2 ,ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3 ,ACPI_DMAR_TYPE_NAMESPACE =4 , - ACPI_DMAR_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +ACPI_DMAR_TYPE_SATC =5 , + ACPI_DMAR_TYPE_RESERVED = 6 /* 5 and greater are reserved */ };/* DMAR Device Scope structure */
@@ -607,6 +608,14 @@ struct acpi_dmar_andd {char device_name[1 ]; }; +/* 5: SOC Integrated Address Translation Cache Reporting Structure */ + +struct acpi_dmar_satc { +struct acpi_dmar_header header; +u8 flags; +u8 reserved; +u16 segment; +};/******************************************************************************* * * DRTM - Dynamic Root of Trust for Measurement table
Signature · 6 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerPATCH 2/3 iommu/vt-d: Parse SATC reporting structure
In reply to Lu BaoluFrom: Yian Chen <[email protected]>
Software should parse every SATC table and all devices in the tables reported by the BIOS and keep the information in kernel list for further SATC policy deployment.
--- drivers/iommu/intel/dmar.c | 9 ++++ drivers/iommu/intel/iommu.c | 89 +++++++++++++++++++++++++++++++++++++ include/linux/dmar.h | 2 + 3 files changed, 100 insertions(+)
drivers/iommu/intel/dmar.c +9 -0
@@ -526,6 +526,7 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)struct acpi_dmar_reserved_memory *rmrr;struct acpi_dmar_atsr *atsr;struct acpi_dmar_rhsa *rhsa; +struct acpi_dmar_satc *satc;switch (header->type) {case ACPI_DMAR_TYPE_HARDWARE_UNIT :
@@ -555,6 +556,11 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)/* We don't print this here because we need to sanity-check it first. So print it in dmar_parse_one_andd() instead. */ break ; +case ACPI_DMAR_TYPE_SATC : + satc = container_of(header, struct acpi_dmar_satc, header); +pr_info ("SATC flags: 0x%x\n" , satc->flags); +break ; + } }
@@ -642,6 +648,7 @@ parse_dmar_table(void) .cb[ACPI_DMAR_TYPE_ROOT_ATS] = &dmar_parse_one_atsr, .cb[ACPI_DMAR_TYPE_HARDWARE_AFFINITY] = &dmar_parse_one_rhsa, .cb[ACPI_DMAR_TYPE_NAMESPACE] = &dmar_parse_one_andd, + .cb[ACPI_DMAR_TYPE_SATC] = &dmar_parse_one_satc, };/*
@@ -2077,6 +2084,7 @@ static guid_t dmar_hp_guid =#define DMAR_DSM_FUNC_DRHD 1#define DMAR_DSM_FUNC_ATSR 2#define DMAR_DSM_FUNC_RHSA 3 +#define DMAR_DSM_FUNC_SATC 4static inline bool dmar_detect_dsm (acpi_handle handle,int func) {
@@ -2094,6 +2102,7 @@ static int dmar_walk_dsm_resource(acpi_handle handle, int func, [DMAR_DSM_FUNC_DRHD] = ACPI_DMAR_TYPE_HARDWARE_UNIT, [DMAR_DSM_FUNC_ATSR] = ACPI_DMAR_TYPE_ROOT_ATS, [DMAR_DSM_FUNC_RHSA] = ACPI_DMAR_TYPE_HARDWARE_AFFINITY, + [DMAR_DSM_FUNC_SATC] = ACPI_DMAR_TYPE_SATC, };if (!dmar_detect_dsm (handle, func))
drivers/iommu/intel/iommu.c +89 -0
135 lines not on this page · raw message
include/linux/dmar.h +2 -0
@@ -138,6 +138,7 @@ extern void intel_iommu_shutdown(void);extern int dmar_parse_one_rmrr (struct acpi_dmar_header *header,void *arg);extern int dmar_parse_one_atsr (struct acpi_dmar_header *header,void *arg);extern int dmar_check_one_atsr (struct acpi_dmar_header *hdr,void *arg); +extern int dmar_parse_one_satc (struct acpi_dmar_header *hdr,void *arg);extern int dmar_release_one_atsr (struct acpi_dmar_header *hdr,void *arg);extern int dmar_iommu_hotplug (struct dmar_drhd_unit *dmaru,bool insert);extern int dmar_iommu_notify_scope_dev (struct dmar_pci_notify_info *info);
@@ -149,6 +150,7 @@ static inline void intel_iommu_shutdown(void) { }#define dmar_parse_one_atsr dmar_res_noop#define dmar_check_one_atsr dmar_res_noop#define dmar_release_one_atsr dmar_res_noop +#define dmar_parse_one_satc dmar_res_noopstatic inline int dmar_iommu_notify_scope_dev (struct dmar_pci_notify_info *info) {
Signature · 6 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerPATCH 3/3 iommu/vt-d: Apply SATC policy
In reply to Lu BaoluFrom: Yian Chen <[email protected]>
Starting from Intel VT-d v3.2, Intel platform BIOS can provide a new SATC table structure. SATC table lists a set of SoC integrated devices that require ATC to work (VT-d specification v3.2, section 8.8). Furthermore, the new version of IOMMU supports SoC device ATS in both its Scalable mode and legacy mode.
When IOMMU is working in scalable mode, software must enable device ATS support. On the other hand, when IOMMU is in legacy mode for whatever reason, the hardware managed ATS will automatically take effect and the SATC required devices can work transparently to the software. As the result, software shouldn't enable ATS on that device, otherwise duplicate device TLB invalidations will occur.
--- drivers/iommu/intel/iommu.c | 72 ++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +68 -4
@@ -872,6 +872,59 @@ static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev)return false; } +static bool iommu_support_ats (struct intel_iommu *iommu) +{ +return ecap_dev_iotlb_support (iommu->ecap); +} + +static bool device_support_ats (struct pci_dev *dev) +{ +return pci_ats_supported (dev) &&dmar_find_matched_atsr_unit (dev); +} + +static int segment_atc_required (u16 segment) +{ +struct acpi_dmar_satc *satc; +struct dmar_satc_unit *satcu; +int ret =1 ; + +rcu_read_lock (); +list_for_each_entry_rcu (satcu, &dmar_satc_units, list) { + satc = container_of(satcu->hdr, struct acpi_dmar_satc, header); +if (satcu->atc_required && + satcu->devices_cnt && + satc->segment == segment) + goto out; + } + ret =0 ; +out: +rcu_read_unlock (); +return ret; +} + +static int device_atc_required (struct pci_dev *dev) +{ +struct dmar_satc_unit *satcu; +struct acpi_dmar_satc *satc; +struct device *tmp; +int i, ret =1 ; + + dev =pci_physfn (dev); +rcu_read_lock (); +list_for_each_entry_rcu (satcu, &dmar_satc_units, list) { + satc = container_of(satcu->hdr, struct acpi_dmar_satc, header); +if (satc->segment ==pci_domain_nr (dev->bus) && satcu->atc_required) { +for_each_dev_scope (satcu->devices, satcu->devices_cnt, i, tmp) +if (to_pci_dev (tmp) == dev) + goto out; + } + } + ret =0 ; +out: +rcu_read_unlock (); +return ret; +} +struct intel_iommu *device_to_iommu (struct device *dev,u8 *bus,u8 *devfn) {struct dmar_drhd_unit *drhd =NULL ;
@@ -2575,10 +2628,16 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,if (dev &&dev_is_pci (dev)) {struct pci_dev *pdev =to_pci_dev (info->dev); -if (ecap_dev_iotlb_support (iommu->ecap) && -pci_ats_supported (pdev) && -dmar_find_matched_atsr_unit (pdev)) - info->ats_supported =1 ; +/* +* Support ATS by default if it's supported by both IOMMU and +* client sides, except that the device's ATS is required by +* ACPI/SATC but the IOMMU scalable mode is disabled. In that +* case the hardware managed ATS will be automatically used. +*/ +if (iommu_support_ats (iommu) &&device_support_ats (pdev)) { +if (!device_atc_required (pdev) ||sm_supported (iommu)) + info->ats_supported =1 ; + }if (sm_supported (iommu)) {if (pasid_supported (iommu)) {
@@ -3175,6 +3234,11 @@ static int __init init_dmars(void)* endfor */ for_each_drhd_unit (drhd) { +if (pci_ats_disabled () &&segment_atc_required (drhd->segment)) { +pr_warn ("Scalable mode disabled -- Use hardware managed ATS because PCIe ATS is disabled but some devices in PCIe segment 0x%x require it." , + drhd->segment); + intel_iommu_sm =0 ; + }/* * lock not needed as this is only incremented in the single * threaded kernel __init code path all other access are read
Signature · 6 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerRe: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
In reply to Lu BaoluHi Baolu,
include/acpi/actbl1.h enum acpi_dmar_type { · line 518
Quoted 7 lines · Lu Baolu
include/acpi/actbl1.h +2
-1@@ -514,7 +514,8 @@ enum acpi_dmar_type {ACPI_DMAR_TYPE_ROOT_ATS =2 ,ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3 ,ACPI_DMAR_TYPE_NAMESPACE =4 , -ACPI_DMAR_TYPE_RESERVED =5 /* 5 and greater are reserved */ +ACPI_DMAR_TYPE_SATC =5 , +ACPI_DMAR_TYPE_RESERVED =6 /* 5 and greater are reserved */
Nit: The comment needs to be updated too.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerRe: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
In reply to Lu Baoludrivers/iommu/intel/dmar.c dmar_table_print_dmar_entry(struct acpi_dmar_header *header) · line 562
Quoted 4 lines · Lu Baolu
drivers/iommu/intel/dmar.c +4
-0+case ACPI_DMAR_TYPE_SATC : + satc = container_of(header, struct acpi_dmar_satc, header); +pr_info ("SATC flags: 0x%x\n" , satc->flags); +break ;
Did the pr_info() slip through or is there a real purpose for having this information in the kernel log?
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerRe: [PATCH 3/3] iommu/vt-d: Apply SATC policy
In reply to Lu Baoludrivers/iommu/intel/iommu.c static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev) · line 916
Quoted 3 lines · Lu Baolu
drivers/iommu/intel/iommu.c +3
-0+list_for_each_entry_rcu (satcu, &dmar_satc_units, list) { + satc = container_of(satcu->hdr, struct acpi_dmar_satc, header); +if (satc->segment ==pci_domain_nr (dev->bus) && satcu->atc_required) {
You can safe a level of indentation and make this look nicer if you do:
if (satc->segment != pci_domain_nr(dev->bus) || !satcu->atc_required) continue;
drivers/iommu/intel/iommu.c static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev) · line 926
Quoted 10 lines
drivers/iommu/intel/iommu.c +10
-0+for_each_dev_scope (satcu->devices, satcu->devices_cnt, i, tmp) +if (to_pci_dev (tmp) == dev) + goto out; + } + } + ret =0 ; +out: +rcu_read_unlock (); +return ret; +}
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
In reply to Lu BaoluQuoted 6 lines · Lu Baolu
From: Yian Chen <[email protected]>
Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping structure SATC for SOC integrated devices, according to section 8.8 of Intel VT-d architecture specification v3.2. The SATC structure reports a list of the devices that require SATC enabling via ATS capacity.
nit: s/require SATC/require ATS for normal device operation. This is a functional requirement that these devices will not work without OS enabling ATS capability.
Quoted 15 lines
This patch introduces the new enum value and structure to represent the remapping information. Kernel should parse the information from the reporting structure and enable ATC for the devices as needed.
Signed-off-by Yian Chen <[email protected]>--- include/acpi/actbl1.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)include/acpi/actbl1.h +0
-0
include/acpi/actbl1.h enum acpi_dmar_type { · line 520
Quoted 8 lines
include/acpi/actbl1.h +2
-1@@ -514,7 +514,8 @@ enum acpi_dmar_type {ACPI_DMAR_TYPE_ROOT_ATS =2 ,ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3 ,ACPI_DMAR_TYPE_NAMESPACE =4 , - ACPI_DMAR_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +ACPI_DMAR_TYPE_SATC =5 , + ACPI_DMAR_TYPE_RESERVED = 6 /* 5 and greater are reserved */ };
Think Joerg spotted the comment update.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
In reply to Lu BaoluQuoted 6 lines · Lu Baolu
From: Yian Chen <[email protected]>
Software should parse every SATC table and all devices in the tables reported by the BIOS and keep the information in kernel list for further SATC policy deployment.
The last part seems bit vague? Are you trying to imply,
if kernel is booted with noats for instance, a device listed in SATC table as "requires ATS" will fail to load?
Otherwise its not clear what the policy enforcement means.
_______________________________________________
iommu mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerRe: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
In reply to Joerg RoedelHi Joerg,
Quoted 13 lines · Joerg Roedel
Hi Baolu,
include/acpi/actbl1.h enum acpi_dmar_type { · line 518
Quoted 7 lines · Lu Baolu
include/acpi/actbl1.h +2
-1@@ -514,7 +514,8 @@ enum acpi_dmar_type {ACPI_DMAR_TYPE_ROOT_ATS =2 ,ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3 ,ACPI_DMAR_TYPE_NAMESPACE =4 , -ACPI_DMAR_TYPE_RESERVED =5 /* 5 and greater are reserved */ +ACPI_DMAR_TYPE_SATC =5 , +ACPI_DMAR_TYPE_RESERVED =6 /* 5 and greater are reserved */ Nit: The comment needs to be updated too.
Yes. Will update it.
Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerRe: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC
In reply to Raj, AshokHi Ashok,
Quoted 12 lines · Ashok
Quoted 6 lines · Lu Baolu
From: Yian Chen <[email protected]>
Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping structure SATC for SOC integrated devices, according to section 8.8 of Intel VT-d architecture specification v3.2. The SATC structure reports a list of the devices that require SATC enabling via ATS capacity.
nit: s/require SATC/require ATS for normal device operation. This is a functional requirement that these devices will not work without OS enabling ATS capability.
Yes. This looks clearer.
Best regards,
baolu
Quoted 10 lines
Quoted 10 lines
This patch introduces the new enum value and structure to represent the remapping information. Kernel should parse the information from the reporting structure and enable ATC for the devices as needed.
Signed-off-by Yian Chen <[email protected]>--- include/acpi/actbl1.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Quoted 16 lines
include/acpi/actbl1.h enum acpi_dmar_type { · line 520
Quoted 13 lines
include/acpi/actbl1.h +2
-1@@ -514,7 +514,8 @@ enum acpi_dmar_type {ACPI_DMAR_TYPE_ROOT_ATS =2 ,ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3 ,ACPI_DMAR_TYPE_NAMESPACE =4 , - ACPI_DMAR_TYPE_RESERVED = 5 /* 5 and greater are reserved */ +ACPI_DMAR_TYPE_SATC =5 , + ACPI_DMAR_TYPE_RESERVED = 6 /* 5 and greater are reserved */ };Think Joerg spotted the comment update.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerRe: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
In reply to Joerg RoedelHi Joerg,
Quoted 9 lines · Joerg Roedel
drivers/iommu/intel/dmar.c dmar_table_print_dmar_entry(struct acpi_dmar_header *header) · line 562
Quoted 4 lines · Lu Baolu
drivers/iommu/intel/dmar.c +4
-0+case ACPI_DMAR_TYPE_SATC : + satc = container_of(header, struct acpi_dmar_satc, header); +pr_info ("SATC flags: 0x%x\n" , satc->flags); +break ;Did the
pr_info()slip through or is there a real purpose for having this information in the kernel log?
Here is just the easiest way for users to know SATC: system has SATC? ATS is required?
Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerRe: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure
In reply to Raj, AshokHi Ashok,
Quoted 7 lines · Ashok
Quoted 6 lines · Lu Baolu
From: Yian Chen <[email protected]>
Software should parse every SATC table and all devices in the tables reported by the BIOS and keep the information in kernel list for further SATC policy deployment.
Quoted 7 lines
The last part seems bit vague? Are you trying to imply,
if kernel is booted with noats for instance, a device listed in SATC table as "requires ATS" will fail to load?
Otherwise its not clear what the policy enforcement means.
Yes. This is a bit vague. The ATS policy is out of the purpose of this patch. It only parses the table and keep the device list for further reference.
Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerRe: [PATCH 3/3] iommu/vt-d: Apply SATC policy
In reply to Joerg RoedelQuoted 11 lines · Joerg Roedel
drivers/iommu/intel/iommu.c static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev) · line 916
Quoted 3 lines · Lu Baolu
drivers/iommu/intel/iommu.c +3
-0+list_for_each_entry_rcu (satcu, &dmar_satc_units, list) { + satc = container_of(satcu->hdr, struct acpi_dmar_satc, header); +if (satc->segment ==pci_domain_nr (dev->bus) && satcu->atc_required) {You can safe a level of indentation and make this look nicer if you do:
if (satc->segment != pci_domain_nr(dev->bus) || !satcu->atc_required) continue;
Yes. Thanks!
Best regards,
baolu
Quoted 10 lines
drivers/iommu/intel/iommu.c static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev) · line 926
Quoted 10 lines
drivers/iommu/intel/iommu.c +10
-0+for_each_dev_scope (satcu->devices, satcu->devices_cnt, i, tmp) +if (to_pci_dev (tmp) == dev) + goto out; + } + } + ret =0 ; +out: +rcu_read_unlock (); +return ret; +}
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 4 lines · Lu Baolu
Intel platform VT-d (v3.2) comes with a new type of DMAR subtable SATC. The SATC table includes a list of SoC integrated devices that require SATC. OS software can use this table to enable ATS only for the devices in the list.
This all sounds like gibberish. Please expand and if necessary explain acronyms when first used in each commit log / cover letter.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Lu Baolu
maintainerHi Christoph,
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Lu Baolu
Intel platform VT-d (v3.2) comes with a new type of DMAR subtable SATC. The SATC table includes a list of SoC integrated devices that require SATC. OS software can use this table to enable ATS only for the devices in the list.
This all sounds like gibberish. Please expand and if necessary explain acronyms when first used in each commit log / cover letter.
I will rephrase the words.
Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu