All of lore.kernel.org
 help / color / mirror / Atom feed
* Question: AMD IOMMU v1 contiguous PTE OA encoding triggers FIELD_PREP overflow
@ 2025-12-23  2:26 Chunyu Hu
  2026-01-08  0:52 ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Chunyu Hu @ 2025-12-23  2:26 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu

While enabling CONFIG_CONSTRUCTORS + GCOV, I ran into a build-time
FIELD_PREP() overflow in amdv1pt_install_leaf_entry() for the
contiguous (NEXT_LEVEL = SIZE) mapping path.

Specifically, this block:

entry |= FIELD_PREP(AMDV1PT_FMT_NEXT_LEVEL,
                    AMDV1PT_FMT_NL_SIZE) |
         FIELD_PREP(AMDV1PT_FMT_OA,
            oalog2_to_int(oasz_lg2 - PT_GRANULE_LG2SZ - 1) - 1);

ends up producing a value that exceeds the width of AMDV1PT_FMT_OA
(GENMASK_ULL(51, 12)), which compiler detect and reject at build time.

However, I’m not familiar with the AMD IOMMU internals, so I wanted
to ask the list: is OA supposed to be re-encoded for SIZE mappings, or
is this overflow indicating that the OA field should be left unchanged
in this case?

Any guidance or correction would be greatly appreciated.

Thanks,
Chunyu Hu

--<
"""
In file included from <command-line>:
In function ‘amdv1pt_install_leaf_entry’,
    inlined from ‘__do_map_single_page’ at drivers/iommu/generic_pt/fmt/../iommu_pt.h:651:3,
    inlined from ‘__map_single_page0’ at drivers/iommu/generic_pt/fmt/../iommu_pt.h:662: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:658:10,
    inlined from ‘__map_single_page1.constprop’ at drivers/iommu/generic_pt/fmt/../iommu_pt.h:662:1:
././include/linux/compiler_types.h:631:45: error: call to ‘__compiletime_assert_251’ declared with attribute error: FIELD_PREP: value too large for the field
  631 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |                                             ^
././include/linux/compiler_types.h:612:25: note: in definition of macro ‘__compiletime_assert’
  612 |                         prefix ## suffix();                             \
      |                         ^~~~~~
././include/linux/compiler_types.h:631:9: note: in expansion of macro ‘_compiletime_assert’
  631 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |         ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
   39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
      |                                     ^~~~~~~~~~~~~~~~~~
./include/linux/bitfield.h:69:17: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
   69 |                 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?           \
      |                 ^~~~~~~~~~~~~~~~
./include/linux/bitfield.h:90:17: note: in expansion of macro ‘__BF_FIELD_CHECK_MASK’
   90 |                 __BF_FIELD_CHECK_MASK(mask, val, pfx);                  \
      |                 ^~~~~~~~~~~~~~~~~~~~~
./include/linux/bitfield.h:137:17: note: in expansion of macro ‘__FIELD_PREP’
  137 |                 __FIELD_PREP(_mask, _val, "FIELD_PREP: ");              \
      |                 ^~~~~~~~~~~~
drivers/iommu/generic_pt/fmt/amdv1.h:220:26: note: in expansion of macro ‘FIELD_PREP’
  220 |                          FIELD_PREP(AMDV1PT_FMT_OA,
      |                          ^~~~~~~~~~
"""


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-13 21:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23  2:26 Question: AMD IOMMU v1 contiguous PTE OA encoding triggers FIELD_PREP overflow Chunyu Hu
2026-01-08  0:52 ` Jason Gunthorpe
2026-01-13 21:12   ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.