Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp546701rwl; Fri, 4 Nov 2022 03:38:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SIdF4xE3ZCS6jHXBqDub6El+GJ2aYr9hgfag6H1HgQJgYUmNFsukXUWTxpa2NYoqSHnEN X-Received: by 2002:aa7:9687:0:b0:56d:a2e0:ea1e with SMTP id f7-20020aa79687000000b0056da2e0ea1emr22068340pfk.33.1667558328076; Fri, 04 Nov 2022 03:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667558328; cv=none; d=google.com; s=arc-20160816; b=meSybeGpwU4NNST5mB/+1jKKG6jgay30yzxNuNcCYGiV+z1oSX9PUCprV8R2Qa2r5t g3U96l5YkMTvHczyjsO9PgHulU4cKrV8nDmTGAdanpvqd7hm6IE0iDVkBBpn/ILHbHXS iy6SUnHoUXJ/YnfLc/ILlBDuQC6loCPs82zv3saAhOfolu/N0tb9gAGBjCmhY6pKhaX4 WXxIn8EHSby814eCuTmVK+w5Lbn/StAlgInpT7nAqjlM4rjkblfyzbTlP1cSgtcYUQ5e WRRW8cWIFu+A0Q6T3lfLg2i00tXmTf9XEYvCiNpCg6QG5eSCdPWpcICuv/UuntXNaIyn Nfew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=I8rFlnWEMF9CWh/ZiFlmsugyqLY4mfzotIfYqwV8f2Y=; b=YE2wKYJxCYVR1HVAd/lMfO4uFJqmBDnCK64JJZExTYSfjclMUICRPSzrltoOqN28QI YcFZGyF3uKgr/L4GpMprtjg5ARqvDBhmy3iXbBMIrbuyx5604DZPfwJhD4gZPsD1LZ2f PsMR4nj9K5dwXm77UyK1Qh2fLLReZvLlPOFpjMMXp6eVCRB3KMFBql7fbO9sA28TeTf8 A1K1KPk3oK938sTG9VF4dNB2b/fM82mDGORivK2h8dCnz5fxGa1nhsCZdcdxaXpv2+wm 4Nxv8t2jPecyIS4h/IWf9ctIZpl+Wk1Mqbg60vZ9RtfzgvTw1UeoMNhSdoSuoU8LeCMe KsIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb18-20020a17090b35d200b0020900585fa2si3260132pjb.102.2022.11.04.03.38.36; Fri, 04 Nov 2022 03:38:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231747AbiKDKUy (ORCPT + 96 others); Fri, 4 Nov 2022 06:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbiKDKUk (ORCPT ); Fri, 4 Nov 2022 06:20:40 -0400 X-Greylist: delayed 932 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 04 Nov 2022 03:20:35 PDT Received: from 3.mo560.mail-out.ovh.net (3.mo560.mail-out.ovh.net [46.105.58.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2B3625E9B for ; Fri, 4 Nov 2022 03:20:35 -0700 (PDT) Received: from player726.ha.ovh.net (unknown [10.110.115.67]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id 9243D255CB for ; Fri, 4 Nov 2022 10:05:01 +0000 (UTC) Received: from RCM-web3.webmail.mail.ovh.net (ip-194-187-74-233.konfederacka.maverick.com.pl [194.187.74.233]) (Authenticated sender: rafal@milecki.pl) by player726.ha.ovh.net (Postfix) with ESMTPSA id 422C230557BA7; Fri, 4 Nov 2022 10:04:57 +0000 (UTC) MIME-Version: 1.0 Date: Fri, 04 Nov 2022 11:04:57 +0100 From: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= To: Christian Lamparter Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, gregkh@linuxfoundation.org, a.fatoum@pengutronix.de Subject: Re: [PATCH v1] nvmem: address crc32 check on redundant-layout powerpc machines In-Reply-To: <41e7ab94800b4a9aef73e212464bd94117429bec.1667555240.git.chunkeey@gmail.com> References: <41e7ab94800b4a9aef73e212464bd94117429bec.1667555240.git.chunkeey@gmail.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: rafal@milecki.pl X-Originating-IP: 194.187.74.233 X-Webmail-UserID: rafal@milecki.pl Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 16414776219705846715 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvgedrvddugddtlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhepggffhffvvefujghffgfkgihitgfgsehtjehjtddtredvnecuhfhrohhmpeftrghfrghlucfoihhlvggtkhhiuceorhgrfhgrlhesmhhilhgvtghkihdrphhlqeenucggtffrrghtthgvrhhnpefgueelueetteefueehhffhgfetvdegjeefleffuedvhfeuffdvheegueevuefhleenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeduvdejrddtrddtrddupdduleegrddukeejrdejgedrvdeffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehrrghfrghlsehmihhlvggtkhhirdhplheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehiedtpdhmohguvgepshhmthhpohhuth X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-11-04 10:47, Christian Lamparter wrote: > The Western Digital MyBook Live (PowerPC 464/APM82181) > has a set of redundant u-boot-env. Loading up the driver > causes it to error out with: > > | u_boot_env: Invalid calculated CRC32: 0x4f8f2c86 (expected: > 0x98b14514) > | u_boot_env: probe of partition@1e000 failed with error -22 > > Looking up the userspace libubootenv utilities source [0], > it looks like the "mark" or "flag" is not part of the > crc32 sum... which is unfortunate :( > > |static int libuboot_load(struct uboot_ctx *ctx) > |{ > |[...] > | if (ctx->redundant) { > | [...] > | offsetdata = offsetof(struct uboot_env_redund, data); > | [...] > | } > | usable_envsize = ctx->size - offsetdata; > | buf[0] = malloc(bufsize); > |[...] > | for (i = 0; i < copies; i++) { > | data = (uint8_t *)(buf[i] + offsetdata); > | uint32_t crc; > | > | ret = devread(ctx, i, buf[i]); > | [...] > | crc = *(uint32_t *)(buf[i] + offsetcrc); > | dev->crc = crc32(0, (uint8_t *)data, usable_envsize); > | Thanks for the fix, it may be I didn't actually test that code. That change has nothing to do with byte swapping so I' suggest TWO separated patches. > Now, this alone didn't fully fix the kernel's uboot-env nvmem > driver. The driver then ran into an endian error on the > big-endian powerpc device: > > | u_boot_env: Invalid calculated CRC32: 0x1445b198 (expected: > 0x98b14514) > > however the __le32 type for the crc32 value is justified because the > the crc32() is just a macro for crc32_le(). So, to side-step that > problem, the crc32 check gets extended to also accept a byteswapped > crc32. Can you try this pending patch, please? [PATCH v2] nvmem: u-boot-env: align endianness of crc32 values https://lore.kernel.org/lkml/20221012155133.287-1-musashino.open@gmail.com/