Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp99053rdb; Fri, 29 Sep 2023 18:51:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9OlxXqI3y3yv8RVUIKIebhYaOwfL1g12ixfY+QAXC3F+8cs6ahhHw6b+3Vf7/IY/e/sbS X-Received: by 2002:a17:90b:4a46:b0:274:945b:6979 with SMTP id lb6-20020a17090b4a4600b00274945b6979mr5839100pjb.16.1696038690487; Fri, 29 Sep 2023 18:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696038690; cv=none; d=google.com; s=arc-20160816; b=D8KxJ2STaTNBjitEL7pr4To6+BO1iloyKJJW8YLDzAtU1VnkDaKGegbr/jmn8mqNLk dBO0JCsBM813ySp5Giqrqy1lJl/Mxq2B5VUr0CS7KDWQEFVEKpPsP+e/XpSdLBHV4VJ1 jjrsm+4fN5V4OTXtfRUjOsEodCdDoEY5Jw4Rqcq+xs11fIPp6/z1H/qI01ZxsBYFyScT UzHb+m+AkSSW0i/ihYRxM/ib6cObqnhkNTr47luJy1iXisoKMkRZhAEFBU2n6FDX5N8o y1GDBwUDOKSZ0f3BgYp9qmFfzggvKTtav8sE2jdAtdU2jtjks6o7JH/2fO3JdZIu2vqd NLaA== 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=jBZ++Ma/15Mpbo5zeP7x6N/KtW5jA3je+XYAgXM2quc=; fh=DZTEBuCdFfe2DSdaI+6ceTR59ce872SNjmboNXW/0pA=; b=aaS532mX7IEsmFov9rxCcQaJqyhttYRumWzkiLGKb+6UgUBgLS3fFVPyCE7qe5HRT8 GTo9lAUby48xSOoCV7UNTRL5W6oqmD8KEdJUKSk03ytwhvW1tzmKZ0nzK+bcGDbM2U1g 21c0D43MSKeR7bpsziBTY2U7H68LrroKHj04WQ5PHJ/MfuvIJzP3FKl07ambvXylJ2gR 9pozLoVX8KdtXLlk68Sy4/8RWG5BfMZnyv3QpncoM9bJ/D7j04KSt5oblWWH1sRDneDv CepVOEYCLcteDxNP8D/7KsKm2yfCz34FStb0Ap4FtZ287TlU4rPQl5t3oL/zdLjshFia 3Zcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dPDrDn2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ng10-20020a17090b1a8a00b002790e0af4aasi2754142pjb.174.2023.09.29.18.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 18:51:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dPDrDn2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 4A84D8083ACE; Fri, 29 Sep 2023 13:45:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233837AbjI2Upb (ORCPT + 99 others); Fri, 29 Sep 2023 16:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233739AbjI2UpZ (ORCPT ); Fri, 29 Sep 2023 16:45:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE1D1B6; Fri, 29 Sep 2023 13:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696020323; x=1727556323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GtDY6ML84SF+F8nWzdP67B1CzR7rZUd3wkHRxH1boOQ=; b=dPDrDn2PqfTfZXefN6JxrbhfdWc3dWOHGAD3lrofUAtvgUw9XNe5XU9I te/76Q/45mtKc7KlIc/xwf2jMDulV6d8Q2ll06lxlQqmae77ULNm0khAZ 2qvlg/crJ6W3VtI3ZI547KrKaOWQ3a3Nkga436NZXk+j612g++BUr5EaZ 4wQ7pRdIVepR8o2/lGjNGMqYpeDw87awAC+c5p1nl1fzCCHFu7rGRPb3i k+Fsd/v2eqWfhjXNk7CfDAEgfg4Ut6KD3iFP4v6EcY1ZdIPAR0LBaiPVP LvhHN5WS2H/ES+ucSe3FzuiykD4lB/Se9yKqF6AwD3C4L/s1mWiEWGHaU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10848"; a="468654433" X-IronPort-AV: E=Sophos;i="6.03,188,1694761200"; d="scan'208";a="468654433" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 13:28:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10848"; a="893539198" X-IronPort-AV: E=Sophos;i="6.03,188,1694761200"; d="scan'208";a="893539198" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 13:27:28 -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 v3 2/9] platform/x86/intel/ifs: Refactor image loading code Date: Fri, 29 Sep 2023 13:24:29 -0700 Message-Id: <20230929202436.2850388-3-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230929202436.2850388-1-jithu.joseph@intel.com> References: <20230922232606.1928026-1-jithu.joseph@intel.com> <20230929202436.2850388-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 13:45:42 -0700 (PDT) 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 Reviewed-by: Ilpo Järvinen 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