From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 7A20848C8BC for ; Tue, 19 May 2026 14:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779200885; cv=none; b=I9DIXgJFqgFR0iMku2XyYWXvQ3zTAegku4gOFEqniLrVzlxOKozY6EzQUN5knAyj9+T/1PBxS+ESktlYHZXsfaulMIZGePpSlFPpxng3oIpiWlMrhg0u9/aoTAOraxY7wGepXV5nub2yRg8zWBLwsYvhE5ur88VtKE/zXN8zUuY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779200885; c=relaxed/simple; bh=vYkb+jBu+S0QIeav6yEnzsOxadQSbJKsWMAoA5G/wvM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MKBHC11uuHbrTHp71aqCuowN6A97HoR9A+1s/d6W5qUI4xjmfA7bYUxp4IQEaZmNr0zIv1vJeSMdNZd+R0SOK69fhoG5y4r9k2PY54S9ON+W6P9wBynOA+qv2BoHoG7ggc+PxVTr9o18sTky2azrBFgmGPQHvJweEN4vbZhvnDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Q/ekQ49Y; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q/ekQ49Y" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-515548f390fso7051cf.0 for ; Tue, 19 May 2026 07:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779200883; x=1779805683; darn=lists.linux.dev; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=FTIuQdBXtpQH67pVdVz1Fjrx/oRpQ8R86tVZsSSuQBc=; b=Q/ekQ49YE/odHoCNYJ8ORxBpDvoTEL7tk8mH6iY5RTRQmPrFwnoRPDCOy5tx95VUl0 jJyyZcxbvBuQKa5z/x91Hj+sNo/LHgpGBWJ4YF0MuIR/EuhLOPCAql6LbMB45UZTPh2s HAxEYkfmNvoV+S+ZTH5bndmFFbrhRt1Ei9GUMuz0L26oFoTBcyj2xK2K8YebIUUDEoOU 99TnWX5ZbTjHShpK4kD1wFMjGxEdqSo0KLHQcXju10Zvf3x5DGRufxo3nn2qvZKpxh3U 23yZdmGzvjih7qHeJzZrV7HdO+OeAMMBuAQaUSgkpzX56835krPNL0ssIY0xTTP2ggQE VyDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779200883; x=1779805683; h=in-reply-to:content-transfer-encoding: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=FTIuQdBXtpQH67pVdVz1Fjrx/oRpQ8R86tVZsSSuQBc=; b=qV6LxMSk7GRN5dp4Y3crdkULj//+wzl0ENXx00eboYzE5I/1hxCDD4EacG10vcuCY9 QX/p3bFMzFyMfhAetMi/ZwEshe0DDgovy7+XUAUbiReJh3gEsgkhnakwZRilyLpqT3y3 LAYIIoFM1eyXuv47uHIIrJUW43GCClJZw+e7TeBCQI8LDiMDXpebCqWCcQZgo3ZabeuR ff5hfuUkazuXOQ8dNh8YVJBVKmZKZUy+LkeZUzgVxVCEdIcAi/KHW6yNuCvalV6CLyd8 VgkSJskpbbyHdzFnj41Tj56kGyGYVtyUTmDt+YkpIhAv/e4MH0snHcr+SLqsxqFSKbLC FCGg== X-Forwarded-Encrypted: i=1; AFNElJ8/TTD4uA9UPOu37LDgGFBD0K66Juf2vzDrol3giC58M/q+XOdvZmgV5Q12zVlBgNC3AxU+PMiZfhS9@lists.linux.dev X-Gm-Message-State: AOJu0YwIs1j1101Hpi6qEiNnKXK3BcxVzPcZKSdsT7MA0Jgln5Sj/61P 6vZpA7tF8HWz9bfXERi9gVCuLwIb3/2l3aXWVKN4QLg9tmxGtK+D8kseMVJa3ro5ZQ== X-Gm-Gg: Acq92OGOV6iXyeHthHsBXPA648uwjZrpr8GxEJ9G03K2v57kP4iA+0Ei4rLqVOrks1q qL/HY9e0pXfECq0ALsDoV0ckFqh+QIwB0buGxtyg7DiZtRBVJQsPAumVrrLDqEgtuwu8dFMrIMm D4SuEoAE+awCfrI2GmRdX/ZriiKJJM7n5zKIr7qtNbWzwmvlKxvUx5j/kTyNWRVfO/2Akm52M8j DwDKSHzorp9hsSbybdWw8zQ7+etVm1zy+GT7tnZeWT+l37LCowwWz/NulELTO62crkfOQ1opXCy FFBAk2Ehu2sHuqJSuxRt2obEJGOyieNHDZlYdbpapJQx0pVeMozlgif9xtDGN7tD/8OmNE37tDw IcUa/rIJtmU1IzHxjd36HmAScOYnfCOxIRCOfIwXDi6rVYUAc6kg89QxPBVnrU/ENeWbxOTLSBE VvJYulalK7xpoFhRHrs2QL4oZ4bNE9jAspTyTwquW5DKv1suD8LuIvyBjcFkFzAK5+Ob2hdNrvl vWS X-Received: by 2002:ac8:5cd0:0:b0:516:4f62:85ee with SMTP id d75a77b69052e-5167b6a87a6mr33333931cf.19.1779200882847; Tue, 19 May 2026 07:28:02 -0700 (PDT) Received: from google.com (136.41.155.104.bc.googleusercontent.com. [104.155.41.136]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7cc9cbb0404sm37077347b3.42.2026.05.19.07.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 07:28:02 -0700 (PDT) Date: Tue, 19 May 2026 14:27:54 +0000 From: Mostafa Saleh To: "Aneesh Kumar K.V" Cc: Jason Gunthorpe , 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 , 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 Subject: Re: [PATCH v4 04/13] dma: swiotlb: track pool encryption state and honor DMA_ATTR_CC_SHARED Message-ID: References: <20260519132911.GA7702@ziepe.ca> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, May 19, 2026 at 07:47:48PM +0530, Aneesh Kumar K.V wrote: > Mostafa Saleh writes: > > > On Tue, May 19, 2026 at 07:30:16PM +0530, Aneesh Kumar K.V wrote: > >> Mostafa Saleh writes: > >> > >> >> > > >> >> > I am still running more tests, but looking more into it. Setting > >> >> > force_dma_unencrypted() to true for pKVM guests is wrong, as the > >> >> > guest shouldn’t try to decrypt arbitrary memory as it can include > >> >> > sensitive information (for example in case of virtio sub-page > >> >> > allocation) and should strictly rely on the restricted-dma-pool > >> >> > for that. > >> >> > >> >> ?? > >> >> > >> >> Where does force_dma_unencrypted() cause arbitary memory passed into > >> >> the DMA API to be decrypted? That should never happen??? > >> > > >> > Sorry, maybe arbitrary is not the right expression again :) > >> > I mean that, with emulated devices that use the DMA-API under pKVM, > >> > they will map memory coming from other layers (VFS, net) through > >> > vitrio-block, virtio-net... These can be smaller than a page, and > >> > > >> > >> Don't we PAGE_ALIGN these requests? > >> > >> dma_direct_alloc > >> size = PAGE_ALIGN(size); > >> > >> iommu_dma_alloc_pages > >> size_t alloc_size = PAGE_ALIGN(size); > >> > >> > > > > For allocation, yes, and that's fine because we bring memory from > > the pool. > > But not for mapping, as dma_direct_map_phys(), where the memory is > > allocated from the driver or other parts in the kernel and the page > > may be shared with other kernel components. > > > > But if we are using restricted-dma-pool, we also have: > > mem->force_bounce = true; > mem->for_alloc = true; > > So, will we use the swiotlb buffers for mapping and copy only the shared > content into those swiotlb buffers? True, that's why under pKVM, force_dma_unencrypted() should never cause any memory to be decrypted and so we set it to false. As in case of any bugs, the guest does not leak any information, similar to what just happened initially here due to missing attrs. However, as I mentioned to Jason, I think with some tweaks to force_dma_unencrypted() we can make it work under pKVM for aligned memory which eliminates some of the bouncing. I am currently investigating that. Thanks, Mostafa > > -aneesh