Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp902948lqo; Wed, 8 May 2024 20:52:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW863DLzF/tedABrwhYZReRYnHwYDyEXvClsFI5VVCDHRcRK49sjoCyQQWW6Ds6R0i4b+KkfNuN1WwkDgkHhAb+mGqhGrQ5epPE/szO6A== X-Google-Smtp-Source: AGHT+IEqD6X7iP5LmmKSAUm+ZqGWGIU8EPd80tlG6+OUiFZd55QzVOs8tx1cjvYdYjOH8ePVpQi3 X-Received: by 2002:a05:6a21:880d:b0:1a9:ac49:ea94 with SMTP id adf61e73a8af0-1afc8dd3af1mr6221312637.61.1715226768823; Wed, 08 May 2024 20:52:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715226768; cv=pass; d=google.com; s=arc-20160816; b=No478IWE0hNCOGF++F8LnzqqnE6ilxV9NQ5waYzLfIUn1Cg8FR3YLvP67pf3MP2eiF 4QXW9rhihgFZIGGcdF4eot1Je4WhUBsQCx+STNsCy8x7z3D17eRusn4HU3l3CAEQME4r p2T30xdNKsX/6mCH274LCDVQ7wpfU2wh5cdgPbdLj0poXzaLliT3t55RgTG3jlv0tpgj s5IOxjISe1rccDkYhEWqDDmg16FsS7FybEZdrLHpV9gKw6qs/mBgQ1nwncBaJPoHTKi6 nlZAhC8+J7DSo+DxZcVkhvPOXqQGgTGWSPsIxDm4lth2WOZTc1tPc/sZHIORvj1oQNVK NelA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=g7n+KD3hz/jYZZXMUsrJhewTTXj0cb12JeU+db0rBiA=; fh=00LNzTwzr6bVCOk1Vc1vzH0d5JR45K48BfBINaSaC1M=; b=tIeH3Qdm4xe5rhqWI62i8Wm1iGAjq1Dhted2HeuUglJZeN15iq6Eml4ruQAm5lJE6p 5sPnNs4idR2WlN0NBZ8DvTZJne60uKdeMcCIQTcrSIoxP8o4ENYL+x3ftmqeLgShP/gT Nl4GChzgWw8Zz2k+8dlEt+wchh8RBzyf8orpKxEbsBYwOt0ObNakcfrr1iLO3tCJoOpO Cqu3YKsPJMr9zQ6xjttrlp6dR9nwJkfCBkj7dNzGqrjjLYv+MjQY3tq7dcjjP33fZWEj Wxfq2d7cx/rGBOBlx3Xo+61YobyxHU9PzJ0LaPItIl08iz/vzycyBwdmlII1bkxbt3Xt r/bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nDflKSIu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-173976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6290d19e4si2660935a91.165.2024.05.08.20.52.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 20:52:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nDflKSIu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-173976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 684CBB220A6 for ; Thu, 9 May 2024 00:45:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9CD1374E3; Thu, 9 May 2024 00:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nDflKSIu" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75BD93D548; Thu, 9 May 2024 00:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715215525; cv=none; b=X0vcGd9zkqHhK9zb0LxhUfkF6a6rA42F/rK+iEnJqB08r9T687YOW6REed2wSjzH9xFerZuoTHbHgg49do94zLIB9E/1ljluSObzz/OPrPCAY9I0NWsqZJ5t0FLJlS+umPkpz4SBubgNSy5H52ocPZY2gdt/IuOTNFuJ/lfIMgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715215525; c=relaxed/simple; bh=fU4qJTjvN/HQfhmAI8Gy/NQ76F8oZKqSQcpO7VySfk0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Qhag6k/C5KGnIhEh2g6d22/WHrK5DdmGpOlPaVJ3ftrA85o68cN4gogrcKDdT2+BKQGm+ZyaPjxH+hG6AZmMlYummMSjEQGkV0YLzrHyV5mmQLutcCfwtmHsNK2Ry/5UTMl7Jlv59F6eU8Xm8ZDqhiB4kCN4NztqddVHZfXkBJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nDflKSIu; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715215523; x=1746751523; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=fU4qJTjvN/HQfhmAI8Gy/NQ76F8oZKqSQcpO7VySfk0=; b=nDflKSIuJ4LF2HAeu7YeY7+seMU/w13YRlYxPfHuEviLuuLPCx9b8A8c Xn506caPeQHfV/pN3jTY6+YWz/McCrtaohDpYPLHMPts7jiQRhyXh1XXH dUpoP/P9khnldeAVpLNWt4G7RrcwDIwHR74RRqZqIvUur65QbhUY7t1En yMkxw0b4kQ4HnIVefM1tyZBVi1JTj/dvUEwoV/BkC86mwcKJDzvkhWJG0 1HjW7dR/2EaqZ2LfpGLlxcdS8v4C/vcDv4ye6NxoZC25W5HIAtUfbOzpb S4zu27mbYC3SVC/sO7k3Zn0SGKHEoIWnT88zLXnxTTadNqwq2SFS9/aVk g==; X-CSE-ConnectionGUID: zzTv5b9WQfKpqwFeaGEHlg== X-CSE-MsgGUID: N4IbIIvTQzK2Nye+8uyBeQ== X-IronPort-AV: E=McAfee;i="6600,9927,11067"; a="22503951" X-IronPort-AV: E=Sophos;i="6.08,146,1712646000"; d="scan'208";a="22503951" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2024 17:45:22 -0700 X-CSE-ConnectionGUID: 9i08LsuQRriO/o05XDxhdg== X-CSE-MsgGUID: JNRQ31J0Tr2ashe2OesSWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,146,1712646000"; d="scan'208";a="66495708" Received: from ibganev-mobl.amr.corp.intel.com (HELO [10.125.110.203]) ([10.125.110.203]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2024 17:45:22 -0700 Message-ID: <0c983c29-d146-4ddb-a554-6c9728ff2af4@linux.intel.com> Date: Wed, 8 May 2024 17:45:21 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] platform/x86/intel/ifs: Initialize AMX state for the scan test To: "Chang S. Bae" , linux-kernel@vger.kernel.org Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, tony.luck@intel.com, ashok.raj@intel.com, jithu.joseph@intel.com References: <20240430212508.105117-1-chang.seok.bae@intel.com> <20240430212508.105117-3-chang.seok.bae@intel.com> Content-Language: en-US From: Kuppuswamy Sathyanarayanan In-Reply-To: <20240430212508.105117-3-chang.seok.bae@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/30/24 2:25 PM, Chang S. Bae wrote: > The scan test does not start when the AMX state remains active and is not > re-initialized. With the extension of kernel_fpu_begin_mask(), the driver > code can now initialize the state properly. > > Introduce custom FPU handling wrappers to ensure compliant with the > established FPU API semantics, as kernel_fpu_begin() exclusively sets > legacy states. This follows the EFI case from commit b0dc553cfc9d > ("x86/fpu: Make the EFI FPU calling convention explicit"). > > Then, use these wrappers to surround the MSR_ACTIVATE_SCAN write to > minimize the critical section. To prevent unnecessary delays, invoke > ifs_fpu_begin() before entering the rendezvous loop. > > Signed-off-by: Chang S. Bae > Reviewed-by: Jithu Joseph > Tested-by: Jithu Joseph > --- Looks good to me. Reviewed-by: Kuppuswamy Sathyanarayanan > drivers/platform/x86/intel/ifs/ifs.h | 14 ++++++++++++++ > drivers/platform/x86/intel/ifs/runtest.c | 6 ++++++ > 2 files changed, 20 insertions(+) > > diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h > index 56b9f3e3cf76..71d8b50854b2 100644 > --- a/drivers/platform/x86/intel/ifs/ifs.h > +++ b/drivers/platform/x86/intel/ifs/ifs.h > @@ -325,4 +325,18 @@ int do_core_test(int cpu, struct device *dev); > extern struct attribute *plat_ifs_attrs[]; > extern struct attribute *plat_ifs_array_attrs[]; > > +static inline void ifs_fpu_begin(void) > +{ > + /* > + * The AMX state must be initialized prior to executing In-Field > + * Scan tests, according to Intel SDM. Nit: May be helpful to include the section title in SDM. > + */ > + kernel_fpu_begin_mask(KFPU_AMX); > +} > + > +static inline void ifs_fpu_end(void) > +{ > + kernel_fpu_end(); > +} > + > #endif > diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c > index 95b4b71fab53..a35eac7c0b44 100644 > --- a/drivers/platform/x86/intel/ifs/runtest.c > +++ b/drivers/platform/x86/intel/ifs/runtest.c > @@ -188,6 +188,9 @@ static int doscan(void *data) > /* Only the first logical CPU on a core reports result */ > first = cpumask_first(cpu_smt_mask(cpu)); > > + /* Prepare FPU state before entering the rendezvous loop*/ > + ifs_fpu_begin(); > + > wait_for_sibling_cpu(&scan_cpus_in, NSEC_PER_SEC); > > /* > @@ -199,6 +202,9 @@ static int doscan(void *data) > * are processed in a single pass) before it retires. > */ > wrmsrl(MSR_ACTIVATE_SCAN, params->activate->data); > + > + ifs_fpu_end(); > + > rdmsrl(MSR_SCAN_STATUS, status.data); > > trace_ifs_status(ifsd->cur_batch, start, stop, status.data); -- Sathyanarayanan Kuppuswamy Linux Kernel Developer