From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <iommu@lists.linux.dev>, "Joerg Roedel (AMD)" <joro@8bytes.org>,
Jean-Philippe Brucker <jpb@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>,
David Matlack <dmatlack@google.com>,
"John Garry" <john.garry@arm.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
<patches@lists.linux.dev>, Pranjal Shrivastava <praan@google.com>,
"Samiullah Khawaja" <skhawaja@google.com>,
Mostafa Saleh <smostafa@google.com>
Subject: Re: [PATCH v3 08/13] iommupt/armv8: Implement the iommu specific components
Date: Fri, 4 Dec 2026 13:08:43 -0800 [thread overview]
Message-ID: <axMr20tSwAkfO/8j@nvidia.com> (raw)
In-Reply-To: <8-v3-97feb2edfbab+748d0a-iommupt_armv8_jgg@nvidia.com>
On Sun, Nov 15, 2026 at 07:30:38PM -0400, Jason Gunthorpe wrote:
> The iommu page table is built on top of the generic components, add the
> peices required to turn that on for ARMv8
s/peices/pieces
> - Makefile and kconfig
> - pt_iommu_* functions for ARMv8, including the complicated
> initialization of the level and structure from a typical pt_iommu cfg
> - pt_iommu_hw_info to return the field values program into the STE
> - 12 kunit patterns covering a range of operating modes
>
> Include an inline helper pt_iommu_armv8_choose_granule_lg2sz() that does
> similar to what iopgtbl does to select an appropriate translation granule
s/iopgtbl/io-pgtble-arm
> +config IOMMU_PT_ARMV8
> + tristate "IOMMU page table for 64 bit ARMv8"
> + depends on !GENERIC_ATOMIC64 # for cmpxchg64
> + help
> + iommu_domain implementation for the ARMv8 VMSAv8-64 and the VMSAv8-32
> + long descriptor pagetable format. This format supports both stage-1
> + and stage-2, as well as address spaces up to 48-bits in size with
I see this patch supports 52 bits.
> +static inline void armv8pt_s2_validate_level(unsigned int top_level,
> + unsigned int tgsz_lg2,
> + unsigned int vasz_lg2, bool lpa2)
> +{
> + unsigned int max_top_level;
> +
> + switch (tgsz_lg2) {
> + case SZLG2_4K:
> + if (lpa2)
> + max_top_level =
> + vasz_lg2 >= 52 ?
> + ARMLn1 :
> + (vasz_lg2 >= 44 ? ARML0 : ARML1);
> + else
> + max_top_level = vasz_lg2 >= 44 ? ARML0 : ARML1;
> + break;
> + case SZLG2_16K: /* ARM level 1 requires PA >= 42 */
> + max_top_level = vasz_lg2 >= 42 ? ARML1 : ARML2;
max_top_level can be 0 in 16K when vasz_lg2 >= 52.
> +static inline int armv8pt_iommu_fmt_init(struct pt_iommu_armv8 *iommu_table,
> + const struct pt_iommu_armv8_cfg *cfg)
> +{
[...]
> + /*
> + * R_SRKBC: For the 4KB granule, an initial lookup level of 3 is
> + * only supported if FEAT_TTST is implemented. See Table D8-9 and
> + * Table D8-24. FEAT_TTST is not supported.
> + */
> + if (pt_feature(&armv8pt->common, PT_FEAT_ARMV8_S2) &&
> + tgsz_lg2 == SZLG2_4K && levels == 1)
> + return -EINVAL;
> +
> + /*
> + * D8.2.2: Always use the S2 concatenated tables feature (I_TDMHR)
> + * to fold a top level of up to 16 tables into the next lower
> + * level. Since FEAT_TTST is not supported single level cannot be
> + * selected here either. Notice that there are a number of cases
> + * in the spec that require concatenated tables (eg R_DXBSH),
> + * since this always uses them it is OK. See commit 4dcac8407fe1
> + * ("iommu/io-pgtable-arm: Fix stage-2 concatenation with 16K")
> + */
> + if (!pt_feature(&armv8pt->common, PT_FEAT_DYNAMIC_TOP) &&
> + pt_feature(&armv8pt->common, PT_FEAT_ARMV8_S2) && levels > 1) {
> + unsigned int topsz_lg2 =
> + vasz_lg2 - (tgsz_lg2 + (tgsz_lg2 - ilog2(sizeof(u64))) *
> + (levels - 1));
> + if (topsz_lg2 <= ilog2(16))
> + levels--;
> + }
Should we move the "levels == 1" test (R_SRKBC) after concatenation?
> +static inline void
> +armv8pt_iommu_fmt_hw_info(struct pt_iommu_armv8 *table,
> + const struct pt_range *top_range,
> + struct pt_iommu_armv8_hw_info *info)
> +{
[...]
> + if (pt_feature(common, PT_FEAT_ARMV8_S2)) {
> + /*
> + * STE S2SL0/S2SL2: Starting level in VTCR_EL2.SL0/SL2
> + * encoding. Table from D24.2.210 SL0:
> + *
> + * 4K: top_level ARMLx S2SL0 S2SL2
> + * 1 ARML2 0 0
> + * 2 ARML1 1 0
> + * 3 ARML0 2 0
> + * 4 ARMLn1 0 1 (FEAT_LPA2)
> + *
> + * 16K/64K:
> + * 0 ARML3 0
> + * 1 ARML2 1
> + * 2 ARML1 2
Is this missing (or on purpose):
* 3 ARML0 3 (16K; FEAT_LPA2)
?
> + */
> + info->s2.sl2 = 0;
> + if (tgsz_lg2 == SZLG2_4K) {
> + if (top_range->top_level == ARMLn1) {
> + info->s2.sl0 = 0;
> + info->s2.sl2 = 1;
> + } else {
> + info->s2.sl0 = top_range->top_level - 1;
Though it's not in the list above, top_level can be 0 (ARML3) for
4K, right? Would 0 - 1 underflow here?
> +#if defined(GENERIC_PT_KUNIT)
> +static const struct pt_iommu_armv8_cfg armv8_kunit_fmt_cfgs[] = {
> + /*
> + * See R_DXBSH: 16K granule + 48-bit S2 is required to start at level 1
> + * with 2 concatenated tables.
> + */
> + [4] = { .tgsz_lg2 = 14,
> + .common.features = BIT(PT_FEAT_ARMV8_S2),
> + .common.hw_max_oasz_lg2 = 48,
> + .common.hw_max_vasz_lg2 = 48 },
> + [5] = { .tgsz_lg2 = 14,
> + .common.features = BIT(PT_FEAT_ARMV8_TTBR1),
> + .common.hw_max_oasz_lg2 = 48,
> + .common.hw_max_vasz_lg2 = 48 },
> + /* 64K granule */
> + [6] = { .tgsz_lg2 = 16,
> + .common.features = BIT(PT_FEAT_ARMV8_DBM),
> + .common.hw_max_oasz_lg2 = 48,
> + .common.hw_max_vasz_lg2 = 48 },
> + [7] = { .tgsz_lg2 = 16,
> + .common.features = BIT(PT_FEAT_ARMV8_S2),
> + .common.hw_max_oasz_lg2 = 48,
> + .common.hw_max_vasz_lg2 = 48 },
> + [8] = { .tgsz_lg2 = 16,
> + .common.features = BIT(PT_FEAT_ARMV8_TTBR1),
> + .common.hw_max_oasz_lg2 = 48,
> + .common.hw_max_vasz_lg2 = 48 },
> + /* S2 concatenated table configurations at smaller IPA sizes */
> + [9] = { .tgsz_lg2 = 12,
> + .common.features = BIT(PT_FEAT_ARMV8_S2),
> + .common.hw_max_oasz_lg2 = 40,
> + .common.hw_max_vasz_lg2 = 40 },
> + [10] = { .tgsz_lg2 = 12,
> + .common.features = BIT(PT_FEAT_ARMV8_S2),
> + .common.hw_max_oasz_lg2 = 42,
> + .common.hw_max_vasz_lg2 = 42 },
> + [11] = { .tgsz_lg2 = 14,
> + .common.features = BIT(PT_FEAT_ARMV8_S2),
> + .common.hw_max_oasz_lg2 = 40,
> + .common.hw_max_vasz_lg2 = 40 },
> +};
Would it be worth adding a 52-bit coverage with PT_FEAT_ARMV8_LPA2?
Nicolin
next prev parent reply other threads:[~2026-12-04 21:09 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 23:30 [PATCH v3 00/13] Use the generic iommu page table for SMMUv3 Jason Gunthorpe
2026-11-15 23:30 ` [PATCH v3 01/13] iommu/arm-smmu-v3: Change how the tlbi describes the invalidation Jason Gunthorpe
2026-11-15 23:30 ` [PATCH v3 02/13] iommu/arm-smmu-v3: Support the DS expansion of range invalidation SCALE Jason Gunthorpe
2026-11-15 23:30 ` [PATCH v3 03/13] iommupt: Remove the sanity check for pt_num_items_lg2() at the top level Jason Gunthorpe
2026-11-24 0:40 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 04/13] iommupt/kunit: Do not test INCOHERENT on anything but x86 Jason Gunthorpe
2026-11-24 0:49 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 05/13] iommupt/kunit: Skip test configs without supported features Jason Gunthorpe
2026-11-24 5:29 ` Nicolin Chen
2026-11-24 15:08 ` Jason Gunthorpe
2026-11-24 19:08 ` Nicolin Chen
2026-11-24 20:07 ` Jason Gunthorpe
2026-11-26 5:00 ` Nicolin Chen
2026-11-30 22:44 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 06/13] iommupt/armv8: Add the 64 bit ARMv8 page table format Jason Gunthorpe
2026-12-03 0:15 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 07/13] iommupt/armv8: Add DBM support Jason Gunthorpe
2026-12-04 1:38 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 08/13] iommupt/armv8: Implement the iommu specific components Jason Gunthorpe
2026-12-04 21:08 ` Nicolin Chen [this message]
2026-11-15 23:30 ` [PATCH v3 09/13] iommu/arm-smmu-v3: Remove io-pgtable-arm from sva.c Jason Gunthorpe
2026-12-04 21:11 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 10/13] iommu/arm-smmu-v3: Move the DMA API comment to flush_iotlb_all Jason Gunthorpe
2026-12-04 21:12 ` Nicolin Chen
2026-11-15 23:30 ` [PATCH v3 11/13] iommu/arm-smmu-v3: Support CONT in paging domains with errata Jason Gunthorpe
2026-11-15 23:30 ` [PATCH v3 12/13] iommu/arm-smmu-v3: Use the generic iommu page table Jason Gunthorpe
2026-11-15 23:30 ` [PATCH v3 13/13] iommu: Remove pgsize from iommu_iotlb_gather Jason Gunthorpe
2026-11-24 0:04 ` [PATCH v3 00/13] Use the generic iommu page table for SMMUv3 Nicolin Chen
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=axMr20tSwAkfO/8j@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=dmatlack@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=john.garry@arm.com \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pasha.tatashin@soleen.com \
--cc=patches@lists.linux.dev \
--cc=praan@google.com \
--cc=robin.murphy@arm.com \
--cc=skhawaja@google.com \
--cc=smostafa@google.com \
--cc=will@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox