All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chunyu Hu <chuhu@redhat.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux.dev
Subject: Question: AMD IOMMU v1 contiguous PTE OA encoding triggers FIELD_PREP overflow
Date: Tue, 23 Dec 2025 10:26:00 +0800	[thread overview]
Message-ID: <aUn9uGPCooqB-RIF@gmail.com> (raw)

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,
      |                          ^~~~~~~~~~
"""


             reply	other threads:[~2025-12-23  2:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23  2:26 Chunyu Hu [this message]
2026-01-08  0:52 ` Question: AMD IOMMU v1 contiguous PTE OA encoding triggers FIELD_PREP overflow Jason Gunthorpe
2026-01-13 21:12   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aUn9uGPCooqB-RIF@gmail.com \
    --to=chuhu@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.