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: "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	linux-s390@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH v6 6/8] dma: swiotlb: Centralize memory-encryption pool sizing
Date: Thu, 24 Sep 2026 06:26:07 +0000	[thread overview]
Message-ID: <20260924062608.028C21F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260924060756.1325156-7-aneesh.kumar@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] dma: swiotlb: missing fallback disables default pool on CC guests with restricted DMA
- [High] x86: crash_reserve: low memory reservation undersized for CC guests
--

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

dma: swiotlb: Centralize memory-encryption pool sizing

Memory-encrypted guests use shared or unencrypted memory for DMA and may
route all DMA through SWIOTLB. The default pool can therefore be too
small for I/O-intensive workloads.

> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c
> index 95bae74fdab23..912f22ca838f8 100644
> --- a/arch/x86/mm/mem_encrypt.c
> +++ b/arch/x86/mm/mem_encrypt.c
[ ... ]
> @@ -114,27 +111,6 @@ void __init mem_encrypt_setup_arch(void)
>  	if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
>  		return;
>  
> -	/*
> -	 * For SEV and TDX, all DMA has to occur via shared/unencrypted pages.
> -	 * Kernel uses SWIOTLB to make this happen without changing device
> -	 * drivers. However, depending on the workload being run, the
> -	 * default 64MB of SWIOTLB may not be enough and SWIOTLB may
> -	 * run out of buffers for DMA, resulting in I/O errors and/or
> -	 * performance degradation especially with high I/O workloads.
> -	 *
> -	 * Adjust the default size of SWIOTLB using a percentage of guest
> -	 * memory for SWIOTLB buffers. Also, as the SWIOTLB bounce buffer
> -	 * memory is allocated from low memory, ensure that the adjusted size
> -	 * is within the limits of low available memory.
> -	 *
> -	 * The percentage of guest memory used here for SWIOTLB buffers
> -	 * is more of an approximation of the static adjustment which
> -	 * 64MB for <1G, and ~128M to 256M for 1G-to-4G, i.e., the 6%
> -	 */
> -	size = total_mem * 6 / 100;
> -	size = clamp_val(size, IO_TLB_DEFAULT_SIZE, SZ_1G);
> -	swiotlb_adjust_size(size);
> -

[Severity: High]
Does moving this SWIOTLB adjustment run too late for crashkernel reservation?

When this was called during mem_encrypt_setup_arch(), the SWIOTLB size was
adjusted before arch_reserve_crashkernel() called crash_low_size_default().

Now the dynamic guest sizing is evaluated later, so crash_low_size_default()
only sees the unadjusted 64MB default.

If the crash kernel is provided with a large amount of memory (e.g.,
crashkernel=4G,high), its own dynamically calculated SWIOTLB size could
exhaust the 256MB of low memory reserved by the main kernel.

Could this lead to out-of-memory errors in the low memory zone and break
kdump functionality on x86 memory-encrypted guests?

>  	/* Set restricted memory access for virtio. */
>  	virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
>  }
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 75ee63cd354e2..e626cca63ad11 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
[ ... ]
> @@ -496,7 +516,8 @@ swiotlb_select_pool_policy(unsigned int flags)
>  	if (swiotlb_force_disable)
>  		return SWIOTLB_POOL_NONE;
>  
> -	if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
> +	if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT) &&
> +	    !restricted_dma_pool_present)
>  		return SWIOTLB_POOL_CC_GUEST;
>  
>  	if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT))

[Severity: High]
Does this disable the default SWIOTLB pool entirely for confidential guests
with a restricted DMA pool?

If restricted_dma_pool_present is true on a confidential guest, this condition
fails.

If no other conditions match later in swiotlb_select_pool_policy()
(for instance, if there are no addressing limits because guest RAM is small,
such as on arm64 CCA), the function falls through and returns
SWIOTLB_POOL_NONE.

