Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3843750ybz; Tue, 28 Apr 2020 01:10:58 -0700 (PDT) X-Google-Smtp-Source: APiQypIrld0fLmoZ2F5khdxbZ7QJczj/mutDXvNczbyvAvWSfTsrMmW8tUW1cv1iX41996ML+Zes X-Received: by 2002:a17:906:4e8a:: with SMTP id v10mr22615723eju.63.1588061458325; Tue, 28 Apr 2020 01:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588061458; cv=none; d=google.com; s=arc-20160816; b=rxIKm3wdyF35faQQnF1LtM2YAx1mJIN/Lg1UbG8eT97dJtiRziqjrH1rp1R9ygHm4B xniDBhKtsAp8aP/mX5pTmN+qWDSj2bxNLyPt0OgklpdcJ1uv0ylYr/n24teUCzQ9KAzw j//2JW72Ny/qlTKPPEVFdnfI05rpDV0W4YZNRNeTEF91+PRbBihX8xLB3MNnK2LVmccH wDkug/wtTV8Cit9z/YVqFlz9O9B7ZqKWQGiFtafaxfwuiDH17dOwPFTuTjalPDWYWvZX x1t8TbMlLJAfpp8ugpE7CJqZbP1ioyvrfbN439fu6C81X3mFjFGj8te15jQ1W5CWoOYM kjjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=9xXP4buVub3Lqo6lpBwh6AkT0U92OLBY0pYTQmHwiQE=; b=uMGw6fPhlB5wA8pdYa4Gue3wCcsEaX7jXI3tcpPRqdHUDpnxwgipszbquoxT16h7q7 0ZaBmvLmbhZGcuo2gnoJ8TMCVGk8XJ54rAhg2+96/j5d/+OxDE0ABUNP6o0rgJb29ruw VTEgSr42deAXuNoUS8KmjJOT2KSE/3c6po9ZyILclTIMIBnMSdaYkN7BiV5W3J4YWQGA 0LSh6mZ2dGdgAeShXFrKSaGnQ/IM/ruv9OAuekDDRotRfHLTVjIzWKIo2NGG8ml2Vjy3 d7g3lhhQg5PmESa0sOtTxvJGvDq7zfM4KFmKUboGIereA7/HthouDKmI+yNG1JzA+pyT 1uaw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch19si1414313ejb.240.2020.04.28.01.10.35; Tue, 28 Apr 2020 01:10:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbgD1IJM (ORCPT + 99 others); Tue, 28 Apr 2020 04:09:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:50608 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbgD1IJM (ORCPT ); Tue, 28 Apr 2020 04:09:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4E629AC4A; Tue, 28 Apr 2020 08:09:09 +0000 (UTC) Subject: Re: [PATCH] xen/swiotlb: correct the check for xen_destroy_contiguous_region To: peng.fan@nxp.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, sstabellini@kernel.org Cc: xen-devel@lists.xenproject.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com References: <1588059225-11245-1-git-send-email-peng.fan@nxp.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <1c01e97a-adcd-a703-55b5-8975b4ce4d2c@suse.com> Date: Tue, 28 Apr 2020 10:09:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <1588059225-11245-1-git-send-email-peng.fan@nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28.04.20 09:33, peng.fan@nxp.com wrote: > From: Peng Fan > > When booting xen on i.MX8QM, met: > " > [ 3.602128] Unable to handle kernel paging request at virtual address 0000000000272d40 > [ 3.610804] Mem abort info: > [ 3.613905] ESR = 0x96000004 > [ 3.617332] EC = 0x25: DABT (current EL), IL = 32 bits > [ 3.623211] SET = 0, FnV = 0 > [ 3.626628] EA = 0, S1PTW = 0 > [ 3.630128] Data abort info: > [ 3.633362] ISV = 0, ISS = 0x00000004 > [ 3.637630] CM = 0, WnR = 0 > [ 3.640955] [0000000000272d40] user address but active_mm is swapper > [ 3.647983] Internal error: Oops: 96000004 [#1] PREEMPT SMP > [ 3.654137] Modules linked in: > [ 3.677285] Hardware name: Freescale i.MX8QM MEK (DT) > [ 3.677302] Workqueue: events deferred_probe_work_func > [ 3.684253] imx6q-pcie 5f000000.pcie: PCI host bridge to bus 0000:00 > [ 3.688297] pstate: 60000005 (nZCv daif -PAN -UAO) > [ 3.688310] pc : xen_swiotlb_free_coherent+0x180/0x1c0 > [ 3.693993] pci_bus 0000:00: root bus resource [bus 00-ff] > [ 3.701002] lr : xen_swiotlb_free_coherent+0x44/0x1c0 > " > > In xen_swiotlb_alloc_coherent, if !(dev_addr + size - 1 <= dma_mask) or > range_straddles_page_boundary(phys, size) are true, it will > create contiguous region. So when free, we need to free contiguous > region use upper check condition. No, this will break PV guests on x86. I think there is something wrong with your setup in combination with the ARM xen_create_contiguous_region() implementation. Stefano? Juergen > > Signed-off-by: Peng Fan > --- > 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 b6d27762c6f8..ab96e468584f 100644 > --- a/drivers/xen/swiotlb-xen.c > +++ b/drivers/xen/swiotlb-xen.c > @@ -346,8 +346,8 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, > /* Convert the size to actually allocated. */ > size = 1UL << (order + XEN_PAGE_SHIFT); > > - if (!WARN_ON((dev_addr + size - 1 > dma_mask) || > - range_straddles_page_boundary(phys, size)) && > + if (((dev_addr + size - 1 > dma_mask) || > + range_straddles_page_boundary(phys, size)) && > TestClearPageXenRemapped(virt_to_page(vaddr))) > xen_destroy_contiguous_region(phys, order); > >