Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3059554rdb; Fri, 22 Sep 2023 17:36:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYR6ZP6+nMADJpvpihfWc4OdyI2RAwmQVlyGkQe60C8IkmwqXLCSnx01XE0EnmcnNKY6jB X-Received: by 2002:a05:6358:94a0:b0:143:8e40:917b with SMTP id i32-20020a05635894a000b001438e40917bmr983145rwb.9.1695429400656; Fri, 22 Sep 2023 17:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695429400; cv=none; d=google.com; s=arc-20160816; b=RdDrsrJNhcyiYl5UczJMCAbiRtmFxkz98wa23M3+xvkO7Xoejh8Z9kdu52hwzFN5gc 2MWYMeUjZ0MHwF9bVOldGzISCEh4L4D3zzZtH6JgqAXNFaUe3eJgil7PlVYbJp7R0Xpj 2ikL+tlWmEQGN1jfH5D1qSKljEcnqxXwFpwRLfOVVHv6BDJsYH2c65raJlYOSl/mvqXY oxmT/t0rKUDlC+9VojCVZCUid++Dokm/mtfdjFyhO3RrG3FJmC3DXEGqXiv3ZPuygCay LDAwl0/WFNBMsK8qTu+1Xyx7rhtNFQVlYIvJUTVHtTqxc8c3sB336hInjgSoGXy2Da0q KOcQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R7m9q0G4xiK8+U3DIwqe5P048phK8son/34LZAlhF14=; fh=DZTEBuCdFfe2DSdaI+6ceTR59ce872SNjmboNXW/0pA=; b=ryJ3qhG+XsMLtg7YnLB5etrb6h1oo8TaqBRKCe7lkSs/NYzmGG1aVYAvT72whqRiGp K6taSLv7QJThgiopThIw2kdoL3RldwSgfIGQuSYsaNkw6aDPQgg6xilLwvYOk7Tf/nRT N+uIjMO85aTSjZHCjr1Aoq9H+kpr7J9SwHQbvXxWEvHnCKOesJZlzrUZCB7kloORnioX 2ToOo/WcxBxkueux2b+cSOhe2+Fz0LssmqPthh6zeDmHVma9fsFRfdhRXyixg0tcy9c5 a5H/czrkKJNnhkHA8gDwP7whyDQva40DleCAIo26eucr1bQfGK52UyEp1gnX3ZxEAhpq r1yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Umv6E5zF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a21-20020a63e855000000b00578d7a3a4fdsi4789062pgk.563.2023.09.22.17.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 17:36:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Umv6E5zF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B0686801B9E2; Fri, 22 Sep 2023 16:30:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbjIVXaW (ORCPT + 99 others); Fri, 22 Sep 2023 19:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjIVXaT (ORCPT ); Fri, 22 Sep 2023 19:30:19 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B04B31A2; Fri, 22 Sep 2023 16:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695425413; x=1726961413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eBFr+P8r5vNXCcrUFO02naJBuqwBT/yzn6Gswd0MWNo=; b=Umv6E5zFNmJNpMgQ3n8HElL4e9N735zfmAhn4dXUZzJf/dhddIseEYFu QDi1Z07Vr1+WNI71BgCpgE4urF/fFtbUIEOW7BduQtgQ7ZWRJLHfF80rA iK70y1j1pvoeXUoeiM9Q/6mZ6Sjtvj75eCP5/llIHjL912H7F478rUsa3 mnqMd2I2cQoEh4Kt2fTakXl8v6k8niU2g2rXok0JSX2L2dFjg6DfnVzVl VGGU30v9rTQ4tuJ4rkePKRivq0/OGCvJTC327gvuEEDoHd1hqCDi6z6bu POA6T0K2RzaDLmwUKFgI77e3Y98IjjovS/GNEU3qk6ysesPH8YvoWdoST w==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="411896932" X-IronPort-AV: E=Sophos;i="6.03,169,1694761200"; d="scan'208";a="411896932" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 16:30:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="921350830" X-IronPort-AV: E=Sophos;i="6.03,169,1694761200"; d="scan'208";a="921350830" Received: from jithujos.sc.intel.com ([172.25.103.66]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 16:30:11 -0700 From: Jithu Joseph To: hdegoede@redhat.com, markgross@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, rostedt@goodmis.org, jithu.joseph@intel.com, ashok.raj@intel.com, tony.luck@intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, patches@lists.linux.dev, ravi.v.shankar@intel.com, pengfei.xu@intel.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH v2 2/9] platform/x86/intel/ifs: Refactor image loading code Date: Fri, 22 Sep 2023 16:25:59 -0700 Message-Id: <20230922232606.1928026-3-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230922232606.1928026-1-jithu.joseph@intel.com> References: <20230913183348.1349409-1-jithu.joseph@intel.com> <20230922232606.1928026-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 22 Sep 2023 16:30:28 -0700 (PDT) X-Spam-Level: ** IFS image loading flow is slightly different for newer IFS generations. In preparation for adding support for newer IFS generations, refactor portions of existing image loading code for reuse. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/load.c | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index cefd0d886cfd..851c97cc6a6b 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -80,6 +80,23 @@ static struct metadata_header *find_meta_data(void *ucode, unsigned int meta_typ return NULL; } +static void hashcopy_err_message(struct device *dev, u32 err_code) +{ + if (err_code >= ARRAY_SIZE(scan_hash_status)) + dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code); + else + dev_err(dev, "Hash copy error : %s\n", scan_hash_status[err_code]); +} + +static void auth_err_message(struct device *dev, u32 err_code) +{ + if (err_code >= ARRAY_SIZE(scan_authentication_status)) + dev_err(dev, "invalid error code 0x%x for authentication\n", err_code); + else + dev_err(dev, "Chunk authentication error : %s\n", + scan_authentication_status[err_code]); +} + /* * To copy scan hashes and authenticate test chunks, the initiating cpu must point * to the EDX:EAX to the test image in linear address. @@ -109,11 +126,7 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work) if (!hashes_status.valid) { ifsd->loading_error = true; - if (err_code >= ARRAY_SIZE(scan_hash_status)) { - dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code); - goto done; - } - dev_err(dev, "Hash copy error : %s", scan_hash_status[err_code]); + hashcopy_err_message(dev, err_code); goto done; } @@ -133,13 +146,7 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work) if (err_code) { ifsd->loading_error = true; - if (err_code >= ARRAY_SIZE(scan_authentication_status)) { - dev_err(dev, - "invalid error code 0x%x for authentication\n", err_code); - goto done; - } - dev_err(dev, "Chunk authentication error %s\n", - scan_authentication_status[err_code]); + auth_err_message(dev, err_code); goto done; } } -- 2.25.1