Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8408549rwr; Thu, 11 May 2023 00:22:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7rDuYdFKlfKgbSQG3NeByHc1XqRtJ+HeLrChgWT8quW218ZMDSBkgPmKfgD00/KW9u82az X-Received: by 2002:a17:903:120d:b0:1aa:f53a:5e47 with SMTP id l13-20020a170903120d00b001aaf53a5e47mr23856769plh.16.1683789761818; Thu, 11 May 2023 00:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683789761; cv=none; d=google.com; s=arc-20160816; b=HtwXJ3lveR7VKo+PSXkwrgyPb6UbzpCEeF197H8bYf4+cHaf+92CnPT5nwSJUE7ECV 1GFBw/WQ8GrDPDUs6EvUONIBqQ0X/fAdxAfrIXomHsbEyctbUptfW9vy6KjpLiJxnEyI 7sSa4tipJB56wUoBeh3qeT6IbVZlj2SmA908svtq/iAbV6ivGa283Tv+RFKp2wtn1GUf sx6UudY8fS018Z5qeu+CW7bhjiiOSAQdk9Hzw1GZCGbt3meJ3QKTespVPWEpm1no2ixl KVLx1iHZnHEOPLkkd/1XaY2xY2XhxKAxFFXrwAJljwJaM3VEvDI3fWBJw7Q5Ticxg/qE 5hBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TYOm+3W0ih7AxCR95FVpll4/4zoedqEUZG8XwTwKcJQ=; b=TnLVzp0rG0OeXhKYHkvTos3OffMZoYJPgLn06wVZtOyosJw9Ujmie9ah3e2C3O54V5 oqlmwihehfOM5UGksMS7wXvoEkOvjZZhMc1hlamyP61MSkVYpsVRVKT8fUD54arCjG2X lvytyBwXXJTC+AK4fdMNXam0VgJClwW9QxmxQPs275gHAqr0ZYjclRjgQMh1DpE8kBiJ b/TIwI5uyqBPAT8ts5tmR8kJVp9kqF29IAp2j65VSdtffRog81TpEU04Z3dejSufldQ5 Mn7NhYAvD4JHjWtz90ME0RZrryra2XaHsc3OvKxnsbhyV8CN66Y4v4uYunbPvfjyVBbw JdaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WC5dvaxY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a1709029f9600b001a1f70cc7dbsi5636649plq.562.2023.05.11.00.22.27; Thu, 11 May 2023 00:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WC5dvaxY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237473AbjEKHN7 (ORCPT + 99 others); Thu, 11 May 2023 03:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237362AbjEKHNn (ORCPT ); Thu, 11 May 2023 03:13:43 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90A421AE; Thu, 11 May 2023 00:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683789218; x=1715325218; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FUetmM3QAjP8/HE1ypNjPP89xC2eIzQHpTYHL+d52N8=; b=WC5dvaxY8+N82py+3WjCqNQTMqcHJdyasEF0gjjufZQf8QG88CvlVZ/l SbR8QPfyUAq8rAbeizaTHWxeg5c1qt0eUmuLc9quNVym/dFF3k+SpsNa6 0t6ildFDPkjQN0YU464a/KTKKjV1aQc3CHDaFcE8YnT3/lQddJwmrC8W6 wG8GfYPAWSqVrzf//xN0DFrefUSO/5Th04iVDjLo1LlebHCm9S/YNVgw7 uBstNHn/OCuWwzPbhjHwI08KkHjuAIZUbfQEhI9CESnrOBb2ZAdXrAlJH skcP4R+lSV1t4xClGa1CpzL3Lfwlbp170bc8ifRNVPkTcfF8VUUKVssjm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="334896583" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="334896583" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 00:13:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="1029512365" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="1029512365" Received: from embargo.jf.intel.com ([10.165.9.183]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 00:13:23 -0700 From: Yang Weijiang To: seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterz@infradead.org, rppt@kernel.org, binbin.wu@linux.intel.com, rick.p.edgecombe@intel.com, weijiang.yang@intel.com, john.allen@amd.com Subject: [PATCH v3 08/21] KVM:x86: Init kvm_caps.supported_xss with supported feature bits Date: Thu, 11 May 2023 00:08:44 -0400 Message-Id: <20230511040857.6094-9-weijiang.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511040857.6094-1-weijiang.yang@intel.com> References: <20230511040857.6094-1-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Initialize kvm_caps.supported_xss with host XSS msr value AND XSS mask. KVM_SUPPORTED_XSS holds all potential supported feature bits, the result represents all KVM supported feature bits which is used for swapping guest and host FPU contents. Signed-off-by: Yang Weijiang --- arch/x86/kvm/vmx/vmx.c | 1 - arch/x86/kvm/x86.c | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 44fb619803b8..c872a5aafa50 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7806,7 +7806,6 @@ static __init void vmx_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_UMIP); /* CPUID 0xD.1 */ - kvm_caps.supported_xss = 0; if (!cpu_has_vmx_xsaves()) kvm_cpu_cap_clear(X86_FEATURE_XSAVES); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ab3360a10933..d2975ca96ac5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -223,6 +223,8 @@ static struct kvm_user_return_msrs __percpu *user_return_msrs; | XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \ | XFEATURE_MASK_PKRU | XFEATURE_MASK_XTILE) +#define KVM_SUPPORTED_XSS 0 + u64 __read_mostly host_efer; EXPORT_SYMBOL_GPL(host_efer); @@ -9472,8 +9474,10 @@ static int __kvm_x86_vendor_init(struct kvm_x86_init_ops *ops) rdmsrl_safe(MSR_EFER, &host_efer); - if (boot_cpu_has(X86_FEATURE_XSAVES)) + if (boot_cpu_has(X86_FEATURE_XSAVES)) { rdmsrl(MSR_IA32_XSS, host_xss); + kvm_caps.supported_xss = host_xss & KVM_SUPPORTED_XSS; + } kvm_init_pmu_capability(ops->pmu_ops); -- 2.27.0