From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D7D93546ED for ; Mon, 13 Jul 2026 18:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783968493; cv=none; b=In9+IgQtBYkUu7ct/IG1tmn1wZojmLuCTqLbNUUMsyNZaOzo3wLoKXXXuSoBHQnb9PVV8T9Lj0nscgFRim6IqjlkLmZkkn+ZLH3BcwXAK3KL5FqVOfO+wp12GX5o4dJN9rS4rJmkR9+drZqflVfsjf+4dgjHsiO7qOPoy/vlWOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783968493; c=relaxed/simple; bh=18BF4tvFtN7rb81d7yZbxHf143U9lHFn+oOlQiGvmi0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rMmKezU2V2vZVq078m+y+5RnlCAVJSi2j1wAkORpwjRKxcY8ZecpgYc811j75PtQkX1iuJI2Lvtb8/8JY78xR9dO83ebYzh6RkAe0cTDe+YL9MMbIhYtrMnL1Pcjbb0/u0lK8tTrN5u2C6zowOwGqin4z2frmjqJz8adjaFBDok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=CX767FRC; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="CX767FRC" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-9030f8ea3b3so29849456d6.1 for ; Mon, 13 Jul 2026 11:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783968491; x=1784573291; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=+4oaM697jjJh0i29DhT77Bw1lzVGGZ7UjxKZh4sSss8=; b=CX767FRCtyqDrNTEqwJX01iLxDPq+FYWWfY4KIKDZJLtwErZGSXtdWesg/vTvC/4h3 KlrUZg/O2W82UlS2Sh6/EljwWVactNzoMpZcFpOp5MVn6D1zQmo7mWSm02YhLU8iT8j7 hdlkTOemS366h6/9zKLPkhEwC6CfMx05gFDb432EGbNBW+AIU76yGVsJXzZVQcqhLqJy W1GW3riQ3vFbsfwxNeCfK/LAyv0hnWwtNo4JE0XimbldCJD3xk0CqgmnzlvDtt6n6IHm Cd2kZ4l9koL/PgRvLeu6RTbwa0imttCC0t4NYCNeFx74lVdV3u/fWzDeowHdeAyNTlLg KVMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783968491; x=1784573291; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+4oaM697jjJh0i29DhT77Bw1lzVGGZ7UjxKZh4sSss8=; b=dJwwtv8ZchHMvTr3Y+aUPyCiJ04QkHe172RPfP1awZancMZFEEAykDM719Q8aYCE7R Za2YNJ3RZioLDwWeJb4sWS6DFUAK7VuhgzWHFbcwXH4hA1Dg9V5Z5B67dR734WHe1+Im 1Vts1HcgkJVFSVCW/LtR8X3mkdKZeauYCW4zP/aZMjnFnurZ4ja/QHc5yXokPb7DGTSW g2AwDvq01YZ+oqClDdyJb2bfTUYj97j6OvX/dvCozowrPDqDW2SmfoPAfnbn9VvRysxu aU4+kdKyig+kqqRyVqtN20R4CC/ZlYqBYl+Wy7Jahygg/cfb1BR97n7J0s5Xu/q55kyM /f6w== X-Forwarded-Encrypted: i=1; AHgh+Rp0P/tPQBejHPOMPiAQ4etikTPwzoqtkJsZVKBfd8uE+GPkNub2Uye/MngQc9jEjI+COylbIQKERnP+Ehw=@vger.kernel.org X-Gm-Message-State: AOJu0YxM4WgVS265zCEIEUGIjADfD0sakVHJz4Q+rTBjUruy6SeglwuC /p0trF3J3BZiOANW0giiVsnRmV4lYzWsftnM7A1J4I7mkn+b0I9+DvU/f/cvwGzZT5Y= X-Gm-Gg: AfdE7cmd2wHR6IQD7Wr5dOSb9iLcGBj1dsw6HbdrveOZu+TBlZnqhtu02yqyXQvNwjR 5qC1o54EwA0ai2d0D+C49PcF9ku1S2HpBRQuZbKTTMkEJww1kJMjOi8VpDCYFE/G36pFiP1ETD2 7Q1hmhT4euCDGKQSd7BcYGKiv5y1czqrJcKqLNaiZsx6KPfpXdXd3kEClegQiRXvPCPh3e58tGy jZ4wfEjUXeNE2csXMkGd/M8t5k7lRS0lpY3p5iAH9WRO/4KvnlJ/5JMdwfEMp0jo0UCh/waN3Bk WvaLVPh6nqjeyeh5W8Tuc0Vkc5P7+7KhlhjxpPWMXFMvLZ6m9LrNWz+se6cTauclctRbNBzZVtc yFd9kecP6F9BXHYmedsShcRovdED7Mstsn84i/X9leQbxmXP6r1eJximfuD5ZHy91dU/yAH4= X-Received: by 2002:a05:6214:e8c:b0:904:49fa:3085 with SMTP id 6a1803df08f44-90449fa364dmr123814316d6.18.1783968491378; Mon, 13 Jul 2026 11:48:11 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd82e8ffdsm139962266d6.37.2026.07.13.11.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 11:48:10 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wjLhK-0000000E1oE-0kyB; Mon, 13 Jul 2026 15:48:10 -0300 Date: Mon, 13 Jul 2026 15:48:10 -0300 From: Jason Gunthorpe To: "Aneesh Kumar K.V (Arm)" Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, Robin Murphy , Marek Szyprowski , Will Deacon , Marc Zyngier , Steven Price , Suzuki K Poulose , Catalin Marinas , Jiri Pirko , Mostafa Saleh , Petr Tesarik , Alexey Kardashevskiy , Dan Williams , Xu Yilun , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , x86@kernel.org, Jiri Pirko , Michael Kelley Subject: Re: [PATCH v7 11/22] dma-pool: track decrypted atomic pools and select them via attrs Message-ID: <20260713184810.GM3133966@ziepe.ca> References: <20260701054926.825925-1-aneesh.kumar@kernel.org> <20260701054926.825925-12-aneesh.kumar@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260701054926.825925-12-aneesh.kumar@kernel.org> On Wed, Jul 01, 2026 at 11:19:15AM +0530, Aneesh Kumar K.V (Arm) wrote: > @@ -114,14 +120,17 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size, > * Memory in the atomic DMA pools must be unencrypted, the pools do not > * shrink so no re-encryption occurs in dma_direct_free(). > */ > - ret = set_memory_decrypted((unsigned long)page_to_virt(page), > - 1 << order); > - if (ret) { > - leak_pages = true; > - goto remove_mapping; > + if (dma_pool->cc_shared) { > + ret = set_memory_decrypted((unsigned long)page_to_virt(page), > + 1 << order); > + if (ret) { > + leak_pages = true; > + goto remove_mapping; > + } > } This makes the memory_decrypted conditional, but it doesn't change the lines a few above: addr = dma_common_contiguous_remap(page, pool_size, pgprot_decrypted(pgprot_dmacoherent(PAGE_KERNEL)), ^^^^^^^^^^^^ __builtin_return_address(0)); if (!addr) goto free_page; It is wrong to pass pgprot_decrypted() to the arch code if set_memory_decrypted() was not called. Also it looks at some point the nature of the atomic pool has become confused. Originally it was just to allocate atomic memory that had been vmap'd outside the atomic context (to set the non-coherent pgprot), so every caller was expecting non-cached memory. Then it was reused to also allocate CC shared memory outside the atomic context. That was fine for x86 that doesn't use DMA_REMAP but on ARM64 it now means all atomic pool CC memory is uncached? That doesn't seem to make any sense... I suppose along the lines of this patch the solution is to add a noncoherent property to the pool so we can select the correct combination: noncoherent !SHARED = vmap pgprot_noncached !noncoherent SHARED= vmap pgprot_decrypted + set_memory_decrypted noncoherent SHARED = (probably unrealistic in real systems) !noncoherent !SHARED = normal __dma_direct_alloc_pages() But I don't view this as that important, the CC hypervisor is probably going to use the S2 page table to force cachable on all system memory so the non-cached pgprot is a NOP, but the extra vmap is wasteful and it is confusing.. So maybe a little fixme is all that is needed here. Jason