Re: [PATCH v2 19/31] iommu/vt-d: Reserve the MSB domain ID bit for the TDX module

Baolu Lu
2026-03-31T07:22:12Z

On 3/29/26 00:57, kernel test robot wrote:
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 11439c4635edd669ae435eec308f4ab8a0804808]
>
> url:https://github.com/intel-lab-lkp/linux/commits/Xu-Yilun/x86-tdx-Move-
> all-TDX-error-defines-into-asm-shared-tdx_errno-h/20260328-151524
> base: 11439c4635edd669ae435eec308f4ab8a0804808
> patch link:https://lore.kernel.org/r/20260327160132.2946114-20-
> yilun.xu%40linux.intel.com
> patch subject: [PATCH v2 19/31] iommu/vt-d: Reserve the MSB domain ID bit for the TDX module
> config: i386-randconfig-141-20260328 (https://download.01.org/0day-ci/archive/20260329/202603290006.za7iiDgF-
> lkp@intel.com/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> smatch: v0.5.0-9004-gb810ac53
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260329/202603290006.za7iiDgF-
> lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot<lkp@intel.com>
> | Closes:https://lore.kernel.org/oe-kbuild-all/202603290006.za7iiDgF-lkp@intel.com/
>
> All warnings (new ones prefixed by >>, old ones prefixed by <<):
>
>>> WARNING: modpost: vmlinux: section mismatch in reference: iommu_max_domain_id+0x55 (section: .text.iommu_max_domain_id) -> acpi_table_parse_keyp (section: .init.text)

acpi_table_parse_keyp() is marked as __init. But this patch causes the
intel iommu driver to call it from a runtime function.

int __init_or_acpilib
acpi_table_parse_keyp(enum acpi_keyp_type id,
acpi_tbl_entry_handler_arg handler_arg, void *arg)
{
return __acpi_table_parse_entries(ACPI_SIG_KEYP,
sizeof(struct
acpi_table_keyp), id,
NULL, handler_arg, arg, 0);
}

One way to solve this might be parsing the table once in the __init
context and store the result in variable that could be used after boot.

How about the following additional change (untested)?

diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 097c4a90302f..0b384a58a3a0 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -63,6 +63,7 @@ LIST_HEAD(dmar_drhd_units);
struct acpi_table_header * __initdata dmar_tbl;
static int dmar_dev_scope_status = 1;
static DEFINE_IDA(dmar_seq_ids);
+static bool tdx_tvm_usable __ro_after_init;

static int alloc_iommu(struct dmar_drhd_unit *drhd);
static void free_iommu(struct intel_iommu *iommu);
@@ -915,6 +916,17 @@ dmar_validate_one_drhd(struct acpi_dmar_header
*entry, void *arg)
return 0;
}

+static void __init intel_iommu_check_tdxc_enhancement(void)
+{
+ int tvm_usable = 0;
+ int ret;
+
+ ret = acpi_table_parse_keyp(ACPI_KEYP_TYPE_CONFIG_UNIT,
+ keyp_config_unit_tvm_usable, &tvm_usable);
+ if (ret >= 0)
+ tdx_tvm_usable = !!tvm_usable;
+}
+
void __init detect_intel_iommu(void)
{
int ret;
@@ -923,6 +935,8 @@ void __init detect_intel_iommu(void)
.ignore_unhandled = true,
};

+ intel_iommu_check_tdxc_enhancement();
+
down_write(&dmar_global_lock);
ret = dmar_table_detect();
if (!ret)
@@ -1046,24 +1060,6 @@ static int keyp_config_unit_tvm_usable(union
acpi_subtable_headers *header,
return 0;
}

-static bool platform_is_tdxc_enhanced(void)
-{
- static int tvm_usable = -1;
- int ret;
-
- /* only need to parse once */
- if (tvm_usable != -1)
- return !!tvm_usable;
-
- tvm_usable = 0;
- ret = acpi_table_parse_keyp(ACPI_KEYP_TYPE_CONFIG_UNIT,
- keyp_config_unit_tvm_usable, &tvm_usable);
- if (ret < 0)
- tvm_usable = 0;
-
- return !!tvm_usable;
-}
-
static unsigned long iommu_max_domain_id(struct intel_iommu *iommu)
{
unsigned long ndoms = cap_ndoms(iommu->cap);
@@ -1075,7 +1071,7 @@ static unsigned long iommu_max_domain_id(struct
intel_iommu *iommu)
* the VMM’s DID setting, reserving the MSB bit for the TDX module. The
* TDX module always sets this reserved bit on the trusted DMA table.
*/
- if (ecap_tdxc(iommu->ecap) && platform_is_tdxc_enhanced()) {
+ if (ecap_tdxc(iommu->ecap) && tdx_tvm_usable) {
pr_info_once("Most Significant Bit of domain ID reserved.\n");
return ndoms >> 1;
}

Thanks,
baolu