From nobody Tue Apr 30 05:16:24 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1582908470; cv=none; d=zohomail.com; s=zohoarc; b=Q4PV//7i0j8rIykMBFk7ho3Rig2sbrv725BML4cRPMCE4Z8rOvXEu9SohbbRw16OdR6HFyBjIG0tJwINnqoGvNE/7aGTSuzGhB0pLgl6UNxXz0fIsqZNFlucICsYeKYrC0Zqc5DV0YImejhaAu8HwbDiF+GQ0zexCb/f2R0KAFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582908470; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=5VB8xLeSpy8BboR4OHbXplSn0wsH+5sfncXvAqqXj5Y=; b=IUxs/e+i4qao6d3q41IF7+vpeIwd6e/IIKCREl5jiFRAJnsQSwh91SJBn4+Iswl2rK4Cdbj1pf17xoW2kaMEN5BkHKUWUB5TxfvY6SHpZnQwmPgsf2SWhAHQCf7JIc4JhjEUgwQfBYu8v6uW6QXuX3QhZAXs/oGSaANQkyk0MhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1582908470784809.2880954110288; Fri, 28 Feb 2020 08:47:50 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j7inA-0000M6-A0; Fri, 28 Feb 2020 16:47:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j7in9-0000M1-4u for xen-devel@lists.xenproject.org; Fri, 28 Feb 2020 16:47:11 +0000 Received: from mail-qv1-xf41.google.com (unknown [2607:f8b0:4864:20::f41]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f6bbeba4-5a49-11ea-b472-bc764e2007e4; Fri, 28 Feb 2020 16:47:10 +0000 (UTC) Received: by mail-qv1-xf41.google.com with SMTP id u10so1639757qvi.2 for ; Fri, 28 Feb 2020 08:47:10 -0800 (PST) Received: from Lubuntu1804nataliya.tkf.ru (kntaon1614w-grc-09-74-15-93-240.dsl.bell.ca. [74.15.93.240]) by smtp.gmail.com with ESMTPSA id m200sm5477487qke.135.2020.02.28.08.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 08:47:09 -0800 (PST) X-Inumbo-ID: f6bbeba4-5a49-11ea-b472-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Ztvrya6bNFV0Urb7uJbXROEu1vVN7v9D8tb3ubUhwD0=; b=JzbsG3uNgyK01937fuhSr4wjEkdvsbU/plA8+Vu22YU5ARpTVGDWHTnPAS7gdr/3c/ oxAiDGqC1Gh6E+CFwycfeAsSLx5pRxCkhbcAoMyzXrGGv4luwG6N19vx+4thaf3HsOCq SYRnSGHmXsvK7BvX+qYKZ4TjtT6FkrSkqyQAhK5LuLZTm0QLOQvP7ioyjcnhBp1WVgPS 8AMWkqGKHsXboQ6yFgJ51etVtfz/TwhPmFnn0TbwrI8Qj6h9yIsEI9Zj3hIn0DBB620H bvgJgsEnvpFJnNcaGzIZe9thC8j6OWpKo1UYmb3DV8KE9auE5TkuIusiUnp5fLO2nO3o xamA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ztvrya6bNFV0Urb7uJbXROEu1vVN7v9D8tb3ubUhwD0=; b=td2Kslk8cJlquNPumzKN8AcDvGKV2wKYNJfigeZZfCniDBvpgwqHTxmLsvytJv5d8S V+3knNVsa3iwiJpgQgRwJDXUojdiwToQHp0pBte1/gadp3aQ9J5PHBQeP2LSI9yAd6sr cexhLGYCZC4XoZu+A7V46YglYV7sFkoV39mLXVh/zSXmMNkK2IiPpfht3IjPFkBCqMN1 EInDCy/JqzKTxyxSDqujTK3dKe0m1nVIyJtc5OW0ZwNdM6SGn0Wrk1emigHdDzxI/0J6 zWmZW6TGC+huO7i1nMUK1iAIOezZC6hSfUk7I4UFGw+MgziSjxxoAf/9N56vd68lPyuP WKhQ== X-Gm-Message-State: APjAAAXa5SswMWqwAlCZdupWfrUeSkubRr+hsP7iQLVMQQJRVRaipdjF 7So0B3ALv+poDcvVURGsddv5PYaX X-Google-Smtp-Source: APXvYqx/fQqS5wdwkhv7F2JRAcoAiweKXo8phJxvmN5lh4cOVYTyvAgYIE7p97IaT2HG3xo9qHtmMg== X-Received: by 2002:ad4:5888:: with SMTP id dz8mr4659418qvb.204.1582908430079; Fri, 28 Feb 2020 08:47:10 -0800 (PST) From: Nataliya Korovkina To: xen-devel@lists.xenproject.org Date: Fri, 28 Feb 2020 11:46:56 -0500 Message-Id: <20200228164656.23774-1-malus.brandywine@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [xev-devel][PATCH][linux-4.19] swiotlb-xen.c: Fixed cache invalidation fault X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: jgross@suse.com, Nataliya Korovkina , konrad.wilk@oracle.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Problem: xen_swiotlb_map_sg_attrs() maps a set of buffers described in scat= terlist. It calls xen_dma_map_page() and sets sglist.dma_address to the address calc= ulated by xen_phys_to_bus(). Let's call it dma_address_1. xen_dma_map_page() maps the area and gets dma address different from dma_ad= dress_1, let's call it dma_address_2. Then function __swiotlb_map_page() makes conve= rsion: dma_addr -> phys_addr -> virt_addr using dma_address_2 and passes "virt_a= ddr" to __dma_map_area(), the latter successfully invalidates cache. When xen_swiotlb_unmap_sg_attrs() unmaps the area it passes dma_address_1 to __swiotlb_unmap_page(). __swiotlb_unmap_page() makes the same converti= on: dma_addr -> phys_addr -> virt_addr using dma_address_1 and passes "virt_add= r" to __dma_map_area(), the latter gets Data Abort in attempt to invalidate ca= che. The problem manfests on devices that have dma_pfn_offset !=3D 0. Specifically, while loading brcmfmac module (BCM4345 WiFi chip) in Dom0. What was done: sglist.dma_address is set to phys_to_dma("phys"). Signed-off-by: Nataliya Korovkina --- drivers/xen/swiotlb-xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index a6f9ba85dc4b..9363a52e4756 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -583,7 +583,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct s= catterlist *sgl, sg->length, dir, attrs); - sg->dma_address =3D dev_addr; + sg->dma_address =3D phys_to_dma(hwdev, dev_addr); } else { /* we are not interested in the dma_addr returned by * xen_dma_map_page, only in the potential cache flushes executed @@ -594,7 +594,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct s= catterlist *sgl, sg->length, dir, attrs); - sg->dma_address =3D dev_addr; + sg->dma_address =3D phys_to_dma(hwdev, dev_addr); } sg_dma_len(sg) =3D sg->length; } --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel