Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1108865ybl; Sun, 1 Dec 2019 20:44:39 -0800 (PST) X-Google-Smtp-Source: APXvYqz0uxWyHd+PvqJhJ3vcgvJNcOrxhT/jNVI7saKfVupsW0aKPLnIG0dZ+FDHfF2oDFenPMqw X-Received: by 2002:a05:6402:150e:: with SMTP id f14mr24576070edw.55.1575261879702; Sun, 01 Dec 2019 20:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575261879; cv=none; d=google.com; s=arc-20160816; b=SHa1a13BJb8jTSHmlGCQUF5bLSpjPCOP6q2Oy7WgQKK7XS5+fvCx6ENLjvLRLOKStv yTq7kyWMVK7Q2oK64dTurry4qQZm6PKvBOcj8pVtAwuU9HfIEgnZRuDphrmxOctjHU2k NXJrjPyy1QwSkT/5zMmBtX61l8tYQbaD6IPD0jr79gWlHfLya5/5gJcrkZSkO6xWXTL1 bD2sqlhYD+ydZI/41UJkJ6cIohYA0yIpnkTIFV94A3yRhM6xuii5L0qB/7URQqzpow1E PzYfvr7TrLUPgNtYZToEkGPSS4B+DecYyMMd6PxFu+a4Fp3K+3JZcV8ub9dYK+4VvHEf Q8jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=IKA+jd7OY4n+Q/wgyh1srRVYoaAqL85S33bS34sBvP4=; b=sEs7qo4CDbUxpzS2Eytwwd+x62i80H2W3Tu5WBsiWoPW3YGBhtRN969xPcee4qenmw 01IN+GHOZAMPYj/Uq2vEmhThhzyqRNQsE43acNp03t63yT6kF+MfUQSFpF8Rybb6GQX9 G1Sa9e8vEGWt6913ekRBGcXhVc38cE7myUiN4MryTV70PGoLoEIv/a+0WSXRHnSVVsLX Hc0f0Wg7T2HpZnW0H3Cbxwm1mmXxlnPZnKZ1io0PxVHnefQgSprVXQqwoJNojtQtym2O SOHIXwe2kdDMz0lxghIOiyxZFjjDGmgmjRNoQ/iRVYdMC5eywuaQWrwGm7/ClZ6PGQ/o tlsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm1 header.b=Iwzb7B00; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=xycrquaq; 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 sa28si13609576ejb.24.2019.12.01.20.44.16; Sun, 01 Dec 2019 20:44:39 -0800 (PST) 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=@aj.id.au header.s=fm1 header.b=Iwzb7B00; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=xycrquaq; 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 S1727394AbfLBEmG (ORCPT + 99 others); Sun, 1 Dec 2019 23:42:06 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:55597 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727298AbfLBEmG (ORCPT ); Sun, 1 Dec 2019 23:42:06 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id F358822486; Sun, 1 Dec 2019 23:42:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 01 Dec 2019 23:42:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=IKA+jd7OY4n+Q/wgyh1srRVYoa AqL85S33bS34sBvP4=; b=Iwzb7B00DBvxx5xICJBKsN+3qEJlfBN+Zgpig4FU9P hkKMYOJdA8et+ruDutI8Bd3apgwtu1++g8Pt4jjkulMM02wUmGeKALE121z+uZSf xfriG05wVFCd+ibtIzFMk2pSf4fkljG9tmBgunaWd22Hpydvxtavac0Pid6c7Dgk 21vQMqcvGmgqapZzLmyyJa5pFHJ2esknxI1Rgh8/WYgnkA3b85ZspUsSoJ1VGHAs ZpVZa+50IBTy+d7P8c1+mL5tnL/W2GnLxoS7asJDDhLrcFHF35EsYQRxg439noZ+ Xauy9Q7zy1nsF6cTTCtUX+ZgJw1cOhNFwbJwFpJQqv0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=IKA+jd7OY4n+Q/wgy h1srRVYoaAqL85S33bS34sBvP4=; b=xycrquaqo9dcSLsNomUgVK2uQVQeO/2FZ wnnzuT2G02A2ShIyAu1UXYVhHBzv+ssEqCQkJQ+Jn+I0ZGw+Cu2mUQe1CRifyxM/ HdjmZ7BlMOM1mSGXf0JHho7LBA9r2zYXmiM/dz/WtlFJWp9rW1xgL06rTKWeJe+c +c8A0S2kXlZGhT8rrWKCRJ1y9RkXbAZDlCgH4NOTi11qElKhNeGrP4ry+XcB5MTJ V0LG/593yYCypPTvI4Ww3htGaDPun74z9Imes59vA9o1gBFjsGghI6Youu3Qkps5 sh3c6UzUzk6wEAkwgVWpAj4PKlC9H3O6W4hPqjk9VoUbGJgacCG8w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudejgedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehnughrvgifucflvghffhgvrhihuceorghnughrvgifsegrjhdr ihgurdgruheqnecukfhppeduudekrddvuddurdelvddrudefnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrnhgurhgvfiesrghjrdhiugdrrghunecuvehluhhsthgvrhfuihiivgep td X-ME-Proxy: Received: from localhost.localdomain (unknown [118.211.92.13]) by mail.messagingengine.com (Postfix) with ESMTPA id 6970530600BD; Sun, 1 Dec 2019 23:42:01 -0500 (EST) From: Andrew Jeffery To: joel@jms.id.au Cc: linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: aspeed: Fail probe of lpc-ctrl if reserved memory is not aligned Date: Mon, 2 Dec 2019 15:13:47 +1030 Message-Id: <20191202044347.14508-1-andrew@aj.id.au> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alignment is a hardware constraint of the LPC2AHB bridge, and misaligned reserved memory will present as corrupted data. Signed-off-by: Andrew Jeffery --- drivers/soc/aspeed/aspeed-lpc-ctrl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/soc/aspeed/aspeed-lpc-ctrl.c b/drivers/soc/aspeed/aspeed-lpc-ctrl.c index 01ed21e8bfee..fec17948cda0 100644 --- a/drivers/soc/aspeed/aspeed-lpc-ctrl.c +++ b/drivers/soc/aspeed/aspeed-lpc-ctrl.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -241,6 +242,18 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev) lpc_ctrl->mem_size = resource_size(&resm); lpc_ctrl->mem_base = resm.start; + + if (!is_power_of_2(lpc_ctrl->mem_size)) { + dev_err(dev, "Reserved memory size must be a power of 2, got %zu\n", + (size_t)lpc_ctrl->mem_size); + return -EINVAL; + } + + if (!IS_ALIGNED(lpc_ctrl->mem_base, lpc_ctrl->mem_size)) { + dev_err(dev, "Reserved memory must be naturally aligned for size %zu\n", + (size_t)lpc_ctrl->mem_size); + return -EINVAL; + } } lpc_ctrl->regmap = syscon_node_to_regmap( -- 2.20.1