Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4129151rdb; Thu, 14 Sep 2023 12:39:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKj+SR6N9F00YtHtyGhzU44dORSa5l31zA1ZsDYStFxbsWdEjG2COgiKppieoVg0o4e49B X-Received: by 2002:a05:6a21:4987:b0:14c:512c:c138 with SMTP id ax7-20020a056a21498700b0014c512cc138mr5799129pzc.60.1694720355446; Thu, 14 Sep 2023 12:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694720355; cv=none; d=google.com; s=arc-20160816; b=mlRgZI+yjkBc0inhXEcRGN93vjPiq61JAoF3/DAWd2kyPsjxHREUbs797AtS94UIc6 hYA+xQjFxXnSfH3aqMPFdY2ZHMDSkDTWpTNB7CxH3y9m7BL1xEYhH3PZaysWg2WBo/yd U5diT1aVxOp4h85l5erSF2E++/bFDh9mtt27QuzgSgveYrDNsw4q/7pjWOniNdVTCYCt 1+5p8lGzHNI95INgZEmd++4sCHpU6r/PI4t3Y8tuUaLCU8JBIrc8dgIFCZQAkXyyikwr tNMkZDNmOkXcsfAT+hxzt2XjWvLaw18PiEF/vJpjpUt1DEdwcLr3bg4Gv3l3EbXAAXEd foaw== 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=ETg1svEQpkz0TqRLyOwkIPxqC7UQ6/paiaK3FUNcbtQ=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=bFrZbtrGkcczzNSNYcil1C0RDBZ8619ZtWmiaUSgI9LEH36SGUCkZOu/9QSrhCLbEw 7HR+yjjegVsFklhftGuoSLjnKmUpAh2ZFLi83rqXc90lLYrJFqSmwl7PniGFNVdUThRy K6IZ1GP/eZnkDFHpIoKpyMs6OIpxPw3teX1SxjQRZwnPKeFN8X63B9IMN0Tnka1XkfHw M8Yb0M1jyBi4rm737RX/gR9l18Hv4M7SrjfgWe/BrVHHanB75KECdr5D1zqle2Oi9010 fvtuVS1N4NVoKVMHmocrVY36GeyM3NAg9dLn64OqjCMqsrShtq991UZFEURuFrP4Pnef Fhcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aDY70ni7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g19-20020a056a00079300b0069026254582si1975651pfu.98.2023.09.14.12.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 12:39:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aDY70ni7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id F1C8C818EC05; Wed, 13 Sep 2023 11:38:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231939AbjIMSiE (ORCPT + 99 others); Wed, 13 Sep 2023 14:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbjIMSh7 (ORCPT ); Wed, 13 Sep 2023 14:37:59 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11DB7A3; Wed, 13 Sep 2023 11:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630275; x=1726166275; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xCxH2O4NnZUcc0zAWHVPgXZ+7sRheSRlMJvoqoWVMlQ=; b=aDY70ni7Dq5ZnccNDiJSseOcbPRryo1PJ8obR1wrVz1j70JoofuRBCUO qBLE+RlfezZVpvc9ctHT+JTtSw/Ub4gWWU4ogSDJRCYCkDChdvZroThVV pzw0VEz1XZp+GZCc2HoOIobk1/ntcqjLfrWy9aFL9Dkbjzr9VTXcQ8cef Dj3T0PXpCNczgMHEIISg4QBSODfFKmEQXrpTTmgJHo4Cj3VRdhr6F01ln 6BefbbxxjazaUU2+rp/Tq8oNMSHDC/5Pv18utw/TNvHW7GyGjBnaSWbEr IHqhteh9XDxh+TaKDwqlikAg+8Xsu8wR2j1lDKv9lFyP/Iep5nRBQ7hvY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019122" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019122" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 11:37:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238578" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238578" Received: from jithujos.sc.intel.com ([172.25.103.66]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 11:37:54 -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 Subject: [PATCH 02/10] platform/x86/intel/ifs: Refactor image loading code Date: Wed, 13 Sep 2023 11:33:40 -0700 Message-Id: <20230913183348.1349409-3-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230913183348.1349409-1-jithu.joseph@intel.com> References: <20230913183348.1349409-1-jithu.joseph@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 11:38:06 -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 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