All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v4 5/5] dma: swiotlb: Remove SWIOTLB_ANY
Date: Mon, 14 Sep 2026 07:59:59 +0000	[thread overview]
Message-ID: <20260914075959.AA0751F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914070135.313337-6-aneesh.kumar@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Subsystem guideline violation: Use of globally uninitialized high_memory in __init code
--

commit 61bbab3b84e605312f21e75e603675cd29154afc
Author: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>

dma: swiotlb: Remove SWIOTLB_ANY

This patch replaces SWIOTLB_ANY with SWIOTLB_INIT_ADDRESSING_LIMIT to
explicitly identify callers that need pools reachable by devices with
limited DMA addressing. It changes the default behavior to allow static
and dynamic pools anywhere in directly mapped memory when the limit flag
is omitted.

[ ... ]
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 6695da682f961..f8a77926b8b09 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
[ ... ]
> @@ -604,10 +599,10 @@ void __init swiotlb_init_remap(unsigned int flags,
>  #ifdef CONFIG_SWIOTLB_DYNAMIC
>  	if (!remap)
>  		io_tlb_default_mem.can_grow = true;
> -	if (flags & SWIOTLB_ANY)
> -		io_tlb_default_mem.phys_limit = virt_to_phys(high_memory - 1);
> -	else
> +	if (flags & SWIOTLB_INIT_ADDRESSING_LIMIT)
>  		io_tlb_default_mem.phys_limit = ARCH_LOW_ADDRESS_LIMIT;
> +	else
> +		io_tlb_default_mem.phys_limit = virt_to_phys(high_memory - 1);

[Severity: High]
This is a pre-existing issue, but does this evaluation of high_memory in an
__init function risk calculating an incorrect physical limit?

The swiotlb_init_remap function in kernel/dma/swiotlb.c evaluates
virt_to_phys(high_memory - 1) during early kernel boot. However, the
high_memory global is uninitialized and evaluates to zero until
free_area_init() runs. Calculating a physical limit using high_memory here
can result in a bogus DMA boundary (such as zero or an underflowed limit),
which could lead to memory allocation failures or data corruption during
DMA mapping.

Could this code use memblock_end_of_DRAM() instead of high_memory during
early boot allocations?

>  #endif
>  
>  	/* if we have host or guest memory encryption */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914070135.313337-1-aneesh.kumar@kernel.org?part=5

  reply	other threads:[~2026-09-14  8:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  7:01 [PATCH v4 0/5] dma: swiotlb: Centralize default pool policy and sizing Aneesh Kumar K.V (Arm)
2026-09-14  7:01 ` Aneesh Kumar K.V (Arm)
2026-09-14  7:01 ` [PATCH v4 1/5] dma: swiotlb: Centralize default pool policy selection Aneesh Kumar K.V (Arm)
2026-09-14  7:01   ` Aneesh Kumar K.V (Arm)
2026-09-14  7:24   ` sashiko-bot
2026-09-17 14:47   ` Catalin Marinas
2026-09-17 14:47     ` Catalin Marinas
2026-09-14  7:01 ` [PATCH v4 2/5] dma: swiotlb: Centralize minimal pool sizing Aneesh Kumar K.V (Arm)
2026-09-14  7:01   ` Aneesh Kumar K.V (Arm)
2026-09-14  7:34   ` sashiko-bot
2026-09-17 15:47   ` Catalin Marinas
2026-09-17 15:47     ` Catalin Marinas
2026-09-18  7:05     ` Aneesh Kumar K.V
2026-09-18  7:05       ` Aneesh Kumar K.V
2026-09-14  7:01 ` [PATCH v4 3/5] dma: swiotlb: Centralize memory-encryption " Aneesh Kumar K.V (Arm)
2026-09-14  7:01   ` Aneesh Kumar K.V (Arm)
2026-09-14  7:41   ` sashiko-bot
2026-09-17 16:02   ` Catalin Marinas
2026-09-17 16:02     ` Catalin Marinas
2026-09-18  7:13     ` Aneesh Kumar K.V
2026-09-18  7:13       ` Aneesh Kumar K.V
2026-09-14  7:01 ` [PATCH v4 4/5] dma: swiotlb: Add an overridable architecture pool opt-out Aneesh Kumar K.V (Arm)
2026-09-14  7:01   ` Aneesh Kumar K.V (Arm)
2026-09-14  7:50   ` sashiko-bot
2026-09-17 16:05   ` Catalin Marinas
2026-09-17 16:05     ` Catalin Marinas
2026-09-14  7:01 ` [PATCH v4 5/5] dma: swiotlb: Remove SWIOTLB_ANY Aneesh Kumar K.V (Arm)
2026-09-14  7:01   ` Aneesh Kumar K.V (Arm)
2026-09-14  7:59   ` sashiko-bot [this message]
2026-09-15  8:46     ` Aneesh Kumar K.V
2026-09-17 16:08   ` Catalin Marinas
2026-09-17 16:08     ` Catalin Marinas

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=20260914075959.AA0751F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=aneesh.kumar@kernel.org \
    --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 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.