From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 3E634481A85 for ; Wed, 17 Jun 2026 15:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781710881; cv=none; b=EOo0gBTKrvjCrSns2w1DaWdh58vrsO8RbUB1diMAD7ditNiXgW5+zkvJyA9KXJolFUJOXA5iefHWRK/h3T5fkIz9bmZFaGkuUqv8oKzzxI0CqXsfmk7fhdmQ4R/wv9r8O9nHsVmYGYjUUtKnQ2/OUYt+LwCREg/FcHBWp2urO50= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781710881; c=relaxed/simple; bh=9QIEPp5EWbcjDNMKHBFL5JldJkQ5+OL5Nn42Ql7e+rM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DRMVfqqH1JQg15DB6wDEGBInkjxlqPFozm7BNAEtsG7kCgseUwWWA4lWeJ+R4WUSzDmVINlDQYFPZH/jkFFjGIj4eBVSNL9Ay6exTq7tVa0ncjk43U/+065bVPlJY+1uK3xIpJ/a1TdOQsijOXQwk/eywtOLwAB0buHzXRB727I= 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=BNaxItY/; arc=none smtp.client-ip=209.85.160.181 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="BNaxItY/" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-517760dc3c2so39006531cf.3 for ; Wed, 17 Jun 2026 08:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1781710864; x=1782315664; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ElWjBVhbO2IQzO43OlPWnTyijSop9myiCxf+4rjWyeA=; b=BNaxItY/Nm3pO+SwE/+o2MlZBzHaWgJpo7MzlvPnaJQNym2Hhs45Ll2TS2NIVxJKV0 WHOrQv4H68aelwt7jHzHWBzlbdiAF7gs98RbwPKX+mRiztm8w53KKerlz9GSLV1up8LG bmOQ9mrrParstns0khNNkLFXV6TNlug+U53Gz7inX6SUpiN9+nkl9Pi2Ljvz7sWNpxDn YMS3uTRo71SKzAoL2uYVyb2blcGBrOaIlzAGhygX6ozdHMigdhRyk36MjUhXX2WUuyS2 6dXoB37uRHL97D4ONuc/aRoRTHfO8gMCbZaZrZDBV/nvrqieROGN1Z4vHordHBGQuj/3 Xr3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781710864; x=1782315664; h=in-reply-to:content-disposition: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; bh=ElWjBVhbO2IQzO43OlPWnTyijSop9myiCxf+4rjWyeA=; b=X9kR05IS3Z71v2dK/D8LEWlgS65MVOwwWHLMGSdeCBkVziWsh2sn3I+VKzbzYHHi7I wqbNjG0bzbZ9GJ6u7ZNz8kh25thkXJp9r3l9ip732WqnC8NRDO75nlJJ2QR8dlv/WCxU L9ZIATA098aoqDt26/v3WqO2I+ABWGwW2ZY8co+/CDoqnCjrcyesqOxw+T9F/Ygj0gs+ /Pwn2YLY/RE+PoCl0ooXCuJNbaiaKQyeY0nyBZgPXoil40dvzfvtP65BBTbZzOob8URh 9KgUhz03M7ql04lijORoe7POk40wxHeZwgvgvH9WAedMawx7ujox1Z96fcx1B7zbQl9H 036g== X-Forwarded-Encrypted: i=1; AFNElJ/edb2/SB9c8Z8rsQs1i+lQ+C3dpk1LQn1k/U0Y9gNlhFe1MllMudUNTSU+5LNZ8CHaUBzk2iMZb8DEiY0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzs5XBdzWbUmN1BPWWayyBfXkjPV056DCMv/SF8ZhJiXiHHonEM UXeZ9BStbGFb8VfHkfU/9/T1m1sxbJGaTRkkTrfDakkebgtJeqbZXhVnI6CFF433I0c= X-Gm-Gg: Acq92OG3swE/XUAIuwUDLy+B8J2MXpcLqB6CfTbJUxXBWouFUaZ/EPTLhNglSo+A/fX qw9vqhR8ATr0GNBP3YfQRHyx6EnGVnUNFtglDsoktcnQIgXZTpl5Fjm5PUCpC1Gh/7EK2g5EYqC RNIcq425HcDImV8ggSu5K2VOMWWORgFLUxxFOhwVocQlB1t29K6BOEIzcnsXK4o/X13NXQFjE56 vXOB0ApgrnROVkK92xmh6kcewWxqR+4L76++UTAxqWookNS7sl535gQKxZDgtf/y7eZo06cVGJr wj4JksUjeGq1JSufe1AFGby/ZW7/hQpZ9NrIBnHRM2e9X5zR889gcotjPeLXNk+xbNPiLQ8Pgof tzBcXhwjvoYr7Jx9ReguEzUx7c2jx7ti/UpBj/6/R1b7sWupCK8v01Cx/tx10/xoqb9Npyon9tL I2DTX5a+CDCrUYn+gnMxVtKFQeDyb6HZUlkaCi7PPDL034OynCc5kLi0OPzX9AmgmRYdSBxfyLq taKKQ== X-Received: by 2002:ac8:638b:0:b0:517:7620:20f9 with SMTP id d75a77b69052e-519a8e01895mr53967651cf.19.1781710863733; Wed, 17 Jun 2026 08:41:03 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-517fb7a3c4asm171544001cf.14.2026.06.17.08.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 08:41:02 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wZsNx-00000000iiO-3Q8i; Wed, 17 Jun 2026 12:41:01 -0300 Date: Wed, 17 Jun 2026 12:41:01 -0300 From: Jason Gunthorpe To: Alexey Kardashevskiy Cc: "Aneesh Kumar K.V (Arm)" , 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 , 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 , "Cheloha, Scott" Subject: Re: [PATCH v6 03/20] dma-direct: use DMA_ATTR_CC_SHARED in alloc/free paths Message-ID: <20260617154101.GE3577091@ziepe.ca> References: <20260604083959.1265923-1-aneesh.kumar@kernel.org> <20260604083959.1265923-4-aneesh.kumar@kernel.org> <845d0c8a-6d51-47aa-8e0b-8381e733444a@amd.com> 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: <845d0c8a-6d51-47aa-8e0b-8381e733444a@amd.com> On Wed, Jun 17, 2026 at 10:50:39AM +1000, Alexey Kardashevskiy wrote: > > @@ -193,16 +193,31 @@ void *dma_direct_alloc(struct device *dev, size_t size, > > dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) > > { > > bool remap = false, set_uncached = false; > > - bool mark_mem_decrypt = true; > > + bool mark_mem_decrypt = false; > > struct page *page; > > void *ret; > > + /* > > + * DMA_ATTR_CC_SHARED is not a caller-visible dma_alloc_*() > > + * attribute. The direct allocator uses it internally after it has > > + * decided that the backing pages must be shared/decrypted, so the > > + * rest of the allocation path can consistently select DMA addresses, > > + * choose compatible pools and restore encryption on free. > > Why this limit? > > Context: I am looking for a memory pool for a few shared pages (to > do some guest<->host communication), SWIOTLB seems like the right > fit but swiotlb_alloc() is not exported and > dma_direct_alloc(DMA_ATTR_CC_SHARED) is not allowed. Thanks, Then setup your struct device so that the DMA API knows the guest<->host channel requires unecrypted and it will work correctly. I think this is a reasonable API to use for that, and I was just advocating that hyperv should be using it too. But it all relies on a properly setup struct device. Jason