Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4002293pxj; Mon, 21 Jun 2021 11:10:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDEQJpjkizMsupimlyEyQINy+fyy/mm8O21h5LFjqdrx9buAJJP6XoyslppbCK6OiYFjGN X-Received: by 2002:a6b:7901:: with SMTP id i1mr20956601iop.41.1624299051819; Mon, 21 Jun 2021 11:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624299051; cv=none; d=google.com; s=arc-20160816; b=Po6mUGLGC199JIHwifpMY03bvv0i86Rs/6oqeqE1ma3X6rU64pWnTRcmJ7JKq1iUyA oVPcn2vNDFDMVATGZpNnt5IREUDZdrnzApkygBxKEWPs9nwT00pX/vqZmszR564Ci0Wi GIqEOS1jZdb+tYFzcScFQAmH351+kk1AwOjXVq/gzFyay4MZq0oHEUxPEl4P4PqtCuAK LEc1cdB/uxLat9LCMLp8kcF5CzVmlYEtJ7kRzc2C0yfMBrFHLhE0/OwfTjEXk7ejb6hr vvueklQqvytSowZeJ28EyhornbtO6ZLN61BgdJegmX2XboOtXlKXIMSGnHr1jBVz0iCv qPjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=YSAxeXIwbeR9Ci6mDkEAAdhezaP/SKCQXt9yPjDmAac=; b=bam2+mGBJxJbjBe9BWIVG8Ouzj3lDL6MGJy9yg2PDF6TcshEh8Qf27HVP68ZFrN8LF OWmOrmailVrvJqKd1aGZcKzx7Y+n+6Muxnsy5oeM+zIz+9noVznb0brfJABY+hd/YuP5 P6Jp1sI5QWxPmTECNhUC0CiY2fRShio8Bnmsgpog6bJY2XY/Fi3k96bgzoxACFnf2yxq D2wkQaxZK6C0vZjhXDlKzd86fMXC/1woyBz/Xa0TDE4Vvy5BvsLzU75dwD2SW24mBUmv ghiDB3oWgjeUwtp1Aq1on70H45ydN3n4EEAx5rscDzgYO4chOPp9rW9KOrWndUmcFVVT xlIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nVdx/hwy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t17si19637451jaj.108.2021.06.21.11.10.36; Mon, 21 Jun 2021 11:10:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nVdx/hwy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233544AbhFUSLe (ORCPT + 99 others); Mon, 21 Jun 2021 14:11:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:45322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234341AbhFUSFG (ORCPT ); Mon, 21 Jun 2021 14:05:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 94438611CE; Mon, 21 Jun 2021 17:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624298362; bh=y8attfyCFvmhE/rEq1lKuxtMSlY+L9uu0zEo4FMjkv8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=nVdx/hwygYr/MG4oSfAecQoTkcAWFsVr6dFhXJUhFXwqSbH08hcJcQHHaJ6yNTgwJ WFFrnk+RLaMbXPz1Xtr0MorwwBCBRCnNVEqXP2tUXHhGV2Usf3U4gjEu3zxeInr5od B9ktxTxXUHFXTSVy1nFGEpPSBK9O5Aws7oD7ucKaVc2hx8hm7IAXVZOQ8U1l9ZRj62 sEXsTrg9MCBDzVl47wBX5+3xzZhCsWmVRvgAWZv47Xmzv8udI19xFqd0CjGvBvgqzh BtSw3vV40r9z2Jdokw3+RVbueWCN8P3KLA5YE9ZkG0ZSqiTJvVk9SGjw4FEHT8nF7N esGUOKjtCMepQ== Date: Mon, 21 Jun 2021 10:59:20 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Christoph Hellwig cc: Tom Lendacky , Claire Chang , Stefano Stabellini , Rob Herring , mpe@ellerman.id.au, Joerg Roedel , Will Deacon , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Marek Szyprowski , benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , Robin Murphy , grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , "Rafael J . Wysocki" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , Tomasz Figa , bskeggs@redhat.com, Bjorn Helgaas , chris@chris-wilson.co.uk, Daniel Vetter , airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, Jianxiong Gao , joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Subject: Re: [PATCH v13 01/12] swiotlb: Refactor swiotlb init functions In-Reply-To: <20210618143212.GA19284@lst.de> Message-ID: References: <20210617062635.1660944-1-tientzu@chromium.org> <20210617062635.1660944-2-tientzu@chromium.org> <741a34cc-547c-984d-8af4-2f309880acfa@amd.com> <20210618143212.GA19284@lst.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 18 Jun 2021, Christoph Hellwig wrote: > On Fri, Jun 18, 2021 at 09:09:17AM -0500, Tom Lendacky wrote: > > > swiotlb_init_with_tbl uses memblock_alloc to allocate the io_tlb_mem > > > and memblock_alloc[1] will do memset in memblock_alloc_try_nid[2], so > > > swiotlb_init_with_tbl is also good. > > > I'm happy to add the memset in swiotlb_init_io_tlb_mem if you think > > > it's clearer and safer. > > > > On x86, if the memset is done before set_memory_decrypted() and memory > > encryption is active, then the memory will look like ciphertext afterwards > > and not be zeroes. If zeroed memory is required, then a memset must be > > done after the set_memory_decrypted() calls. > > Which should be fine - we don't care that the memory is cleared to 0, > just that it doesn't leak other data. Maybe a comment would be useful, > though, Just as a clarification: I was referring to the zeroing of "mem" in swiotlb_late_init_with_tbl and swiotlb_init_with_tbl. While it looks like Tom and Christoph are talking about the zeroing of "tlb". The zeroing of "mem" is required as some fields of struct io_tlb_mem need to be initialized to zero. While the zeroing of "tlb" is not required except from the point of view of not leaking sensitive data as Christoph mentioned. Either way, Claire's v14 patch 01/12 looks fine to me.