linux/drivers/iommu/generic_pt
Sherry Yang 8b72aa5704 iommupt/amdv1: mark amdv1pt_install_leaf_entry as __always_inline
After enabling CONFIG_GCOV_KERNEL and CONFIG_GCOV_PROFILE_ALL, following
build failure is observed under GCC 14.2.1:

In function 'amdv1pt_install_leaf_entry',
    inlined from '__do_map_single_page' at drivers/iommu/generic_pt/fmt/../iommu_pt.h:650:3,
    inlined from '__map_single_page0' at drivers/iommu/generic_pt/fmt/../iommu_pt.h:661:1,
    inlined from 'pt_descend' at drivers/iommu/generic_pt/fmt/../pt_iter.h:391:9,
    inlined from '__do_map_single_page' at drivers/iommu/generic_pt/fmt/../iommu_pt.h:657:10,
    inlined from '__map_single_page1.constprop' at drivers/iommu/generic_pt/fmt/../iommu_pt.h:661:1:
././include/linux/compiler_types.h:706:45: error: call to '__compiletime_assert_71' declared with attribute error: FIELD_PREP: value too large for the field
  706 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |

......

drivers/iommu/generic_pt/fmt/amdv1.h:220:26: note: in expansion of macro 'FIELD_PREP'
  220 |                          FIELD_PREP(AMDV1PT_FMT_OA,
      |                          ^~~~~~~~~~

In the path '__do_map_single_page()', level 0 always invokes
'pt_install_leaf_entry(&pts, map->oa, PAGE_SHIFT, …)'. At runtime that
lands in the 'if (oasz_lg2 == isz_lg2)' arm of 'amdv1pt_install_leaf_entry()';
the contiguous-only 'else' block is unreachable for 4 KiB pages.

With CONFIG_GCOV_KERNEL + CONFIG_GCOV_PROFILE_ALL, the extra
instrumentation changes GCC's inlining so that the "dead" 'else' branch
still gets instantiated. The compiler constant-folds the contiguous OA
expression, runs the 'FIELD_PREP()' compile-time check, and produces:

    FIELD_PREP: value too large for the field

gcov-enabled builds therefore fail even though the code path never executes.

Fix this by marking amdv1pt_install_leaf_entry as __always_inline.

Fixes: dcd6a011a8 ("iommupt: Add map_pages op")
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sherry Yang <sherry.yang@oracle.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2026-03-27 09:41:48 +01:00
..
fmt iommupt/amdv1: mark amdv1pt_install_leaf_entry as __always_inline 2026-03-27 09:41:48 +01:00
.kunitconfig iommupt: Fix the kunit building 2026-01-10 10:40:57 +01:00
Kconfig genpt: Make GENERIC_PT invisible 2025-11-28 08:40:24 +01:00
iommu_pt.h iommupt: Fix short gather if the unmap goes into a large mapping 2026-03-27 09:07:13 +01:00
kunit_generic_pt.h iommupt: Add a kunit test for the SW bits 2025-11-05 09:50:21 +01:00
kunit_iommu.h iommu/iommupt: Fix build error in genericpt unit-tests 2025-11-07 16:06:19 +01:00
kunit_iommu_pt.h iommupt: Add a kunit test for the IOMMU implementation 2025-11-05 09:08:58 +01:00
pt_common.h iommupt: Actually correct pt_test_sw_bit_{acquire_release}() parameter description 2025-11-17 09:46:22 +01:00
pt_defs.h iommupt: Make pt_feature() always_inline 2026-01-10 10:50:45 +01:00
pt_fmt_defaults.h iommupt: Add basic support for SW bits in the page table 2025-11-05 09:47:44 +01:00
pt_iter.h iommupt: Add map_pages op 2025-11-05 09:07:10 +01:00
pt_log2.h