[v10,07/27] x86/fpu/xstate: Warn if kernel dynamic xfeatures detected in normal fpstate
Message ID | 20240219074733.122080-8-weijiang.yang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70873-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1136324dyc; Sun, 18 Feb 2024 23:53:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWH+3lyyohfHONynCtED8waUlgGACoHLIFrVjaflCbqcgTxjsDY2xD+VO811VXKlJrlpSIO7BMHd5pf7z7OOk6g3HAw6g== X-Google-Smtp-Source: AGHT+IFWna7jEJgd9Mnl1Z9PZGLgO/cNWBQBoIpvMIXwiPxkK6IYehShTRmqMkkNiMv3xVWUCf06 X-Received: by 2002:a0c:ca12:0:b0:68f:6be:9f94 with SMTP id c18-20020a0cca12000000b0068f06be9f94mr5413587qvk.12.1708329222701; Sun, 18 Feb 2024 23:53:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708329222; cv=pass; d=google.com; s=arc-20160816; b=AnC00Uc4WoTTTakyv8OPGk1NfpA6lQoRgva5qvWwpG6uV09psm2lfBN4r+xHtH+6oE C2fuHd1CzAznj/DymwdpKhYRZhQjpMC6t8rBa0+4J3Nnr5kn29p2M2pjXhH8XMyjFvJa RzylZTZozhN+YsSykpEFkiyyScf/swu8iSfkA1rtPQqDqTOcS0P9iNfSi2sdUyGAqCPk IUpGeuwaSw1W5s151HBkoonPWEsQoW6tDxtP2icaD3BiyppUW/hPKtwv6tjeJENnnd1v h8vyEJsFkm59ukZCP+t/8SCRJYokX13zsu6yHMUXKfWWUwfvcA871bNhaqZaDqqPviuS OShQ== 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=J4wFmg8dEBmvjAU2P4yqUFfssMFXWBMn+u1s4DAc9Bc=; fh=6bYtQoKQxNJSYrJA1a9vseXH6qHZpRYO7L/7krtpXA0=; b=RUDEd461OdyTezrbew7SPq4p293htUwCvQ339/mMoh0NFZJVbI1SknIykO0Ze6boH5 IIjmtcFgrjpXxC97JpPZF3dfaIicxe8p0k8MqW5ZKOC0F01ILvAmhEy7lxmA3mrilQCB swFytSKT3hLpHY8W7cCUEy54LxPwQWw3V48wBlFT27wRbGiipAMMjKBHZ6mJGE+YkhfZ rc/s3ZA00F0BXV9kcjgmFmJWZp/b5keW7rfvzkHMAd1JPR637QLkkz4dbvNMp34V3HW9 Z9qrt2KTNL9kVetY9rT9gj87amiEmyUZ+2hfk77wcEiW6p6q3YYB5RjbKY8WboQgppBh iLtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZZLLBN70; 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-70873-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70873-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u7-20020a0562141c0700b0068cf8ab1139si5758816qvc.374.2024.02.18.23.53.42 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 23:53:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70873-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZZLLBN70; 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-70873-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70873-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7F4271C21C7E for <ouuuleilei@gmail.com>; Mon, 19 Feb 2024 07:53:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6982736137; Mon, 19 Feb 2024 07:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZZLLBN70" 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 6133124B47; Mon, 19 Feb 2024 07:47:49 +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=1708328871; cv=none; b=WTvBXr6F/osXu7x8/gdcd+djA6QyRGQpG0omnoGNJmEHoC3GJVRM2m0SG4klZyFbWZ997fQ9dpY/dwoSiKDQe1M5xn/xpicULd91osnCpaCcXZhVzdr/IcD9V4YTsic1bokfeAiPp5afKcS7q95UdTE8UK3FdYmfWg5r6mhTTBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708328871; c=relaxed/simple; bh=CJ0Jw/rZGxVuVyRHLbKDpIzAQO9DG/ph6iOAbNKFjzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pMTUn0fI5Er1b94CtacZndKE4wo287djEyEOJ2PQBX+3qiNxDmZNHaR1jvqV5k5EvYFpL6johoTSaxbM9np/m3IuCy+PtKOKj7CAq9c+xCHGATz7kvHJBsHF2Ly0dmeBREUGz6xDOzSPbQE9itm1Mi3RgofmxgiA88O/wSN9sAk= 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=ZZLLBN70; 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=1708328869; x=1739864869; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CJ0Jw/rZGxVuVyRHLbKDpIzAQO9DG/ph6iOAbNKFjzE=; b=ZZLLBN70XfKV1LaLqdB9OHpt84JhXZ9iiTmWz382BJlKhr5HLW1k9HBS akqrKVUVQS+HzGi36E/LwQSRCtuN6vJb0nurXru/XtfJfS8jKPbcQZrqy QsqgFwbvtc6IRGheyb96o5me8195Gpcr1PhU89Ml9oiLNNYYw+ll9qDAV oMEi8eO3uKG0svRzg0ULOeNveE5b/JMnibfKMlszi2d0LmceDRO/dP53S n7WZ/CTkK4WsbtEe/hxN3tALXBmfgUWjUk+vNIf2/7IYKxX45pmhyR/rl q54osEFVXEJ5sQFFaVfPWTJnfW77zjQdrZbBMnLFm4HAey48Obh6m5OqD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10988"; a="2535053" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="2535053" 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="826966078" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="826966078" 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 07/27] x86/fpu/xstate: Warn if kernel dynamic xfeatures detected in normal fpstate Date: Sun, 18 Feb 2024 23:47:13 -0800 Message-ID: <20240219074733.122080-8-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: 1791313023208899010 X-GMAIL-MSGID: 1791313023208899010 |
Series |
Enable CET Virtualization
|
|
Commit Message
Yang, Weijiang
Feb. 19, 2024, 7:47 a.m. UTC
Kernel dynamic xfeatures now are __ONLY__ enabled for guest fpstate, i.e., never for normal kernel fpstate. The bits are added when guest FPU config is initialized. Guest fpstate is allocated with fpstate->is_guest set to %true. For normal fpstate, the bits should have been removed when initializes kernel FPU config settings, WARN_ONCE() if kernel detects normal fpstate xfeatures contains kernel dynamic xfeatures before executes xsaves. Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> --- arch/x86/kernel/fpu/xstate.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h index 3518fb26d06b..83ebf1e1cbb4 100644 --- a/arch/x86/kernel/fpu/xstate.h +++ b/arch/x86/kernel/fpu/xstate.h @@ -185,6 +185,9 @@ static inline void os_xsave(struct fpstate *fpstate) WARN_ON_FPU(!alternatives_patched); xfd_validate_state(fpstate, mask, false); + WARN_ON_FPU(!fpstate->is_guest && + (mask & XFEATURE_MASK_KERNEL_DYNAMIC)); + XSTATE_XSAVE(&fpstate->regs.xsave, lmask, hmask, err); /* We should never fault when copying to a kernel buffer: */