Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp6668ybt; Fri, 12 Jun 2020 17:44:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL3n7kzNdnrHSW2TLiEjnLtWKrS2BvwY2D1V7U+3zNdh3t7EDlJ0W5xuoqiHvKcnD3zqd1 X-Received: by 2002:a17:907:429b:: with SMTP id ny19mr15897344ejb.498.1592009053554; Fri, 12 Jun 2020 17:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592009053; cv=none; d=google.com; s=arc-20160816; b=cqRhpMutAi7e0tM6m9fs4BoOmKfdHyLTILGG2FVkIcz/GfB+w6jjbPqym+aHE2sCrM o/dpKKuNdXrzQX6R9VkOoYoKkcVL/imd2dCgSvKZepz5166VBK880S5FopZDpmnHYxs7 da7nMsHb/XVuy0bv++0wXDa1Lito+S41wJJ0Zh/CRjP8CNgqoJ27qL2xaNU5KFYxgchq N4jWK2BVOAJRMrIpwFcxtWLFPIERhOw55c528r0Zdll7Y8pZKIHcE4fLMz7iw26EDvGl IyDCyRjmzyqwriN7mhGC8JEbPZ+s6BBLbTKBdue354KsD8WItpTgA6EnY+zA0HZogHpt ymRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=Ss89vOGv7Qv/HJ0vBp0JTwrnFVlRA6CUeCY2bwnIEC0=; b=zCROWJJ3aFVhNAnKojVAOjmrhwYsuDKdFPgP29YUANl8ervAzOwwIlYjJrPtaAvMHt NTM+fIXEa8mUI0SNX5nQl82DXIYHgZIn00qnB2kT4ZaYXpGVYcCF6L6QhdnBplPMU/pH K19ija7RwKbeL5cbOcw726L70e/LPRiJz0i2t2oFLNLPgbAUoM/U6FfGqxdUO/M90SVJ NSsYkLJD1TPwi0G7ul5MdAUDxgGTjB1BAiq+anDk8G0JRHd+1lzBTwMZdjVg1M9vPg7j L9CdnHgN+MqLo7zEMMn0G8qiqMSA5ZTgjR6rMX+eOSE/FgpEKuNR3YHfCisVBP1s0jGq ibjg== 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 ds3si5911224ejc.545.2020.06.12.17.43.51; Fri, 12 Jun 2020 17:44:13 -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 S1726514AbgFMAl7 (ORCPT + 99 others); Fri, 12 Jun 2020 20:41:59 -0400 Received: from mga12.intel.com ([192.55.52.136]:1253 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgFMAlw (ORCPT ); Fri, 12 Jun 2020 20:41:52 -0400 IronPort-SDR: 05v0ap1nVNDf5eXp2ZFhicf4cV02nQ9d0a5WK6v+J5+m5NlXKwBneNzvvWtgqsl5GaNjnkEAI0 nmbMQOholdLA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2020 17:41:51 -0700 IronPort-SDR: sB097uKH01ClgoMWD45uuW4FwLaRlss12+YW1BekxXLe/VkcxglD827UDO2L0D7BROmIvit9QQ wZuuFjd7v5bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,505,1583222400"; d="scan'208";a="261011220" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga007.jf.intel.com with ESMTP; 12 Jun 2020 17:41:51 -0700 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "David Woodhouse" , "Lu Baolu" , "Frederic Barrat" , "Andrew Donnellan" , "Felix Kuehling" , "Joerg Roedel" , "Dave Hansen" , "Tony Luck" , "Ashok Raj" , "Jacob Jun Pan" , "Dave Jiang" , "Yu-cheng Yu" , "Sohil Mehta" , "Ravi V Shankar" Cc: "linux-kernel" , "x86" , iommu@lists.linux-foundation.org, "amd-gfx" , "linuxppc-dev" , Fenghua Yu Subject: [PATCH v2 06/12] x86/fpu/xstate: Add supervisor PASID state for ENQCMD feature Date: Fri, 12 Jun 2020 17:41:27 -0700 Message-Id: <1592008893-9388-7-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1592008893-9388-1-git-send-email-fenghua.yu@intel.com> References: <1592008893-9388-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu-cheng Yu ENQCMD instruction reads PASID from IA32_PASID MSR. The MSR is stored in the task's supervisor FPU PASID state and is context switched by XSAVES/XRSTORS. Signed-off-by: Yu-cheng Yu Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- v2: - Modify the commit message (Thomas) arch/x86/include/asm/fpu/types.h | 10 ++++++++++ arch/x86/include/asm/fpu/xstate.h | 2 +- arch/x86/kernel/fpu/xstate.c | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h index f098f6cab94b..00f8efd4c07d 100644 --- a/arch/x86/include/asm/fpu/types.h +++ b/arch/x86/include/asm/fpu/types.h @@ -114,6 +114,7 @@ enum xfeature { XFEATURE_Hi16_ZMM, XFEATURE_PT_UNIMPLEMENTED_SO_FAR, XFEATURE_PKRU, + XFEATURE_PASID, XFEATURE_MAX, }; @@ -128,6 +129,7 @@ enum xfeature { #define XFEATURE_MASK_Hi16_ZMM (1 << XFEATURE_Hi16_ZMM) #define XFEATURE_MASK_PT (1 << XFEATURE_PT_UNIMPLEMENTED_SO_FAR) #define XFEATURE_MASK_PKRU (1 << XFEATURE_PKRU) +#define XFEATURE_MASK_PASID (1 << XFEATURE_PASID) #define XFEATURE_MASK_FPSSE (XFEATURE_MASK_FP | XFEATURE_MASK_SSE) #define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK \ @@ -229,6 +231,14 @@ struct pkru_state { u32 pad; } __packed; +/* + * State component 10 is supervisor state used for context-switching the + * PASID state. + */ +struct ia32_pasid_state { + u64 pasid; +} __packed; + struct xstate_header { u64 xfeatures; u64 xcomp_bv; diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index 422d8369012a..ab9833c57aaa 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -33,7 +33,7 @@ XFEATURE_MASK_BNDCSR) /* All currently supported supervisor features */ -#define XFEATURE_MASK_SUPERVISOR_SUPPORTED (0) +#define XFEATURE_MASK_SUPERVISOR_SUPPORTED (XFEATURE_MASK_PASID) /* * Unsupported supervisor features. When a supervisor feature in this mask is diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index bda2e5eaca0e..31629e43383c 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -37,6 +37,7 @@ static const char *xfeature_names[] = "AVX-512 ZMM_Hi256" , "Processor Trace (unused)" , "Protection Keys User registers", + "PASID state", "unknown xstate feature" , }; @@ -51,6 +52,7 @@ static short xsave_cpuid_features[] __initdata = { X86_FEATURE_AVX512F, X86_FEATURE_INTEL_PT, X86_FEATURE_PKU, + X86_FEATURE_ENQCMD, }; /* @@ -316,6 +318,7 @@ static void __init print_xstate_features(void) print_xstate_feature(XFEATURE_MASK_ZMM_Hi256); print_xstate_feature(XFEATURE_MASK_Hi16_ZMM); print_xstate_feature(XFEATURE_MASK_PKRU); + print_xstate_feature(XFEATURE_MASK_PASID); } /* @@ -590,6 +593,7 @@ static void check_xstate_against_struct(int nr) XCHECK_SZ(sz, nr, XFEATURE_ZMM_Hi256, struct avx_512_zmm_uppers_state); XCHECK_SZ(sz, nr, XFEATURE_Hi16_ZMM, struct avx_512_hi16_state); XCHECK_SZ(sz, nr, XFEATURE_PKRU, struct pkru_state); + XCHECK_SZ(sz, nr, XFEATURE_PASID, struct ia32_pasid_state); /* * Make *SURE* to add any feature numbers in below if -- 2.19.1