Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp863324rdb; Tue, 23 Jan 2024 18:47:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMK4APukeDNTj0qAA27iMZVrFGpukuBCRC5IeOxET5+rHIlfByVVtOY5X/BManrh+NlnFs X-Received: by 2002:a05:6a20:bf04:b0:19c:6744:2b87 with SMTP id gc4-20020a056a20bf0400b0019c67442b87mr122712pzb.100.1706064423569; Tue, 23 Jan 2024 18:47:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706064423; cv=pass; d=google.com; s=arc-20160816; b=cBCNWIZ6X6eajU9R6pnBa4bWRlN+G6P5PKa71ENYK927XVhy8YXYyDV7V46qOwov81 4/isnq1r9K+LdgPoIMOW0JEtiJMFpaABy0NvOS88aR7/yvuGHYj5LjJ61KtNz1l/SjkS cCF7/S+N9uyKvGokee4ufVVzvHiNi0/Ov0OJ8CE3viQUi5s6OpG75YrnzYVZVyHRGNnY lDqxDTtusgRicJ7bjDQsxABrPpiY24BG82egjQRZ0/WZIeSInVLnp8WHQcsV9VQvNPyt iMnRzL0EyPXJ4j7rjXRZGbHOEh9qr0UxBIGKbVw+sZg+5+HNUrzAC3j5OMyMsPP5jJ5i 0GOg== 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=dJFJSLlnaQA4+7DAio3F4Xa3gj03ms0ZUCKyWoq2Jlo=; fh=D+u40KSnYgjUYLGDRdXdD62xsMHg3nFDmpf3sEnyojA=; b=oFKdXQ7P7qHJXyqD5nsql1AfogZdbJ6LPfYUgx58+4deJNg5q1NuUllDcDOATPXaC+ klaGMg8pMtc3uAu7KYjyGEIjbXZWUhW8UpNAOhh09KHS2Tg5bj1y1fXcKlBuHqs6wSdc +IoHSF2FJ8ZJKaPzzCfvaxDx7ODKLEzJVzxFOgBZHrCtF6WLnM7zxg2PzKbIgqVYfFpR olWbFQtOdXZiBrVMGvL2KpVxAVFwT17EmlWRP+oW0cbuppPn5dVMTYbAY+08dzMfoY2F 6RrfAcEv4dVSeyZHIYxfVMvVkH0aehr8ohKvkedNiF/NcEw4Ta/iKyAEmPx8zTdcHC05 Ls/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kg3FblHW; 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-36332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d18-20020a170902aa9200b001d3fbe6900dsi10354067plr.622.2024.01.23.18.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 18:47:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kg3FblHW; 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-36332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36332-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 023C228A586 for ; Wed, 24 Jan 2024 02:46:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A747179BE; Wed, 24 Jan 2024 02:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Kg3FblHW" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 B61D217559; Wed, 24 Jan 2024 02:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706064162; cv=none; b=b9O4pxN/1nQRZwTBdgmpWO42MWKdD9xx3cOs0Lzcxl9/SIQgELKRWGr27yR3C53Ztfm55movb+VfmrA21/QxCCbxB1HZWJFWrarVszM7HROdsgfZT8xraX/E8xDkjNoYzP4TctvmzikofX/tJUpKRJzSMDPGHDHFP215mUDKm/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706064162; c=relaxed/simple; bh=T3X3fq7AuhPHM7WBbIb8WSrvU0kDaKc1Pze+7ySZgmo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q1Z8AEW9byAoxQidpxzFvYo7bxyP1diw7MJW4SEWjuPAaOx70HLNP/6NBbTHa2JhgykSQ196ogK3mkTA9libnqLEdDRxR8qwFLblgcsMEKtb7hLUiZer8R9jZXGn/1Yx99mJX0v5MlUq0QLXXuJHLEqMA2tSOelMBAywmcTJZLE= 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=Kg3FblHW; arc=none smtp.client-ip=192.55.52.120 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=1706064160; x=1737600160; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T3X3fq7AuhPHM7WBbIb8WSrvU0kDaKc1Pze+7ySZgmo=; b=Kg3FblHWQpYERXvNPXmRkdkQ9Tw3fgEtYhtSc66+i/y3VJJoeWhBGyR0 c/MwoFWyHcCqMvRrlj9w+AfpSRkS5PqEQi/Od7Z1EH3TSkXPrXg70aISW nhOJUjy5iRLjlVESwR59shHCCLu3BTSouvuOo60G0RcMimfIYNiQ6fxZx MQZ5uc/1iRF12QPGIaofaVwVEkn2fqZhalj1sYOJQvFxJ4zRb79QGDfl2 4kyC70f6ncU0CmGG+4yljVJ1zNWnws96QmpvjDQ83Bod8BF7btenAlqKt EfpVPQT5tnrwNlNNSDJILMgKUa/klMRjM/lDPiYC9MlSjHPl8V73K6Avu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="400586493" X-IronPort-AV: E=Sophos;i="6.05,215,1701158400"; d="scan'208";a="400586493" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 18:42:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,215,1701158400"; d="scan'208";a="1825861" Received: from 984fee00a5ca.jf.intel.com ([10.165.9.183]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 18:42:36 -0800 From: Yang Weijiang To: seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, yuan.yao@linux.intel.com 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 v9 12/27] KVM: x86: Report XSS as to-be-saved if there are supported features Date: Tue, 23 Jan 2024 18:41:45 -0800 Message-Id: <20240124024200.102792-13-weijiang.yang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240124024200.102792-1-weijiang.yang@intel.com> References: <20240124024200.102792-1-weijiang.yang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sean Christopherson Add MSR_IA32_XSS to list of MSRs reported to userspace if supported_xss is non-zero, i.e. KVM supports at least one XSS based feature. Before enabling CET virtualization series, guest IA32_MSR_XSS is guaranteed to be 0, i.e., XSAVES/XRSTORS is executed in non-root mode with XSS == 0, which equals to the effect of XSAVE/XRSTOR. Signed-off-by: Sean Christopherson Signed-off-by: Yang Weijiang Reviewed-by: Maxim Levitsky --- arch/x86/kvm/x86.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 594c9e025f95..b3a39886e418 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1464,6 +1464,7 @@ static const u32 msrs_to_save_base[] = { MSR_IA32_UMWAIT_CONTROL, MSR_IA32_XFD, MSR_IA32_XFD_ERR, + MSR_IA32_XSS, }; static const u32 msrs_to_save_pmu[] = { @@ -7374,6 +7375,10 @@ static void kvm_probe_msr_to_save(u32 msr_index) if (!(kvm_get_arch_capabilities() & ARCH_CAP_TSX_CTRL_MSR)) return; break; + case MSR_IA32_XSS: + if (!kvm_caps.supported_xss) + return; + break; default: break; } -- 2.39.3