Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4593029rdb; Fri, 15 Sep 2023 07:00:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ4jMVY7GKVhqh+KAxO8rrQGYFN4QDpYOWw44q1PlQPWs8uOmBiqh2+Ftpfq6Uksxxmigf X-Received: by 2002:a05:6a20:3246:b0:15a:68a4:519a with SMTP id hm6-20020a056a20324600b0015a68a4519amr1350668pzc.14.1694786421802; Fri, 15 Sep 2023 07:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694786421; cv=none; d=google.com; s=arc-20160816; b=jizZnPQu/euVUkaiNBAGFyWvOARnDLjroR8dqwv42bHnBZGii+vqpEN6UxCrycY4QC A2yDge3jUx+QbHqmH5agyxZc0G0LH2K36jxx/n1iGF6kqrc73OaYhcTijf7w4ulQFzcm 7Y5n9otKRbyyVAESCEHulOqcFqHBiIN3s09O5Tc6H/Dc5kJUfyWLTuLEdaTu8Bho+rZj xIZ0G5r1IjyttBrUArNtmY+ORJl6RcFBMguzZJo1uIZy0iPeScG4R9AeICKKFeBavfRk RskbuP7t3nVUiqbCvaO9xmyFSDbffQqDwSa3k5o7uTrUmTlPHWuAjth8yNC8X72uLcdo 8+VQ== 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=ejCSRWNUtjfScEInpv1vLC5+M/MCs3U5cD6mcWKXJtQ=; fh=jQqUhNQZPAXcZ44u72Wu3jv2pQizzn2Be2T8mkd1RwU=; b=sxBwsHHfRarvyRRP4OeqLLOyDcCMIpb6gPuzpi09bdI5im9NutVoX6GGrQFa9nfHDw 6XQqp21WY67dCYGiG7rlguKHh5gbvdv3cudPYvkxzSqXVnn6ylQOSkxShdpfz86hLaOU WasO/P5stYdjh7qkXNuD8GfAb87PnZj2TwXfy6MlYOku74EOM3Qk7f6WX5mQ2SHYEP0v Isn2fKXPf8WVdUVhhgwIhl2P+D2zOV96AEKvmwRgcifyCDMqaiqQg7e7+S9rfYCv841Y ON911STxua1WrO/8cc98g+xXDkpeHGnlrUNWG4hFF8zRd7LA5DwmUiv4q/bvQQHDnZAN WVzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E0BwAGNp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id eb8-20020a056a004c8800b0068fcccf5c87si3424229pfb.300.2023.09.15.07.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:00:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E0BwAGNp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7DDEF824BAC6; Thu, 14 Sep 2023 02:39:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237579AbjINJjU (ORCPT + 99 others); Thu, 14 Sep 2023 05:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237403AbjINJi2 (ORCPT ); Thu, 14 Sep 2023 05:38:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76EA31FCD; Thu, 14 Sep 2023 02:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694684302; x=1726220302; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+nX7XbfVJDmuajtuURcflfcN8G9QEQqgxp6V39Gi2/4=; b=E0BwAGNpX3ZGaRcX3ukmz3L68KkLiByzH4Uk5e/pIHyqAc+0vPRahE8r YXrYMYsDHUnRSurguhEP38+V+rTSBaleENKqAZlX3AEGLQdPn0sSR1p/X KLitecvwT0b65iHHROUaAqVZjuSr/yaaoyctYECmszOo1MthqIm8xgcGu OXvpjCJMe7XZXbUMCsmzmLeRGitm7tv5oTE0I2zOxoOoW941VMByN52pY YWjPR4SKkJC7a7TL9oW+P0vTVcIrNoPUTyN9n8nAJMKLuX473GQ4iTH75 J0WF88st1/xsYbqiuAbABxH1yQTsBb84/titEFpiX2ZT/jyDSiB4AR5CJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="409857407" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="409857407" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 02:38:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="747656279" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="747656279" Received: from embargo.jf.intel.com ([10.165.9.183]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 02:38:21 -0700 From: Yang Weijiang To: seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dave.hansen@intel.com, peterz@infradead.org, chao.gao@intel.com, rick.p.edgecombe@intel.com, weijiang.yang@intel.com, john.allen@amd.com Subject: [PATCH v6 18/25] KVM: x86: Use KVM-governed feature framework to track "SHSTK/IBT enabled" Date: Thu, 14 Sep 2023 02:33:18 -0400 Message-Id: <20230914063325.85503-19-weijiang.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230914063325.85503-1-weijiang.yang@intel.com> References: <20230914063325.85503-1-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:39:30 -0700 (PDT) X-Spam-Status: No, score=0.2 required=5.0 tests=DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Use the governed feature framework to track whether X86_FEATURE_SHSTK and X86_FEATURE_IBT features can be used by userspace and guest, i.e., the features can be used iff both KVM and guest CPUID can support them. Signed-off-by: Yang Weijiang --- arch/x86/kvm/governed_features.h | 2 ++ arch/x86/kvm/vmx/vmx.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/x86/kvm/governed_features.h b/arch/x86/kvm/governed_features.h index 423a73395c10..db7e21c5ecc2 100644 --- a/arch/x86/kvm/governed_features.h +++ b/arch/x86/kvm/governed_features.h @@ -16,6 +16,8 @@ KVM_GOVERNED_X86_FEATURE(PAUSEFILTER) KVM_GOVERNED_X86_FEATURE(PFTHRESHOLD) KVM_GOVERNED_X86_FEATURE(VGIF) KVM_GOVERNED_X86_FEATURE(VNMI) +KVM_GOVERNED_X86_FEATURE(SHSTK) +KVM_GOVERNED_X86_FEATURE(IBT) #undef KVM_GOVERNED_X86_FEATURE #undef KVM_GOVERNED_FEATURE diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 9409753f45b0..fd5893b3a2c8 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7765,6 +7765,8 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_XSAVES); kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_VMX); + kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_SHSTK); + kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_IBT); vmx_setup_uret_msrs(vmx); -- 2.27.0