From patchwork Wed Sep 13 18:33:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp132060vqb; Wed, 13 Sep 2023 15:51:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELvq+cDrPbOsf3laLO9hHk5vo9jceUx/7F17u5WIcODRoyOIfcHOLJOa3Pj2L/UL4oHuCO X-Received: by 2002:a05:6a00:9a0:b0:68f:c9df:2ccb with SMTP id u32-20020a056a0009a000b0068fc9df2ccbmr4499348pfg.1.1694645474748; Wed, 13 Sep 2023 15:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694645474; cv=none; d=google.com; s=arc-20160816; b=G4VE/esw29sNqA3x19uHtgKJ0sXbXzXsEjV/uGZDCKF+B9i2jj3urMCzeo5bsSaDQC tmQZDO7CahvsBrDADmGQrrjYpGKVpLeIS/LkR+kpJsNjtdcnvz5DYmP1wWTVPFy7SYnw 6ZEi1HEYUQJV1drBo8eS5MKyfWu77Xfjb6TQcnoEpDXnCy365ExIO4u6QGfOI8tJqEeH 00FA4JCnMsVlEsVfIVeFCKAlxq8vqqpZHJyK547M6ynjl/dCgMEgoG6h4Jz1iQ13aRI/ Cw4i5CR4u+mLBg9+IpIes7Nn4sFx0xyC+7qYNtxtB/pMS6GM3kUEvKSyAznCFSOsGCwA I2QA== 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=mHabYtRN1t0xWYb49oCu8HtJOPNCBVGe90dv/65PDy8=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=nF+C6eCPnFcxFODiinCORYLWqlcokO9BVCctaj/cGjnGsvwC8lv8nObV04OBXQaacM Z3gPTVYhW3iEijs1ySPNvyPG2I2blLTTQ0PoleSLpCgmWQLHRynZJd7GLCI277GaiMhr 02LP/lGFgUjaky7PuCuNvToLoZKdK0iZMHTjSub8cVzxABhGFVSB1HfI+qLMIurJGXra 9b0n8r04OHhAkjk0QrmzMitBHsfO8JPDrvfYLPg6AXGRYzl5I6oRhsg2lt//2g1MOQaG BwN64GqpFHdHnNSom/f4gDqeERD39l4fEl1mxxWMdio8aXzAaXdH9D2ONeO8dICs9SMT xVCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c22BAhIA; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b67-20020a633446000000b00565e9c3a308si115508pga.788.2023.09.13.15.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 15:51:14 -0700 (PDT) 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=@intel.com header.s=Intel header.b=c22BAhIA; 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=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 9DA5C818F683; Wed, 13 Sep 2023 11:38:04 -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 S231928AbjIMSiC (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjIMSh6 (ORCPT ); Wed, 13 Sep 2023 14:37:58 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3EBC1BC6; Wed, 13 Sep 2023 11:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630274; x=1726166274; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zYniCTlI2hRtCCmtPBhkZpW2hr3gRwPR25GRONFDmyM=; b=c22BAhIA5kRI5fagxc0Bfmd7/LS3xBFH51O2r5dj88HqIYaDgLjmj5va SCrgxnuHVc76+w+egJBIzThWDQ4LxvXl+fc3HxhTUwH2ppxvkp3VkCxD2 iaUb5WVvg60SRm5+rVUaxeYuLVm0ED4MGcPvhEk1AOI37UeXAGo8OsSeu i8kVCYejyO6E4F1cLcJ3fQrC4v2v9t870DnvkVTrygDrq9FrlOwZO3Gij MgujrYqlp0nQXflxVsY2DRx2+eVmcuzdygoS4OoTvpHEgza9ETmztV9cp VzyFPtZkbf8jhaH/DofGw/hqnGSTgi3DoVw1UYRWpO3/0dE3xkQdrJlE8 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019114" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019114" 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="744238575" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238575" 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:53 -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 01/10] platform/x86/intel/ifs: Store IFS generation number Date: Wed, 13 Sep 2023 11:33:39 -0700 Message-Id: <20230913183348.1349409-2-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 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:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776964573245312947 X-GMAIL-MSGID: 1776964573245312947 IFS generation number is reported via MSR_INTEGRITY_CAPS. As IFS support gets added to newer CPUs, some differences are expected during IFS image loading and test flows. Define MSR bitmasks to extract and store the generation in driver data, so that driver can modify its MSR interaction appropriately. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- arch/x86/include/asm/msr-index.h | 2 ++ drivers/platform/x86/intel/ifs/ifs.h | 2 ++ drivers/platform/x86/intel/ifs/core.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 1d111350197f..a71a86a01488 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -222,6 +222,8 @@ #define MSR_INTEGRITY_CAPS_ARRAY_BIST BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT) #define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT 4 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT) +#define MSR_INTEGRITY_CAPS_SAF_GEN_REV_SHIFT 9 +#define MSR_INTEGRITY_CAPS_SAF_GEN_REV_MASK (0x3ull << MSR_INTEGRITY_CAPS_SAF_GEN_REV_SHIFT) #define MSR_LBR_NHM_FROM 0x00000680 #define MSR_LBR_NHM_TO 0x000006c0 diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 93191855890f..d666aeed20fc 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -229,6 +229,7 @@ struct ifs_test_caps { * @status: it holds simple status pass/fail/untested * @scan_details: opaque scan status code from h/w * @cur_batch: number indicating the currently loaded test file + * @generation: IFS test generation enumerated by hardware */ struct ifs_data { int loaded_version; @@ -238,6 +239,7 @@ struct ifs_data { int status; u64 scan_details; u32 cur_batch; + u32 generation; }; struct ifs_work { diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index 306f886b52d2..88d84aad9334 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -94,6 +94,8 @@ static int __init ifs_init(void) for (i = 0; i < IFS_NUMTESTS; i++) { if (!(msrval & BIT(ifs_devices[i].test_caps->integrity_cap_bit))) continue; + ifs_devices[i].rw_data.generation = (msrval & MSR_INTEGRITY_CAPS_SAF_GEN_REV_MASK) + >> MSR_INTEGRITY_CAPS_SAF_GEN_REV_SHIFT; ret = misc_register(&ifs_devices[i].misc); if (ret) goto err_exit; From patchwork Wed Sep 13 18:33:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp14664vqi; Wed, 13 Sep 2023 17:14:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHq5MRgHGvFnqCM50NLvsUAWExoTV7Z1owwBaJy5MDsrUl3ch+woZq75vg6pmylKYLRISGb X-Received: by 2002:a17:90b:3a82:b0:268:dad:2fdc with SMTP id om2-20020a17090b3a8200b002680dad2fdcmr4018920pjb.21.1694650491274; Wed, 13 Sep 2023 17:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694650491; cv=none; d=google.com; s=arc-20160816; b=i+Tao0K6Gk+sOe8wBOos0WjhLQQ6RdUgckKIj0/vgiqjuNZuQQWq6TxvqrV6os5RN6 svu6TuRqPeEEo4TemC/9n3+O7xPiMXShxOi58zGOQPb9+LdnTOs0rO0VsnKMnE9uQM4y vrUs8eEdpa2F9vdIXX9wxR3Zcc8X+mJ3aw4CnsDuZB2mRc6ScioC+CAu8sULqFecbrPv PFijY6/f4sjqoVnbXJavC4HPutcknyOeQWEgbk1KM7DPJK2gKzIbwe16OegOSsOSV6Lt /YvJy+MYlJ7fgRpGvh2waIH5AwNUbyT7PcdnevhDpf9h6PYbzzH/QklY+ogQU2dRyAkS gsKA== 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 Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ob12-20020a17090b390c00b0026d42d35d5csi2879287pjb.78.2023.09.13.17.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 17:14:51 -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 72D4D8191449; Wed, 13 Sep 2023 11:38:08 -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 S231941AbjIMSiE (ORCPT + 34 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 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:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776969833232172393 X-GMAIL-MSGID: 1776969833232172393 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; } } From patchwork Wed Sep 13 18:33:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp695375vqi; Thu, 14 Sep 2023 16:47:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFDZ254I674Mkm/uRPntZaJUZRYsYwO3TVcbPqYbkFeogabTU8XbLmZkCZEeLDXbG3thf1 X-Received: by 2002:a05:6358:91a9:b0:13c:eef8:dec0 with SMTP id j41-20020a05635891a900b0013ceef8dec0mr358876rwa.3.1694735229794; Thu, 14 Sep 2023 16:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694735229; cv=none; d=google.com; s=arc-20160816; b=M3mxMU+ycHhG/1z2F3rbNMEic+AILLtNgj6Tukv9OgQC6oiF7U+PnUmgebwTXJcP+a zEwD5tlmGEB/C7utYmuwKgVlOavbgcqXQ+zebI7KbB4ySf5AAsMQfp3rMZECa2ZUFseN eWIbegjbGFvLRq+7mj3FgS7Q85bKW0JH1soT/w6yCEcVEdczt5gMgIeZlZvLFwbGJF/c mOy4FAqfqm/6VFIW4ntaSJiEez9Gb30Fp7APCnWe0lGHgKw4tdnUzmA7iQtdn+h0kD1P 8St+a7T28SbudniZKJ7lTv0XrGRupERY2Gbo539WaIqFBKH0h+b2z1feaDWfolImyGUl 74UA== 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=tMytS1KUpCIWcXTQ6Sm2GryU2PwZFC0p/YoribnEQf0=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=fVcekCR1A60VaNiyaoP5ihr3/MJjfEWKUqRSRR0I+GmkvpXlcmVlZmC2rymmL09eF7 OyEu8r6vzdHFiKBNOpXyKkoXstP1ne3h4QSam83K19hoRv34GANbrEWMV5CBGg7Qlj+y lJ6bvh6cTkXq+Qxy1E0vvRSGbzXmbscQ/OnakXKk5EFFkptPLZ45NfVOzFzQ1sFxYtmf 1ejjvcsxF+yBVzOEPoVWxmEiBwRsSJOJZ17xGavZMqe/0JwxjnDzALr3xLvrqygy24P7 BsIX37OcXM5OEmW2vMlfxvuy6hjr+vHRf6rNIf41NkcxiRcUHTUMnUiUnBdbQQbA+c+7 0w0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OYmUsYEn; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o66-20020a634145000000b005777bea0b5esi2171053pga.901.2023.09.14.16.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:47:09 -0700 (PDT) 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=@intel.com header.s=Intel header.b=OYmUsYEn; 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=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 CB07581B800E; Wed, 13 Sep 2023 11:38:10 -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 S231955AbjIMSiH (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbjIMSh7 (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 780E01BC8; 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=6MhxqnHOvCXv4ju38K3n2pUcud6lHegci+sskmbkXkc=; b=OYmUsYEnOezXPkc6IZYXGStXitBQVoTgOMwtPtO24q46OeaH4CvV3mTe yMRwISI+fteiW3DysiilLRIqUoDyltWf+6PGrHXqbOBRd0b5iJtjGuRol umUgSk0OyunMu2nRcWue4PwHJll09HbZREbxEO0gzARivR4JY65FTIFUW Dy+z1QuAvrrg4toV+gN+iv1muEIzXCcKKPrrU0nPIkxTfuAbJgLuO5I8q Vb8x1afmvMFQK8l1RO1RBIZBWcXAxqx4EjZTLDFYWr3Ltt3W86bfBO7Et xTsc9Xau0JURizklfHzf7DwwJtzUYidVT75Zv+2IujPNxcJbtTHii5x8W A==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019134" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019134" 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:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238581" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238581" 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 03/10] platform/x86/intel/ifs: Image loading for new generations Date: Wed, 13 Sep 2023 11:33:41 -0700 Message-Id: <20230913183348.1349409-4-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 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:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777058687956584744 X-GMAIL-MSGID: 1777058687956584744 Scan image loading flow for newer IFS generations (1 and 2) are slightly different from that of current generation (0). In newer schemes, loading need not be done once for each socket as was done in gen0. Also the width of CHUNK related bitfields in SCAN_HASHES_STATUS MSR has increased from 8 -> 16 bits. Similarly there are width differences for CHUNK_AUTHENTICATION_STATUS too. Further the parameter to AUTHENTICATE_AND_COPY_CHUNK is passed differently in newer generations. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/ifs.h | 27 ++++++ drivers/platform/x86/intel/ifs/load.c | 113 +++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index d666aeed20fc..886dc74de57d 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -137,6 +137,8 @@ #define MSR_CHUNKS_AUTHENTICATION_STATUS 0x000002c5 #define MSR_ACTIVATE_SCAN 0x000002c6 #define MSR_SCAN_STATUS 0x000002c7 +#define MSR_SAF_CTRL 0x000004f0 + #define SCAN_NOT_TESTED 0 #define SCAN_TEST_PASS 1 #define SCAN_TEST_FAIL 2 @@ -158,6 +160,19 @@ union ifs_scan_hashes_status { }; }; +union ifs_scan_hashes_status_gen2 { + u64 data; + struct { + u16 chunk_size; + u16 num_chunks; + u8 error_code; + u32 chunks_in_stride :9; + u32 rsvd :2; + u32 max_core_limit :12; + u32 valid :1; + }; +}; + /* MSR_CHUNKS_AUTH_STATUS bit fields */ union ifs_chunks_auth_status { u64 data; @@ -170,6 +185,16 @@ union ifs_chunks_auth_status { }; }; +union ifs_chunks_auth_status_gen2 { + u64 data; + struct { + u16 valid_chunks; + u16 total_chunks; + u8 error_code; + u32 rsvd :24; + }; +}; + /* MSR_ACTIVATE_SCAN bit fields */ union ifs_scan { u64 data; @@ -230,6 +255,7 @@ struct ifs_test_caps { * @scan_details: opaque scan status code from h/w * @cur_batch: number indicating the currently loaded test file * @generation: IFS test generation enumerated by hardware + * @chunk_size: size of a test chunk */ struct ifs_data { int loaded_version; @@ -240,6 +266,7 @@ struct ifs_data { u64 scan_details; u32 cur_batch; u32 generation; + u32 chunk_size; }; struct ifs_work { diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index 851c97cc6a6b..e8fb03dd8bcf 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -26,6 +26,11 @@ union meta_data { #define IFS_HEADER_SIZE (sizeof(struct microcode_header_intel)) #define META_TYPE_IFS 1 +#define INVALIDATE_STRIDE (0x1UL) +#define IFS_GEN_STRIDE_AWARE 2 +#define AUTH_INTERRUPTED_ERROR 5 +#define IFS_AUTH_RETRY_CT 10 + static struct microcode_header_intel *ifs_header_ptr; /* pointer to the ifs image header */ static u64 ifs_hash_ptr; /* Address of ifs metadata (hash) */ static u64 ifs_test_image_ptr; /* 256B aligned address of test pattern */ @@ -44,7 +49,10 @@ static const char * const scan_hash_status[] = { static const char * const scan_authentication_status[] = { [0] = "No error reported", [1] = "Attempt to authenticate a chunk which is already marked as authentic", - [2] = "Chunk authentication error. The hash of chunk did not match expected value" + [2] = "Chunk authentication error. The hash of chunk did not match expected value", + [3] = "Reserved", + [4] = "Chunk outside the current stride", + [5] = "Authentication flow interrupted" }; #define MC_HEADER_META_TYPE_END (0) @@ -154,6 +162,104 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work) complete(&ifs_done); } +static int get_num_chunks(int gen, union ifs_scan_hashes_status_gen2 status) +{ + return gen >= IFS_GEN_STRIDE_AWARE ? status.chunks_in_stride : status.num_chunks; +} + +static bool need_copy_scan_hashes(struct ifs_data *ifsd) +{ + if (!ifsd->loaded || ifsd->generation < IFS_GEN_STRIDE_AWARE || + ifsd->loaded_version != ifs_header_ptr->rev) { + return true; + } + return false; +} + +static int copy_hashes_authenticate_chunks_gen2(struct device *dev) +{ + union ifs_scan_hashes_status_gen2 hashes_status; + union ifs_chunks_auth_status_gen2 chunk_status; + u32 err_code, valid_chunks, total_chunks; + int i, num_chunks, chunk_size; + union meta_data *ifs_meta; + int starting_chunk_nr; + struct ifs_data *ifsd; + u64 linear_addr, base; + u64 chunk_table[2]; + int retry_count; + + ifsd = ifs_get_data(dev); + + if (need_copy_scan_hashes(ifsd)) { + wrmsrl(MSR_COPY_SCAN_HASHES, ifs_hash_ptr); + rdmsrl(MSR_SCAN_HASHES_STATUS, hashes_status.data); + + /* enumerate the scan image information */ + chunk_size = hashes_status.chunk_size * 1024; + err_code = hashes_status.error_code; + + num_chunks = get_num_chunks(ifsd->generation, hashes_status); + + if (!hashes_status.valid) { + hashcopy_err_message(dev, err_code); + return -EIO; + } + ifsd->loaded_version = ifs_header_ptr->rev; + ifsd->chunk_size = chunk_size; + } else { + num_chunks = ifsd->valid_chunks; + chunk_size = ifsd->chunk_size; + } + + if (ifsd->generation >= IFS_GEN_STRIDE_AWARE) { + wrmsrl(MSR_SAF_CTRL, INVALIDATE_STRIDE); + rdmsrl(MSR_CHUNKS_AUTHENTICATION_STATUS, chunk_status.data); + if (chunk_status.valid_chunks != 0) { + dev_err(dev, "Couldn't invalidate installed stride - %d\n", + chunk_status.valid_chunks); + return -EIO; + } + } + + base = ifs_test_image_ptr; + ifs_meta = (union meta_data *)find_meta_data(ifs_header_ptr, META_TYPE_IFS); + starting_chunk_nr = ifs_meta->starting_chunk; + + /* scan data authentication and copy chunks to secured memory */ + for (i = 0; i < num_chunks; i++) { + retry_count = IFS_AUTH_RETRY_CT; + linear_addr = base + i * chunk_size; + + chunk_table[0] = starting_chunk_nr + i; + chunk_table[1] = linear_addr; +auth_retry: + wrmsrl(MSR_AUTHENTICATE_AND_COPY_CHUNK, (u64)chunk_table); + rdmsrl(MSR_CHUNKS_AUTHENTICATION_STATUS, chunk_status.data); + err_code = chunk_status.error_code; + if (err_code == AUTH_INTERRUPTED_ERROR && --retry_count) + goto auth_retry; + if (err_code) { + ifsd->loading_error = true; + auth_err_message(dev, err_code); + return -EIO; + } + } + + valid_chunks = chunk_status.valid_chunks; + total_chunks = chunk_status.total_chunks; + + if (valid_chunks != total_chunks) { + ifsd->loading_error = true; + dev_err(dev, "Couldn't authenticate all the chunks.Authenticated %d total %d.\n", + valid_chunks, total_chunks); + return -EIO; + } + ifsd->valid_chunks = valid_chunks; + + return 0; +} + static int validate_ifs_metadata(struct device *dev) { struct ifs_data *ifsd = ifs_get_data(dev); @@ -206,7 +312,9 @@ static int scan_chunks_sanity_check(struct device *dev) return ret; ifsd->loading_error = false; - ifsd->loaded_version = ifs_header_ptr->rev; + + if (ifsd->generation > 0) + return copy_hashes_authenticate_chunks_gen2(dev); /* copy the scan hash and authenticate per package */ cpus_read_lock(); @@ -226,6 +334,7 @@ static int scan_chunks_sanity_check(struct device *dev) ifs_pkg_auth[curr_pkg] = 1; } ret = 0; + ifsd->loaded_version = ifs_header_ptr->rev; out: cpus_read_unlock(); From patchwork Wed Sep 13 18:33:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp305492vqi; Thu, 14 Sep 2023 05:19:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNaw06/abHPYVswCz617NgfxBLyIRaBQRCaBpfQMfCsOtcoi5lbcSmhaelMQkUWWKjgLf6 X-Received: by 2002:a05:6a00:198a:b0:68e:417c:ed5c with SMTP id d10-20020a056a00198a00b0068e417ced5cmr5906111pfl.32.1694693960464; Thu, 14 Sep 2023 05:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694693960; cv=none; d=google.com; s=arc-20160816; b=S81iuuGVX8KwG1VHwD4UhBLcxMx1aNXVSJluFV5TuUEpFMUOty6YixoYZ27PrvXUxG 2eoZbNHxfBKSIZSKjnBQ+VPRi0mbW2343yQtEtrNEC0lJdkPLsSC7ZcNX6HgH+Fiosus 5j/tZFRcOhODhQMOKrKvDqNICEHkbBMozz2y1A+4K4+41qUpF56mKw9SeXANmMlCSARV /o/S/VZFudL+f/T6bq5j/Hi9swmOJFo5dUcVwA3Z2FcFMwIvbUwSGU+96NgRwd8GRWed b7UK2IMN0npfrwUq/kn0tQ/gvWqC5eiOGVgiAoyhHk+OKmtI5oZvY2UgCCS7KFjnIiYS SvMg== 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=x60hwmu/3eRAgjUMDugaXXHQGYqucKV2m6BSqTzUYcg=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=zRr/dZ4w1sj38xn7vlpGY+/Nz9u6bAGJPC0y4ZwSQkyr0ZGi975H5S9c6C3hiFvL8L i3aHizINXmyjyr8/co4BircCCWQtBFFaDE8CDD5UIkISUhrnNXcCXCPy8cz7XFozKAmz JMDvXkBgIbLqnhv2qivDn9n9hjnHDNNgpJWucl2DekVn4Ph2gbY09G8E5m1B4aj7JREI tarBUoTrjIsUXEQIvotGKFIvXG43e0qcs+Z7POhp9eBO8Az0OUzDuN7kimdeaVglI+8R eofwcHb1gIt35kjpBb/OhIUi+gNGcBrcoGMmsGKeNdcLUfd592NGqnjGJoXBiQVf0q1+ BR8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UcDrEkDT; 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id br14-20020a056a00440e00b0068e4debbe12si1409597pfb.371.2023.09.14.05.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 05:19:20 -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=UcDrEkDT; 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 A910D81CEB0E; Wed, 13 Sep 2023 11:38:15 -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 S231966AbjIMSiJ (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230433AbjIMSh7 (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 BDF9DA3; 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=7jiyu/bEO46k0jXXC149ozOKb3OC/lXOxys31r8AOQ4=; b=UcDrEkDT3xdrOQNdO1It/PixlfB7HUjyEMkl5vulR7pmWhKlIMXEbHLF U24H+EmN/N2/lZSg4nUtSoH632fQQzRzVANxf+F6dGGaqjgiwvhAK2Lib FzLQTieB5a+l+RytnYTW1c2nRQMwKKhocVK4JGK9rvMoEulh5epcis5Ix hLYYat8Umfo4S2lWUlhuLMkLnZhCSWNzN2sCyQFrXRDkrx3vImNmfzpHH Bfg+PNjdNcpPc8x6aYty3akLGDVQlJfxvp3Dx4BF6KaS/T83F+VntNXvF bS7WjljqiRZC9lETcDFvXn9wPKhStLTJa3xIwY/BiZnSFdhGX6TdUJw/s w==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019143" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019143" 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:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238584" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238584" 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:55 -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 04/10] platform/x86/intel/ifs: Scan test for new generations Date: Wed, 13 Sep 2023 11:33:42 -0700 Message-Id: <20230913183348.1349409-5-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 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:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777015414192267676 X-GMAIL-MSGID: 1777015414192267676 Make changes to scan test flow such that MSRs are populated appropriately based on the generation supported by hardware. Width of chunk related bitfields is ACTIVATE_SCAN and SCAN_STATUS MSRs are different in newer IFS generation compared to gen0. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/ifs.h | 14 ++++++++++++++ drivers/platform/x86/intel/ifs/runtest.c | 23 ++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 886dc74de57d..3265a6d8a6f3 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -205,6 +205,12 @@ union ifs_scan { u32 delay :31; u32 sigmce :1; }; + struct { + u16 start; + u16 stop; + u32 delay :31; + u32 sigmce :1; + } gen2; }; /* MSR_SCAN_STATUS bit fields */ @@ -219,6 +225,14 @@ union ifs_status { u32 control_error :1; u32 signature_error :1; }; + struct { + u16 chunk_num; + u16 chunk_stop_index; + u8 error_code; + u32 rsvd1 :22; + u32 control_error :1; + u32 signature_error :1; + } gen2; }; /* MSR_ARRAY_BIST bit fields */ diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 1061eb7ec399..4bbab6be2fa2 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -171,6 +171,8 @@ static void ifs_test_core(int cpu, struct device *dev) union ifs_status status; unsigned long timeout; struct ifs_data *ifsd; + int to_start, to_stop; + int status_chunk; u64 msrvals[2]; int retries; @@ -179,13 +181,21 @@ static void ifs_test_core(int cpu, struct device *dev) activate.rsvd = 0; activate.delay = IFS_THREAD_WAIT; activate.sigmce = 0; - activate.start = 0; - activate.stop = ifsd->valid_chunks - 1; + to_start = 0; + to_stop = ifsd->valid_chunks - 1; + + if (ifsd->generation) { + activate.gen2.start = to_start; + activate.gen2.stop = to_stop; + } else { + activate.start = to_start; + activate.stop = to_stop; + } timeout = jiffies + HZ / 2; retries = MAX_IFS_RETRIES; - while (activate.start <= activate.stop) { + while (to_start <= to_stop) { if (time_after(jiffies, timeout)) { status.error_code = IFS_SW_TIMEOUT; break; @@ -202,7 +212,8 @@ static void ifs_test_core(int cpu, struct device *dev) if (!can_restart(status)) break; - if (status.chunk_num == activate.start) { + status_chunk = ifsd->generation ? status.gen2.chunk_num : status.chunk_num; + if (status_chunk == to_start) { /* Check for forward progress */ if (--retries == 0) { if (status.error_code == IFS_NO_ERROR) @@ -211,7 +222,9 @@ static void ifs_test_core(int cpu, struct device *dev) } } else { retries = MAX_IFS_RETRIES; - activate.start = status.chunk_num; + ifsd->generation ? (activate.gen2.start = status_chunk) : + (activate.start = status_chunk); + to_start = status_chunk; } } From patchwork Wed Sep 13 18:33:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp40920vqi; Wed, 13 Sep 2023 18:18:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzrfzmhl4RgqubmOCTt8W8KG3Sr5HFTugwiZHPYmSqlm+sGCHgnnEttMbL2ailBu+t85Qh X-Received: by 2002:a05:6a00:3306:b0:690:1720:aa83 with SMTP id cq6-20020a056a00330600b006901720aa83mr2497086pfb.21.1694654280413; Wed, 13 Sep 2023 18:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694654280; cv=none; d=google.com; s=arc-20160816; b=pCVZWjCKLZ4LomqFMjThY8anRZbNTfVfZ6+Fk3+bn/C+d7GqvSrj0G2TlTpTrtoyZR Bo46zqT8DJ1zqhQMb5rrlZlcaqfqHfpW6JIGB7l4+9OM+GYnZqfS3Br4OhYNfxnXqHEL qTuSUYMZnjJAyhtECGscfa+JyTjXbsKk42kjsnu9mnT10OAhvB0Sq7w+uAR3jK/LzeSQ qrem3mZ9dslm6DyXvJeLHMxrJfRS5ZhNMJWVNvE3cDU9Qe9dvnS06wafunv0zl2AEsE0 8y4cyCX2aBJ/w+wAiXm0Vr+u5t1wu8FS1tFVMAHQWdtnT9g8qK9aRZ40g8tpEdgN8W8A rdjg== 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=BaPXEhyTHar+Z9iFiuX4H+2rX52D1gCM2x0bzrYZGKw=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=weYW66CcnHL8fP3MgQAtHYpZ493/WGWwGuwupdnjCfs3chN+G3JD1+ZAGZAuZj3y19 Xdfl7wuLRNec0+e4H2ZcWuhi99akuOYLK33IE1ImTWNkxVRlk92sEeKbqZiS6VglWtuW GgE4/WD3IrMS7bkdNYAbfsa/cbhavZq7S28Jigf3ZD8DOm1ogMwkHq9W385r4JJCB3QY bgXvU5nG8JeTleoAvVh6wROvV5O3hCQXXiqQiptVB/0LyXDRGsycyVFkkeYL827sG7Xj DEiGTv7zD8VttKRZ957+llwsmLtzYc1SYL70n2RW1z1f2AhKRaoKMQN8Cw4JQ5iR//EB 7jcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V79RYm2I; 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g14-20020a056a000b8e00b0068722b7ab8esi469212pfj.222.2023.09.13.18.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:18:00 -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=V79RYm2I; 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 54C7783EE9EC; Wed, 13 Sep 2023 11:38:20 -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 S231977AbjIMSiM (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbjIMSiA (ORCPT ); Wed, 13 Sep 2023 14:38:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B6A6A3; Wed, 13 Sep 2023 11:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630276; x=1726166276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z8Z0UQUOAbWvwtFJniXI4N/ipWPW87ZWVEGdjD0eBS0=; b=V79RYm2IUEkWgsPARVyFPUZtgSizfBKRusXPyE/9EqrPZPhM5gU35/tE FTnqgPoMwBENvSlp/1mTyrID4z9dFPQOIq1g6P649QAfsTxnAPP1vNEfQ p076ovaojNrHjNRD0+8Ed3cvqfAP+x4TFwYg712iF4BjMU2z5UNk6hmRr BQhb82tMc/6Z92AqTmcLsTnWhsNccwcXmAZEg8WxLV1rIRjnoDMhrroJN 0SVsOh1BaAbSSRB9XNy+VCnt0ytUBQ3clI4Dlv6b7pO45jhWWuT9dNG80 YChCrXUNMYkJF/BdwcAMaPnR5GTM9bl3MSw3jUwv6Gtkl+vTyEtb3TYSe Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019159" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019159" 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:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238587" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238587" 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:55 -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 05/10] trace: platform/x86/intel/ifs: Modify scan trace Date: Wed, 13 Sep 2023 11:33:43 -0700 Message-Id: <20230913183348.1349409-6-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 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]); Wed, 13 Sep 2023 11:38:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776973806668920855 X-GMAIL-MSGID: 1776973806668920855 Account for the 8/16 bit MSR bitfield width differences between gen0 and newer generations in the scan trace path. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- include/trace/events/intel_ifs.h | 16 ++++++++-------- drivers/platform/x86/intel/ifs/runtest.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/trace/events/intel_ifs.h b/include/trace/events/intel_ifs.h index d7353024016c..af0af3f1d9b7 100644 --- a/include/trace/events/intel_ifs.h +++ b/include/trace/events/intel_ifs.h @@ -10,25 +10,25 @@ TRACE_EVENT(ifs_status, - TP_PROTO(int cpu, union ifs_scan activate, union ifs_status status), + TP_PROTO(int cpu, int start, int stop, u64 status), - TP_ARGS(cpu, activate, status), + TP_ARGS(cpu, start, stop, status), TP_STRUCT__entry( __field( u64, status ) __field( int, cpu ) - __field( u8, start ) - __field( u8, stop ) + __field( u16, start ) + __field( u16, stop ) ), TP_fast_assign( __entry->cpu = cpu; - __entry->start = activate.start; - __entry->stop = activate.stop; - __entry->status = status.data; + __entry->start = start; + __entry->stop = stop; + __entry->status = status; ), - TP_printk("cpu: %d, start: %.2x, stop: %.2x, status: %llx", + TP_printk("cpu: %d, start: %.4x, stop: %.4x, status: %.16llx", __entry->cpu, __entry->start, __entry->stop, diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 4bbab6be2fa2..ba3f9ad88a82 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -206,7 +206,7 @@ static void ifs_test_core(int cpu, struct device *dev) status.data = msrvals[1]; - trace_ifs_status(cpu, activate, status); + trace_ifs_status(cpu, to_start, to_stop, status.data); /* Some cases can be retried, give up for others */ if (!can_restart(status)) From patchwork Wed Sep 13 18:33:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139066 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp58451vqb; Wed, 13 Sep 2023 13:08:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoyjeQb2kK/KRgyd6dUCOHyNYiTYptpJi6YlZEyuQPsZS1upqjWXJq2YLudYpSBjg/L6Sh X-Received: by 2002:a17:90b:4d85:b0:26c:f6d2:2694 with SMTP id oj5-20020a17090b4d8500b0026cf6d22694mr3330981pjb.12.1694635682554; Wed, 13 Sep 2023 13:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694635682; cv=none; d=google.com; s=arc-20160816; b=IBp0xlfa0tE6ljQh5/hFnN50bIAVyVwQfbAs5l+j9oMopjb4bAyeZPIDMB1wAulrNP x5rVCYG7Or/Iov1TXg+c9eCc03XfPctqrqX89aMp92kI+gSZuZhONZ7CzVPpeZqFhP7a 6jVt8GVlRSPTqnL1noc9rxu9eitm9F/5CLnEsDvviSBqwmnMY/96+x/p7Gb6m0GQ+8Ye DkaZkGtuIwW6zOMFccgf+637RC3A1j8xzd005t07KfO7Tk9M3/2523c/48648/Mt43JW /7qQKA6V7DEKqy0Wtrh1IlEaE6MqW2N7PBeIXHTGMS2GVEt8eN3E2+wtnAGHx2KLOOAP TD/g== 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=NRMsg5ftdqMaSRAJN9gPrIpxylk/Xfx5TJFB1AqXEuE=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=xa7eYw6uygLhxlqsV/IPl2xUFJrv5kFtiQ0Jdz9FVm3pyAeYxpyZDCwkjRaMI1+nco K0o9BT3iVmXu4GV6dPk8vBlJMQOJ9Rj/8mIDVYFzXqDZpncwYLKOsO5JqSNOt8vfr+nB 8kF8hklqsbmjRAkHv2U2CR0jzEIAjkXLOmwH1DOnrMUaLKvJyWggixE7qVdTlfOq+zqH hxFvRmFnQSdUk0wCA4TMANP3DzG2JbN5D8GHXzlBXRLGWf4aVk+IRR4e6m3dEH9QUuIy Gly052Cpc0xDMhGquqHTb3A1SSalg3iJpuXSFOrDqm0GcWWV5TafbtbNgh2SmNgnBTIL s3qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KmkCiurj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q102-20020a17090a17ef00b0025c238650d1si24212pja.174.2023.09.13.13.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KmkCiurj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 A496E83F5327; Wed, 13 Sep 2023 11:38:21 -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 S231963AbjIMSiR (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231897AbjIMSiA (ORCPT ); Wed, 13 Sep 2023 14:38:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A95C11BC6; Wed, 13 Sep 2023 11:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630276; x=1726166276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1QD1hfFNbY0dgb7El0Aw5L89YdqnDMRaACvnIzni/zs=; b=KmkCiurjD4OIJKYPCtR1x2bAZOtz1apLafTigQ6XdFkPtp3T0XfrOx/N 0cX645alEVU7+tytPxmwZOM1rh0IBUJNlAeZoYPxZ5insLq31iiMlu5T2 j6qL+8unc5Kqlti+IH7Kv0PgQKkB6xldueGN5YS/pRWR597H61WgT8+3V gSqdxCrCge8YE43qdeH3WgIJXof9mgEgFQwmCKgO/7b4R0juaJXm4DfI+ yANAoRumD4Qc4r3gn3Nv4K+m6l0JjxmT221j0SRnfNFG5I8HAhVQgT0Ha E17oB+vXiKRk2D22tiGm3vTsp0HKGnuytP291bGEgG0zTXyWHiTxHo2Uy g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019171" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019171" 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:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238590" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238590" 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:55 -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 06/10] platform/x86/intel/ifs: Validate image size Date: Wed, 13 Sep 2023 11:33:44 -0700 Message-Id: <20230913183348.1349409-7-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 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]); Wed, 13 Sep 2023 11:38:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776954305697691553 X-GMAIL-MSGID: 1776954305697691553 Perform additional validation prior to loading IFS image. Error out if the size of the file being loaded doesn't match the size specified in the header. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/load.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index e8fb03dd8bcf..778a3b89a24d 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -376,6 +376,7 @@ int ifs_load_firmware(struct device *dev) { const struct ifs_test_caps *test = ifs_get_test_caps(dev); struct ifs_data *ifsd = ifs_get_data(dev); + unsigned int expected_size; const struct firmware *fw; char scan_path[64]; int ret = -EINVAL; @@ -390,6 +391,13 @@ int ifs_load_firmware(struct device *dev) goto done; } + expected_size = ((struct microcode_header_intel *)fw->data)->totalsize; + if (fw->size != expected_size) { + dev_err(dev, "File size mismatch (expected %d, actual %ld). Corrupted IFS image.\n", + expected_size, fw->size); + return -EBADFD; + } + ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data); if (ret) goto release; From patchwork Wed Sep 13 18:33:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139042 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp29710vqb; Wed, 13 Sep 2023 12:13:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSIiw5wmKDVSCZm1hj+k2+8EzWXUSH3IkLcQaB2BPfrNp7tzHo5XCYmd8DflqwsMj7xwNT X-Received: by 2002:a05:6a20:8e0b:b0:14b:f365:288a with SMTP id y11-20020a056a208e0b00b0014bf365288amr3951164pzj.47.1694632389240; Wed, 13 Sep 2023 12:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694632389; cv=none; d=google.com; s=arc-20160816; b=BzOiJULc5CFViEvIk4B3ppXXmFtMtJw2rd6RfOoPzNNscGI6/6r0+Eiqsz+xb/GxOX GHRr6f14dVRe4EpLbsSORR8tSd19YIve9nLHB4PTm2nFNuVy20dGJeDqamxQ/qjvANXE BaH+jxNftFf7Dh9pIq0BK5pB9uQ7HPwwHgr/89td2yFACQPKLUPrGN6v1ygUoQjmnBR1 GtnHJVdv8gv1cB7a/jb0xY07DJiX5fB1tacCGNCxR/Kn/Eloq2F+TMaRLASMBFhNhqoD StCfvHRc7RObEKECNNbHPvdgtj4gQDvZfNz5wzBKNSiFeWKNLDCNfqSpvWL0ZNPuaES0 wH+Q== 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=NZFJ4o5mm7FUH+JVrXnTP4TPi/EPJAj11O68yJJRzQo=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=yOqU3SabzZv6UUVz/tNAMUZb0QXo3b3/iiY/V7Aw01iITC9dV/BeADrQpSxJ4nduIu s+pRhg/tWzfAUrWuUTf514jvT68gMZIeOMvYlYSZwITeIyE598P2plmwlNO7oQLvKcdI RdcOs1TPYbsshSP67YOipA3QjFjEkz6/5jhCOgNeIHRyXZRRPxWluyd0QYIueZvuI7Mu 1+VbdvIZ9Xp6EHz5VhO1Lvvt7hi2Ww8Yr4WWZHtKVwTSn9nwXrZsvz5/7hw5pa53lugw OHeu4nQlM6K/H7XbjH3A0RyFvNKxktgplaFroeue+8qz5RJN25dE3DwRhRcoZzFBU3Xh TB5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DWixgxhi; 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s12-20020a170903200c00b001bc650255b6si10157009pla.390.2023.09.13.12.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 12:13:09 -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=DWixgxhi; 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 09F1F83F531F; Wed, 13 Sep 2023 11:38:23 -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 S232010AbjIMSiV (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbjIMSiB (ORCPT ); Wed, 13 Sep 2023 14:38:01 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C58BA3; Wed, 13 Sep 2023 11:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630277; x=1726166277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=27uuSgwznKYWiVr2rzZGk8zPvF6mY8zY3sne3jlCPzw=; b=DWixgxhi9Wc+QQu863a2xfIfb363nxibe+8INkzu0gFUZFgQ70wDmh3X Pl8vH6ho2uuh5E6YIyBHYtxZBAnzIWv2uiaBCwm8Iuy0IABqvg0Y8NAD0 MjbCqk1Axs859rylCYxs56pPDGUpH97X9at0VZ6m23yQz15IKx0AmGwPB amOk7X4x+Eo4XEcLT7ORH0flqiuy5McpGsdtST+/VBEXc/+Q79zqL0elg T98mZitDM8wvJbgrHUq57DkDSltjXpcThkHTRhINQCadQx/w/bDtVPrZ4 V7+jMi2s6ePiWy6/WjSXH6TTppKsh68ZgUuzzyjC0nedulJGGAPyI9NQn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019182" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019182" 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:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238595" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238595" 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:56 -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 07/10] platform/x86/intel/ifs: Metadata validation for start_chunk Date: Wed, 13 Sep 2023 11:33:45 -0700 Message-Id: <20230913183348.1349409-8-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 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]); Wed, 13 Sep 2023 11:38:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776950852170563737 X-GMAIL-MSGID: 1776950852170563737 Add an additional check to validate IFS image metadata field prior to loading the test image. If start_chunk is not a multiple of chunks_per_stride error out. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/load.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c index 778a3b89a24d..88630366a23c 100644 --- a/drivers/platform/x86/intel/ifs/load.c +++ b/drivers/platform/x86/intel/ifs/load.c @@ -292,6 +292,13 @@ static int validate_ifs_metadata(struct device *dev) return ret; } + if (ifs_meta->chunks_per_stride && + (ifs_meta->starting_chunk % ifs_meta->chunks_per_stride)) { + dev_warn(dev, "Starting chunk num %d not a multiple of chunks_per_stride %d\n", + ifs_meta->starting_chunk, ifs_meta->chunks_per_stride); + return ret; + } + return 0; } From patchwork Wed Sep 13 18:33:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp69423vqi; Wed, 13 Sep 2023 19:43:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQz0JdAH4b9VrViNTppt5ioL2M6fCZU3eA2/hdzeq3lLT63FX59s9CgiWs8uuG2ztw6N82 X-Received: by 2002:a17:902:d504:b0:1c3:e3b1:98df with SMTP id b4-20020a170902d50400b001c3e3b198dfmr5409016plg.52.1694659433899; Wed, 13 Sep 2023 19:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694659433; cv=none; d=google.com; s=arc-20160816; b=FiH2muiXxl/lL2LlbsjHVY+GMOftausTMk2NKHQ4TgP0m+KTFrz3JH07Ya29+PBUsz fpbsU571oqYbOv/MKg5jOs9Y9NF0QcDqzRkbJ6vG2gT59JTK50e8GwLEx0T/dahkVXWi CNUFbCJnzKESgGTZTOdMAdh/vRVE9qgefpsoJmtXhfbTXQxGBe2sUNEj/VMql0KOfnXM GakYjpv+NAJ01r7K8womrHB63x5JOh3lwGrjOiFhI8RqsR5UoTGwWD6ASGUdooYm79YF gdlqIo/ckBUCL66VeHRoJB/sX9jmX1RyoNEjBz47MNb5vdIOYn0v2/h4tuQMdmwDUTNV yOBw== 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=bG49Q1lHa7nPOXn0aYmsCjCq5ASr7/pIGqGbOAfJ694=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=O7jSbL7zroDGPGhgj5jnnvmqofS9oVXyKFkt1LlxsH37/v3CE6/YVMceP9tXYEzJGI aj9zm97qSTjR6CUOgjCM06CQkIuuzA3glkLeDr6QNhTdsB/oxEk7jq/2e8bk3C7RQXy+ H443KvLuhNHcT+lgDBWqggmC81frxT5DJOtdRYT+3GxlKd1t2R+kPP8Z50FixEEedv53 lA8sbf678blz8jXcFB3fYStKWMBVYSxahATr6eNo7iCgO35Ta4gtvmvNqtQrIR3SiPuP tiAcpKe+n5fKfattcbVQ8BQJnPROQq7IIO7zdR61wh54qS8K/Yh8bDyb/a8mlbArGuFA BTWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=auO6pXmC; 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f18-20020a170902ce9200b001bbd0358ef7si715295plg.518.2023.09.13.19.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:43:53 -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=auO6pXmC; 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 C920E822CE24; Wed, 13 Sep 2023 11:38:24 -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 S232070AbjIMSiZ (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbjIMSiB (ORCPT ); Wed, 13 Sep 2023 14:38:01 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744A41BC6; Wed, 13 Sep 2023 11:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630277; x=1726166277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fMds6ddtYEBj87eO05LdIcscm0u5ZaXyeSf+N8ojEGg=; b=auO6pXmCmenFztpsy9+ckvI/xQ0FPZJzXmEQoZmLtkJZihAB9okK35aY GBpUPUXgP70O+OeKF59r4rHDM3ku4S9kog+/SSBbsdnvpcaJuws4UQWTj CEEg97KreB+Tr2jXYAueJ3pWHlcAIgACJpis61ZEr6zeyYxW6mAoKh1Yd 8FuYMM8yr1Uv+5nlds/+bkmtMFcgglnIpr9Sss75Iy+M45aSi1y+fJvoN ltzccMZ/MRWWqktAjfQ66JX3C63EccbyNw9Faz4ZkCe+ga8+QW0D3y3Nn Tl5M+HurHW28FjeYeBS3opwNfjCY2Cicu9bUTVOEIPpwrydN8QhivBmNU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019192" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019192" 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:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238599" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238599" 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:56 -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 08/10] platform/x86/intel/ifs: Add new CPU support Date: Wed, 13 Sep 2023 11:33:46 -0700 Message-Id: <20230913183348.1349409-9-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 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:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776979210166214178 X-GMAIL-MSGID: 1776979210166214178 Add Granite Rapids and Sierra Forest cpuids to x86 match table so that IFS driver can be loaded for those. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index 88d84aad9334..0938bfbd9086 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -17,6 +17,9 @@ static const struct x86_cpu_id ifs_cpu_ids[] __initconst = { X86_MATCH(SAPPHIRERAPIDS_X), X86_MATCH(EMERALDRAPIDS_X), + X86_MATCH(GRANITERAPIDS_X), + X86_MATCH(GRANITERAPIDS_D), + X86_MATCH(ATOM_CRESTMONT_X), {} }; MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids); From patchwork Wed Sep 13 18:33:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp26437vqi; Wed, 13 Sep 2023 17:42:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHalCOkLYQ0rOpbvggnW0x80CtlTKn42drhtTbqWOIp4P+1iIyhu/GEpkjH9xU+AqaP6iWK X-Received: by 2002:a17:903:1104:b0:1c0:c86a:5425 with SMTP id n4-20020a170903110400b001c0c86a5425mr4964968plh.19.1694652147094; Wed, 13 Sep 2023 17:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694652147; cv=none; d=google.com; s=arc-20160816; b=T1CLkegej6oS2o2nvTT+8VU29Fej2QazF62Huuw5z3EaxPUOooQyEKGEKGv09SDrmB 2KS3SltILiAVkVURDjC2yulojHarW4gcOnejXwGTCZ7c7nEH5KOq0qq5nxDXtJjnpkLS 1iIpi6lj6B7QZlNsQsAFn5qtlKIaBvj1U4EkmV6grdHnPhfJ/eiwVjhlm7V9TKipM+sW XXWdruvoOkDPWbRuoo2Zr6vA+VKvoIhH1lOCN+olDb88eUsLmjOdO1faYDMna1MEf4UP lZ0vwB+4TGNLI4NDTNdx5UsyXEStiKjyPTGa344HaV56xkJwMoutzkisOAx59172NktP pTRA== 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=DyC+xV0PgVoYWPw6gMwPuHtGiNljTWAakUXdBoA1lTs=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=VVO+fJB4wUAD/kXliei+j8C/xNkeqB5RQqSqFYrFIdkg9uYvfprLqzrp2rmsDV3ag+ UU7Q6au40DMEIZyHoVJGLQPtca7nPM9wp2GOi+0EBIzKV09Wvzi0y5qSc3NSIGpNiSgt 4K9vF8tDK1Fw6+KmD2I2SUSBQOYx+gOtTMrhCGgOTZ8Px6nU+iihUKHRqRrKH5MygbF2 /yqGSnVSgiZfMze6xmovpXkW/v5zX/AayWlF3t/FFg85PwQX/u71WURhDixx+OgmRFND dF2OTTckDZvE3r8ZypNdTPKgS0+HENrhLqBOqk9k93CyAWbEsK61AWeyYOp4p2/5S0x4 gW6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f3fC0vmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id p12-20020a170902c70c00b001bdc8611801si451092plp.186.2023.09.13.17.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 17:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f3fC0vmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 F3CEA83F0297; Wed, 13 Sep 2023 11:38:24 -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 S232042AbjIMSiX (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbjIMSiB (ORCPT ); Wed, 13 Sep 2023 14:38:01 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E763EA3; Wed, 13 Sep 2023 11:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630277; x=1726166277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xI88hAM69WWRoFYmYgNa2YKj3tBz+3B5FzPZW/C4gzc=; b=f3fC0vmL1vzgRRu8q2gAd2+/f9HiVV3nbItRn5aKArpYKX7Tw76Q1UAz V9diXBYhVt57EQT1X0BYreK5WzGl2EtT2QpTeHMFeXEOB2WnbMH4vgZwW sjXGegrxqEz/j2bsaFgWT/nxLHQ8Bgj7gvqW3bzNlN/8DzqG7DUFQMLpH D8f9Ys7cODwEX+FJljER66uwf75Bi1I42G+BT5EioKLjAiUX7K7ajnZlK DmnQJ1EGH8q6TPyWfk5GhtkpjZX9rz/cBueEWBCdOtFy0lG+4mT2+9elf nTaaTX4mZFQviQz57WV/sYdeejCtqNUPm9b1ICbsS9ugkwY+Eb1O1eI8r Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019203" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019203" 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:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238603" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238603" 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:57 -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 09/10] platform/x86/intel/ifs: Add new error code Date: Wed, 13 Sep 2023 11:33:47 -0700 Message-Id: <20230913183348.1349409-10-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 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]); Wed, 13 Sep 2023 11:38:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776971569808652751 X-GMAIL-MSGID: 1776971569808652751 Make driver aware of a newly added error code so that it can provide a more appropriate error message. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/runtest.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index ba3f9ad88a82..997d2f07aa0c 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -40,6 +40,8 @@ enum ifs_status_err_code { IFS_UNASSIGNED_ERROR_CODE = 7, IFS_EXCEED_NUMBER_OF_THREADS_CONCURRENT = 8, IFS_INTERRUPTED_DURING_EXECUTION = 9, + IFS_UNASSIGNED_ERROR_CODE_0xA = 0xA, + IFS_CORRUPTED_CHUNK = 0xB, }; static const char * const scan_test_status[] = { @@ -55,6 +57,8 @@ static const char * const scan_test_status[] = { [IFS_EXCEED_NUMBER_OF_THREADS_CONCURRENT] = "Exceeded number of Logical Processors (LP) allowed to run Scan-At-Field concurrently", [IFS_INTERRUPTED_DURING_EXECUTION] = "Interrupt occurred prior to SCAN start", + [IFS_UNASSIGNED_ERROR_CODE_0xA] = "Unassigned error code 0xA", + [IFS_CORRUPTED_CHUNK] = "Scan operation aborted due to corrupted image. Try reloading", }; static void message_not_tested(struct device *dev, int cpu, union ifs_status status) @@ -123,6 +127,8 @@ static bool can_restart(union ifs_status status) case IFS_MISMATCH_ARGUMENTS_BETWEEN_THREADS: case IFS_CORE_NOT_CAPABLE_CURRENTLY: case IFS_UNASSIGNED_ERROR_CODE: + case IFS_UNASSIGNED_ERROR_CODE_0xA: + case IFS_CORRUPTED_CHUNK: break; } return false; From patchwork Wed Sep 13 18:33:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 139032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp12460vqb; Wed, 13 Sep 2023 11:45:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcVK3etyOUDlf7+/Gl6QJqEoYeWsY+x0ES9ySiRPNq9PmjIjKexYHbWKh3eNL6xziaGfVa X-Received: by 2002:a05:6358:6f86:b0:134:c650:cc0a with SMTP id s6-20020a0563586f8600b00134c650cc0amr2870176rwn.15.1694630744062; Wed, 13 Sep 2023 11:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694630744; cv=none; d=google.com; s=arc-20160816; b=KIQnnd1tBqdecd+MjpAdcd9NGzOEeSRhsRvPmb5bJKWKrXFjRz+DFBlyZ+mW+Ubrbz XWrxA2hPZdmq40SESVuwV0osR8/L9aBIaSLu0JsWOwXQi8bOSOEptUuDl7y3yzVbC8QG QBnzSMmXiksXV3zVrZAVtjtzQP5xuvPbSjQr/+sXSciW5vmu/UHNpaQNmbKmM5wOWlSE K2/pm856y7iuICGGCRePA2zCM05+D7xtz8JGM9gLlnozZtTrDVID2yNNZxvMNg5dCEuH 9FwSBRBuJrMVJiZAA0cREJHDeuqrySmDiqURpQazKn0VNi4t6i/ku/wUikqfLVWuZhHQ 1okQ== 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=I7MBgiNzBO90OfAAEN+/NivWfoOx6PXMPq3wrtNbeqM=; fh=8xS9zNNEexx7KHEczBpq5wXIDtxA/g5mXnxETx6X+p0=; b=dUMK5k72zFcDaiW/6L9UwPXg+fBd5V38NCNFkq+RNYTP58FmyRPMQ+hEEQux/OPdk3 3oN6YWXBzT84XMAAh1r+1GgZ9K10jkZ/feAMtaHKwVymTCp+cr8wL6BdkhJk2XvpAEdf GCaet2X5NlPkxr54KO2R3YAtoss63NlRNTUhFWXxEAx6mfNzLz1YV8gWrlSbLfBjMqFy P6/hEsz7WJeE2lJtDrEsfW6uXjdhHmmjukixIYMblqrxQYXuqmh2SBOdXvQ4e6aPt/v/ Ib/6I9RAjXE4P/fWb3v1brfJHgynJVX4GdsPOsMWJAV4x4uh6u9Amba68bTN1uCXVBkf MAow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EBL9DFrl; 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id k73-20020a636f4c000000b0056c4d97e152si10481296pgc.68.2023.09.13.11.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:45:44 -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=EBL9DFrl; 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 5AEE4844D4F4; Wed, 13 Sep 2023 11:38:34 -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 S231982AbjIMSi1 (ORCPT + 34 others); Wed, 13 Sep 2023 14:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbjIMSiC (ORCPT ); Wed, 13 Sep 2023 14:38:02 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71DF51BCA; Wed, 13 Sep 2023 11:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694630278; x=1726166278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EjDox062EDhdZ+SfdzKgsTzvA5pkiDGzCn8j0HCk/Ec=; b=EBL9DFrlx/JtolH2StcwXFQdYscbhb+WjWSOcUKhahrSwEebs+Nhsnze zNlfrbbbgaLs+T6+Vec61SzySXlZslpF8d79YirO7wiC8Agcswbnwq+Rz 94x4E+soRh058eqBmDHPwTbgWygc5MMBk0IQNi+oDFtOU+SmNwT/tQ2yD 7XvZzPlnEkwDsNYTp/lIMb/VJQFg1YzATM3thBWRjfwNEqPJIAnOZ18A1 bbS8XJmNPFtv8KVNdxq02z4qnrs7EYflmsz+vHc9S8RcAVBcH3EZucuQ8 2hutSuNpCmlGWjD5rWmQzAcCgJRdxQJENmGSiqLSbl92XMm4mAxnoG8bj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="369019212" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="369019212" 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:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="744238606" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="744238606" 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:57 -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 10/10] platform/x86/intel/ifs: ARRAY BIST for Sierra Forest Date: Wed, 13 Sep 2023 11:33:48 -0700 Message-Id: <20230913183348.1349409-11-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 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]); Wed, 13 Sep 2023 11:38:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776949126708072897 X-GMAIL-MSGID: 1776949126708072897 Array BIST MSR addresses, bit definition and semantics are different for Sierra Forest. Branch into a separate Array BIST flow on Sierra Forest when user invokes Array Test. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck Tested-by: Pengfei Xu --- drivers/platform/x86/intel/ifs/ifs.h | 4 +++ drivers/platform/x86/intel/ifs/core.c | 15 +++++----- drivers/platform/x86/intel/ifs/runtest.c | 37 +++++++++++++++++++++++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 3265a6d8a6f3..2f20588a71f1 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -137,6 +137,8 @@ #define MSR_CHUNKS_AUTHENTICATION_STATUS 0x000002c5 #define MSR_ACTIVATE_SCAN 0x000002c6 #define MSR_SCAN_STATUS 0x000002c7 +#define MSR_ARRAY_TRIGGER 0x000002d6 +#define MSR_ARRAY_STATUS 0x000002d7 #define MSR_SAF_CTRL 0x000004f0 #define SCAN_NOT_TESTED 0 @@ -270,6 +272,7 @@ struct ifs_test_caps { * @cur_batch: number indicating the currently loaded test file * @generation: IFS test generation enumerated by hardware * @chunk_size: size of a test chunk + * @array_gen: test generation of array test */ struct ifs_data { int loaded_version; @@ -281,6 +284,7 @@ struct ifs_data { u32 cur_batch; u32 generation; u32 chunk_size; + u32 array_gen; }; struct ifs_work { diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index 0938bfbd9086..e8b570930c16 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -10,16 +10,16 @@ #include "ifs.h" -#define X86_MATCH(model) \ +#define X86_MATCH(model, array_gen) \ X86_MATCH_VENDOR_FAM_MODEL_FEATURE(INTEL, 6, \ - INTEL_FAM6_##model, X86_FEATURE_CORE_CAPABILITIES, NULL) + INTEL_FAM6_##model, X86_FEATURE_CORE_CAPABILITIES, array_gen) static const struct x86_cpu_id ifs_cpu_ids[] __initconst = { - X86_MATCH(SAPPHIRERAPIDS_X), - X86_MATCH(EMERALDRAPIDS_X), - X86_MATCH(GRANITERAPIDS_X), - X86_MATCH(GRANITERAPIDS_D), - X86_MATCH(ATOM_CRESTMONT_X), + X86_MATCH(SAPPHIRERAPIDS_X, 0), + X86_MATCH(EMERALDRAPIDS_X, 0), + X86_MATCH(GRANITERAPIDS_X, 0), + X86_MATCH(GRANITERAPIDS_D, 0), + X86_MATCH(ATOM_CRESTMONT_X, 1), {} }; MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids); @@ -99,6 +99,7 @@ static int __init ifs_init(void) continue; ifs_devices[i].rw_data.generation = (msrval & MSR_INTEGRITY_CAPS_SAF_GEN_REV_MASK) >> MSR_INTEGRITY_CAPS_SAF_GEN_REV_SHIFT; + ifs_devices[i].rw_data.array_gen = (u32)m->driver_data; ret = misc_register(&ifs_devices[i].misc); if (ret) goto err_exit; diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 997d2f07aa0c..9cfd5c015cb2 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -327,6 +327,38 @@ static void ifs_array_test_core(int cpu, struct device *dev) ifsd->status = SCAN_TEST_PASS; } +#define ARRAY_GEN1_TEST_ALL_ARRAYS (0x0ULL) +#define ARRAY_GEN1_STATUS_FAIL (0x1ULL) + +static int do_array_test_gen1(void *status) +{ + int cpu = smp_processor_id(); + int first; + + first = cpumask_first(cpu_smt_mask(cpu)); + + if (cpu == first) { + wrmsrl(MSR_ARRAY_TRIGGER, ARRAY_GEN1_TEST_ALL_ARRAYS); + rdmsrl(MSR_ARRAY_STATUS, *((u64 *)status)); + } + + return 0; +} + +static void ifs_array_test_gen1(int cpu, struct device *dev) +{ + struct ifs_data *ifsd = ifs_get_data(dev); + u64 status = 0; + + stop_core_cpuslocked(cpu, do_array_test_gen1, &status); + ifsd->scan_details = status; + + if (status & ARRAY_GEN1_STATUS_FAIL) + ifsd->status = SCAN_TEST_FAIL; + else + ifsd->status = SCAN_TEST_PASS; +} + /* * Initiate per core test. It wakes up work queue threads on the target cpu and * its sibling cpu. Once all sibling threads wake up, the scan test gets executed and @@ -354,7 +386,10 @@ int do_core_test(int cpu, struct device *dev) ifs_test_core(cpu, dev); break; case IFS_TYPE_ARRAY_BIST: - ifs_array_test_core(cpu, dev); + if (ifsd->array_gen == 0) + ifs_array_test_core(cpu, dev); + else + ifs_array_test_gen1(cpu, dev); break; default: return -EINVAL;