From patchwork Tue Jan 31 23:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 51102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp98026wrn; Tue, 31 Jan 2023 15:45:47 -0800 (PST) X-Google-Smtp-Source: AK7set/F1xVnNvnr9qivGxme+OXifHHPUd0AksnnjfE+uywFPg+bcYvLCv0Ceak8apBh1QCal/DK X-Received: by 2002:a17:906:ce2c:b0:7c1:4d35:a143 with SMTP id sd12-20020a170906ce2c00b007c14d35a143mr4599433ejb.3.1675208747067; Tue, 31 Jan 2023 15:45:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675208747; cv=none; d=google.com; s=arc-20160816; b=CvC1fWCAXL65hmKKCzYjvpgnTB/+i+oDnz7ccGVzckD+ek17RQgtzW022xScvkMZSc BJ7K736YpjM54D7bdQFcGNGo72JfTa8g8J1TVsY2XXCyVIq8t6+TpdC//SWy6Y6YQ5eL OyYb4srpvJtEUGYRi4z1lSh2Ms05wVX7gQThWPK71k/vinRqOdV34G+3SRPJMA/1+Luo tty4L7HjaPEHsCMY8gRlmZfQ4NCUBk2yDZGT2BiYuc6LiPORhXLwPSCV6vipyKy4SWwP zOi3GYWC9GRHuBbeAZONOxDDh+UWXUn9rn7WZQyGiRmg5FNUT3ufE5yFlHeai+/RwwUo Sq7A== 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=KlZNF4bJMw7wDyGGkwEVCDxJp7qpc08PsOuSDPDhJJc=; b=WwOUAzRkVaafpYJ3bvVZ6D4S+AcTWWrxbbj1KbR/Kq3BAaLJPeRARXvb2XFDykoP0z iKos1Yh5GlCwPu0cdx2piAYoAMmXDJPnaJWED/KNoyN8DvbBr3r+WMJ5QY2AHUNi0rV9 xTRh6nps/9MBatK0I2cj7wPORypy9XEhl1880AjD1vZMHLoKNaYTIqRkiuBowOh3VQTs g9SF4JTcruXGs4x756UF31ltxz5HRGqcWJMCjn2CU221otiyRjJ1uYTC/4kSmU6ehQQ/ PRPgnN9vBieBxoUhk4cjV3JNI7xo6idwltMgFMy3obTbzqQStcSynGVtAGJsarVQZK98 ysfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="H0Bz/4BM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ms15-20020a170907620f00b0087bca83172asi4470586ejc.320.2023.01.31.15.45.23; Tue, 31 Jan 2023 15:45:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="H0Bz/4BM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbjAaXpA (ORCPT + 99 others); Tue, 31 Jan 2023 18:45:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbjAaXo5 (ORCPT ); Tue, 31 Jan 2023 18:44:57 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70B74C6EF; Tue, 31 Jan 2023 15:44:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675208696; x=1706744696; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RJlwSFVpT1cewwIwRvUfBxfg5OygWbxR/zFOIt+ZgzQ=; b=H0Bz/4BMZ9c6loNizuD1/ey0E+v97kR7DYOxwAXEwSIoyWb7GoljGFlC 9Crv29lOZ+4h3JeIfuNnq3w25PNhjF5CGpLje1iTJmbJWN5XdBC+qtqdD 9bzn7W7ckOSFosGVEJcZcQOpAvNtL2sC5vsok0g0Emn5k9Qna1Gu8l/wu VQv/Nq40EpUJFwDrNCc8RL7Z9IlhJFQ8NQ6J9iTuVtNcnQSnUbPaAIoGr eCsWj62EyRYxlQf5d4cdQuYQPakChQgrct7hrv/x2UVV6lwjT7YUCw5co C7E6OpzDr9AQTI1MkJcVrjlFWpShm8qt5o3z4ENbIGzgQY4Iuy0hWThJh A==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390360415" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="390360415" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="773192024" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="773192024" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 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, gregkh@linuxfoundation.org, 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, thiago.macieira@intel.com, athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com Subject: [PATCH 1/5] x86/include/asm/msr-index.h: Add IFS Array test bits Date: Tue, 31 Jan 2023 15:42:58 -0800 Message-Id: <20230131234302.3997223-2-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131234302.3997223-1-jithu.joseph@intel.com> References: <20230131234302.3997223-1-jithu.joseph@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756583687208982608?= X-GMAIL-MSGID: =?utf-8?q?1756583687208982608?= Define MSR bitfields for enumerating support for Array BIST test. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck --- arch/x86/include/asm/msr-index.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index d3fe82c5d6b6..ad8997773ad3 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -197,6 +197,8 @@ /* Abbreviated from Intel SDM name IA32_INTEGRITY_CAPABILITIES */ #define MSR_INTEGRITY_CAPS 0x000002d9 +#define MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT 2 +#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) From patchwork Tue Jan 31 23:42:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 51103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp98452wrn; Tue, 31 Jan 2023 15:46:54 -0800 (PST) X-Google-Smtp-Source: AK7set/15UzceLAQxSl91tFB+tu25wd+1u6lTU4C4MiIFxoyoxx/ku9qejQtVxR8qJ9ajpNqVSwK X-Received: by 2002:a17:906:c411:b0:884:d15e:10f0 with SMTP id u17-20020a170906c41100b00884d15e10f0mr216775ejz.23.1675208814756; Tue, 31 Jan 2023 15:46:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675208814; cv=none; d=google.com; s=arc-20160816; b=G2IdtHFhYyl5bwjfogx+77htBe1eAoYmZoVY9rWlYqSaJOM4MVySaS6vA3pX1jbHMs swK8+TGZPHWpfiUx1G1tVIPVNoC8twGcyZfMDh2WmeezbozjVtqWcgrlKugqZINAm238 GXQ2kUBwcwQRnJywjaySrzPvpqQzBONBaXTpZaavsqchHAmnCKGPagXwTzcfa8b+f/tP ewr+1l6q/MND10nLcpgDBDcsvBskKs68NsQfg4rv0gVM+gj7ZSQ6kJYf46Dn9e5IeY1C jQIDiXAZUrLOhx6UnoGlx7NQ+A1QriUpp936nK+UmD97UrKuLdpxYCM76zoagN225CYM nLsQ== 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=mQ0HfA4yudtc0r3xSa6QEe9zY2R6Lo4G2gfoZJPMCmU=; b=SQiDkE8vDRVaPqIRYifhADuBsUKKVfcnZzTmG9nusfYaeo1OdAXy95P84aYC8lAiF1 UfVwgKjxCiH5HVnKhoyRlwS5PwNmtxnvJzW9NkKy0F0H8T0BgU5oVkIEZ/4dWrD4vh6e JQKaS1JZ5cAA0/qYFLCFAZ9GmJt7jpWPAJGRqpiJx2nkFo34Lj2ebbcDV5OZOfG8AX9H KiMSNTnd21YLt7vfFLYrWNEKAUX4xQDgXLcT1Kjo8Qs0cuTHPTk2mY0XmH9Uj6SCAHKv IaE8LeMHxE3FtbKDW3gqW2Tl3gB+V1CWPMr+bViFmDjgp8X5TVZXs4i7HqW8Br7bGHxt w5Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="T+/5KMma"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a056402321900b004a245025d2esi9298538eda.278.2023.01.31.15.46.30; Tue, 31 Jan 2023 15:46:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="T+/5KMma"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbjAaXpD (ORCPT + 99 others); Tue, 31 Jan 2023 18:45:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbjAaXo6 (ORCPT ); Tue, 31 Jan 2023 18:44:58 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8744DE03; Tue, 31 Jan 2023 15:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675208697; x=1706744697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mvhv6zkaH9H97cKt0p0n94x4bwBzoDv9AW5TNmZ4ZsU=; b=T+/5KMmazvK4W1YlOvzqkYJ9oBt8KMXf/DCduU0FCxDTrUIdfJ6KjiZ8 plEmjFj5n75xDgcb1QF/ypZIIVWE6NY5m4/Xx1fH3qtm0eUUyKDfGSmtJ ISUpjFpVvJ1jhwRvwgu6ChzQqzyTmkgh3LagLKnNg/+f3yKZ8GPjfSKR2 xWkBJfP5fysz2A71BONdA403MMeRZk3K9Eft39nW5ncqKAFr9k11pVqhX n+s7CvHpiDn3MDg0pmdc7XWag66psftJY9dHoVLeD/agItXDj7JhzDH5t mm9RaqvwSmmx+Y/Bpd5BCAzjWyfLugPNyRHe9Wz4+Em1qxdT91RjiW5CY A==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390360422" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="390360422" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="773192027" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="773192027" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 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, gregkh@linuxfoundation.org, 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, thiago.macieira@intel.com, athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com Subject: [PATCH 2/5] platform/x86/intel/ifs: Introduce Array Scan test to IFS Date: Tue, 31 Jan 2023 15:42:59 -0800 Message-Id: <20230131234302.3997223-3-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131234302.3997223-1-jithu.joseph@intel.com> References: <20230131234302.3997223-1-jithu.joseph@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756583758392248897?= X-GMAIL-MSGID: =?utf-8?q?1756583758392248897?= Array BIST is a new type of core test introduced under the Intel Infield Scan (IFS) suite of tests. Emerald Rapids (EMR) is the first CPU to support Array BIST. Array BIST performs tests on some portions of the core logic such as caches and register files. These are different portions of the silicon compared to the parts tested by the first test type i.e Scan at Field (SAF). Make changes in the device driver init flow to register this new test type with the device driver framework. Each test will have its own sysfs directory (intel_ifs_0 , intel_ifs_1) under misc hierarchy to accommodate for the differences in test type and how they are initiated. Upcoming patches will add actual support. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck --- drivers/platform/x86/intel/ifs/ifs.h | 5 ++ drivers/platform/x86/intel/ifs/core.c | 70 ++++++++++++++++++--------- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 046e39304fd5..2cef88a88aa9 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -137,6 +137,11 @@ #define SCAN_TEST_PASS 1 #define SCAN_TEST_FAIL 2 +enum test_types { + IFS_SAF, + IFS_ARRAY, +}; + /* MSR_SCAN_HASHES_STATUS bit fields */ union ifs_scan_hashes_status { u64 data; diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index 206a617c2e02..ab234620ef4c 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -16,27 +16,44 @@ static const struct x86_cpu_id ifs_cpu_ids[] __initconst = { X86_MATCH(SAPPHIRERAPIDS_X), + X86_MATCH(EMERALDRAPIDS_X), {} }; MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids); -static struct ifs_device ifs_device = { - .data = { - .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, - .test_num = 0, +static struct ifs_device ifs_devices[] = { + [IFS_SAF] = { + .data = { + .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, + .test_num = IFS_SAF, + }, + .misc = { + .name = "intel_ifs_0", + .nodename = "intel_ifs/0", + .minor = MISC_DYNAMIC_MINOR, + }, }, - .misc = { - .name = "intel_ifs_0", - .nodename = "intel_ifs/0", - .minor = MISC_DYNAMIC_MINOR, + [IFS_ARRAY] = { + .data = { + .integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT, + .test_num = IFS_ARRAY, + }, + .misc = { + .name = "intel_ifs_1", + .nodename = "intel_ifs/1", + .minor = MISC_DYNAMIC_MINOR, + }, }, }; +#define IFS_NUMTESTS ARRAY_SIZE(ifs_devices) + static int __init ifs_init(void) { const struct x86_cpu_id *m; + int ndevices = 0; u64 msrval; - int ret; + int i; m = x86_match_cpu(ifs_cpu_ids); if (!m) @@ -51,28 +68,35 @@ static int __init ifs_init(void) if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval)) return -ENODEV; - ifs_device.misc.groups = ifs_get_groups(); - - if (!(msrval & BIT(ifs_device.data.integrity_cap_bit))) - return -ENODEV; + for (i = 0; i < IFS_NUMTESTS; i++) { + if (!(msrval & BIT(ifs_devices[i].data.integrity_cap_bit))) + continue; - ifs_device.data.pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL); - if (!ifs_device.data.pkg_auth) - return -ENOMEM; + ifs_devices[i].data.pkg_auth = kmalloc_array(topology_max_packages(), + sizeof(bool), GFP_KERNEL); + if (!ifs_devices[i].data.pkg_auth) + continue; + ifs_devices[i].misc.groups = ifs_get_groups(); - ret = misc_register(&ifs_device.misc); - if (ret) { - kfree(ifs_device.data.pkg_auth); - return ret; + if (misc_register(&ifs_devices[i].misc)) + kfree(ifs_devices[i].data.pkg_auth); + else + ndevices++; } - return 0; + return ndevices ? 0 : -ENODEV; } static void __exit ifs_exit(void) { - misc_deregister(&ifs_device.misc); - kfree(ifs_device.data.pkg_auth); + int i; + + for (i = 0; i < IFS_NUMTESTS; i++) { + if (ifs_devices[i].misc.this_device) { + misc_deregister(&ifs_devices[i].misc); + kfree(ifs_devices[i].data.pkg_auth); + } + } } module_init(ifs_init); From patchwork Tue Jan 31 23:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 51104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp98517wrn; Tue, 31 Jan 2023 15:47:05 -0800 (PST) X-Google-Smtp-Source: AK7set8oT0kqqzqDWrg/Fc7xAGUHLbOLDP7r31mf4A43mfHGwEVWEf6An92H19NsIbx0zkR5Y4HG X-Received: by 2002:a17:906:4713:b0:87b:d597:1fd5 with SMTP id y19-20020a170906471300b0087bd5971fd5mr174295ejq.75.1675208825209; Tue, 31 Jan 2023 15:47:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675208825; cv=none; d=google.com; s=arc-20160816; b=N7HeHjVDu5VjsdGsoNIRBjB6wOJdz7z3pem6E49MBv1qJcIcr4eOGiErlsRwanehEA +xMjtPDCthsOgutRSzx75YmvFLqGKJuXX6EvXnEFiKY2nXrgvo0HiWWqM3xDN2OPHDRx HrUfHVChbi3OGcy0fiI5p5C+I62CyH/epsaFqg7HLFr1gnwDsYkv3E2Epc9uKjB+VQNh iRQ3pCF2A3FQBMAgLPdB5mSMr41swbpFcFbyYFBzET7yOunDcvBYTgf2BI4h0WFKgCi+ ZUpFVPxMJLW5tezTDltR7xeqU1BUvq9BW355wS7Nn4qbSLwSlpuNtE4QLE+DeBLyX8oe LcQA== 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=M5XHsAC3ul2mAkOryo67gOMC/9A3gP+10FSLZZ4NlAc=; b=MTRF1Uq0e8Uq7EIClBemuJsZ4ui7YaXict/HxEXzJc46MMXlpozWaNYOKGvvenOIFi uqWr1an4OeO0XyiApha762IQH187BxYGQvyWOf37RMp1HoyePx1Uf5joZwaAcasXKbw6 xMyIn+TPTWt9lVymM/3mCo28M4cvcJyyjQ58uD9RBlPSHueo60OjEgf4AyzEPG9RVSVx fUDvN3rbksCWzGX3PYloGilI/gPKe87XRchBC/zvOF3avu2FxD3n4gOruQNlX1nm4eiZ bHpmYuRBjddpr8qFPnYn/paNySx0qi2t0cnJqXO7hmsCfcLq1nF08QJh1u9AD0NTrXD0 kGTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AORAxdgr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gc10-20020a1709072b0a00b0088c224bf5b0si3772814ejc.144.2023.01.31.15.46.41; Tue, 31 Jan 2023 15:47:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AORAxdgr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbjAaXpF (ORCPT + 99 others); Tue, 31 Jan 2023 18:45:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjAaXo7 (ORCPT ); Tue, 31 Jan 2023 18:44:59 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56E32B619; Tue, 31 Jan 2023 15:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675208697; x=1706744697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f9j1tac3fXJ7zWWtJKdbIWJZZUO6h9XAWqOwYcAGIU0=; b=AORAxdgr/PRbTMMk44zmmftLJ1g4sXfqXgsCD+1C4NWYy4w+HI5lHxEV PmMfIqBtcBTzeLobgnVtcqrqj3U28pwx6u0dxm2oprmUInq5U1jdn4fFR 0BS+nf9x/jgtMgEc5fSO1f8IrhAUBl/s5iTj8oirNYnsbGZxJAOlvjrB0 iXZd/QnBbOYkCJng5jFbqH/HwuT6erC2JlYeaHpju39OxxgwtTifo5r/t lrPzSaMianq/38kXgGxS+k3JZUoG/q3a979Sc6mFkK+I3GrXBc4b7vKxw oTopSfR6fghtgNxksMl7NaINMAuUpG7bv3lnxQTUqckTpydC97uJfK5gQ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390360430" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="390360430" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="773192030" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="773192030" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 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, gregkh@linuxfoundation.org, 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, thiago.macieira@intel.com, athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com Subject: [PATCH 3/5] platform/x86/intel/ifs: Sysfs interface for Array BIST Date: Tue, 31 Jan 2023 15:43:00 -0800 Message-Id: <20230131234302.3997223-4-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131234302.3997223-1-jithu.joseph@intel.com> References: <20230131234302.3997223-1-jithu.joseph@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756583768866045221?= X-GMAIL-MSGID: =?utf-8?q?1756583768866045221?= The interface to trigger Array BIST test and obtain its result is similar to the existing scan test. The only notable difference is that, Array BIST doesn't require any test content to be loaded. So binary load related options are not needed for this test. Add sysfs interface array BIST test, the testing support will be added by subsequent patch. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck --- drivers/platform/x86/intel/ifs/ifs.h | 1 + drivers/platform/x86/intel/ifs/core.c | 18 +++++++++++++----- drivers/platform/x86/intel/ifs/runtest.c | 11 ++++++++++- drivers/platform/x86/intel/ifs/sysfs.c | 17 ++++++++++++++++- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 2cef88a88aa9..07423bc4e368 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -249,5 +249,6 @@ static inline struct ifs_data *ifs_get_data(struct device *dev) int ifs_load_firmware(struct device *dev); int do_core_test(int cpu, struct device *dev); const struct attribute_group **ifs_get_groups(void); +const struct attribute_group **ifs_get_array_groups(void); #endif diff --git a/drivers/platform/x86/intel/ifs/core.c b/drivers/platform/x86/intel/ifs/core.c index ab234620ef4c..2b7a49fd473d 100644 --- a/drivers/platform/x86/intel/ifs/core.c +++ b/drivers/platform/x86/intel/ifs/core.c @@ -25,6 +25,7 @@ static struct ifs_device ifs_devices[] = { [IFS_SAF] = { .data = { .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, + .pkg_auth = NULL, .test_num = IFS_SAF, }, .misc = { @@ -36,6 +37,7 @@ static struct ifs_device ifs_devices[] = { [IFS_ARRAY] = { .data = { .integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT, + .pkg_auth = NULL, .test_num = IFS_ARRAY, }, .misc = { @@ -72,11 +74,17 @@ static int __init ifs_init(void) if (!(msrval & BIT(ifs_devices[i].data.integrity_cap_bit))) continue; - ifs_devices[i].data.pkg_auth = kmalloc_array(topology_max_packages(), - sizeof(bool), GFP_KERNEL); - if (!ifs_devices[i].data.pkg_auth) - continue; - ifs_devices[i].misc.groups = ifs_get_groups(); + switch (ifs_devices[i].data.test_num) { + case IFS_SAF: + ifs_devices[i].data.pkg_auth = kmalloc_array(topology_max_packages(), + sizeof(bool), GFP_KERNEL); + if (!ifs_devices[i].data.pkg_auth) + continue; + ifs_devices[i].misc.groups = ifs_get_groups(); + break; + case IFS_ARRAY: + ifs_devices[i].misc.groups = ifs_get_array_groups(); + } if (misc_register(&ifs_devices[i].misc)) kfree(ifs_devices[i].data.pkg_auth); diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 0bfd8fcdd7e8..65e08af70994 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -236,6 +236,7 @@ static void ifs_test_core(int cpu, struct device *dev) */ int do_core_test(int cpu, struct device *dev) { + struct ifs_data *ifsd = ifs_get_data(dev); int ret = 0; /* Prevent CPUs from being taken offline during the scan test */ @@ -247,7 +248,15 @@ int do_core_test(int cpu, struct device *dev) goto out; } - ifs_test_core(cpu, dev); + switch (ifsd->test_num) { + case IFS_SAF: + ifs_test_core(cpu, dev); + break; + case IFS_ARRAY: + default: + return -EINVAL; + } + out: cpus_read_unlock(); return ret; diff --git a/drivers/platform/x86/intel/ifs/sysfs.c b/drivers/platform/x86/intel/ifs/sysfs.c index ee636a76b083..7cf32184ce6a 100644 --- a/drivers/platform/x86/intel/ifs/sysfs.c +++ b/drivers/platform/x86/intel/ifs/sysfs.c @@ -75,7 +75,7 @@ static ssize_t run_test_store(struct device *dev, if (down_interruptible(&ifs_sem)) return -EINTR; - if (!ifsd->loaded) + if (ifsd->test_num != IFS_ARRAY && !ifsd->loaded) rc = -EPERM; else rc = do_core_test(cpu, dev); @@ -156,3 +156,18 @@ const struct attribute_group **ifs_get_groups(void) { return plat_ifs_groups; } + +/* global array sysfs attributes */ +static struct attribute *plat_ifs_array_attrs[] = { + &dev_attr_details.attr, + &dev_attr_status.attr, + &dev_attr_run_test.attr, + NULL +}; + +ATTRIBUTE_GROUPS(plat_ifs_array); + +const struct attribute_group **ifs_get_array_groups(void) +{ + return plat_ifs_array_groups; +} From patchwork Tue Jan 31 23:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 51105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp100500wrn; Tue, 31 Jan 2023 15:53:26 -0800 (PST) X-Google-Smtp-Source: AK7set+o0MKWtx7PRL0ajwziR4mYzYmwqAkGO1U3y1+B1vcaFJE6hjEnn0N4hNoNBe9ITwuW9Nmg X-Received: by 2002:a05:6a20:d2c7:b0:b9:2705:4e46 with SMTP id ir7-20020a056a20d2c700b000b927054e46mr393913pzb.22.1675209205909; Tue, 31 Jan 2023 15:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675209205; cv=none; d=google.com; s=arc-20160816; b=BwfZemAGLnN2XY02lmIKG7Bu6/xSPWTt1RxhboUdPsFcdp4eTmM0yU46uEGdY/2qlU Q+BcIRAY4iuSD0DEzshDHemGn6kfn1vUO78p0baFjL5vQXuLa4ZG1dQWNdIgpVgqPKyL SiUkjQ/fizhi5W+/MdSVB2YGplXD8uhoJawARpy/LviJAJ1eAydo5AXGpUYjhk7JGD8m y6l4wy7P8Rbnjy1NxojfEvUd6hy/F1yCWkTAhvuihL6rdMkGviTj4MoTb19hpAciN3qW MIhXOHrze5aybiDmdIG9WRZpBJdE3CA7SFZ5uVB4sVHsNTxLvdV6fsISyFTJXmC+U07B yaig== 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=bRav5MNeXKH8CAwjIuQI2KaxgLrzIKfGtyo1Wg0gZMo=; b=VSCpqPnUhEOV+h45+3BHBTc9WnOyZFfoZBHHSvDo+Df7IBso81kFWmzdzz0L1qU+C7 W+FM1MxCAzCku2PJaHh6YvkqArsv58NeZMi2+LxYNwGplzv86ECiMCIIvhd8mWQqBEyL Xm28mSPSB1OZSNuJB+s9V/1toD+BxhxKy+hXB2951g00Af6IwZAySjKKtAEBrdiml8UD mt4sNYhCBg06vbHx9EdWAcQN+7ljQ5mcElShNw29jgt4gwR/M9andnKNzKOD6pJByXSX RIUjxf/l2NAHUTFXqtPLQEWaLI0R/Z0RyHa0+WN2y3F3xt9zdMRSeZDzfxB/j5DbFDEK /Djw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VgyzqcmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s123-20020a637781000000b004e0c6ebca06si14574330pgc.601.2023.01.31.15.53.12; Tue, 31 Jan 2023 15:53:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VgyzqcmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbjAaXpJ (ORCPT + 99 others); Tue, 31 Jan 2023 18:45:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjAaXo7 (ORCPT ); Tue, 31 Jan 2023 18:44:59 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 276804C6EF; Tue, 31 Jan 2023 15:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675208698; x=1706744698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ar2gkz6ChPb2jBvdRtwjD+KktDkQQZm5UI6aP2nLoyI=; b=VgyzqcmCfETSJjDDxfNeL2nSJ2TlB38jMs3Iijih0GJvEFPeSBD5fPB9 Zv55ATBoEiyELcOsx5E2Iq+yPTL+p3pSNQ8qwOBxmf2B7n8K8E93lTiYy lyyHZABar093+yZdjA0il+WDtQpjKmfHzYUoDwKVL3ymbwc/i9T+bW4H6 eSPn5gEUC5XVKhv4RVjNuhxPxX4gfedCjr55bAkGeoUEJ23i1SCKDfbTy GSGTGdKi5ahS2lAIj+UikwLpE/iofxh7EkP7nPlxtMsfT+9UaXD3RT7ig Fz9RPiatC3BYuoqvrlpkAbOeJPyuj9011L3gLmoAfLUNjaeL4laPOrxVn w==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390360438" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="390360438" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:56 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="773192033" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="773192033" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 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, gregkh@linuxfoundation.org, 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, thiago.macieira@intel.com, athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com Subject: [PATCH 4/5] platform/x86/intel/ifs: Implement Array BIST test Date: Tue, 31 Jan 2023 15:43:01 -0800 Message-Id: <20230131234302.3997223-5-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131234302.3997223-1-jithu.joseph@intel.com> References: <20230131234302.3997223-1-jithu.joseph@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756584168277401634?= X-GMAIL-MSGID: =?utf-8?q?1756584168277401634?= Array BIST test (for a particlular core) is triggered by writing to MSR_ARRAY_BIST from one sibling of the core. This will initiate a test for all supported arrays on that CPU. Array BIST test may be aborted before completing all the arrays in the event of an interrupt or other reasons. In this case, kernel will restart the test from that point onwards. Array test will also be aborted when the test fails, in which case the test is stopped immediately without further retry. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck --- drivers/platform/x86/intel/ifs/ifs.h | 12 ++++ drivers/platform/x86/intel/ifs/runtest.c | 92 ++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 07423bc4e368..b1a997e39216 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -127,6 +127,7 @@ #include #include +#define MSR_ARRAY_BIST 0x00000105 #define MSR_COPY_SCAN_HASHES 0x000002c2 #define MSR_SCAN_HASHES_STATUS 0x000002c3 #define MSR_AUTHENTICATE_AND_COPY_CHUNK 0x000002c4 @@ -194,6 +195,17 @@ union ifs_status { }; }; +/* MSR_ARRAY_BIST bit fields */ +union ifs_array { + u64 data; + struct { + u32 array_bitmask :32; + u32 array_bank :16; + u32 rsvd :15; + u32 ctrl_result :1; + }; +}; + /* * Driver populated error-codes * 0xFD: Test timed out before completing all the chunks. diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 65e08af70994..ec0ceb6b5890 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -229,6 +229,96 @@ static void ifs_test_core(int cpu, struct device *dev) } } +#define SPINUNIT 100 /* 100 nsec */ +static atomic_t array_cpus_out; + +/* + * Simplified cpu sibling rendezvous loop based on microcode loader __wait_for_cpus() + */ +static void wait_for_sibling_cpu(atomic_t *t, long long timeout) +{ + int cpu = smp_processor_id(); + const struct cpumask *smt_mask = cpu_smt_mask(cpu); + int all_cpus = cpumask_weight(smt_mask); + + atomic_inc(t); + while (atomic_read(t) < all_cpus) { + if (timeout < SPINUNIT) + return; + ndelay(SPINUNIT); + timeout -= SPINUNIT; + touch_nmi_watchdog(); + } +} + +static int do_array_test(void *data) +{ + int cpu = smp_processor_id(); + u64 *msrs = data; + int first; + + /* + * Only one logical CPU on a core needs to trigger the Array test via MSR write. + */ + first = cpumask_first(cpu_smt_mask(cpu)); + + if (cpu == first) { + wrmsrl(MSR_ARRAY_BIST, msrs[0]); + /* Pass back the result of the test */ + rdmsrl(MSR_ARRAY_BIST, msrs[1]); + } + + /* Tests complete faster if the sibling is spinning here */ + wait_for_sibling_cpu(&array_cpus_out, NSEC_PER_SEC); + + return 0; +} + +static void ifs_array_test_core(int cpu, struct device *dev) +{ + union ifs_array activate, status; + bool timed_out = false; + struct ifs_data *ifsd; + unsigned long timeout; + u64 msrvals[2]; + + ifsd = ifs_get_data(dev); + + activate.data = 0; + activate.array_bitmask = ~0U; + activate.ctrl_result = 0; + timeout = jiffies + HZ / 2; + + do { + if (time_after(jiffies, timeout)) { + timed_out = true; + break; + } + + msrvals[0] = activate.data; + + atomic_set(&array_cpus_out, 0); + stop_core_cpuslocked(cpu, do_array_test, msrvals); + status.data = msrvals[1]; + + if (status.ctrl_result) + break; + + activate.array_bitmask = status.array_bitmask; + activate.array_bank = status.array_bank; + + } while (status.array_bitmask); + + ifsd->scan_details = status.data; + + if (status.ctrl_result) + ifsd->status = SCAN_TEST_FAIL; + else if (timed_out || status.array_bitmask) + ifsd->status = SCAN_NOT_TESTED; + 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 @@ -253,6 +343,8 @@ int do_core_test(int cpu, struct device *dev) ifs_test_core(cpu, dev); break; case IFS_ARRAY: + ifs_array_test_core(cpu, dev); + break; default: return -EINVAL; } From patchwork Tue Jan 31 23:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Joseph X-Patchwork-Id: 51107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp105969wrn; Tue, 31 Jan 2023 16:06:37 -0800 (PST) X-Google-Smtp-Source: AK7set86hp5pd0st/8+5itPn6RhrF7VC1nmvzxukkO6NNk7EB6GGezIWPhwYFJ9LF9Z5ahnbz7he X-Received: by 2002:a17:90b:378f:b0:229:bc1:7cd1 with SMTP id mz15-20020a17090b378f00b002290bc17cd1mr1121776pjb.33.1675209996952; Tue, 31 Jan 2023 16:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675209996; cv=none; d=google.com; s=arc-20160816; b=lZ35V5zrVXIRIVnT1Cr1DOtTwRj9aIS1F+OVGKncyngLBXJC1gmbp4D7RWxZtXGvS1 Pc+v+/AZC0jJsLPziT23rf9V9Sf4/LQ0pMbnmfceSgbJ0850XBCZsi4v80rQ0otr8NHM erhYEq/ub/R6tQXRoT35MbxwWf1bQVV7feqqt23EYbj96gB1q0Ywfn9T/21oeKUWcyBz wWCjOUjznrgetjV1475hiYRBdDCL4Mfd16nBjZyitL0D6MbFa87fbp1tbL1JPTvIrKWx fpOo52D4MJ256aEAnJrpnUpUoZYub0tM5lorOgm4BlbJd0tJIJHioVQuD/0uepiZc3yH IeCA== 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=FMFbUySmE1SVEI4TuoMnXmId43OlWsYfcgXyvvA2A78=; b=cq/FVw6tQBPT4dLRy2nyhJybhd3H5h6eBRQ6IksclJ4Jr7QscMXtRnN6rvrFljpiIh Jv4XxYNA8falpB3XM/vcFiHwgmgJH53kj36XC6/2uHi3FmtgRVBolHOwXBtT+3KLughf jCI82krAgX25UeFaCX16o8WI9HExypFsbLyImN5cOoc027e06k291SuHcUTC/NcSKhDp TWjIrGBw0oWRKud0ucDUFwtlVoSHFXm+vNG2qLzv0rvj6hq8q3ea4FZGBDY1rUOFeQil bgPXrlN3wEiXasy8aASk6l2l7SE1Y2zYHS+dD4SF2v4nnLgx8C+ADXWQRU2MqGXS45hl E5dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=A15Jtwrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m19-20020a656a13000000b004cf0cc0dc35si22694086pgu.874.2023.01.31.16.06.23; Tue, 31 Jan 2023 16:06:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=A15Jtwrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbjAaXpL (ORCPT + 99 others); Tue, 31 Jan 2023 18:45:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbjAaXo7 (ORCPT ); Tue, 31 Jan 2023 18:44:59 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 597714ED07; Tue, 31 Jan 2023 15:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675208698; x=1706744698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=by5qRdZTxe0QTHHwMBIcWAw1uHYiJKW6XwzKCf+gNJo=; b=A15JtwrfA3ghpprrnQuDEzlAjBxflazXs/OwFmuqPrLseaL5kvvX9TUC hcVg4qSwL7O22utSKEyxe3jPHm4jTYOfc5opkI6VAve5cq7z/8pOyHnxm 8uExTXO0KAuv5mUoWZNb3/ky8tUH6p0ECJcHpWX632ctFmpQLpxiNbDxg NOAFDZsPhIiTUcKzexkN7HzfkOr9Xiw+n8Ie08fOmQ7RZifj0gq/zXw9a nM+y5UpSdEwVMDMKujD/83y79Do9wwGm6AYZ6PJtd4HRtFbRpz2EkBgLm //FwtzC6jvo98SM/tkIJtbICRO1gPnRm049yM1hXxneWV4oYkokDlQpA6 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390360446" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="390360446" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:56 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="773192036" X-IronPort-AV: E=Sophos;i="5.97,261,1669104000"; d="scan'208";a="773192036" Received: from jithujos.sc.intel.com ([172.25.103.66]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 15:44:55 -0800 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, gregkh@linuxfoundation.org, 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, thiago.macieira@intel.com, athenas.jimenez.gonzalez@intel.com, sohil.mehta@intel.com Subject: [PATCH 5/5] platform/x86/intel/ifs: Trace support for array test Date: Tue, 31 Jan 2023 15:43:02 -0800 Message-Id: <20230131234302.3997223-6-jithu.joseph@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131234302.3997223-1-jithu.joseph@intel.com> References: <20230131234302.3997223-1-jithu.joseph@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756584997906336167?= X-GMAIL-MSGID: =?utf-8?q?1756584997906336167?= Enable tracing support in array test flow. Signed-off-by: Jithu Joseph Reviewed-by: Tony Luck --- include/trace/events/intel_ifs.h | 27 ++++++++++++++++++++++++ drivers/platform/x86/intel/ifs/runtest.c | 1 + 2 files changed, 28 insertions(+) diff --git a/include/trace/events/intel_ifs.h b/include/trace/events/intel_ifs.h index d7353024016c..db43df4139a2 100644 --- a/include/trace/events/intel_ifs.h +++ b/include/trace/events/intel_ifs.h @@ -35,6 +35,33 @@ TRACE_EVENT(ifs_status, __entry->status) ); +TRACE_EVENT(ifs_array, + + TP_PROTO(int cpu, union ifs_array activate, union ifs_array status), + + TP_ARGS(cpu, activate, status), + + TP_STRUCT__entry( + __field( u64, status ) + __field( int, cpu ) + __field( u32, arrays ) + __field( u16, bank ) + ), + + TP_fast_assign( + __entry->cpu = cpu; + __entry->arrays = activate.array_bitmask; + __entry->bank = activate.array_bank; + __entry->status = status.data; + ), + + TP_printk("cpu: %d, array_list: %.8x, array_bank: %.4x, status: %.16llx", + __entry->cpu, + __entry->arrays, + __entry->bank, + __entry->status) +); + #endif /* _TRACE_IFS_H */ /* This part must be outside protection */ diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index ec0ceb6b5890..4fd80d91ea29 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -301,6 +301,7 @@ static void ifs_array_test_core(int cpu, struct device *dev) stop_core_cpuslocked(cpu, do_array_test, msrvals); status.data = msrvals[1]; + trace_ifs_array(cpu, activate, status); if (status.ctrl_result) break;