Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3984547rwe; Tue, 30 Aug 2022 02:26:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR6f/RsxQOHZwwh7c74CVxKy31xvCcFZVN9VKP7Y3LVUJYDtxZQA4pwN1AP0yf+s85tDM68D X-Received: by 2002:a17:907:6096:b0:73d:9d12:4b04 with SMTP id ht22-20020a170907609600b0073d9d124b04mr16723856ejc.745.1661851596056; Tue, 30 Aug 2022 02:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661851596; cv=none; d=google.com; s=arc-20160816; b=fAFl3OlS2tYwg1si0o73VE6x/3yJy3x4FumEiLYPJ33EcY1EoozFJMay5hBRo8xecf cbl5b7rd2UHz5TMEnnciXXSALnPEewAT9TaRrP7AZi4OO0FdJlf7hj504DUop9Xl7nYI WbptHHqZIITIt6CtwGhVLL5MrJiJjsXZkI1B7p9AxvtUZUcVxegUIbifB19oFsitzeJq dt01coXMjawwzXKvWo4tQertrzhTqFHsYyAtMiqI5UmM7Msl1LcGDTDt3hjyxr1pNfnL EJq1uYknEyuMRc0eqx+EUkWLYMaTqYL9EX2O2qDIhyhutqWBbvKm0cwzFIhV7UHp6c4Q YXzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=GLDAOz9Sc20AyOGgLTD+sQQaKlO5YLgtQJ1tc57c9ow=; b=JKWFao9nS5JSKc0YKPheHiHpWYQwLRhOvW2RMv/Ir/y7nkl8+WHj4ueJp+E5w/4W0p 5Rz9YbUbXUXWOoyikU+NiOWs0jyEfaIMeoExvYFnxgHO3qyhwtQMK4IBLovCshfWc9D0 RJ9v3usd3ndec2r76toDdqjZ59EHvxTh3FJq90HLXEKIE2tS+v/73S+TODMZmmsMPTWL MXVOk/GLvmu4vlSKYkQSzQVo7yk5ALaPlMYpgP2wStAZr+22DMzCwXVBmhPme7tAMXby MBgXq+kBX7dkvYpcjjLa9lW5HEwBSaW8xo4PQGeeD4URB3Un/PYqYQG9KvRqkAi1zSfX BEXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a056402524300b0043da4dd1b2dsi3568846edd.575.2022.08.30.02.26.08; Tue, 30 Aug 2022 02:26:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbiH3JYU (ORCPT + 99 others); Tue, 30 Aug 2022 05:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231686AbiH3JYA (ORCPT ); Tue, 30 Aug 2022 05:24:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 789F37392A for ; Tue, 30 Aug 2022 02:23:58 -0700 (PDT) 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 7BD991474; Tue, 30 Aug 2022 02:24:03 -0700 (PDT) Received: from [10.57.13.45] (unknown [10.57.13.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E28D3F766; Tue, 30 Aug 2022 02:23:56 -0700 (PDT) Message-ID: Date: Tue, 30 Aug 2022 10:23:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH] swiotlb: fix a typo Content-Language: en-GB To: Chao Gao , linux-kernel@vger.kernel.org, iommu@lists.linux.dev Cc: hch@infradead.org, m.szyprowski@samsung.com References: <20220826095046.880626-1-chao.gao@intel.com> From: Robin Murphy In-Reply-To: <20220826095046.880626-1-chao.gao@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-08-26 10:50, Chao Gao wrote: > "overwirte" isn't a word. It should be "overwrite". > > Signed-off-by: Chao Gao > --- > BTW, I am wondering if copying the original buffer to the tlb buffer > unconditionally will leak the original buffer to the VMM, especially > when VMM isn't trusted e.g., by confidential VMs. Would it be better > to zero the tlb buffer for dir == DMA_FROM_DEVICE? No, at the point of dma_map(), the buffer contents are owned by the caller, so if parts of that buffer are sensitive and shouldn't be exposed to DMA, then don't map the whole buffer for DMA. There are more DMA API implementations than SWIOTLB. The whole point of bouncing the original contents here is that doing anything else effectively corrupts any part of the mapping that the device may end up *not* writing to - see the whole sordid original discussion (but don't be confused by the fact that the caller's original data happened to be zeros in that particular case). Thanks, Robin. > > kernel/dma/swiotlb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > index c5a9190b218f..f67e5f50ee3c 100644 > --- a/kernel/dma/swiotlb.c > +++ b/kernel/dma/swiotlb.c > @@ -765,7 +765,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr, > /* > * When dir == DMA_FROM_DEVICE we could omit the copy from the orig > * to the tlb buffer, if we knew for sure the device will > - * overwirte the entire current content. But we don't. Thus > + * overwrite the entire current content. But we don't. Thus > * unconditional bounce may prevent leaking swiotlb content (i.e. > * kernel memory) to user-space. > */