Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp414242rdb; Fri, 17 Nov 2023 02:28:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbOjqz80YNHUxrfxXR21tDTktfm3WV/CV5zZTiFFfVg1MSZVE67zpVtCtFjMd36iB/aUTT X-Received: by 2002:a17:902:e84b:b0:1cc:787f:fd2 with SMTP id t11-20020a170902e84b00b001cc787f0fd2mr12724758plg.49.1700216922658; Fri, 17 Nov 2023 02:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700216922; cv=none; d=google.com; s=arc-20160816; b=VM55hWsGsR5w9j3ORJBfJS2tDy1L20KJi0EIBZ++BPglNC+vpJErmd8YsEy3bsi7YL Ie8dGoV81TkYeX+wBy4nFY6oQsTDWeY0+vK3F/N/VXYJalBhwZ+pvf+snInAu+7a+d+u WpjTMS8/Veryfmem+JDUidR49QzGUeEP6zu8s2LQRAo+1AEl9hiNynIuoPZvE+FSSEL4 moSmxdwRJz7nKZqJg88UA+k1IdItzDdnze7YVySvrO3tpGYh8vDkCJ8nPfzJ33pAZDMb q2mYO3vGKZIqXy6h+NqH8ToEOSYs+yya90pYLI6g7751cs5AVROZxCK6vIoBrnTPvlkd b71w== 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=hssYZxQ7oYF62vZivWNVQkuQ1Tob1SL3kJykunvJ4/0=; fh=Avs0nA1edBJBlzsDKSjKkRZ9u0UC21Sdr9dOq4MNZwQ=; b=VEdTExbWJCCXnEgfk+Vu6nsqf5fDgK0OFgeMODOHnhQ1nk0oWBDVdT1LyTcT7ZwAfZ b9sO4z4CMjXlyyj2goavyubFZRIteRF0fG2R8BXtOGabqda8v3bZeVR4D+/P6HBmUStn eXXB3bK3ei1K0ipyEVK772OmTKxLCoFKuQmebGSGkZO3CmDHiOhqVGxyxX3z93ZOY/31 HjIS6gjVEcQTQX4rFVSXUjBZG43/0dJrhKMgR4+HgqNIRVy45DxTxdVNhdx7WHcBf5cc yFvKNg2SmovWvALpX8Jd8g13vvCDIbyaVxRAo/P1oXRmSIuYurUmhySxOMsc7tKAF60Q Grig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OojY2ahI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id jg19-20020a17090326d300b001cc385b457asi1417873plb.284.2023.11.17.02.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:28:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OojY2ahI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 9DDD881E5E4C; Fri, 17 Nov 2023 02:28:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345756AbjKQK23 (ORCPT + 99 others); Fri, 17 Nov 2023 05:28:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235027AbjKQK20 (ORCPT ); Fri, 17 Nov 2023 05:28:26 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA65FD49 for ; Fri, 17 Nov 2023 02:28:20 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id CAE89240002; Fri, 17 Nov 2023 10:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700216899; 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=hssYZxQ7oYF62vZivWNVQkuQ1Tob1SL3kJykunvJ4/0=; b=OojY2ahINfBpf0qydeGz+bModeIomJL0J4gdEXqwOR1DsOnBHPiIYI0KVvFUejAunfsP80 zJXmFqNOKAZG2Bei5aTGSIChuBwW3qQKRj/REPrcRrdB3mZHqM8OPTJeNBSoA6QS6AnPBr zOctfr0ClJRANXoKsGTHeez5FNXau/+7W0nXD83Eyv6tC6bOw9vk3sLLin1eVFM2LKBfkP MvWCTSf1Oxe4vNoOSDlf8Oxb7qj+SUNIN2SO/FdzkdzpnzZA0vlyYRDfkK6a+2P8YVuKLv T6bdW4t1azyXiEaNtwpwLnTa4Eg6fvO1sUWtL4phXmhZ/VFu0vRfuyizAyRjqw== From: Kory Maincent Date: Fri, 17 Nov 2023 11:27:53 +0100 Subject: [PATCH] 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: <20231117-feature_firmware_error_code-v1-1-92c973a50847@bootlin.com> X-B4-Tracking: v=1; b=H4sIAChAV2UC/x3MQQqDMBBG4avIrBswdmHwKkVkNP+0s9CUidWCe HeDu/dt3kEZpsjUVQcZNs2algL/qGj68PKG01hMTd08vfetE/D6MwyiNu9cAmbJhilFuDHElqU OHARUDl+D6P++v/rzvAA6CmJwbQAAAA== To: Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, Conor Dooley , Andrew Lunn , Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 02:28:39 -0800 (PST) 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 Acked-by: Greg Kroah-Hartman Signed-off-by: Kory Maincent --- This patch was initially submitted as part of a net patch series. Conor expressed interest in using it in a different subsystem. Consequently, I extracted it from the series and submitted it separately to the main tree, driver-core. https://lore.kernel.org/netdev/20231116-feature_poe-v1-7-be48044bf249@bootlin.com/ --- drivers/base/firmware_loader/sysfs_upload.c | 1 + include/linux/firmware.h | 2 ++ 2 files changed, 3 insertions(+) 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 }; --- base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 change-id: 20231117-feature_firmware_error_code-b8d7af08a8fe Best regards, -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com