[net-next,v2] firmware_loader: Expand Firmware upload error codes with firmware invalid error
Message ID | 20231121-feature_firmware_error_code-v2-1-f879a7734a4e@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp533723vqb; Tue, 21 Nov 2023 02:52:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsPWjgk9IGT2BVxg5l8fvadK+97DkLcjT0wb4VJ4LTFQ+H1PCHOfZrD1qvMKg0B5m6PRlF X-Received: by 2002:a05:6a21:3806:b0:187:6de5:4c5b with SMTP id yi6-20020a056a21380600b001876de54c5bmr9990090pzb.49.1700563963610; Tue, 21 Nov 2023 02:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700563963; cv=none; d=google.com; s=arc-20160816; b=oUAq3o1NgDoHlsyv8j5LUNg3nU5IoDkgSig9tEPgaitQzmJyCP1nhtxMOrSjplQUJT xITEFZnXwCrBH30c2pJRH2Nc/HXr5tZY86tM7az7+bzVCHZAn3cVzOxw3qFR9qbao2st i7rzglAnNzNsnaXgPUTUjHcSsUA3ixEQo3sn7VYAZx8u34vgyTXM1QCGYkpPathcF+P0 uRgPQrrIbDAjn/f3zRa7g4gYKQMdHEg7QlBoqJBBPzhMJd7swWFoGqZJykx+OStA8Doz B65wKbdAB9LZKamY5kBMZoaLBJnprLX0Gg4sI8j1pvo2EZNMq2lpR5oeGNzSHUCO8MYl i1HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=A3NccixUkZgOsEUs7FqXe1NE2YZDf8SEnuhprc2W6ZM=; fh=D18ShTGxbz5Dm/mA+EeVLSr7wERt/sJxtCWEr/2FKIE=; b=SjLRZE/pQOHBop06YUY7YoZ3kS6sn+xfZdVUquzGWKLcuo+U+neDdRxOOLTwJPBkPa dAQkxaQjIqc/RvJpOd46g2i0a6B0PjdlG5FkI0O6a5wKVAu5mrcsRYphhl8/AahFicvU GeY0Cj+fs1lpMHG6z80nRCMvic40GOYf//D+Ea96ZxR9mDJPREbJsgDmBX3/hBjTUKYa TqSzDFHSGaBF0oQN0VyAM6yPPF4BPjLoIeBVBNsrZZh7ITWKglowwU9XnxnT+jrtizJB G88p1bUAMs+ZsGKe324BKM98dXeUVyfLyQu+z47kfgbpznFjaG9FvqsV+kc+FY8WNl8U goWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dQAx+xrH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i18-20020a17090332d200b001bf5c12ea06si11036423plr.404.2023.11.21.02.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dQAx+xrH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id E50898077987; Tue, 21 Nov 2023 02:51:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232300AbjKUKvP (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Tue, 21 Nov 2023 05:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjKUKvO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Nov 2023 05:51:14 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB54595; Tue, 21 Nov 2023 02:51:09 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9428F6000B; Tue, 21 Nov 2023 10:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700563868; 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; bh=A3NccixUkZgOsEUs7FqXe1NE2YZDf8SEnuhprc2W6ZM=; b=dQAx+xrHxBTgX9Xp5PcYtc6mX8O/vZ53FjFsyyoWnUkrNQVkhie5NI3uPthA3/OjRQ1pKi 2e6QBIJuNcolSKLbo1o/NHj2+aa7LaUouBgjlbd0ubtwn4cw6mQA5Dog7xJe34V6liJRKw 6rI4yv/hJREMP68lbsU+jXQ3OTHC/diWb6OPMmcfVF48Jk/0Ernu8CBl4ujUbcylJzLKHn ljilaBb1ts9OkKj+F7uhN7i2kUQYSK3YJz8TyxkOG0LBnT2vfL/jkSwV8TS9EIyzq1thC6 HdDVqRLbKqnhHbts1Esqvmv3+GSaZhWYRLB3monugxHyXzAny5pmuno9dQWBeA== From: Kory Maincent <kory.maincent@bootlin.com> Date: Tue, 21 Nov 2023 11:50:35 +0100 Subject: [PATCH net-next v2] firmware_loader: Expand Firmware upload error codes with firmware invalid error MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231121-feature_firmware_error_code-v2-1-f879a7734a4e@bootlin.com> X-B4-Tracking: v=1; b=H4sIAHqLXGUC/42NQQrCMBBFr1JmbaRJlaSuvIeUkqYTO6CJTGKtl N7d0BO4+48H76+QkAkTXKoVGGdKFEMBdajATTbcUdBYGFStGimlFh5tfjP2nvj5sWUgc+TexRH FYEZtfW2s8Qil8GL0tOz1GwTMIuCSoStmopQjf/fbWe7+r4dZCila5Vrd2HNtTvo6xJgfFI4uP qHbtu0Hl7pOJtIAAAA= To: Jakub Kicinski <kuba@kernel.org>, Luis Chamberlain <mcgrof@kernel.org>, Russ Weight <russ.weight@linux.dev>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>, linux-kernel@vger.kernel.org, Conor Dooley <conor@kernel.org>, Andrew Lunn <andrew@lunn.ch>, netdev@vger.kernel.org, Kory Maincent <kory.maincent@bootlin.com> X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:51:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783170558764599441 X-GMAIL-MSGID: 1783170558764599441 |
Series |
[net-next,v2] firmware_loader: Expand Firmware upload error codes with firmware invalid error
|
|
Commit Message
Köry Maincent
Nov. 21, 2023, 10:50 a.m. UTC
No error code are available to signal an invalid firmware content. Drivers that can check the firmware content validity can not return this specific failure to the user-space Expand the firmware error code with an additional code: - "firmware invalid" code which can be used when the provided firmware is invalid Acked-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> --- This patch was initially submitted as part of a net patch series. Conor expressed interest in using it in a different subsystem. https://lore.kernel.org/netdev/20231116-feature_poe-v1-7-be48044bf249@bootlin.com/ Consequently, I extracted it from the series and submitted it separately. I first tried to send it to driver-core but it seems also not the best choice: https://lore.kernel.org/lkml/2023111720-slicer-exes-7d9f@gregkh/ Jakub could you create a stable branch for this patch and share the branch information? This way other Maintainers can then pull the patch. --- drivers/base/firmware_loader/sysfs_upload.c | 1 + include/linux/firmware.h | 2 ++ 2 files changed, 3 insertions(+) --- base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 change-id: 20231117-feature_firmware_error_code-b8d7af08a8fe Best regards,
Comments
On Tue, 21 Nov 2023 11:50:35 +0100 Kory Maincent wrote: > No error code are available to signal an invalid firmware content. > Drivers that can check the firmware content validity can not return this > specific failure to the user-space > > Expand the firmware error code with an additional code: > - "firmware invalid" code which can be used when the provided firmware > is invalid Any idea what this is? lib/test_firmware.o: warning: objtool: test_fw_upload_prepare() falls through to next function __cfi_test_fw_upload_cancel() My build shows this on an incremental clang 17 build.
Hello Jakub, On Tue, 21 Nov 2023 17:30:22 -0800 Jakub Kicinski <kuba@kernel.org> wrote: > On Tue, 21 Nov 2023 11:50:35 +0100 Kory Maincent wrote: > > No error code are available to signal an invalid firmware content. > > Drivers that can check the firmware content validity can not return this > > specific failure to the user-space > > > > Expand the firmware error code with an additional code: > > - "firmware invalid" code which can be used when the provided firmware > > is invalid > > Any idea what this is? > > lib/test_firmware.o: warning: objtool: test_fw_upload_prepare() falls through > to next function __cfi_test_fw_upload_cancel() > > My build shows this on an incremental clang 17 build. Thanks for the report. It seems I have to update fw_upload_err_str accordingly. Didn't know about this test_firmware.c file. Regards,
On Tue, 21 Nov 2023 17:30:22 -0800 Jakub Kicinski <kuba@kernel.org> wrote: > On Tue, 21 Nov 2023 11:50:35 +0100 Kory Maincent wrote: > > No error code are available to signal an invalid firmware content. > > Drivers that can check the firmware content validity can not return this > > specific failure to the user-space > > > > Expand the firmware error code with an additional code: > > - "firmware invalid" code which can be used when the provided firmware > > is invalid > > Any idea what this is? > > lib/test_firmware.o: warning: objtool: test_fw_upload_prepare() falls through > to next function __cfi_test_fw_upload_cancel() > > My build shows this on an incremental clang 17 build. For my curiosity, how do you get this error? Enabling test_firmware and building with W=1 does not show the error. Regards,
On Wed, Nov 22, 2023 at 11:43:25AM +0100, Köry Maincent wrote: > On Tue, 21 Nov 2023 17:30:22 -0800 > Jakub Kicinski <kuba@kernel.org> wrote: > > > On Tue, 21 Nov 2023 11:50:35 +0100 Kory Maincent wrote: > > > No error code are available to signal an invalid firmware content. > > > Drivers that can check the firmware content validity can not return this > > > specific failure to the user-space > > > > > > Expand the firmware error code with an additional code: > > > - "firmware invalid" code which can be used when the provided firmware > > > is invalid > > > > Any idea what this is? > > > > lib/test_firmware.o: warning: objtool: test_fw_upload_prepare() falls through > > to next function __cfi_test_fw_upload_cancel() > > > > My build shows this on an incremental clang 17 build. > > For my curiosity, how do you get this error? > > Enabling test_firmware and building with W=1 does not show the error. Hi Kory, I am able to observe this warning when compiling with clang-16 make LLVM=1 lib/test_firmware.o ...
diff --git a/drivers/base/firmware_loader/sysfs_upload.c b/drivers/base/firmware_loader/sysfs_upload.c index a0af8f5f13d8..829270067d16 100644 --- a/drivers/base/firmware_loader/sysfs_upload.c +++ b/drivers/base/firmware_loader/sysfs_upload.c @@ -27,6 +27,7 @@ static const char * const fw_upload_err_str[] = { [FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size", [FW_UPLOAD_ERR_RW_ERROR] = "read-write-error", [FW_UPLOAD_ERR_WEAROUT] = "flash-wearout", + [FW_UPLOAD_ERR_FW_INVALID] = "firmware-invalid", }; static const char *fw_upload_progress(struct device *dev, diff --git a/include/linux/firmware.h b/include/linux/firmware.h index de7fea3bca51..0311858b46ce 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h @@ -27,6 +27,7 @@ struct firmware { * @FW_UPLOAD_ERR_INVALID_SIZE: invalid firmware image size * @FW_UPLOAD_ERR_RW_ERROR: read or write to HW failed, see kernel log * @FW_UPLOAD_ERR_WEAROUT: FLASH device is approaching wear-out, wait & retry + * @FW_UPLOAD_ERR_FW_INVALID: invalid firmware file * @FW_UPLOAD_ERR_MAX: Maximum error code marker */ enum fw_upload_err { @@ -38,6 +39,7 @@ enum fw_upload_err { FW_UPLOAD_ERR_INVALID_SIZE, FW_UPLOAD_ERR_RW_ERROR, FW_UPLOAD_ERR_WEAROUT, + FW_UPLOAD_ERR_FW_INVALID, FW_UPLOAD_ERR_MAX };