Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1111252pxb; Thu, 21 Oct 2021 16:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8/hHOamqvd4duQwNJaHsfgzJfCQCTHRioddxuHUtkA+Ap9eoN46aFqLl7BMTpdfIAuBkn X-Received: by 2002:a17:90b:1d06:: with SMTP id on6mr10160368pjb.119.1634857765312; Thu, 21 Oct 2021 16:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634857765; cv=none; d=google.com; s=arc-20160816; b=pXxAA+XIgbSCSgYHhKd/ke4FVwT7NLWND8MXFdzFMgV2tjQW6Jkfel1xOg10nCZsxo DRoMs7RLFnCzRho4TJGLqEFQaGa5tfuPlmnEsJz7uufT95yoccFG79Zu2KQG6EFF3AQj xbP98Uf6+j4H/6cL9OkQ2ft5pPGirh5Xn7RLdeCTP/CFTndGa4nQ7vcylJyWF+ELs0Id J0F+6FAfzlQQ8zfebF4S66HCLSN5FHqEFgrxHGRXdL7TmELu2U14gwFsiXhNe2Iv/8Ow kPIJmA6jLGRCAioxsInhbLDERga9jygA+mPycu6t5lClXYPZA6KSaMBt96XzPsGZipKJ uR7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=LjDN/DYMfoWZwjDjDHRCi2iLcAD0Wx7fIPyfYw3zUK8=; b=GBV1c7Kw7M0ly3com2exkv/qFSTaHT70CL8YDdRnvb2Fxvl7YsgasHs7A0ViJkc0A+ TOCMFGx3i/FBl7eqhcxMU5bsDxpDc7EyAQjBV58zS9RhDWwVPSCWgtQa0pXC7xqtHZUh 1lA3K+EsoN12z4aiaCMtMiB0c7n3CXNsjZnV5a/JmUDT2gUi1rTLXZi/w84vXTBJ/JEn eNnIQsHH1iL/9j8jdhgsr8tqNGIPq+h6GRPFHPieBtT84suCJmvZdb446MolmYwyOthb frQYzb0v7qbzWoCtMoGLa7RdQmlUsQf0OncBubolUMrYgSnywAB6CdRhtjuOUx9cXCxi HrMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si8876788pls.54.2021.10.21.16.09.07; Thu, 21 Oct 2021 16:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232420AbhJUXIu (ORCPT + 99 others); Thu, 21 Oct 2021 19:08:50 -0400 Received: from mga07.intel.com ([134.134.136.100]:4522 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbhJUXI3 (ORCPT ); Thu, 21 Oct 2021 19:08:29 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10144"; a="292634928" X-IronPort-AV: E=Sophos;i="5.87,170,1631602800"; d="scan'208";a="292634928" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2021 16:02:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,170,1631602800"; d="scan'208";a="445033491" Received: from chang-linux-3.sc.intel.com ([172.25.66.175]) by orsmga006.jf.intel.com with ESMTP; 21 Oct 2021 16:02:29 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com, arjan@linux.intel.com, ravi.v.shankar@intel.com, chang.seok.bae@intel.com Subject: [PATCH 23/23] x86/fpu/amx: Enable the AMX feature in 64-bit mode Date: Thu, 21 Oct 2021 15:55:27 -0700 Message-Id: <20211021225527.10184-24-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211021225527.10184-1-chang.seok.bae@intel.com> References: <20211021225527.10184-1-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the AMX state components in XFEATURE_MASK_USER_SUPPORTED and the TILE_DATA component to the dynamic states and update the permission check table accordingly. This is only effective on 64 bit kernels as for 32bit kernels XFEATURE_MASK_TILE is defined as 0. TILE_DATA is caller-saved state and the only dynamic state. Add build time sanity check to ensure the assumption that every dynamic feature is caller- saved. Make AMX state depend on XFD as it is dynamic feature. Signed-off-by: Chang S. Bae Signed-off-by: Thomas Gleixner Signed-off-by: Chang S. Bae --- Changes from the tglx tree: * Add compile time sanity check. (Dave Hansen) * Make AMX depend on XFD. --- arch/x86/include/asm/fpu/xstate.h | 5 +++-- arch/x86/kernel/cpu/cpuid-deps.c | 1 + arch/x86/kernel/fpu/core.c | 6 ++++++ arch/x86/kernel/fpu/xstate.c | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index 0c850def4d13..ffb08dc298bb 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -35,7 +35,8 @@ XFEATURE_MASK_Hi16_ZMM | \ XFEATURE_MASK_PKRU | \ XFEATURE_MASK_BNDREGS | \ - XFEATURE_MASK_BNDCSR) + XFEATURE_MASK_BNDCSR | \ + XFEATURE_MASK_XTILE) /* * Features which are restored when returning to user space. @@ -46,7 +47,7 @@ (XFEATURE_MASK_USER_SUPPORTED & ~XFEATURE_MASK_PKRU) /* Features which are dynamically enabled for a process on request */ -#define XFEATURE_MASK_USER_DYNAMIC 0ULL +#define XFEATURE_MASK_USER_DYNAMIC XFEATURE_MASK_XTILE_DATA /* All currently supported supervisor features */ #define XFEATURE_MASK_SUPERVISOR_SUPPORTED (XFEATURE_MASK_PASID) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c index d9ead9c20408..cb2fdd130aae 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -76,6 +76,7 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_SGX1, X86_FEATURE_SGX }, { X86_FEATURE_SGX2, X86_FEATURE_SGX1 }, { X86_FEATURE_XFD, X86_FEATURE_XSAVES }, + { X86_FEATURE_AMX_TILE, X86_FEATURE_XFD }, {} }; diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index f66beea2d1f8..323ae0c2a137 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -496,6 +496,12 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags) return 0; } + /* + * If a new feature is added, ensure all dynamic features are + * caller-saved from here! + */ + BUILD_BUG_ON(XFEATURE_MASK_USER_DYNAMIC != XFEATURE_MASK_XTILE_DATA); + /* * Save the default portion of the current FPU state into the * clone. Assume all dynamic features to be defined as caller- diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 81b40f119ce7..3195dc116fa8 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -404,7 +404,8 @@ static __init void os_xrstor_booting(struct xregs_state *xstate) XFEATURE_MASK_PKRU | \ XFEATURE_MASK_BNDREGS | \ XFEATURE_MASK_BNDCSR | \ - XFEATURE_MASK_PASID) + XFEATURE_MASK_PASID | \ + XFEATURE_MASK_XTILE) /* * setup the xstate image representing the init state @@ -1633,7 +1634,7 @@ static int __xstate_request_perm(u64 permitted, u64 requested) * Permissions array to map facilities with more than one component */ static const u64 xstate_prctl_req[XFEATURE_MAX] = { - /* [XFEATURE_XTILE_DATA] = XFEATURE_MASK_XTILE, */ + [XFEATURE_XTILE_DATA] = XFEATURE_MASK_XTILE_DATA, }; static int xstate_request_perm(unsigned long idx) -- 2.17.1