Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp208054lqj; Wed, 10 Apr 2024 08:15:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWx5GWhEV0RihTB0MztHfyaQO2qaqmL5fhIEALGoXhpP2WAbPrjxY7rdGAEPfTTZhBoB7UQ4HBTuOQ+oeXd84olRXP7Tlimm6061SqZRQ== X-Google-Smtp-Source: AGHT+IFOTqlpSOwai4mZbAQbnV5Lit0+i6gAKlUdYuYnnmxgtfo3fs0cqcbMxcYDA2ZV3KdY5vrZ X-Received: by 2002:a17:902:d551:b0:1e3:dfdd:21c0 with SMTP id z17-20020a170902d55100b001e3dfdd21c0mr3816582plf.27.1712762125878; Wed, 10 Apr 2024 08:15:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712762125; cv=pass; d=google.com; s=arc-20160816; b=bBWvFKNrlDk6pHuZE6CGiR2KdJ1Y2VSFdmelG84jhL95W10aWKxXxa2QDjSkBRMsAr LfJa1yELt2bpZk77/BF8QJWBCoQt+ZRwEar9ig8zhq4c/L7vSFbJ/P+yJbZ4AErmDF3e cObA1xrdUUeYfCD6r3nWlegQvfcAp84Ljw8ta8+dPw1tf1hEATfOLFX2b2wHuasgsHA1 m9fqwHCepZQ3yZgq7af4nZz4ZI+2E9J24VFZuBqz6dH/ZeoVse5X6XXnoUiSJDGPyIYE 6XGGjesHaqH1xwDd+RnyBWQwB6JC7I/8TYcOh/wocbO5R7YskJCmhK5/vCDbCVdmWUmC mKwQ== 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=l67X+K1DES6ZD/6eqqM9eHK4D8eFRi+Y97e0WR3691g=; fh=/RcyqM9yI3r8nElMPc7iVz0fjDeKVDKSRE+vhuZPInI=; b=MwKbBUFi9A8KNI04hujYwnRMoo2xahPTHULHQMaUFLQjeczxtT8OIY1K9StXom44jk 3G01649qPmvi5S6x5xDpKz2Kc8WNR0XHFEnT22quRbN/eyafY/vuehQu6Ve3E4noLSlc secZGqBIX48FP8gwEuTNH6FWag6nPVkyMAwC+PtS+GYTRWItgyROHJg8urF69owM1awt jjSbxImy6ZxYYGsIQMlvhNxgJ+gTnT1DeJhun7izdifnuAlKtLWF1mm+eZypxlxV2mYc Gquew6U5r0qwNI1GaDYG5jPFJetPXCTQII89POZUfFpAwH8BDkTfbMlc3FAuP5vTw6yb z/Tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XmFiC3Tc; 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-138763-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 23-20020a630a17000000b005dbe2220330si11065702pgk.171.2024.04.10.08.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 08:15:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138763-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XmFiC3Tc; 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-138763-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138763-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 12346B31E54 for ; Wed, 10 Apr 2024 14:39:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB1DC175557; Wed, 10 Apr 2024 14:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XmFiC3Tc" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 87AD716E866; Wed, 10 Apr 2024 14:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759760; cv=none; b=laMTsSDdgIsh6jAU8ORn9uh3RagirLGxOdfv+zDQ0uyolOeYnnu5MwYWxepRTEvstNRtoKlEViJFkxys7IbysuyuWN72UoAjF0nfS7lEr4AKRkB6aYyJrnqDuUJPoob1VgtspJNcXJt8ieCgeLb/IVISvF9GKF02hM/GdExG8xw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759760; c=relaxed/simple; bh=jdPSsyHlYjQqP3LARjfkhXrm0nOtLrLPubyWHx7h94Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RNnhfhnqamQL+aqhnly/8BOLEqZ/dlQT7w/PhfdYSEPcR13gfSOlfTK7ivhDAWqfMIoeaII65MW3ROsZw3/EpaieUpW7JpMcWyE4hk2vZq3z6QEAp+ZN5Vo8yirbvCDQ261X8RE2dFmc72ILvs+Z9a04XlzNffQlsYrc9EfLa0A= 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=XmFiC3Tc; arc=none smtp.client-ip=192.198.163.9 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=1712759759; x=1744295759; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jdPSsyHlYjQqP3LARjfkhXrm0nOtLrLPubyWHx7h94Y=; b=XmFiC3TcBibFRjA9UD6g45iNiggWM8qBMJ2i8A8jwe7L7daZ0af2c2Aa hwltAeeOif4/LAQ1rmCgM2SggJUN9E1P8oFfbkh3fALypTOPwx3NK5Zsa eBr2IQL1Z23+QG/ItT++9lkBgrkzAULcQ4FZOFQQXXtWEaywrD885jV7f 3wGhEYQSZvdct/EAtn3Fto8dujMMwnFwfvj250OYJMO/7LAC11c3/fOib tlYjmewzcrqEXCGNUuP4PldRxroDxpvCcAIXKM7Fnh/irtEh94apE23X8 gHzn9wBb/4OdUAj27mR/KATebbM5ZBm76YV2aVd/6sTfpTR7JOFOs3uRZ w==; X-CSE-ConnectionGUID: T3km9xF1QYezFYtReetSkw== X-CSE-MsgGUID: QcDcbAA+RdS6tik/kdnAeg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="18837881" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="18837881" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 07:35:58 -0700 X-CSE-ConnectionGUID: aRgrC8THQLWC3UotmZwHqQ== X-CSE-MsgGUID: ip7l6a3QS3mvJd0R5CfSmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="25095588" Received: from unknown (HELO spr.sh.intel.com) ([10.239.53.118]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 07:35:55 -0700 From: Chao Gao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: daniel.sneddon@linux.intel.com, pawan.kumar.gupta@linux.intel.com, Chao Gao , Zhang Chen , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Subject: [RFC PATCH v3 10/10] KVM: VMX: Advertise MITI_ENUM_RETPOLINE_S_SUPPORT Date: Wed, 10 Apr 2024 22:34:38 +0800 Message-Id: <20240410143446.797262-11-chao.gao@intel.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20240410143446.797262-1-chao.gao@intel.com> References: <20240410143446.797262-1-chao.gao@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 Allow guest to report if retpoline is used in supervisor mode. KVM will deploy RRSBA_DIS_S for guest if guest is using retpoline and the processor enumerates RRSBA. Signed-off-by: Zhang Chen Signed-off-by: Chao Gao --- arch/x86/kvm/vmx/vmx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index c5ceaebd954b..235cb6ad69c0 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1956,8 +1956,10 @@ static inline bool is_vmx_feature_control_msr_valid(struct vcpu_vmx *vmx, } #define VIRTUAL_ENUMERATION_VALID_BITS VIRT_ENUM_MITIGATION_CTRL_SUPPORT -#define MITI_ENUM_VALID_BITS MITI_ENUM_BHB_CLEAR_SEQ_S_SUPPORT -#define MITI_CTRL_VALID_BITS MITI_CTRL_BHB_CLEAR_SEQ_S_USED +#define MITI_ENUM_VALID_BITS (MITI_ENUM_BHB_CLEAR_SEQ_S_SUPPORT | \ + MITI_ENUM_RETPOLINE_S_SUPPORT) +#define MITI_CTRL_VALID_BITS (MITI_CTRL_BHB_CLEAR_SEQ_S_USED | \ + MITI_CTRL_RETPOLINE_S_USED) static int vmx_get_msr_feature(struct kvm_msr_entry *msr) { @@ -2508,6 +2510,11 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) if (data & ~MITI_CTRL_VALID_BITS) return 1; + if (data & MITI_CTRL_RETPOLINE_S_USED && + kvm_cpu_cap_has(X86_FEATURE_RRSBA_CTRL) && + host_arch_capabilities & ARCH_CAP_RRSBA) + spec_ctrl_mask |= SPEC_CTRL_RRSBA_DIS_S; + if (data & MITI_CTRL_BHB_CLEAR_SEQ_S_USED && kvm_cpu_cap_has(X86_FEATURE_BHI_CTRL) && !(host_arch_capabilities & ARCH_CAP_BHI_NO)) -- 2.39.3