From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
linux-s390@vger.kernel.org,
Alexander Gordeev <agordeev@linux.ibm.com>
Subject: Re: [PATCH v5 5/6] dma: swiotlb: Add an overridable architecture pool opt-out
Date: Tue, 22 Sep 2026 12:34:20 +0530 [thread overview]
Message-ID: <yq5ajyod3gy3.fsf@kernel.org> (raw)
In-Reply-To: <20260921065154.9DA361F00893@smtp.kernel.org>
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] dma: swiotlb: default opt-out incorrectly overrides iommu=soft
> --
>
> commit 8a081ec4054b9ec450c0c293130d0ceb6b8d20fa
> Author: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
>
> dma: swiotlb: Add an overridable architecture pool opt-out
>
> This commit introduces SWIOTLB_INIT_DEFAULT_OFF to allow an architecture
> to opt out of SWIOTLB pool initialization without losing placement
> constraints.
>
>> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
>> index 0cff255827baf..ce257b20ea9cf 100644
>> --- a/arch/x86/kernel/pci-dma.c
>> +++ b/arch/x86/kernel/pci-dma.c
>> @@ -44,9 +44,13 @@ static unsigned int x86_swiotlb_flags;
>> static void __init pci_swiotlb_detect(void)
>> {
>> /* don't initialize swiotlb if iommu=off (no_iommu=1) */
>> - if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN) {
>> - x86_swiotlb_enable = true;
>> + if (no_iommu)
>> + x86_swiotlb_flags |= SWIOTLB_INIT_DEFAULT_OFF;
>
> [Severity: High]
> When this is combined with iommu=soft (which sets
> SWIOTLB_INIT_ADDRESSING_LIMIT), doesn't this flag overwrite the user's
> explicit fallback request?
>
> [ ... ]
>
>> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
>> index c19675846fc1d..46b789eb08063 100644
>> --- a/kernel/dma/swiotlb.c
>> +++ b/kernel/dma/swiotlb.c
>> @@ -563,10 +563,16 @@ swiotlb_select_pool_policy(unsigned int flags)
>> if (flags & SWIOTLB_INIT_REMAP)
>> return SWIOTLB_POOL_DEFAULT;
>>
>> - if (flags & SWIOTLB_INIT_ADDRESSING_LIMIT)
>> + if (swiotlb_force_bounce)
>> return SWIOTLB_POOL_DEFAULT;
>>
>> - if (swiotlb_force_bounce)
>> + /*
>> + * Explicit requirements above override an architecture's default opt-out.
>> + */
>> + if (flags & SWIOTLB_INIT_DEFAULT_OFF)
>> + return SWIOTLB_POOL_NONE;
>> +
>> + if (flags & SWIOTLB_INIT_ADDRESSING_LIMIT)
>> return SWIOTLB_POOL_DEFAULT;
>>
>> if (swiotlb_kmalloc_needs_bounce())
>
> [Severity: High]
> By evaluating SWIOTLB_INIT_DEFAULT_OFF before SWIOTLB_INIT_ADDRESSING_LIMIT
> and swiotlb_kmalloc_needs_bounce(), does the default opt-out incorrectly
> override explicit requests for a software bounce pool and unaligned kmalloc
> bouncing?
>
> For instance, if a user boots an x86 system with iommu=off iommu=soft,
> pci_swiotlb_detect() sets SWIOTLB_INIT_DEFAULT_OFF because of no_iommu=1.
> The iommu=soft parameter also sets SWIOTLB_INIT_ADDRESSING_LIMIT.
>
I don't think combining iommu=off with iommu=soft is valid.
>
> Because the opt-out is checked first here in swiotlb_select_pool_policy(),
> it returns SWIOTLB_POOL_NONE and prevents the pool from being allocated.
> Could this lead to DMA mapping failures for devices that cannot address all
> system memory, contradicting the commit message which states that iommu=soft
> retains the addressing limit?
>
-aneesh
next prev parent reply other threads:[~2026-09-22 7:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 6:36 [PATCH v5 0/6] dma: swiotlb: Centralize default pool policy and sizing Aneesh Kumar K.V (Arm)
2026-09-21 6:36 ` [PATCH v5 1/6] dma: swiotlb: Centralize default pool policy selection Aneesh Kumar K.V (Arm)
2026-09-21 6:56 ` sashiko-bot
2026-09-21 15:25 ` Robin Murphy
2026-09-22 5:32 ` Aneesh Kumar K.V
2026-09-21 6:36 ` [PATCH v5 2/6] dma: swiotlb: Track whether the pool size was explicitly set Aneesh Kumar K.V (Arm)
2026-09-21 6:44 ` sashiko-bot
2026-09-21 12:50 ` Catalin Marinas
2026-09-21 15:45 ` Robin Murphy
2026-09-22 5:42 ` Aneesh Kumar K.V
2026-09-21 6:36 ` [PATCH v5 3/6] dma: swiotlb: Centralize minimal pool sizing Aneesh Kumar K.V (Arm)
2026-09-21 6:45 ` sashiko-bot
2026-09-21 12:52 ` Catalin Marinas
2026-09-21 16:49 ` Robin Murphy
2026-09-22 6:56 ` Aneesh Kumar K.V
2026-09-21 6:36 ` [PATCH v5 4/6] dma: swiotlb: Centralize memory-encryption " Aneesh Kumar K.V (Arm)
2026-09-21 6:52 ` sashiko-bot
2026-09-22 7:02 ` Aneesh Kumar K.V
2026-09-23 12:47 ` Robin Murphy
2026-09-23 14:28 ` Aneesh Kumar K.V
2026-09-21 6:36 ` [PATCH v5 5/6] dma: swiotlb: Add an overridable architecture pool opt-out Aneesh Kumar K.V (Arm)
2026-09-21 6:51 ` sashiko-bot
2026-09-22 7:04 ` Aneesh Kumar K.V [this message]
2026-09-23 13:04 ` Robin Murphy
2026-09-23 14:18 ` Aneesh Kumar K.V
2026-09-21 6:36 ` [PATCH v5 6/6] dma: swiotlb: Remove SWIOTLB_ANY Aneesh Kumar K.V (Arm)
2026-09-21 6:48 ` sashiko-bot
2026-09-23 13:12 ` Robin Murphy
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=yq5ajyod3gy3.fsf@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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