From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: sashiko-reviews@lists.linux.dev, Jason Gunthorpe <jgg@nvidia.com>,
linux-coco@lists.linux.dev
Cc: Marc Zyngier <maz@kernel.org>,
dri-devel@lists.freedesktop.org, media-ci@linuxtv.org,
kvmarm@lists.linux.dev, Oliver Upton <oupton@kernel.org>
Subject: Re: [RFC PATCH v8 06/14] dma-pool: Allocate CoCo atomic pools using CoCo shared memory allocator
Date: Tue, 13 Oct 2026 11:41:25 +0530 [thread overview]
Message-ID: <yq5aqzhuqgdu.fsf@kernel.org> (raw)
In-Reply-To: <20260924101945.95D7F1F000FF@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-pool: atomic_pool_expand() falsely returns success on failure
> --
>
> commit 7de8bc3a8ea9e2bbef83e09d72fa88999ce898b9
> Author: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
>
> dma-pool: Allocate CoCo atomic pools using CoCo shared memory allocator
>
> This commit modifies atomic DMA pools to use the CoCo shared memory allocator.
> It prevents allocation fallback below the required shared granule size, and
> uses the cc_make_shared() helper to transition the backing allocations in a
> sleepable context.
>
>> diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
>> index 70b7f64b17ab5..f059312c15aa5 100644
>> --- a/kernel/dma/pool.c
>> +++ b/kernel/dma/pool.c
> [ ... ]
>> @@ -85,6 +85,9 @@ static bool cma_in_zone(gfp_t gfp)
>> static int atomic_pool_expand(struct dma_gen_pool *dma_pool, size_t pool_size,
>> gfp_t gfp)
>> {
>> + struct cc_shared_layout layout;
>> + unsigned long attrs = 0;
>> + unsigned int min_order = 0;
>> unsigned int order;
>> struct page *page = NULL;
>> bool leak_pages = false;
>> @@ -92,6 +95,17 @@ static int atomic_pool_expand(struct dma_gen_pool *dma_pool, size_t pool_size,
>> int ret = -ENOMEM;
>> pgprot_t prot __maybe_unused;
>>
>> + if (dma_pool->cc_shared) {
>> + ret = cc_shared_calc_layout(pool_size, &layout);
>> + if (ret)
>> + goto out;
>
> [Severity: High]
> If cc_shared_calc_layout() succeeds, it returns 0 and overwrites the initial
> ret = -ENOMEM. Could this cause the function to falsely return 0 (success) on
> subsequent failures?
>
> For instance, if page allocation fails below, the function jumps to out and
> returns the current value of ret:
>
> if (!page)
> goto out;
>
> Similarly, if remapping fails later in the function:
>
> addr = dma_common_contiguous_remap(...)
> if (!addr)
> goto free_page;
>
> In both cases, ret will be 0 instead of -ENOMEM. Would it be better to reset
> ret back to -ENOMEM when these failures occur, or use a separate variable
> for the cc_shared_calc_layout() return value?
>
Fixed as
modified kernel/dma/pool.c
@@ -96,9 +96,11 @@ static int atomic_pool_expand(struct dma_gen_pool *dma_pool, size_t pool_size,
pgprot_t prot __maybe_unused;
if (dma_pool->cc_shared) {
- ret = cc_shared_calc_layout(pool_size, &layout);
- if (ret)
- goto out;
+ int err;
+
+ err = cc_shared_calc_layout(pool_size, &layout);
+ if (err)
+ return err;
pool_size = layout.shared_size;
min_order = get_order(layout.alignment);
if (min_order > MAX_PAGE_ORDER)
-aneesh
next prev parent reply other threads:[~2026-10-13 6:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 10:05 [RFC PATCH v8 00/14] coco: guest: Add a shared-granule allocator for host-shared memory Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 01/14] mm: Add an allocator for CoCo shared memory Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 02/14] mm: Zero memory during shared memory transitions Aneesh Kumar K.V (Arm)
2026-09-25 12:08 ` Kiryl Shutsemau
2026-10-13 5:12 ` Aneesh Kumar K.V
2026-10-13 13:47 ` Kiryl Shutsemau
2026-09-24 10:05 ` [RFC PATCH v8 03/14] irqchip/gic-v3-its: Resolve the default NUMA node explicitly Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 04/14] irqchip/gic-v3-its: Allocate shared tables using CoCo shared memory allocator Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 05/14] dma-contiguous: Derive shared alignment from DMA attributes Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 06/14] dma-pool: Allocate CoCo atomic pools using CoCo shared memory allocator Aneesh Kumar K.V (Arm)
[not found] ` <20260924101945.95D7F1F000FF@smtp.kernel.org>
2026-10-13 6:11 ` Aneesh Kumar K.V [this message]
2026-09-24 10:05 ` [RFC PATCH v8 07/14] dma-direct: Align CoCo shared DMA allocations to the shared granule size Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 08/14] swiotlb: Align shared IO TLB pools " Aneesh Kumar K.V (Arm)
[not found] ` <20260924102254.60C431F00893@smtp.kernel.org>
2026-10-13 6:46 ` Aneesh Kumar K.V
2026-09-24 10:05 ` [RFC PATCH v8 09/14] swiotlb: Reject misaligned restricted DMA pools for CoCo guests Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 10/14] dma-buf: system_heap: Limit scatterlist entries to the buffer size Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 11/14] dma-buf: system_heap: Allocate shared buffers using CoCo shared memory allocator Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 12/14] swiotlb: Make rounded shared pool capacity allocatable Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 13/14] mm: Assert CoCo shared allocations may sleep Aneesh Kumar K.V (Arm)
2026-09-24 10:05 ` [RFC PATCH v8 14/14] irqchip/gic-v3-its: Preallocate VPE L1 tables Aneesh Kumar K.V (Arm)
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=yq5aqzhuqgdu.fsf@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-coco@lists.linux.dev \
--cc=maz@kernel.org \
--cc=media-ci@linuxtv.org \
--cc=oupton@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