Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2273169imm; Mon, 28 May 2018 05:11:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZolS0khwtrvtxMTM/y3xNKCPKFkBb0hOQ00hmWerelDofaKE3fX3OaDvlQaWo1sNyA6gVXJ X-Received: by 2002:a65:590e:: with SMTP id f14-v6mr10373911pgu.282.1527509460722; Mon, 28 May 2018 05:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527509460; cv=none; d=google.com; s=arc-20160816; b=L1n2iykvMZJdhx+swlAZlHUQV31+eLsfa7lG8pcAkhMuZhgUJx0quvAyCE+IEh+yNs 2nceELBbmkLX3wwOnL2R1HqLZPIVjMn4tsTxz3uzE7mEQKHxEcyCDfl5mGuYFj5mfS8b fY3xNZF+HGXZ6mnvlNPy0H0xf5DpYL0YEgwD4BqapYNkQhnQUr+nUeke07WOeyK6aWFp g/jrolK9NkzSca7B0oTirF8G27SvRGGLpqUmDaZ3DKOHLEa+hBt0EbXMAWhRrySdboRU BxohbNnDR9r1hFaAeMr/FXeNH87S93tvvmEJ7EsZvFzj8zAiXD2YaRzQHF7g/k8usQ64 Np4w== 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=oKkqHZ5BZwjoSM9eqDu/Hg8qszcLbbbyzCU9E8fICuc=; b=K1lYM2LM76GYsRSMWsjdhEFAcM8zJNVX3MIOJPPdGCGTrBQQT2ldLb1m6r/6et/99t D4jYjcvlwUD+lUcz0L24T5JSS59nmghH5gqozdPnEiE58LRgshM6zHE6Slc6sdQ4dj7U o851qhy/9rVvzDo/WcNHPIFZefV9JZhg3Zvhd3kFLvBYkp9wfUfiYYlEtdbCzI6goCiN ruV4zxLJiN8k5mvx1A3haTd9EN4uZZ5X64gOG/osWcGBC2Ulm3npbmlDHp472T6rAxVb XYtsayniIscyp2MQw8+f7k0yvhvBxe7BI77LUAczBGK+dlf9pW9ObDAjOGh/NgJqX18x CggQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eLl6km+N; 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 x6-v6si4295105pll.24.2018.05.28.05.10.46; Mon, 28 May 2018 05:11:00 -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=eLl6km+N; 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 S1423163AbeE1MJK (ORCPT + 99 others); Mon, 28 May 2018 08:09:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:51990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165032AbeE1LEu (ORCPT ); Mon, 28 May 2018 07:04:50 -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 9E3C0208A1; Mon, 28 May 2018 11:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505490; bh=DHtoEm1uv5PpdI39dLwCAX+x6VQCM2o2jIsHwnhVeSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eLl6km+NbmOKPt22dq/oaYgIaCZAmg6LrU1VP/b+ChPW8G4mAcncNQzb7vsaQz2oD dApMBi1J7NrIbtQzcczkOqiO+Qr76B6zlR9TUGyL5NXjb9XqGqaRQZfDR97TT2nlRK IY6ZWkwqR65A92w+Rfayq6GKtrr9koxoD0r/ZISw= 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.16 022/272] xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent Date: Mon, 28 May 2018 12:00:55 +0200 Message-Id: <20180528100242.322563496@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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);