Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2479273imm; Mon, 28 May 2018 08:52:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKhfkzdPrVJuUeMncBxr73Q8nqZrSqVfV2Sz0CbCmiAcCoJBx5SSXUQaWb+dLgHUKJYVHzG X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr3385602pgt.98.1527522763366; Mon, 28 May 2018 08:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527522763; cv=none; d=google.com; s=arc-20160816; b=O4tDWofKaA7twTcN5LzIwWHzT/mMBUbtwItcGoymt5g5UaVLAytU9Niuxz8x26x6/W GEcUJ2sLz/YhIOEeMkNIQ9UKyjLQ3fSs7NbSVX61ZVLJkAbvo8Y1WERW7/Lfl5EXMBkf 6NAlBhFVhDnTsH6TvGd6vmPSL2vM5AxguhuX8egQeSJYP7+f/94b8vHylkCtZMDwpISG SfPnGREzHn2fNS3aO05tuWDC73evE6cRX3fVnpU4D5bVjOo4V5ODBb7kPG/FEVpFkX7M odCeRKhwjkXL996WJ8udK1HWOFQjIQCxAFs735p6XAELxN/45p2UOgQktrI8Mu796vLs WFpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KJqdBNJ8HOlGCfSOBXt3sorRbD6PbrnNxI+9YXhBcjc=; b=r+4ywA2y/zqvUxFCakisPILcVasfpSQzzsdaGfwNWf/8u9orP0lCVLyKBU+hqY5rMP PQsL1yzLK22BJ6GnOOd2h4NPFxnhT9gYefGST6wZ+8Q3ntEP2m48i/mHbbZH/prTvJJJ uMkkdtyetBg1FEYcmyUDxtn1ynneDpRex/+bAI0rLBngcvieIbi9eAt6L9iYX/af4uTK JkK9YK61MLsspolvyEExPu/8gHCR8VJ5UaIpXB2BfDaKiwYuUIh+I7KN4Cda2xVvIFF9 /GvnxWjiyni/gOJHN7Mh2dZx0dEB9hOlGv4ziVGyXK8pe3hFxoCI46RCuKqdw3IgNjqe dS3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TlxamQM5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23-v6si14271478ply.563.2018.05.28.08.52.28; Mon, 28 May 2018 08:52:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TlxamQM5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967510AbeE1KP4 (ORCPT + 99 others); Mon, 28 May 2018 06:15:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:36008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967010AbeE1KPv (ORCPT ); Mon, 28 May 2018 06:15:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F66F20843; Mon, 28 May 2018 10:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502551; bh=hhN+13qX6PfabQ/WSttVnjl/j464SuW5T4t5NaiF/Zs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TlxamQM5r4aBB646urQtce9eXEgLrxFQaVKS3QGevOeYzVJ4ZD2Coycez/EP+tODJ hE9n0wreVytwvEmJuADY2lQlXyICDb6WXAhzkzIaZal7xWHHhUW6ASA8CY9g0IBkIP stmjWFIKSSNg1zKyooDPqDgjh/G/7diRaNWdRFs0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Jin , John Sobecki , Rzeszutek Wilk Subject: [PATCH 4.4 010/268] xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent Date: Mon, 28 May 2018 11:59:44 +0200 Message-Id: <20180528100203.277622038@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joe Jin commit 4855c92dbb7b3b85c23e88ab7ca04f99b9677b41 upstream. When run raidconfig from Dom0 we found that the Xen DMA heap is reduced, but Dom Heap is increased by the same size. Tracing raidconfig we found that the related ioctl() in megaraid_sas will call dma_alloc_coherent() to apply memory. If the memory allocated by Dom0 is not in the DMA area, it will exchange memory with Xen to meet the requiment. Later drivers call dma_free_coherent() to free the memory, on xen_swiotlb_free_coherent() the check condition (dev_addr + size - 1 <= dma_mask) is always false, it prevents calling xen_destroy_contiguous_region() to return the memory to the Xen DMA heap. This issue introduced by commit 6810df88dcfc2 "xen-swiotlb: When doing coherent alloc/dealloc check before swizzling the MFNs.". Signed-off-by: Joe Jin Tested-by: John Sobecki Reviewed-by: Rzeszutek Wilk Cc: stable@vger.kernel.org Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Greg Kroah-Hartman --- drivers/xen/swiotlb-xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -359,7 +359,7 @@ xen_swiotlb_free_coherent(struct device * physical address */ phys = xen_bus_to_phys(dev_addr); - if (((dev_addr + size - 1 > dma_mask)) || + if (((dev_addr + size - 1 <= dma_mask)) || range_straddles_page_boundary(phys, size)) xen_destroy_contiguous_region(phys, order);