From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 240F73ED3CB for ; Tue, 19 May 2026 14:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779199477; cv=none; b=mD16EkfYVaVOJKgpFk/X4/O/QFiXV8pJkldgc4+LAirOmmXNEd91TNb7pYK2VrnublelLsM1YY+S5yMyC4OpEvqWVZUdR+GCRtvbqeAAnKtyEad+0dd3BkS6Bb/LR8SLzX+5JbFl0Ch3QvRtH087oeuA7G9bln8PWwNI+qrC5yE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779199477; c=relaxed/simple; bh=ldMlyu6KW0ehhtOLgHgTLzNQrPjv+3vF2LX9OYDZKO4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Zu21UD0cwCHn03C7XrQDE3KDXm55Wz55XYgQVlWKv2wt6ZsB3WtID8hiC0GYXIUw2XZ8Rf4xOBVtkO7bpoXmQtWK6K0khawf0nSt0nyDktShQ2y6SVC/fGJQt6juBShatNStvtWG0eEe8Te46d2jW/+JJlB+xaCTg+g6wVKJhTc= 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=AVRLGNd1; arc=none smtp.client-ip=209.85.128.52 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="AVRLGNd1" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4891ca4ce02so3075e9.1 for ; Tue, 19 May 2026 07:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779199474; x=1779804274; 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=/eckcCpi0xrpFbE201pgVvuYoNal9URjmldCWt34Ap8=; b=AVRLGNd16UAV58dV0bPWiCKmwRD60coTqNF/OKoxnw2i3YkIK4uLiRvefLKCkN34TR ymKNmjIXFDpGpT2o01sx7mhzwcQzqH4auCDL7PaDKKDqqWNRcZWWfoOR36nBN5gIFvyO w+WcnpEoKoRYuzLjcyO0OC15RFhSDfG+shhM8xAvYbUgU3B1ZyCPuCm/BwtsTVBhpn3x jR5nq+PL5PfcUz390hboCCW2eHd/xHl5//JstgmxLogVnlWVNrtS3MAqIYTdbsPYMQpe V4v71tq0mVminLVB/30dabQBg8URTEka6qHCNRY4lwuBnTUnMj6t4G08OEXNMHZOVgPL ldCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779199474; x=1779804274; 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=/eckcCpi0xrpFbE201pgVvuYoNal9URjmldCWt34Ap8=; b=i0xm48nJXldS4rjg1VJYdZ+sWgmh11f+ljVaMFeL2rrmoZJ7aPI90G0140jZbt64J1 GB3+IcRszRhE7ilKes7154gDYg2aJNmh383RBTiSpycr3d9OcmrRX5evPqVkI1BXEgrN tvJR2L0O3/5QmFOAEhtljsbHhlUWyvLautD5VQEmYBr6qKN6gcfuc/JyhpmsaHIYCU+p 5kzPJrNEWQovldYa6WRaGySMS4u5pgXggTxUxREP/npl3ck+VD3S/c1JsOcIz7POg63/ d2YPirHFJFOpIJ/w0upVQU9RGFIjtCH0Xr1Jd3RicomEwqqOcWXQ5fQZbUz3h6UvMvfC hsug== X-Forwarded-Encrypted: i=1; AFNElJ8UxJtHFTusAlqr7GFDXxSnB5Dlpg1NaQYac/NK/sCneUGvx0Bs9S11f3jIY8oAcHVmiQsa1J+Up79C@lists.linux.dev X-Gm-Message-State: AOJu0YzqdAYJ0CJfCvqgfoE0W9dcR5POL5prQMjxoUcXmyi1iUH8uMiV flYEOKMSwNpIoe4/f/QVaX1w1JNKbyqOZXSyVOHCR1tobUfu1U4Q4tVNMw3YSYZV8A== X-Gm-Gg: Acq92OFCd3yCs6y8CFJYlq83S1FaDJ4SHOFTVM6Lz1lefMt1Dfbxqddy34Q/SBC7s0a N3zTtDRPWF+lLvU5KkyeCuy52fZzqJsvPgIvi2Rw+ICE3ISQmBSDCJ/EIPaW9KljUgoBngABcn3 AvNhkC4FB6QUkTFts8H2kE6kr44NWt3TOcEwRss+C6RAogo7Md4zoYiuVCG914JBYKJdw3ZzBLJ dgEdsSdS7Fv2fe6fkurgM0vZPBeFESQzDivMillbmDxOvx8ZIfRcosJ8X7DLJ5zQrFzg6+wK2TB al6/0odlis6MlWLsOhUnzNYhT++DCmOEWdSqg2leUHmEgBMFBrakur5wZmEgCg8qgmNzfI4FKCU Fq40wcA0WS55a6NoH5ojLOyfFI5HPulAeSSGqYrIgvcaF4jngOcXYjbdakUSLJESWMNFNaEjk1m 12S4EXVK8InlMcfbcUtM5IwxAUJ+MrN4Tivr0JHJjrknNv1WqQh8DrBWWG9ZPc19aeix6ixEc9o jY= X-Received: by 2002:a05:600c:621a:b0:489:1adc:f017 with SMTP id 5b1f17b1804b1-4901573b1a3mr2225915e9.5.1779199473882; Tue, 19 May 2026 07:04:33 -0700 (PDT) Received: from google.com (136.41.155.104.bc.googleusercontent.com. [104.155.41.136]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a19b1dsm45189665f8f.17.2026.05.19.07.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 07:04:33 -0700 (PDT) Date: Tue, 19 May 2026 14:04:29 +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: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. Thanks, Mostafa > > > using force_dma_unencrypted() will share the whole page. > > And as discussed, that leaks sensitive information to the untrusted > > host. > > I am currently investigating passing iova/phys/size > > to force_dma_unencrypted() and then we can share pages inplace only > > if possible without leaking extra information. > > I am trying to get some performance results first. But the tricky part > > is to get the semantics right, I believe in that case those devices > > shouldn’t use restricted-dma-pools as those should always force > > bouncing. Instead bouncing happens through the default SWIOTLB pool, > > if not possible to decrypt in place. > > > > -aneesh