Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2527162imm; Mon, 28 May 2018 09:46:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJl5Do9WwBOKh8/AT0vmLA/H37U9WRgTP8ZAQVsTawGmfqthkGQxfUOoBpQagAAyFCSbbSM X-Received: by 2002:a65:504d:: with SMTP id k13-v6mr1502570pgo.11.1527526008012; Mon, 28 May 2018 09:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527526007; cv=none; d=google.com; s=arc-20160816; b=iYsga/XRhf52DAVqrSHjpyDTNiYacLj6pUN/PpJjXDbzgGN1NIG/HSTocJ2dsbgdh3 D12AWAi3K2/+8ysRvLnufWPjwEZrZKBwlRFx6iP15CNTYBw4FubebJDOXA25Gv6j5t7T w6l8TDuTympvXZ89jEOGOvQM7b5p/IhBX9yfIiJGgCxuOn4YMqKxgHb1FpuqGv5sn8cs hLKsiAVseKsRGYIdYe0PyI9F8/PoS7a2CK20nOLKjnMwc4B+HNO8ZsL0tPP2oOcsc+38 VtcQROcVNHHcSBR2MJp/iQ/oEbs/7jg6iysWRHsJv5RKOe6u3wndMFRMljusv2CwTXdQ Qa8Q== 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=xRIpVI+jkiEJ1UOvaRRW2IhdA03BeE1qrj9nG9Khijc=; b=SQCpebNoujU88KN7jwhd/ICFHt6H1k7DncaWJ1zLLqJlZPS5erYMD5OAjMSw9QrJUK I5Jxjg/OdKCOVSyilIss3Ew0RbUThdc99rnwINrwf9TQTqCvvYw6vOGXLUgX/qbzg2qv IihaUkk13tWrrs5+aR+jBzVh8ajHfG4KWQNfLje3NewiT02B495XDLTrVMpNE4n8xEaS 5PnhBFtmMrJiEUZZLD4fPjW0BCaLdU54gHgX5hl5G3VSh4RD1qYcLqAZ8ltZHM2dzVlb ++FDuCqguCiIcpWu9VQfuW9phCSOS7L4yiC68rC0wmZfnDtWBqDoQliVKwZ9u2kjiI1e vtrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uCrF3nWK; 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 3-v6si29914541plx.591.2018.05.28.09.46.33; Mon, 28 May 2018 09:46:47 -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=uCrF3nWK; 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 S1425448AbeE1QpJ (ORCPT + 99 others); Mon, 28 May 2018 12:45:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:55374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932195AbeE1KHU (ORCPT ); Mon, 28 May 2018 06:07:20 -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 44CDD20843; Mon, 28 May 2018 10:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502039; bh=t+qzIXJZ6zxhCh8D3tJJBg5cxIDlu0Cx1qC/yMnIj0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uCrF3nWKwgbbDXQKuSzJS7I8KiEaa4yWPuJnCOtgl3Cw++XeF/mpJiOzxC+967M8C 5TQ1SPP63C0h7kXObk/zA3TexUEosCEGfLaokUTdkQp5YVZWX7JK9Vx1s7yMk7NFeD iloD11WsI3OllZVG14o3zUIEimBuFICiynqcWxpQ= 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 3.18 008/185] xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent Date: Mon, 28 May 2018 12:00:49 +0200 Message-Id: <20180528100051.198174783@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -366,7 +366,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);