Could this result in devices not explicitly assigned to the restricted DMA pool
failing to map memory, leading to device malfunction or a system panic?

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

  reply	other threads:[~2026-09-24  6:26 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260924060823eucas1p1d27fbf57221c9b4c0e9831a9b0cdd7d3@eucas1p1.samsung.com>
2026-09-24  6:07 ` [PATCH v6 0/8] dma: swiotlb: Centralize default pool policy and sizing Aneesh Kumar K.V (Arm)
2026-09-24  6:07   ` Aneesh Kumar K.V (Arm)
2026-09-24  6:07   ` [PATCH v6 1/8] dma: swiotlb: Rename swiotlb_size_or_default() Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:14     ` sashiko-bot
2026-09-24  6:07   ` [PATCH v6 2/8] dma: swiotlb: Consolidate slab rounding Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:19     ` sashiko-bot
2026-09-24  6:07   ` [PATCH v6 3/8] dma: swiotlb: Track whether the pool size was explicitly set Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:16     ` sashiko-bot
2026-09-24  6:07   ` [PATCH v6 4/8] dma: swiotlb: Centralize default pool policy selection Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:22     ` sashiko-bot
2026-09-24  6:07   ` [PATCH v6 5/8] dma: swiotlb: Centralize minimal pool sizing Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:18     ` sashiko-bot
2026-09-24  6:07   ` [PATCH v6 6/8] dma: swiotlb: Centralize memory-encryption " Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:26     ` sashiko-bot [this message]
2026-10-06 21:49     ` Will Deacon
2026-10-06 21:49       ` Will Deacon
2026-10-07 10:04       ` Catalin Marinas
2026-10-07 10:04         ` Catalin Marinas
2026-10-07 10:43         ` Will Deacon
2026-10-07 10:43           ` Will Deacon
2026-10-07 11:13           ` Catalin Marinas
2026-10-07 11:13             ` Catalin Marinas
2026-10-07 12:15           ` Aneesh Kumar K.V
2026-10-07 12:15             ` Aneesh Kumar K.V
2026-10-08  5:33             ` Aneesh Kumar K.V
2026-10-08  5:33               ` Aneesh Kumar K.V
2026-10-08 12:51               ` Catalin Marinas
2026-10-08 12:51                 ` Catalin Marinas
2026-10-08 14:32                 ` Aneesh Kumar K.V
2026-10-08 14:32                   ` Aneesh Kumar K.V
2026-10-08 15:32                   ` Marek Szyprowski
2026-10-08 15:32                     ` Marek Szyprowski
2026-10-09 10:18                     ` Will Deacon
2026-10-09 10:18                       ` Will Deacon
2026-10-08 10:05           ` Marek Szyprowski
2026-10-08 10:05             ` Marek Szyprowski
2026-10-08 11:42             ` Aneesh Kumar K.V
2026-10-08 11:42               ` Aneesh Kumar K.V
2026-10-07 12:17         ` Aneesh Kumar K.V
2026-10-07 12:17           ` Aneesh Kumar K.V
2026-09-24  6:07   ` [PATCH v6 7/8] dma: swiotlb: Add an overridable architecture pool opt-out Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:26     ` sashiko-bot
2026-09-24  6:07   ` [PATCH v6 8/8] dma: swiotlb: Remove SWIOTLB_ANY Aneesh Kumar K.V (Arm)
2026-09-24  6:07     ` Aneesh Kumar K.V (Arm)
2026-09-24  6:26     ` sashiko-bot
2026-09-25  8:57   ` [PATCH v6 0/8] dma: swiotlb: Centralize default pool policy and sizing Marek Szyprowski
2026-09-25  8:57     ` Marek Szyprowski
2026-10-06 21:42   ` Marek Szyprowski
2026-10-06 21:42     ` Marek Szyprowski
2026-10-06 21:52     ` Will Deacon
2026-10-06 21:52       ` Will Deacon

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=20260924062608.028C21F00893@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.