From patchwork Tue Dec 22 07:10:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "majun \(F\)" X-Patchwork-Id: 58822 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3062684lbb; Mon, 21 Dec 2015 23:12:55 -0800 (PST) X-Received: by 10.66.142.201 with SMTP id ry9mr34048336pab.89.1450768375161; Mon, 21 Dec 2015 23:12:55 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id t10si2009512pfa.174.2015.12.21.23.12.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2015 23:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aBH6z-0007xr-DW; Tue, 22 Dec 2015 07:11:57 +0000 Received: from szxga01-in.huawei.com ([58.251.152.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aBH6u-0007jx-Cd for linux-arm-kernel@lists.infradead.org; Tue, 22 Dec 2015 07:11:54 +0000 Received: from 172.24.1.50 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.50]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DBH62042; Tue, 22 Dec 2015 15:10:38 +0800 (CST) Received: from localhost (10.177.235.245) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Tue, 22 Dec 2015 15:10:29 +0800 From: MaJun To: , , , , , , , , , , , , , Subject: [RFC PATCH] irqchip/gic-v3-its:Fix the bug while calculating the page number of ITS table Date: Tue, 22 Dec 2015 15:10:23 +0800 Message-ID: <1450768223-10860-1-git-send-email-majun258@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.235.245] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5678F772.0083, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b1df2b140859aeda971176f128305cb8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151221_231152_968227_E332EFBC X-CRM114-Status: GOOD ( 12.21 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [58.251.152.64 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [58.251.152.64 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Ma Jun Hi Marc, Robert: Maybe there is a bug introduced by commit "irqchip/gicv3-its: Add range check for number of allocated pages" 30f2136346cab91e1ffd9ee6370d76809f20487a I think, before setting the page number, the variable "alloc_pages" should be calculated and checked again. Or else, the page number programmed into GITS_BASER register is always the number of 64KB even though the page size is 16KB or 4KB. Signed-off-by: Ma Jun --- drivers/irqchip/irq-gic-v3-its.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) -- 1.7.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Tested-by: Ma Jun diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index e23d1d1..100181b 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -879,7 +879,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) if (alloc_pages > GITS_BASER_PAGES_MAX) { alloc_pages = GITS_BASER_PAGES_MAX; order = get_order(GITS_BASER_PAGES_MAX * psz); - pr_warn("%s: Device Table too large, reduce its page order to %u (%u pages)\n", + pr_warn("%s: Table too large, reduce its page order to %u (%u pages)\n", node_name, order, alloc_pages); } @@ -911,6 +911,13 @@ retry_baser: break; } + alloc_pages = (alloc_size / psz); + if (alloc_pages > GITS_BASER_PAGES_MAX) { + alloc_pages = GITS_BASER_PAGES_MAX; + pr_warn("%s: Table too large, reduce its page number to %u pages\n", + node_name, alloc_pages); + } + val |= alloc_pages - 1; writeq_relaxed(val, its->base + GITS_BASER + i * 8);