Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1111428lqm; Thu, 2 May 2024 05:50:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEeCEjETXWvJD9jpnc0HzJEsgKkb5lyEmP2AkMG8Mcupih//0sT6COcIiblK1T90wkj94DnFhwsP7KHoG74JO7zVVvYoqZkjubJVzGXQ== X-Google-Smtp-Source: AGHT+IHdZMw4xIFx4KCFFxtK2fnH+WvvYKM3mJBhq/A0wuSwE9Fde2e1WysMgivzzDxFZpotxg3j X-Received: by 2002:a50:c304:0:b0:572:7b08:d497 with SMTP id a4-20020a50c304000000b005727b08d497mr3608990edb.17.1714654259668; Thu, 02 May 2024 05:50:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714654259; cv=pass; d=google.com; s=arc-20160816; b=YT6zeuZsksQDTCanfdr01PxUR+gwuTu9zDX5oAUjD1notUA7Qie230Zedye3D4Qu2/ WfoGOF5wzthunns58213rKFHMK3ZKBoRe7rujlXRhU6+L0N8bdMr/KWKFU8mDCe4t8EZ zKsBuBZoUd69H18pDZ8zATCKTydUExfIwcNJxYyMlagsH5AW/d+cQ5HTBNS2gzVgwwTF k20uBBG58W83uOoAmT4enkQESNTnh1Zfe1N8bfbB4H1QpgI1+DldHSxmUiOBDMaXA2XL ykS7TnCrvJm4ZpAx4zAQA72G3FbDA/B/BAAgXOEPH1ZjV2QEl5TwHozBTxiROt5JbW2Z JMAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=0gbcnTeLzihVS5Qy6QTYUY8THl3vseIaHTMw6czJ+yY=; fh=zNDnzO//EIarKFLtn/qzWEeaft7/E22LuH67c1pd2Xg=; b=VujPOtAAOUvtFllbWhtdwA9IWu5b4EIeaNaLBRFKiI1CvlM0ZVcFF8iUOf4LnpERoo 7XPGrWCah0TwQvaP6XTD+cWFz/J267NLatD/O0gO/6UG81JxBDRQHe3G3JhxJNJ1GkU3 oZHTeUjE8uVV2OR9baJaFOvRBwncK/6ojXmZ/uYrw4W/1GL6nGw2zR52YUTV5uiCyK1i 315jIl6rHtOVcZ5GnaNoitXuy+wCmgXlx2DH8XjcTzkXztJHDIYW9SuciOKe3fG9fa0V FuyTa26Y6+bErA4wm0JODRU60b/YRHKF6KA2S8PHKUzF3M+FwNRuTe3xCd1plJCapapU mmEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-166470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m17-20020aa7c491000000b005721240c40bsi478670edq.492.2024.05.02.05.50.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 05:50:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-166470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4FDB31F21A19 for ; Thu, 2 May 2024 12:50:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F4C177F1B; Thu, 2 May 2024 12:50:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D71BB6A8AC for ; Thu, 2 May 2024 12:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714654252; cv=none; b=us2LSeTRos9thP+tvS+arp7xz1G0+N3rkJp5Vvw51q7JPsrNwH0dR5p4fCEj69Ffu5lmHMNrWqTGEBbeJjTvx2cDuYCWNELVHZzyXI7aKfdQrfunuLXDwF7CtJS06+xbndzeoLxt9Ct05ap4QqAcR3rao5haMtFzfgVM/8hNuaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714654252; c=relaxed/simple; bh=m/a0B/l1IBvnIQwe/oxF5PawDKzGaXpKpMSPcwifgEQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=V+bbKU9Xefdo57K5F4q7lCrftFzIXs4dhDTWLwYOamXrStolVD5577sdVmV+dXXkE9Yls2uN3VVuFe6gczWYfUaA770W5JJaxySSVLEkUDeq/hlGbsl5x5PJs/TBOsBG7ld2EAUperjiXDLAO2xH+IyJDZTJt7zgTfwng/p1bYQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A94402F4; Thu, 2 May 2024 05:51:14 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 02FD23F71E; Thu, 2 May 2024 05:50:47 -0700 (PDT) Message-ID: Date: Thu, 2 May 2024 13:50:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] iommu/dma: Respect SWIOTLB force_bounce To: Christoph Hellwig , "T.J. Mercier" Cc: Joerg Roedel , Will Deacon , Andrew Morton , Catalin Marinas , isaacmanjarres@google.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240501201319.586289-1-tjmercier@google.com> From: Robin Murphy Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02/05/2024 6:07 am, Christoph Hellwig wrote: > On Wed, May 01, 2024 at 08:13:18PM +0000, T.J. Mercier wrote: >> iommu_dma_map_page and iommu_dma_map_sg conditionally use SWIOTLB, but >> checking if force_bounce is set for the device is not part of that >> condition. Check if devices have requested to force SWIOTLB use as part >> of deciding to take the existing SWIOTLB paths. > > This fails to explain why you'd want this somewhat surprising behavior, > and why you consider it a bug fix. Indeed, it's rather intentional that the "swiotlb=force" argument doesn't affect iommu-dma, since that's primarily for weeding out drivers making dodgy assumptions about DMA addresses, and iommu-dma is inherently even better at that already. Beyond that I think this change also seems likely to interact badly with CC_ATTR_GUEST_MEM_ENCRYPT on x86, where we invoke the SWIOTLB_FORCE flag for dma-direct, but expect that an IOMMU can provide a decrypted view in-place, thus bouncing in that path would be unnecessarily detrimental. Thanks, Robin.