Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1077176rda; Mon, 23 Oct 2023 01:26:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEIA12ybmX0rrStCwhD6pOI5pEAyE89TpqRPubJnxG6FpsOCLkJEddc+rtDU1dZpsCG5IM X-Received: by 2002:a05:6a00:845:b0:68f:dcc1:4bef with SMTP id q5-20020a056a00084500b0068fdcc14befmr10397766pfk.7.1698049580797; Mon, 23 Oct 2023 01:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698049580; cv=none; d=google.com; s=arc-20160816; b=WD1/ZYpiqv7h7iDguEc5ZpUgziJMIHFCh2V3g/Auz3nJHFuPP1S2nwsgbqbuCdgcXN mxu/kqaMpk3mFwvp3AoX/uo9LtjHPfqSBKhSyzCFk634cmfnpz+kUXjeTniA8LiC4suL 8CXbB0B2MhvzdIHqXfvFNgXu37boU8qLIuuHcB2nfxXRQfuY16M2G1RtoMZzBke3V7ji Pr/pnl9HYuNBQ5s+0hGTGV6Sir0134Jmsx6jWz3jXkfFaTn9It6XzUdXTQneAuPsOVRz htBIM2VHnTJ6zKlNwxx9YfMk50/VVUKXz9IhG2lKPGOGsuTQw6uZbdkXlUqFG9a7cTmL bYsA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=zH7kvmH3ojoWMj9A0P1moFfx4wi0a2NDXu5JLkLu5dI=; fh=JSP1GHxRj5t21yLzZaMwQcBwIJ2DL/BdTf4boKw7sac=; b=v03mKg+xIwG3zG83fVaA2mZJz1kJSQEbTTYnBgQyBqSXTgzMXrMw+NjcZPKP9GDk+o Jx5ZwL7proAcFPodP3YJntcLV4pgW+pmGHaoXKU2ZbgrjBG2t4KzuLjCdXdA9ssPT3iZ MTe2aHX4Q0r8eGQ8Nqx9ryvmesBL1nbAJCbmUK3EPFr4izMnw+vIlhEqk7/5o6gBc68f EYU3XEiy90NNwJSRD3EgAl3JOGTdTITu7cVdwBufIYY3dTHNS26W+17VwYZ0NmZkLxzq 0Xy3swkq+0vskqNqbVqG1wc+AE3phymSlMBDH09POIuZs5elUp35Dz4g8o2OFl8RJgxL K/ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ORcCWdoQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w15-20020a056a0014cf00b0069025078128si6330132pfu.240.2023.10.23.01.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 01:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ORcCWdoQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4796D8096BB7; Mon, 23 Oct 2023 01:26:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbjJWIZ7 (ORCPT + 99 others); Mon, 23 Oct 2023 04:25:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbjJWIZ7 (ORCPT ); Mon, 23 Oct 2023 04:25:59 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4535EE; Mon, 23 Oct 2023 01:25:56 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 85424E000B; Mon, 23 Oct 2023 08:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1698049554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zH7kvmH3ojoWMj9A0P1moFfx4wi0a2NDXu5JLkLu5dI=; b=ORcCWdoQOxle8Dj1g3NtvFSN1Kn3zGbnY+5+WIch8s2EmUwNNFyJEX4Yv0BPYN62nhHbxX C1SaoZesOnCZWUXZKcNLu1MAqd11Uji4mpuq4/ghZ3VvpHrKSQ8gDln0rNNQTUa2tkmc/O Bih2B8DULFedvN6KO7KEiASDeTaGc8xFa5J0H6xDRE3RqeqYLIF1CVp6a7sZFhKUooX5Yi 1cJ/ZeiB0edSteaBp3HGQoLU7pDMvm+pTzMZuIQ3VYeRj0g/liY2IaBHEdDCibJ012ghyD aeUuiZyu5O2LKQO2iFea6Dr2t1dKMlpemycAF3nHsOLUO6Gl9T5d42ydVPknnA== Date: Mon, 23 Oct 2023 10:25:52 +0200 From: Miquel Raynal To: Linus Walleij Cc: Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Nicolas Pitre Subject: Re: [PATCH v4] mtd: cfi_cmdset_0001: Byte swap OTP info Message-ID: <20231023102552.4b053b17@xps-13> In-Reply-To: <20231020-mtd-otp-byteswap-v4-1-0d132c06aa9d@linaro.org> References: <20231020-mtd-otp-byteswap-v4-1-0d132c06aa9d@linaro.org> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-0.8 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 01:26:18 -0700 (PDT) Hi Linus, linus.walleij@linaro.org wrote on Fri, 20 Oct 2023 22:30:29 +0200: > Currently the offset into the device when looking for OTP > bits can go outside of the address of the MTD NOR devices, > and if that memory isn't readable, bad things happen > on the IXP4xx (added prints that illustrate the problem before > the crash): >=20 > cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x00000= 100 > ixp4xx_copy_from copy from 0x00000100 to 0xc880dd78 > cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x12000= 000 > ixp4xx_copy_from copy from 0x12000000 to 0xc880dd78 > 8<--- cut here --- > Unable to handle kernel paging request at virtual address db000000 > [db000000] *pgd=3D00000000 > (...) >=20 > This happens in this case because the IXP4xx is big endian and > the 32- and 16-bit fields in the struct cfi_intelext_otpinfo are not > properly byteswapped. Compare to how the code in read_pri_intelext() > byteswaps the fields in struct cfi_pri_intelext. >=20 > Adding a small byte swapping loop for the OTP in read_pri_intelext() > and the crash goes away. >=20 > The problem went unnoticed for many years until I enabled > CONFIG_MTD_OTP on the IXP4xx as well, triggering the bug. >=20 > Cc: stable@vger.kernel.org Would you like to add a Fixes tag as well? Or is this skipped on purpose? > Reviewed-by: Nicolas Pitre > Signed-off-by: Linus Walleij > --- > ChangeLog v3->v4: > - Collected Nico's ACK. > - Stalled since june! Has this been missed? Our current organization relies on Vignesh to pick-up (or tell me to pick-up) cfi patches. But he is slightly less active these days, so if I don't get any feedback from him soon I will take it for the next merge window. Sorry for the delay anyway. Cheers, Miqu=C3=A8l