* Re: [PATCH v1 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active
2026-06-03 11:45 ` [PATCH v1 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active Michal Camacho Romero
@ 2026-06-11 8:49 ` Baolu Lu
2026-08-07 9:16 ` [PATCH v2 " Michal Camacho Romero
2026-08-07 10:14 ` Michal Camacho Romero
2 siblings, 0 replies; 9+ messages in thread
From: Baolu Lu @ 2026-06-11 8:49 UTC (permalink / raw)
To: Michal Camacho Romero, Ning Sun, Thomas Gleixner
Cc: baolu.lu, x86, iommu, tboot-devel, linux-kernel, Mateusz Mowka,
Adam Pawlicki, Pawel Randzio
On 6/3/2026 7:45 PM, Michal Camacho Romero wrote:
> When Intel TXT Protection Regions (TPRs) are present in the DTPR table,
> hardware-level DMA protection is already enforced by the SINIT ACM.
> In this case:
>
> - Skip forcing IOMMU enablement in tboot_force_iommu(), since TPRs
> already provide DMA protection.
> - Tear down PMRs during intel_iommu_init() when TPRs are active,
> while PMRs are redundant with TPR-based protection.
> - Call tboot_parse_dtpr_table() from parse_dmar_table() to disable
> TPR regions early, allowing the kernel to manage DMA protection
> prior to the OS boot.
>
> Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
> Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
> Signed-off-by: Michal Camacho Romero <michal.camacho.romero@intel.com>
> ---
> drivers/iommu/intel/dmar.c | 12 ++++++++++++
> drivers/iommu/intel/iommu.c | 8 +++++++-
> 2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index d33c119a935e..3ab09117c79e 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -635,6 +635,8 @@ static int __init
> parse_dmar_table(void)
> {
> struct acpi_table_dmar *dmar;
> + struct acpi_table_dtpr *dtpr;
> + void *txt_heap;
Please avoid using extra whitespace before the variable name. Just use:
void *txt_heap;
> int drhd_count = 0;
> int ret;
> struct dmar_res_callback cb = {
> @@ -670,6 +672,16 @@ parse_dmar_table(void)
> return -EINVAL;
> }
>
> + dtpr = tboot_get_dtpr_table(&txt_heap);
> + if (dtpr) {
> + /* TPR is enabled
> + * This will also tell not to establish IOMMU PMRs
> + */
Please use the standard kernel multiple-line comment format:
/*
* TPR is enabled. This will also tell not to establish IOMMU
* PMRs.
*/
> + tboot_parse_dtpr_table(dtpr);
> + iounmap(txt_heap);
> + }
> +
> + txt_heap = NULL;
> pr_info("Host address width %d\n", dmar->width + 1);
> ret = dmar_walk_dmar_table(dmar, &cb);
> if (ret == 0 && drhd_count == 0)
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 4d0e65bc131d..486693a13dc6 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2540,6 +2540,12 @@ static __init int tboot_force_iommu(void)
> if (!tboot_enabled())
> return 0;
>
> + /* If TPR is enabled we don't need to force IOMMU,
> + * TPR set by SINIT ACM will take care of DMA protection
> + */
Ditto.
> + if (tboot_is_tpr_enabled())
> + return 0;
> +
> if (no_iommu || dmar_disabled)
> pr_warn("Forcing Intel-IOMMU to enabled\n");
>
> @@ -2597,7 +2603,7 @@ int __init intel_iommu_init(void)
> * calling SENTER, but the kernel is expected to reset/tear
> * down the PMRs.
> */
> - if (intel_iommu_tboot_noforce) {
> + if (intel_iommu_tboot_noforce || tboot_is_tpr_enabled()) {
> for_each_iommu(iommu, drhd)
> iommu_disable_protect_mem_regions(iommu);
> }
With these nits fixed:
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v2 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active
2026-06-03 11:45 ` [PATCH v1 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active Michal Camacho Romero
2026-06-11 8:49 ` Baolu Lu
@ 2026-08-07 9:16 ` Michal Camacho Romero
2026-08-07 10:14 ` Michal Camacho Romero
2 siblings, 0 replies; 9+ messages in thread
From: Michal Camacho Romero @ 2026-08-07 9:16 UTC (permalink / raw)
To: Baolu Lu, Ning Sun, Thomas Gleixner
Cc: Michal Camacho Romero, x86, iommu, tboot-devel, linux-kernel,
Mateusz Mowka, Adam Pawlicki, Pawel Randzio
When Intel TXT Protection Regions (TPRs) are present in the DTPR table,
hardware-level DMA protection is already enforced by the SINIT ACM.
In this case:
- Skip forcing IOMMU enablement in tboot_force_iommu(), since TPRs
already provide DMA protection.
- Tear down PMRs during intel_iommu_init() when TPRs are active,
while PMRs are redundant with TPR-based protection.
- Call tboot_parse_dtpr_table() from parse_dmar_table() to disable
TPR regions early, allowing the kernel to manage DMA protection
prior to the OS boot.
Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Michal Camacho Romero <michal.camacho.romero@intel.com>
---
drivers/iommu/intel/dmar.c | 13 +++++++++++++
drivers/iommu/intel/iommu.c | 9 ++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 767ec092accd..17c26d222253 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -635,6 +635,8 @@ static int __init
parse_dmar_table(void)
{
struct acpi_table_dmar *dmar;
+ struct acpi_table_dtpr *dtpr;
+ void *txt_heap;
int drhd_count = 0;
int ret;
struct dmar_res_callback cb = {
@@ -670,6 +672,17 @@ parse_dmar_table(void)
return -EINVAL;
}
+ dtpr = tboot_get_dtpr_table(&txt_heap);
+ if (dtpr) {
+ /*
+ * TPR is enabled. This will also tell not to establish IOMMU
+ * PMRs.
+ */
+ tboot_parse_dtpr_table(dtpr);
+ iounmap(txt_heap);
+ }
+
+ txt_heap = NULL;
pr_info("Host address width %d\n", dmar->width + 1);
ret = dmar_walk_dmar_table(dmar, &cb);
if (ret == 0 && drhd_count == 0)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 849d06dfe1ae..5bc6f2dd25c4 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2543,6 +2543,13 @@ static __init int tboot_force_iommu(void)
if (!tboot_enabled())
return 0;
+ /*
+ * If TPR is enabled we don't need to force IOMMU, TPR set by SINIT
+ * ACM will take care of DMA protection.
+ */
+ if (tboot_is_tpr_enabled())
+ return 0;
+
if (no_iommu || dmar_disabled)
pr_warn("Forcing Intel-IOMMU to enabled\n");
@@ -2600,7 +2607,7 @@ int __init intel_iommu_init(void)
* calling SENTER, but the kernel is expected to reset/tear
* down the PMRs.
*/
- if (intel_iommu_tboot_noforce) {
+ if (intel_iommu_tboot_noforce || tboot_is_tpr_enabled()) {
for_each_iommu(iommu, drhd)
iommu_disable_protect_mem_regions(iommu);
}
--
2.55.0
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v2 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active
2026-06-03 11:45 ` [PATCH v1 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active Michal Camacho Romero
2026-06-11 8:49 ` Baolu Lu
2026-08-07 9:16 ` [PATCH v2 " Michal Camacho Romero
@ 2026-08-07 10:14 ` Michal Camacho Romero
2026-08-20 3:28 ` Baolu Lu
2 siblings, 1 reply; 9+ messages in thread
From: Michal Camacho Romero @ 2026-08-07 10:14 UTC (permalink / raw)
To: Baolu Lu, Ning Sun, Thomas Gleixner
Cc: Michal Camacho Romero, x86, iommu, tboot-devel, linux-kernel,
Mateusz Mowka, Adam Pawlicki, Pawel Randzio
From: Michal Camacho Romero <michal.camacho.romero@intel.com>
When Intel TXT Protection Regions (TPRs) are present in the DTPR table,
hardware-level DMA protection is already enforced by the SINIT ACM.
In this case:
- Skip forcing IOMMU enablement in tboot_force_iommu(), since TPRs
already provide DMA protection.
- Tear down PMRs during intel_iommu_init() when TPRs are active,
while PMRs are redundant with TPR-based protection.
- Call tboot_parse_dtpr_table() from parse_dmar_table() to disable
TPR regions early, allowing the kernel to manage DMA protection
prior to the OS boot.
Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Michal Camacho Romero <michal.camacho.romero@intel.com>
---
drivers/iommu/intel/dmar.c | 13 +++++++++++++
drivers/iommu/intel/iommu.c | 9 ++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 767ec092accd..17c26d222253 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -635,6 +635,8 @@ static int __init
parse_dmar_table(void)
{
struct acpi_table_dmar *dmar;
+ struct acpi_table_dtpr *dtpr;
+ void *txt_heap;
int drhd_count = 0;
int ret;
struct dmar_res_callback cb = {
@@ -670,6 +672,17 @@ parse_dmar_table(void)
return -EINVAL;
}
+ dtpr = tboot_get_dtpr_table(&txt_heap);
+ if (dtpr) {
+ /*
+ * TPR is enabled. This will also tell not to establish IOMMU
+ * PMRs.
+ */
+ tboot_parse_dtpr_table(dtpr);
+ iounmap(txt_heap);
+ }
+
+ txt_heap = NULL;
pr_info("Host address width %d\n", dmar->width + 1);
ret = dmar_walk_dmar_table(dmar, &cb);
if (ret == 0 && drhd_count == 0)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 849d06dfe1ae..5bc6f2dd25c4 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2543,6 +2543,13 @@ static __init int tboot_force_iommu(void)
if (!tboot_enabled())
return 0;
+ /*
+ * If TPR is enabled we don't need to force IOMMU, TPR set by SINIT
+ * ACM will take care of DMA protection.
+ */
+ if (tboot_is_tpr_enabled())
+ return 0;
+
if (no_iommu || dmar_disabled)
pr_warn("Forcing Intel-IOMMU to enabled\n");
@@ -2600,7 +2607,7 @@ int __init intel_iommu_init(void)
* calling SENTER, but the kernel is expected to reset/tear
* down the PMRs.
*/
- if (intel_iommu_tboot_noforce) {
+ if (intel_iommu_tboot_noforce || tboot_is_tpr_enabled()) {
for_each_iommu(iommu, drhd)
iommu_disable_protect_mem_regions(iommu);
}
--
2.55.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active
2026-08-07 10:14 ` Michal Camacho Romero
@ 2026-08-20 3:28 ` Baolu Lu
2026-09-03 9:33 ` [PATCH v3 " Michal Camacho Romero
0 siblings, 1 reply; 9+ messages in thread
From: Baolu Lu @ 2026-08-20 3:28 UTC (permalink / raw)
To: Michal Camacho Romero, Ning Sun, Thomas Gleixner
Cc: Michal Camacho Romero, x86, iommu, tboot-devel, linux-kernel,
Mateusz Mowka, Adam Pawlicki, Pawel Randzio
On 8/7/26 18:14, Michal Camacho Romero wrote:
> From: Michal Camacho Romero <michal.camacho.romero@intel.com>
>
> When Intel TXT Protection Regions (TPRs) are present in the DTPR table,
> hardware-level DMA protection is already enforced by the SINIT ACM.
> In this case:
>
> - Skip forcing IOMMU enablement in tboot_force_iommu(), since TPRs
> already provide DMA protection.
> - Tear down PMRs during intel_iommu_init() when TPRs are active,
> while PMRs are redundant with TPR-based protection.
> - Call tboot_parse_dtpr_table() from parse_dmar_table() to disable
> TPR regions early, allowing the kernel to manage DMA protection
> prior to the OS boot.
>
> Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
> Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Michal Camacho Romero <michal.camacho.romero@intel.com>
> ---
> drivers/iommu/intel/dmar.c | 13 +++++++++++++
> drivers/iommu/intel/iommu.c | 9 ++++++++-
> 2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index 767ec092accd..17c26d222253 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -635,6 +635,8 @@ static int __init
> parse_dmar_table(void)
> {
> struct acpi_table_dmar *dmar;
> + struct acpi_table_dtpr *dtpr;
> + void *txt_heap;
> int drhd_count = 0;
> int ret;
> struct dmar_res_callback cb = {
> @@ -670,6 +672,17 @@ parse_dmar_table(void)
> return -EINVAL;
> }
>
> + dtpr = tboot_get_dtpr_table(&txt_heap);
> + if (dtpr) {
> + /*
> + * TPR is enabled. This will also tell not to establish IOMMU
> + * PMRs.
> + */
> + tboot_parse_dtpr_table(dtpr);
> + iounmap(txt_heap);
> + }
> +
> + txt_heap = NULL;
> pr_info("Host address width %d\n", dmar->width + 1);
> ret = dmar_walk_dmar_table(dmar, &cb);
> if (ret == 0 && drhd_count == 0)
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 849d06dfe1ae..5bc6f2dd25c4 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2543,6 +2543,13 @@ static __init int tboot_force_iommu(void)
This patch doesn't apply cleanly on top of the recent mainline tree —
tboot_force_iommu() has been refactored by a recent merge. Please rebase
and re-post it after 7.3-rc1.
> if (!tboot_enabled())
> return 0;
>
> + /*
> + * If TPR is enabled we don't need to force IOMMU, TPR set by SINIT
> + * ACM will take care of DMA protection.
> + */
> + if (tboot_is_tpr_enabled())
> + return 0;
> +
> if (no_iommu || dmar_disabled)
> pr_warn("Forcing Intel-IOMMU to enabled\n");
>
> @@ -2600,7 +2607,7 @@ int __init intel_iommu_init(void)
> * calling SENTER, but the kernel is expected to reset/tear
> * down the PMRs.
> */
> - if (intel_iommu_tboot_noforce) {
> + if (intel_iommu_tboot_noforce || tboot_is_tpr_enabled()) {
> for_each_iommu(iommu, drhd)
> iommu_disable_protect_mem_regions(iommu);
> }
Thanks,
baolu
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v3 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active
2026-08-20 3:28 ` Baolu Lu
@ 2026-09-03 9:33 ` Michal Camacho Romero
2026-09-04 2:19 ` Baolu Lu
0 siblings, 1 reply; 9+ messages in thread
From: Michal Camacho Romero @ 2026-09-03 9:33 UTC (permalink / raw)
To: Baolu Lu, Ning Sun, Thomas Gleixner
Cc: Michal Camacho Romero, x86, iommu, tboot-devel, linux-kernel,
Mateusz Mowka, Adam Pawlicki, Pawel Randzio,
Michal Camacho Romero
When Intel TXT Protection Regions (TPRs) are present in the DTPR table,
hardware-level DMA protection is already enforced by the SINIT ACM.
In this case:
- Skip forcing IOMMU enablement in tboot_force_iommu(), since TPRs
already provide DMA protection.
- Tear down PMRs during intel_iommu_init() when TPRs are active,
while PMRs are redundant with TPR-based protection.
- Call tboot_parse_dtpr_table() from parse_dmar_table() to disable
TPR regions early, allowing the kernel to manage DMA protection
prior to the OS boot.
Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
---
drivers/iommu/intel/dmar.c | 13 +++++++++++++
drivers/iommu/intel/iommu.c | 9 ++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index ba675b08cd20..c98a44487706 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -635,6 +635,8 @@ static int __init
parse_dmar_table(void)
{
struct acpi_table_dmar *dmar;
+ struct acpi_table_dtpr *dtpr;
+ void *txt_heap;
int drhd_count = 0;
int ret;
struct dmar_res_callback cb = {
@@ -670,6 +672,17 @@ parse_dmar_table(void)
return -EINVAL;
}
+ dtpr = tboot_get_dtpr_table(&txt_heap);
+ if (dtpr) {
+ /*
+ * TPR is enabled. This will also tell not to establish IOMMU
+ * PMRs.
+ */
+ tboot_parse_dtpr_table(dtpr);
+ iounmap(txt_heap);
+ }
+
+ txt_heap = NULL;
pr_info("Host address width %d\n", dmar->width + 1);
ret = dmar_walk_dmar_table(dmar, &cb);
if (ret == 0 && drhd_count == 0)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 2e3b3ab216f8..ce40b1bf0296 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2563,6 +2563,13 @@ static __init void tboot_force_iommu(void)
if (!tboot_enabled() || intel_iommu_tboot_noforce)
return;
+ /*
+ * If TPR is enabled we don't need to force IOMMU, TPR set by SINIT
+ * ACM will take care of DMA protection.
+ */
+ if (tboot_is_tpr_enabled())
+ return;
+
if (!dmar_can_force_on(DMAR_FORCEON_TBOOT))
panic("tboot: Failed to force IOMMU on\n");
@@ -2623,7 +2630,7 @@ int __init intel_iommu_init(void)
* calling SENTER, but the kernel is expected to reset/tear
* down the PMRs.
*/
- if (intel_iommu_tboot_noforce) {
+ if (intel_iommu_tboot_noforce || tboot_is_tpr_enabled()) {
for_each_iommu(iommu, drhd)
iommu_disable_protect_mem_regions(iommu);
}
--
2.55.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v3 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active
2026-09-03 9:33 ` [PATCH v3 " Michal Camacho Romero
@ 2026-09-04 2:19 ` Baolu Lu
0 siblings, 0 replies; 9+ messages in thread
From: Baolu Lu @ 2026-09-04 2:19 UTC (permalink / raw)
To: Michal Camacho Romero, Ning Sun, Thomas Gleixner
Cc: baolu.lu, Michal Camacho Romero, x86, iommu, tboot-devel,
linux-kernel, Mateusz Mowka, Adam Pawlicki, Pawel Randzio
On 9/3/2026 5:33 PM, Michal Camacho Romero wrote:
> When Intel TXT Protection Regions (TPRs) are present in the DTPR table,
> hardware-level DMA protection is already enforced by the SINIT ACM.
> In this case:
>
> - Skip forcing IOMMU enablement in tboot_force_iommu(), since TPRs
> already provide DMA protection.
> - Tear down PMRs during intel_iommu_init() when TPRs are active,
> while PMRs are redundant with TPR-based protection.
> - Call tboot_parse_dtpr_table() from parse_dmar_table() to disable
> TPR regions early, allowing the kernel to manage DMA protection
> prior to the OS boot.
>
> Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
> Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
> ---
> drivers/iommu/intel/dmar.c | 13 +++++++++++++
> drivers/iommu/intel/iommu.c | 9 ++++++++-
> 2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index ba675b08cd20..c98a44487706 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -635,6 +635,8 @@ static int __init
> parse_dmar_table(void)
> {
> struct acpi_table_dmar *dmar;
> + struct acpi_table_dtpr *dtpr;
> + void *txt_heap;
> int drhd_count = 0;
> int ret;
> struct dmar_res_callback cb = {
> @@ -670,6 +672,17 @@ parse_dmar_table(void)
> return -EINVAL;
> }
>
> + dtpr = tboot_get_dtpr_table(&txt_heap);
What happens if parse_dmar_table() returns failure after this call?
That would mean TPR teardown happens even if DMAR parsing later fails
and returns error. Is that the intended behavior (i.e., parse/disable
TPR regardless of whether DMAR is ultimately usable)?
Also, does tboot_get_dtpr_table() become a no-op and return NULL when
tboot is not active? This is important, since it is called
unconditionally on every boot.
> + if (dtpr) {
> + /*
> + * TPR is enabled. This will also tell not to establish IOMMU
> + * PMRs.
> + */
> + tboot_parse_dtpr_table(dtpr);
Can this fail? If yes, why is there no error handling?
> + iounmap(txt_heap);
txt_heap is not used in the IOMMU driver. Why map it inside a hidden
helper call and then unmap it here?
> + }
> +
> + txt_heap = NULL;
txt_heap is never used after this line, so this assignment is dead code?
> pr_info("Host address width %d\n", dmar->width + 1);
> ret = dmar_walk_dmar_table(dmar, &cb);
> if (ret == 0 && drhd_count == 0)
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 2e3b3ab216f8..ce40b1bf0296 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2563,6 +2563,13 @@ static __init void tboot_force_iommu(void)
> if (!tboot_enabled() || intel_iommu_tboot_noforce)
> return;
>
> + /*
> + * If TPR is enabled we don't need to force IOMMU, TPR set by SINIT
> + * ACM will take care of DMA protection.
> + */
> + if (tboot_is_tpr_enabled())
> + return;
> +
> if (!dmar_can_force_on(DMAR_FORCEON_TBOOT))
> panic("tboot: Failed to force IOMMU on\n");
>
> @@ -2623,7 +2630,7 @@ int __init intel_iommu_init(void)
> * calling SENTER, but the kernel is expected to reset/tear
> * down the PMRs.
> */
> - if (intel_iommu_tboot_noforce) {
> + if (intel_iommu_tboot_noforce || tboot_is_tpr_enabled()) {
> for_each_iommu(iommu, drhd)
> iommu_disable_protect_mem_regions(iommu);
> }
Thanks,
baolu
^ permalink raw reply [flat|nested] 9+ messages in thread