Message ID | 20240219074733.122080-5-weijiang.yang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70870-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1136111dyc; Sun, 18 Feb 2024 23:52:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjEEHIp70XFC166YDeAA97wAXidU6QnX122zG414E7edHiNERTUx4W9/pr3WioVCsiIsad+vc6XNxUSGK7hDAL5bqwng== X-Google-Smtp-Source: AGHT+IGM0+/ug9a5YsvXgW0Y15Y5RrwYmPdP9aDAT7xyxLuep4gVXVwicZe1KZr4vhbXQsbgbvc9 X-Received: by 2002:a05:6a20:d04f:b0:19c:a2ef:c45e with SMTP id hv15-20020a056a20d04f00b0019ca2efc45emr11137210pzb.37.1708329172801; Sun, 18 Feb 2024 23:52:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708329172; cv=pass; d=google.com; s=arc-20160816; b=fX3jgOvRvGJ6Z1JaPRA9wZTbaUnZZKFAWeDtGA9K3xGEoiphgz0fgyA3GVgAL8bfUd 1PkaA4u+UirpfDeWYeVR2zkYY09v6xcnPV8ytqJDEqm7bWGvnror8arGyuJWhoSHVQBO mUin4uiM9s9pQr5vZ9w4TngzizqfLx8aXwTEUgp/6qjZL5HSTB0VhTUYR/LujeW2pzvt f24ag/NOsqn9VQxJFA0Dumkbfi2XZCLPviXc8AqHQlU3f3ZOfxKfdSJIYCFEEbG/T2gI sq9Cf9LykS8Auxlq0H7WYaujrG0w55c/eQAij87Pfp5E1Ihg32mtqhuT88SXNCg35mHs FpgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=G7wjpoLGCCTSbUsnqUS48XYwb/YDQastibmJhHxgXJ8=; fh=6bYtQoKQxNJSYrJA1a9vseXH6qHZpRYO7L/7krtpXA0=; b=rbqXs8c5zoMfT1UU7K1+Kq2UKe6bGMLFGHk1AGBbMuLtjO25NDfTRkVOKwMgMfGfTx 95Fk54AH03w4hUsSep03Ha2bNM+muvlpKYx0NksWbwcwcMJKex45wsSyanxRiYgVVNyd ia+/nNLI8VxhEdUD1en6kCkqDm6O4vkUrejufxG+KKnijszDGGAbyoOfv27YquCs2MBs 8d5UaI6awej/jvFXzBAoDdc999deQatFyd6gv1zeXhkhhLL0bnVnR7Ldh8A+trt4XvdF Jw3EEOQDciwx3JM3SmavHFDdwI7gAKfpQEV1eISLP/4oQxCVGmQg6o11ATd4XLk7CW2+ 2tJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="B0aO/FND"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-70870-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70870-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o5-20020a635a05000000b005dc12b1dd59si4042298pgb.128.2024.02.18.23.52.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 23:52:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70870-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="B0aO/FND"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-70870-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70870-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9D96F28147B for <ouuuleilei@gmail.com>; Mon, 19 Feb 2024 07:52:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1612B328DB; Mon, 19 Feb 2024 07:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B0aO/FND" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 29DE721101; Mon, 19 Feb 2024 07:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328869; cv=none; b=BYTxIxHfM2ggAX5hM9Dx9xhRD2y5U+Z8CWFE1MwM3sfntfSXdRdqbS+xn1yIVXEzjgzvTxGyRdBnW0SctLO9n+CX0AoJUwbg1y5hrZFLzCwHpdNETThGHVORQvPmDW2ABb5xlshLmfCrh6FsybzqZKGyuuO5/yDrgJFJ9szpQ7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328869; c=relaxed/simple; bh=MlqnfeMU4VB44Hds9887OeMo+hsI9GbnOK6otdEL9WA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OuX1QYSATmzI4/KiMExbl6/ZJSjS6nUzD/iDfcpyAxvGEq/wZc/AKREFG5xLGJ8tlgyB8LKv1g3GDetBG8WdxUIKOx13OjGPHeB6DYGqJ2D1E1MWkvsOmZdKjYRY/xduIi13Lc7N8Bu4KmROu1pFFb5sixItoaZ6WME/7vUowW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=B0aO/FND; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708328867; x=1739864867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MlqnfeMU4VB44Hds9887OeMo+hsI9GbnOK6otdEL9WA=; b=B0aO/FNDVdQ4BqhOLxI3ip3ZW6QSpg52i8od/nLfewIXb6XAIalPZtlo SQ9l17pauXFg214aNiHfy6P/10o6IcWp5HAoVEgfL6MGS742ApUQkcN44 KyyQ9HoEiJELZ2+/WBTv/MbrawoglVst3n0bZSl9dP5WwIGFD3Jy9Q3nn fNZ0z/9iBXN4Tfi6pE+Db2/kejcxhtqTeSz0gN/LLeY858nfcSchIB61X mOetZni7w433nPlTsQ0b27uIu8jPDTdrPIF+zZAiU4s1FZy5YXV0qpPNo XIAu46kTwgVCbT+s/LMY0rip8xgw5xe/inIAVWOzDr9DFlVFjP8IeNfAZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10988"; a="2535033" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="2535033" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2024 23:47:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10988"; a="826966069" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="826966069" Received: from jf.jf.intel.com (HELO jf.intel.com) ([10.165.9.183]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2024 23:47:43 -0800 From: Yang Weijiang <weijiang.yang@intel.com> To: seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterz@infradead.org, chao.gao@intel.com, rick.p.edgecombe@intel.com, mlevitsk@redhat.com, john.allen@amd.com, weijiang.yang@intel.com Subject: [PATCH v10 04/27] x86/fpu/xstate: Introduce XFEATURE_MASK_KERNEL_DYNAMIC xfeature set Date: Sun, 18 Feb 2024 23:47:10 -0800 Message-ID: <20240219074733.122080-5-weijiang.yang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240219074733.122080-1-weijiang.yang@intel.com> References: <20240219074733.122080-1-weijiang.yang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791312970489578796 X-GMAIL-MSGID: 1791312970489578796 |
Series |
Enable CET Virtualization
|
|
Commit Message
Yang, Weijiang
Feb. 19, 2024, 7:47 a.m. UTC
Define a new XFEATURE_MASK_KERNEL_DYNAMIC mask to specify the features that can be optionally enabled by kernel components. This is similar to XFEATURE_MASK_USER_DYNAMIC in that it contains optional xfeatures that can allows the FPU buffer to be dynamically sized. The difference is that the KERNEL variant contains supervisor features and will be enabled by kernel components that need them, and not directly by the user. Currently it's used by KVM to configure guest dedicated fpstate for calculating the xfeature and fpstate storage size etc. The kernel dynamic xfeatures now only contain XFEATURE_CET_KERNEL, which is supported by host as they're enabled in kernel XSS MSR setting but relevant CPU feature, i.e., supervisor shadow stack, is not enabled in host kernel therefore it can be omitted for normal fpstate by default. Remove the kernel dynamic feature from fpu_kernel_cfg.default_features so that the bits in xstate_bv and xcomp_bv are cleared and xsaves/xrstors can be optimized by HW for normal fpstate. Suggested-by: Dave Hansen <dave.hansen@intel.com> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> --- arch/x86/include/asm/fpu/xstate.h | 5 ++++- arch/x86/kernel/fpu/xstate.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index 3b4a038d3c57..a212d3851429 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -46,9 +46,12 @@ #define XFEATURE_MASK_USER_RESTORE \ (XFEATURE_MASK_USER_SUPPORTED & ~XFEATURE_MASK_PKRU) -/* Features which are dynamically enabled for a process on request */ +/* Features which are dynamically enabled per userspace request */ #define XFEATURE_MASK_USER_DYNAMIC XFEATURE_MASK_XTILE_DATA +/* Features which are dynamically enabled per kernel side request */ +#define XFEATURE_MASK_KERNEL_DYNAMIC XFEATURE_MASK_CET_KERNEL + /* All currently supported supervisor features */ #define XFEATURE_MASK_SUPERVISOR_SUPPORTED (XFEATURE_MASK_PASID | \ XFEATURE_MASK_CET_USER | \ diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 03e166a87d61..ca4b83c142eb 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -824,6 +824,7 @@ void __init fpu__init_system_xstate(unsigned int legacy_size) /* Clean out dynamic features from default */ fpu_kernel_cfg.default_features = fpu_kernel_cfg.max_features; fpu_kernel_cfg.default_features &= ~XFEATURE_MASK_USER_DYNAMIC; + fpu_kernel_cfg.default_features &= ~XFEATURE_MASK_KERNEL_DYNAMIC; fpu_user_cfg.default_features = fpu_user_cfg.max_features; fpu_user_cfg.default_features &= ~XFEATURE_MASK_USER_DYNAMIC;