From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 EFF95235358 for ; Mon, 13 Jul 2026 19:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783969932; cv=none; b=d+ILfnh522tNGrRkSqsbfPbrJ7wZk/nl0g3XieYFYBtInmUIvOYCNC6rq/gXoSmbWljRdwH7HFfkjvLJaD3WOLIYeqCCoA0e/Xjap3EnZIvvCwKKbW2OsgRQG8pZcThadzGcELrEh64GnbLvQvGcv5jcK1Cq3azSaIo+/PXHmBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783969932; c=relaxed/simple; bh=zQwwTTQgdWMUuBKytoq9EwDKG6Cm405oXwoG7/OyDFg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PjO2WSA2dwWSYXASvehyp3qHNCv0NwUL3fanetqGCNB0xF0ve9Ypi+8ef65feHJ+qcFeSvQC58EBA8ZX0UIhK7zCs4tHc7gGgo+BiYxvQuJEmANYpA7nEZ53LX8C8mGNkuow6hvOFnPwzxMSfi2iYcrLwFpXc0npzQ5NU7xAE6g= 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=GdjML5oU; arc=none smtp.client-ip=209.85.160.172 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="GdjML5oU" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-51c01089e8aso1446521cf.2 for ; Mon, 13 Jul 2026 12:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783969929; x=1784574729; 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=/NxveP/pyfIFv71kVfPTlg3b5XZeJTUOET5rnvr6kHo=; b=GdjML5oUAiB5fwMk1sx4IHaxbg0B8M0bAdE0szIBg03X78fA/WTaZH+bl5SdNjHQu7 DPhE7NxEZFPbOOCMsvl/A9WLFnIDUBz8swIZCadbIsSoShm1Y5+0SOHIxHK7QIUi1EPv xej9K9S8C5JOEgAcDBLIaG8+eRy7un5u6qs0RGhcyZ2PRgDKDFdVHVIV3CcVDF52W7AK pLtFJDsP1akKhn8DMCozkVbvZOXlNqhqoE8V//J6tANUfq1OUIAbhQ3ANpooFNjFehcc 5zU/6+oUsEdMc4JGJjRUPxTwmc98BQ3dOZKtBWtfm1G8/Lo/W2ha7hUUhTH7d2xpr2jQ isKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783969929; x=1784574729; 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=/NxveP/pyfIFv71kVfPTlg3b5XZeJTUOET5rnvr6kHo=; b=c1lhWUZnspbRk6haTqePDldspfIyjedYIdrFKpie6/r6rEaS4IVIYX688C2wqYG1HW a3TpZO2nJCF/KvOvM+F4scKhw4iFAoi6KC8LH87pQ+RzyFAEVfPJoL8JSYsHmR7B1109 X6m1s3maeGc/ZWA/9XlISbeVwsXJacKDgADljMxV+T6ikub+Xe9tNtGmJ/DAzpIScMWp udIr4yV9kX5FxD0wknERejJfvucFr4UDU7T0QVWu1ZXiJ1qRbbln+0wBK8tycY/8k6Yy qZDVsj4hP0AjKzc28U2dkF26qmewDBfkcHVnCI+0JdaYQmONCIwfYfOBCFZgYD7M3h7T LuxA== X-Forwarded-Encrypted: i=1; AHgh+RpNm3Twp9np4X9M3cw/QQAFhwxWyhS8EvcVx20Lzk3eby7knk74nGOmAzLcGf0nnE0VHnalYDhaGCzIDN0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/LlG32dTg//FC4DVbiham1Yisw2Isy9U8dVeTS9Eqm9zZdUD0 cwg4f3pPjwZG0ZsBibyGszF2U+5AbxeimMnBSP3eodZyMMlZwY+bMbgBfm+oaSfEFuk= X-Gm-Gg: AfdE7cl+0V3c8i66W5TH56u5hcVfvi5gQ69XmjyolMyTT3vUb/xfFxGgXHN4Pk+XiA9 bcuL8N+kzpAhmmF12lhNgJBorory/qYPP8E72+3cgdzv6jawZLMJJVbah+QI9uL313FY8qHG82O 4wq/ZdDfEqLbfDdmzaA6+Au7kNkE0vM9b1ykqEOIKnwHp9f46+z0S1Ss92qMXGhhQs19IC2An4a 4RYCTOCCaObXbHl72YdScWthtbDmetMYiIxmOVTPtFuGd+jBQM9NKCSTV0UJemnEt6G76EE3yPq aac1StfNY+HMTxrCoMuy/ZiHTboh44m+AIGSUQNa1KIhva7rIY1VnVCh5fp0eZ+KBSzlLqztQez liakV4NJia/eVSTyH/aVIzI0QNZ3eWvH/6V/GerQjHm/oin++MkZMaQYXapBT X-Received: by 2002:a05:622a:551a:b0:51b:f217:539f with SMTP id d75a77b69052e-51cbf0569bbmr98856591cf.17.1783969928867; Mon, 13 Jul 2026 12:12:08 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51caacad30asm88764001cf.9.2026.07.13.12.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 12:12:08 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wjM4V-0000000E4Bs-31V7; Mon, 13 Jul 2026 16:12:07 -0300 Date: Mon, 13 Jul 2026 16:12:07 -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 07/22] dma-direct: swiotlb: handle swiotlb alloc/free outside __dma_direct_alloc_pages Message-ID: <20260713191207.GO3133966@ziepe.ca> References: <20260701054926.825925-1-aneesh.kumar@kernel.org> <20260701054926.825925-8-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-8-aneesh.kumar@kernel.org> On Wed, Jul 01, 2026 at 11:19:11AM +0530, Aneesh Kumar K.V (Arm) wrote: > Move swiotlb allocation out of __dma_direct_alloc_pages() and handle it in > dma_direct_alloc() / dma_direct_alloc_pages(). > > This is needed for follow-up changes that simplify the handling of > memory encryption/decryption based on the DMA attribute flags. > > swiotlb backing pages are already mapped decrypted by > swiotlb_update_mem_attributes() and rmem_swiotlb_device_init(), so > dma-direct should not call dma_set_decrypted() on allocation nor > dma_set_encrypted() on free for swiotlb-backed memory. > > Update alloc/free paths to detect swiotlb-backed pages and skip > encrypt/decrypt transitions for those paths. Keep the existing highmem > rejection in dma_direct_alloc_pages() for swiotlb allocations. > > Only for "restricted-dma-pool", we currently set `for_alloc = true`, while > rmem_swiotlb_device_init() decrypts the whole pool up front. This pool is > typically used together with "shared-dma-pool", where the shared region is > accessed after remap/ioremap and the returned address is suitable for > decrypted memory access. So existing code paths remain valid. > > Tested-by: Jiri Pirko > Tested-by: Michael Kelley > Tested-by: Mostafa Saleh > Signed-off-by: Aneesh Kumar K.V (Arm) > --- > include/linux/swiotlb.h | 6 ++++ > kernel/dma/direct.c | 71 ++++++++++++++++++++++++++++++----------- > kernel/dma/swiotlb.c | 6 ++++ > 3 files changed, 65 insertions(+), 18 deletions(-) Reviewed-by: Jason Gunthorpe Jason