Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp242074pxb; Mon, 13 Sep 2021 18:07:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn91r7C0NBZej65lAOXAJLmo0ESA0ztgmxOlbTdjzWYgFvI6IKC4fLHTrAMmpgNcfTMx9v X-Received: by 2002:a17:906:d04f:: with SMTP id bo15mr16130398ejb.309.1631581677636; Mon, 13 Sep 2021 18:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631581677; cv=none; d=google.com; s=arc-20160816; b=bHR/tigFSnPdc3PUNaRpy56wL7eE4xNjcO9gf1CWCDOBWZZthPhWjEy5v/c70EmdY7 r2nQvjZGAb20Y0NwWalmgcyeCRuI0xu1XILTMULaY3XjYsndwOQGcrnJOQDO7TYOkxEv vHnrw/eUID6bL+eTaZUqjlpF6g2kPqrcK6efUJ8deMv94WIyDb1pKyhsBsJYCyf+Uq8i f/5yHYlINXVEHqjJ2olcdDOuOD1m8/2AfDaskR0phq7PomYSiGISzcuSbtUhfGsGhsh3 asWUJbz5wBLDZ5tG5hC4LZs1s5s2f6Wgzo1DSp2yWE7jPhWgnmqVKWVk+BvbWpXGYq2J QVSw== 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=UghDPnCgTOOruC0uBzsPoENnVvsHKQ6O1++uAJN5dJc=; b=jcPw42t2OAXuRPutyUcfDpSCVSSoKZ0ARIS7BroCTTJUzl+hblnmPBICGiUDomsEcB 1SxjJ6xoh6b6FbBqnzphRvSiDqQiSM2I+u0BhrnYmFhz06hYXScf6n+nfEbKyltIQiXg mVYfvTwqkxn1jIHnWlmkfAWx7i6ZVT/nD6avRptiho7VpVhnCLuXqdD/9cL2/+gBb3uY /NuMjXVGwSj1bK7+GvwN6XSLSaWS1DnNBKNavgrazPCrJEY4XMl9PtivUUWXyPnHYUJg adMGDspoDKstASIl3PsihXtzd+MZLriz6k+/Om9VaQdglYbFbcSK/b4fG5dYaVVejjL7 FhFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DHwsMX7i; 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 mp36si10068689ejc.478.2021.09.13.18.07.33; Mon, 13 Sep 2021 18:07:57 -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=DHwsMX7i; 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 S243385AbhIMUuW (ORCPT + 99 others); Mon, 13 Sep 2021 16:50:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242743AbhIMUuV (ORCPT ); Mon, 13 Sep 2021 16:50:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6463A610FE; Mon, 13 Sep 2021 20:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631566145; bh=hUiqmRGtEXepWEODLRwwvcp5j41ZXDQIlBCemxiVKNw=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=DHwsMX7ikvWdd/BI8zDeHuw+7Tapq9FDRv/8U/Wc5GJhsdDEr0PZBkADcNC3Cw4/l XVIYVS3fpf4IB/pEf/TBDYctfkgqE5TknKGwK5w28r1T0PfvZgGxfh5u4emxheYskE tfJGnP6f/saAr4DBa9u2FuM//73eD3+3Ma38STWt9N64jckrDfpLuZsst7TasKtIXx vFlplwL562zn3HK9rwxFYC1y4bQe7btGfdnMb5FDi/TilVePV2YX60eoSVjbN+C9Oj eGh0ylJCU9jw2iP9ocX1Qp0BMnuv15otYWsJrZYReV/tsLjmDecY0Nc2ev8c2d0QaN wqK6HMy1fcSRg== Date: Mon, 13 Sep 2021 13:49:04 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Jan Beulich cc: Stefano Stabellini , Juergen Gross , Boris Ostrovsky , lkml , "xen-devel@lists.xenproject.org" , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Christoph Hellwig Subject: Re: [PATCH 12/12] swiotlb-xen: this is PV-only on x86 In-Reply-To: Message-ID: References: <588b3e6d-2682-160c-468e-44ca4867a570@suse.com> <004feaef-f3bb-e4bb-fb10-f205a9f69f28@suse.com> 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 Mon, 13 Sep 2021, Jan Beulich wrote: > On 11.09.2021 01:48, Stefano Stabellini wrote: > > On Wed, 8 Sep 2021, Christoph Hellwig wrote: > >> On Tue, Sep 07, 2021 at 02:13:21PM +0200, Jan Beulich wrote: > >>> The code is unreachable for HVM or PVH, and it also makes little sense > >>> in auto-translated environments. On Arm, with > >>> xen_{create,destroy}_contiguous_region() both being stubs, I have a hard > >>> time seeing what good the Xen specific variant does - the generic one > >>> ought to be fine for all purposes there. Still Arm code explicitly > >>> references symbols here, so the code will continue to be included there. > >> > >> Can the Xen/arm folks look into that? Getting ARM out of using > >> swiotlb-xen would be a huge step forward cleaning up some DMA APIs. > > > > On ARM swiotlb-xen is used for a different purpose compared to x86. > > > > Many ARM SoCs still don't have an IOMMU covering all DMA-mastering > > devices (e.g. Raspberry Pi 4). As a consequence we map Dom0 1:1 (guest > > physical == physical address). > > > > Now if it was just for Dom0, thanks to the 1:1 mapping, we wouldn't need > > swiotlb-xen. But when we start using PV drivers to share the network or > > disk between Dom0 and DomU we are going to get DomU pages mapped in > > Dom0, we call them "foreign pages". They are not mapped 1:1. It can > > happen that one of these foreign pages are used for DMA operations > > (e.g. related to the NIC). swiotlb-xen is used to detect these > > situations and translate the guest physical address to physical address > > of foreign pages appropriately. > > Thinking about this some more - if Dom0 is 1:1 mapped, why don't you > map foreign pages 1:1 as well then? That's because the foreign page, from Linux POV, would appear out of thin air. It would just show up in a region not considered memory just few moments before, so there would be no memblock, no struct page, nothing. At least in the past that caused serious issues to the kernel. This is the reason why the kernel is using ballooned-out pages to map foreign pages even on x86: drivers/block/xen-blkback/blkback.c:xen_blkbk_map -> gnttab_page_cache_get drivers/xen/grant-table.c:gnttab_page_cache_get drivers/xen/grant-table.c:gnttab_alloc_pages drivers/xen/unpopulated-alloc.c:xen_alloc_unpopulated_pages drivers/xen/balloon.c:alloc_xenballooned_pages