From patchwork Fri Sep 29 05:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 114490 Delivered-To: patch@linaro.org Received: by 10.140.104.133 with SMTP id a5csp417439qgf; Thu, 28 Sep 2017 23:02:15 -0700 (PDT) X-Received: by 10.107.10.77 with SMTP id u74mr11334535ioi.243.1506664935072; Thu, 28 Sep 2017 23:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506664935; cv=none; d=google.com; s=arc-20160816; b=aY+0cyChSRb4VgnrFSfkU6ZNxi0MkUWr3HlXwALIVAlX1NjZfSu389sYJpiosoDXLe obzvsKfcEI31HwbD22xwUThUkx5Xe0Rygm7My556nzZ624PU1cHdl/jM008j9xfHbTm1 tfcv6VgBnnJfnq9beKNq6p4i2lJeoGBNNobnWrgcopwOGPvEtyeZZpIjgzEJZeUX10ZS r1WwQJMjo16I7tTbQXWSJPG7yEvc8BPKDPb7vSbXIBoVdKTi0qy16i62kk2nsGjPK/F5 1Rff/YJYQh0BubRuqA7CyO7xhAhVjvqj7a3vkfFwdXFVyh536NwgBbac8YCFv51hvW4e lBXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=UqCZdYputOxjb4PG23fR8unF/NDp0CzDY6ebkCmps/0=; b=sdSGBX3PiY/OA3AQp2lI68RArq9VEhGSvdJ4pg1TM/x3RypfGVmvXzi5EEALxtlTsj AJWo0m4o3u2KLzt1OMY8UMy+er2z6H8GMLYCEgkeHg2fCXuGbng8CfTCFrDrM5XAvjCM w9hg9Js1EGKEoH8Km4SqhNswJ/34cWk96YpkBbLkf/VgqBhfKX9Ov8+4AckpLFhIwdDx w+xJW7oGeV441H5Jl6dq3fs+gkh1BaxnbSCAkt3k6hHYpuKXMSkNeUSbQVUmt2lc90pS M8s8brk8bUEHc7AQDk5JRRznDgFfaUZmAOEy47oIwhSEI8Xk95k+BvIfmnF9Wn/MW2mc S3Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hi4qMQu7; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 3si2408521ity.188.2017.09.28.23.02.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 23:02:15 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hi4qMQu7; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxoL8-0002Gm-BA; Fri, 29 Sep 2017 05:59:58 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxoL7-0002Gg-Ct for xen-devel@lists.xenproject.org; Fri, 29 Sep 2017 05:59:57 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 43/94-17770-C51EDC95; Fri, 29 Sep 2017 05:59:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsVyMfTABt2Yh2c jDQ79ZLf4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNO3PAuOMVVMf3sH/YGxhscXYxcHEIC0xkl HnxZxwrisAi0M0t8+vSIDcSREHjHIvG8cQ5LFyMnkJMncffqRqAEB5CdJvFiPTNEuFpi1Z8T7 CC2kICWxNFTs1khpi5nkviy5TQjSD2bgInErA4JkBoRASWJe6smM4HYzAKhElP/PgAbLywQId H56CwbiM0ioCrx+GYrK4jNK+AlsezIFyaIXXISN891Mk9g5F/AyLCKUb04tagstUjXVC+pKDM 9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzB4GIBgB+P0y/6HGCU5mJREedlun40U4kvK T6nMSCzOiC8qzUktPsQow8GhJMHb/AAoJ1iUmp5akZaZAwxjmLQEB4+SCO9ikDRvcUFibnFmO kTqFKM9x4U7l/4wcXzpvQEkD+y5BSQ7bt79wyTEkpeflyolzusJ0iYA0pZRmgc3FBZ3lxhlpY R5GYHOFOIpSC3KzSxBlX/FKM7BqCTMmwQyhSczrwRu9yugs5iAzpo88QzIWSWJCCmpBsZN0gn HLTesvr2PJ5PV8t/33cKXA63rrC9aLZmszBR393jY5pdr2C8+6ip4/NZ27Zfmb1am792eZ/Pt TN53LSDgZu3zkvUXpJY8OtTo/fXp2x+hyvsSDrDNKPlwWSuaRW/JzMccKhuv/WY7NeOw/F3Z+ OxWo9Zrx8vM19sZXK0+febiyUP7tvtZK7EUZyQaajEXFScCACdOZXa2AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-21.messagelabs.com!1506664794!81713203!1 X-Originating-IP: [209.85.192.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53506 invoked from network); 29 Sep 2017 05:59:55 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-3.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Sep 2017 05:59:55 -0000 Received: by mail-pf0-f176.google.com with SMTP id n24so223772pfk.5 for ; Thu, 28 Sep 2017 22:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=tdVkyryuITrlxLQAnyrYSUuGJERaiuvW1X3MB4ckcBc=; b=Hi4qMQu7Bu9XahxuflDODDpS3kIuWDSorYPs1IUsZExyCEb6ACfGyoEyhxrjYHT6Mz Yc3hDHxqPnxrCKjy2c6brTZGKj92ye9sSrRlX8u8w7RBRZUXgv+nyrtOm9dUcnAWka0D S4CeMjfU7mFzBNEWk3UnZ/uI3+xzh2AG54aAY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tdVkyryuITrlxLQAnyrYSUuGJERaiuvW1X3MB4ckcBc=; b=aa/psFRgczIsUEBTXrtqlJHb0ZvjZauHeYpC9zfBd5MjsxkbnYmcKKMAeJecfpbPfQ IiJgVO5wWtFQpUz5eaFejscbuSe2e5f/X3j6LWFWVrNIdCtGYJK+i0bcs9wUuPMnFuZU r+yUVO0naVxIGR4pEZNEd1/Io6A44Mc5kcP6+cFbWHNZ6C1vXhJfptDzOLXxD0C01Pfy Z6skVXus6Q0eJyp46nArT95oDktoAPkJYT+4KgN6UEbfkjzt2IFtWvdB+aIXlJRASZFQ PEYcZoZyGipxl63SHQp1CMeue3u/LZTPOIcN6dqZtd3fbYR5o4I4RgA5B8r/zKt8niXC fmBQ== X-Gm-Message-State: AMCzsaUjBr/8NzhRKZqFzpny9paSLtNt6akWHe6CrhKU8QqfPIvT6VBL uw1BdVIbUosxm/eXFMrbv1pUoZ/Zi6s= X-Google-Smtp-Source: AOwi7QBvxptbIibLyP0htN10SNI8xWQ1jr0bFF/VCnHOH2iOCUY2bi2bu4NK94tYoPZ5wS3D2ndoBQ== X-Received: by 10.159.247.139 with SMTP id e11mr1021994pls.340.1506664794114; Thu, 28 Sep 2017 22:59:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id f13sm6075830pfj.127.2017.09.28.22.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Sep 2017 22:59:53 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 29 Sep 2017 11:29:46 +0530 Message-Id: <1506664786-8343-1-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v3] xen/arm: Fix the issue in cmp_mmio_handler used in find_mmio_handler X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch fixes the wrong range check done in cmp_mmio_handler(). This function returns -1 , 0 or 1 based on whether the key value is below the range, in the range or above the range where the range is (start, start+size). However, it should check against (start, start+size-1) because start+size falls outside the range. This resulted in returning a wrong mmio_handler for a given mmio address which happened to be start+size. This bug was introduced when the mmio region search switched from linear search to binary search in the following commit: 8047e09 "xen/arm: io: Use binary search for mmio handler lookup". Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini --- CC: Stefano Stabellini CC: Julien Grall This patch may have to be back ported to 4.8 also. xen/arch/arm/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index e216128..c748d8f 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -79,7 +79,7 @@ static int cmp_mmio_handler(const void *key, const void *elem) if ( handler0->addr < handler1->addr ) return -1; - if ( handler0->addr > (handler1->addr + handler1->size) ) + if ( handler0->addr >= (handler1->addr + handler1->size) ) return 1; return 0;