Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp775518rdb; Tue, 19 Sep 2023 09:44:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEr8sNny0jfFidGXa0wEbztcjBGJGIY2nnOo9FjoIl49RIkpxgL+GARNxsXXohh/QabU0xf X-Received: by 2002:a17:902:7202:b0:1bc:10cf:50d8 with SMTP id ba2-20020a170902720200b001bc10cf50d8mr11073997plb.23.1695141887029; Tue, 19 Sep 2023 09:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695141887; cv=none; d=google.com; s=arc-20160816; b=ufFL0HotE0yFscmFT73DN6rQf5kCH+0E51iN/TwO50r1ytxR0JDwtch+gw/H8pP+8T 1PKmlntwEWdH2Mac72mtwO4NxcRSBsGA5/TS1CyNWG4BolRjPxo6b+rUidyg0cxthyvE BjLIXdxdDFjKaeky84oOthw7S0lNt9caeYUmIm016Pp2oX8FLGMMeFSFFfWr5CxQ3JKt 5nsIiL134QDFbjhgtFbAcLpBzKFQM3O/IsV4EkvPYnmoEIp4F07EGtAMm/ET8wQPo6Vr CBLOk7QLK9O5Nn6EUL4gaqEJgauqHrGG2A41ofaITGrjX3fMdVL0221syLYYropwmMBw asSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=K2A2PAUnE9j4r0bvfMULyyO54Q1ghBSOYLvBI7DnlD0=; fh=Cqu/PMj1TTRIVJ18R4kG7BJYmXvWJoZpEKy7SgeLeeM=; b=dsFkJ5un8GnSGu5qnuKVoOP8Az7Dj+cbFDe/dXXPVi6w0VTQTnsXx3mg2uwL+Hjc2u 0Frgi2BRn7xSjtD1X2GVseWhHu54BCXj2ncJLzDaUDOJNoLUf+PAM0amJtiHKDXhBrEw xpShjFcC9On/OW/DjAfjAze56/AM+0hxA7xBUdVonWi8mOyGCf8hpCeqflJMieTW3hC1 c+bcao+yRwKwNpkE+LRBOb7XA43QSZUEHqb+PrFB75LF+a10VzYoDrn2K0I9we3roCny hKp1L4wNnNnNLyoGrQftbTgCg7POgnLSeGwx62VQRmGnXfOb1Kj4N8RT2EbGMtNKRnco ZgNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yxqFG7Z+; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id jx11-20020a170903138b00b001bd9d2e20absi9795596plb.230.2023.09.19.09.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 09:44:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yxqFG7Z+; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D250880765FB; Tue, 19 Sep 2023 04:35:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbjISLfC (ORCPT + 99 others); Tue, 19 Sep 2023 07:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjISLfA (ORCPT ); Tue, 19 Sep 2023 07:35:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F9CE3 for ; Tue, 19 Sep 2023 04:34:55 -0700 (PDT) From: Shivamurthy Shastri DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695123293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=K2A2PAUnE9j4r0bvfMULyyO54Q1ghBSOYLvBI7DnlD0=; b=yxqFG7Z+B++kL3d0+j8S6CBXJsy0Fl3Z3Qp3xVy1gcpHYB2A9czAOt8CMO4AlCCdAKrh2l JzXNWQqNYpHNmxHIrVgTzwwJmQY9rFJjRiuR8ZNX1KllzIealcP4re8xyD6va9bZuMy/Zx WGK8/pZH9fFWN7m9CAB0zMuNiPwlFG32FxRNQ7QFJe4uqcAKXCQO2rJ1Hq7WW1bPqWfdoy l2keHyrd0XwozNNW2LkunnQMeTX1Pkv/zQquGb6VhitkKv40R1plVr/Aut50IoJWVTGb9D vZy5SeRQXlY6FRTsarTT+v0c0MGjbe1GgmA2GklAMEWB2FBCTYN4rsP06HOwNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695123293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=K2A2PAUnE9j4r0bvfMULyyO54Q1ghBSOYLvBI7DnlD0=; b=daifXY8/6UqNcZCv3usko3EDxMPUhJXqWDt7X5SoZ0tZU3zfH3rMkCCRLzX2svl0QMJF/f D+uEPfkmWr0szRDQ== To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org Cc: linus.walleij@linaro.org, b.spranger@linutronix.de, shivamurthy.shastri@linutronix.de, linux-kernel@vger.kernel.org Subject: [PATCH] mtd: map_ram: prevent use of point and unpoint when NO_XIP is set Date: Tue, 19 Sep 2023 13:33:20 +0200 Message-Id: <20230919113320.16953-1-shivamurthy.shastri@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 04:35:14 -0700 (PDT) When the DT property no-unaligned-direct-access is set, map->phys is set to NO_XIP. With this property set, the flash should not be exposed directly to MTD users, since it cannot be mapped. map_ram() exposes the flash direct access unconditionally which leads to access errors (when the bus width does not match the RAM width). Therefore do not set point and unpoint when NO_XIP is set. Signed-off-by: Shivamurthy Shastri Reviewed-by: Benedikt Spranger --- drivers/mtd/chips/map_ram.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index e8dd6496927e..f9d3e32ef8e9 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c @@ -70,12 +70,16 @@ static struct mtd_info *map_ram_probe(struct map_info *map) mtd->_read = mapram_read; mtd->_write = mapram_write; mtd->_panic_write = mapram_write; - mtd->_point = mapram_point; mtd->_sync = mapram_nop; - mtd->_unpoint = mapram_unpoint; mtd->flags = MTD_CAP_RAM; mtd->writesize = 1; + /* Disable direct access when NO_XIP is set */ + if (map->phys != NO_XIP) { + mtd->_point = mapram_point; + mtd->_unpoint = mapram_unpoint; + } + mtd->erasesize = PAGE_SIZE; while(mtd->size & (mtd->erasesize - 1)) mtd->erasesize >>= 1; -- 2.34.1