Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2369838imm; Mon, 28 May 2018 06:54:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKjEOf8S+nVmUeRA5qpJR8O9upHabj60dLcE67UyWdBVNEKwBeYU5yZIq1CEpGyuNBDdukj X-Received: by 2002:a17:902:8604:: with SMTP id f4-v6mr5275245plo.4.1527515646057; Mon, 28 May 2018 06:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527515646; cv=none; d=google.com; s=arc-20160816; b=WRYhPPw+uneeH975SgMuANEfaH4zhBy4SQIQA2gbANXFrjfyKyDiYGyleiomyQEWsC NSl/p0oDY4kjJSBx0EYI2Bj1riauzMH4cYCr7YnsVV9Y+HkMF90rGXaDRxTLg2Op4/0c FpyVCnDTJ+RYiBDFYzpXPhFnRoeqP84La91YNi3Dst8TWPbyxPQqOSnNuhu33eBMfTss He1Y9qiXgoFTypPV4XMbZGjigF8wRPQ2YMYzQkwo1nhxfJyi/bQo5G75yKnzr3E2W2IV ppuBhVZKyQqy4bMzpJEFW+nTINokk0c/V93lHOkpi0EK/A6ObwL0sEqV4NKi9ORo6EF7 A29A== 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=9JuoJIZO6jgqZQ6ZXXgiK43tLUT/LQalLe9lzFQlqJc=; b=fa6r0dg6S9g3/wW6s6eyt2zIAsn2r7cnQZVr3Nl69Q88Rj6K/RMlLRHIE+PCwLkL+a vb9LKHgeoz5jsrWkt3dl1RWDuVjeVVnZF6NL2ngwx5xypu/I71U5iRLCDDIHCp5zaLM3 xDHFyCtB4WX6YczXSX2k0qTQP7bro8F7DQGWddARg/eML+VShJ+U0QG0Hfixcuhce+Wu zP+0T48vlFdwHhk3Re5k/t5+9DkrUDE8ueqwcXfHZzXZVunrRqfHlY+TpPGSNeK0a687 djcNbtN6qoN6PwhlByHybMBNsemj1n77xFf9nyiHrrKGj+1OZTQ8n/RwwXhmRUHOGSDM 2oPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=trAUxIT3; 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 m2-v6si22362168pgm.306.2018.05.28.06.53.51; Mon, 28 May 2018 06:54:06 -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=trAUxIT3; 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 S937665AbeE1NxG (ORCPT + 99 others); Mon, 28 May 2018 09:53:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163015AbeE1Kln (ORCPT ); Mon, 28 May 2018 06:41:43 -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 9255D2086D; Mon, 28 May 2018 10:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504103; bh=WgHPOyDv5HGxoslQ2LZ+j9pp3uZzVcx8gxmsO05QGEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=trAUxIT3uaf8XwVpu7L6VEfdTBAQ5q7speOLBSDvzHmrScbEnlQEc4fIRH/4Ui8Iq AXX+mOTMAC7G/pZAZkJXHq/yt/dI89ZI2xpi9ttxbDmPg+mHnHcMa1lIgw4KOHqnFM wZUJN93DM99ZpsqjlDoS8IAfHULAvrZmKoj51l5k= 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.14 015/496] xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent Date: Mon, 28 May 2018 11:56:40 +0200 Message-Id: <20180528100320.211722874@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@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.14-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 @@ -365,7 +365,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);