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: 9977125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2966060365 for ; Fri, 29 Sep 2017 06:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A740297CB for ; Fri, 29 Sep 2017 06:02:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DE70297CD; Fri, 29 Sep 2017 06:02:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 807D5297CB for ; Fri, 29 Sep 2017 06:02:32 +0000 (UTC) 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" X-Virus-Scanned: ClamAV using ClamSMTP 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;