Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp895152rdh; Fri, 24 Nov 2023 00:01:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtklPCqMtxGGljcLe1CH5u3kjIVoxvQbtqBahWjz+J4ChIzatWY+Aotn/ZNqYiR/ACq8H3 X-Received: by 2002:a05:6e02:1c0f:b0:35b:861:a8f4 with SMTP id l15-20020a056e021c0f00b0035b0861a8f4mr2655387ilh.0.1700812897709; Fri, 24 Nov 2023 00:01:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700812897; cv=none; d=google.com; s=arc-20160816; b=t668daJeUgYqfhJBCWqTzykgDVH8tLIzpM/+AIx/HMwWb6HPlfm6OoZn74DfN8+Tt9 XmwXT76Ei4Ot55dv/4ykpPGDXiBk64kBWeQkCop1Se15ik91t6XDTtjILYMhhYYK6kVD 7PFmwKhHBd/+qhKqaNm8BZDCB3fvpQFyV5qfsX8jQNzfCACFnFWj/+AFy3xp8GIlJKrd 60Lx65jJVyt+E0QHDAlrhrr0eBkdNJlEM86KXbjoyYOPrr3L5IFsvEDXGTEEsC+LGaqK VUGuFgTS+lu8gU+mL33nxq4AEDZyPh1RzCVszEejcLIEt01VXOxvhK3jzkLtv1UHWoWh C3HQ== 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=ZFgvPMy7Evo9i8PljfA9l3MGdeQAQ0kXhnAjLWkCh04=; fh=uy0EBGgYIm8+MgsxUvKHUXUo3s9z4H9hdLwRv8YoeJU=; b=eUDoaObHJel3uBetXJumrISH2eeQi6jMpAvo23RPXNnrhiv58f9zbVOVDvpmhBwjc/ ctNacVMEPJfIwOQ+rlEnigjKCPvsjXhDG6avA/yiOklrEyx3QlbUHCVKEus1PxH02h+m 9c07RRXZUkZwK8USrv2MWpwC1/PT4y2UVzN0uH+ZI7ZvPxawS24E4kFG7FkaFMJ0flHU URff7RPx2qYD6an5HmqpOk+SorqUXQ1sS4kk4csrZHG0zNWKpirJREaul8dxwJblBVsv uICq3rjt9TJZ6oxudnDmzE7tZubRrRRjt2o9K1RXaPUp78dmlRN3HhoIP+me5ERGWFMx YcVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fXRbtmq9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fc4-20020a056a002e0400b006cba60de063si3045402pfb.22.2023.11.24.00.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 00:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fXRbtmq9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id D2F06806E4CE; Fri, 24 Nov 2023 00:00:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345201AbjKXIAY (ORCPT + 99 others); Fri, 24 Nov 2023 03:00:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbjKXH6l (ORCPT ); Fri, 24 Nov 2023 02:58:41 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3603B1711; Thu, 23 Nov 2023 23:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700812728; x=1732348728; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dKuF/arCze+lNWNbIVwbb5cqE0y+kfgXSzDJUMBR+Nk=; b=fXRbtmq9iS0k//0VwvngbE1bXQuEEuOfmv6YR07Sq+eZGBs23qgjeUun xvsW+CSMvLMEU71TzAMxMopuDOI3lM/D8TpaiUa6aslVzaTV70nO4Td0e L7kqM+RY6qLwsAMZzr2WRU9bK5LZlDtHnfq5Kk31wfWC74EwFLNjqKXke wweqHftBIjJe16xWmiSQCojNbni/6bI7au8ubrAWct9cifRopcXki3DxA rbduMqjvGtaht04JrGrdKUhkLr5QhER6PlQZBkVfx682zMu+18wuYROWl SAXhEbaPt8CMlvA3K8DKVqATi6WzDZCiZWwtqOcmHusfMIB0AyDRn5fAc Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="458872380" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="458872380" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2023 23:58:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="833629850" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="833629850" Received: from unknown (HELO embargo.jf.intel.com) ([10.165.9.183]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2023 23:58:41 -0800 From: Yang Weijiang To: seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, 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 v7 19/26] KVM: x86: Use KVM-governed feature framework to track "SHSTK/IBT enabled" Date: Fri, 24 Nov 2023 00:53:23 -0500 Message-Id: <20231124055330.138870-20-weijiang.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231124055330.138870-1-weijiang.yang@intel.com> References: <20231124055330.138870-1-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Fri, 24 Nov 2023 00:00:58 -0800 (PST) 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. TODO: remove this patch once Sean's refactor to "KVM-governed" framework is upstreamed. See the work here [*]. [*]: https://lore.kernel.org/all/20231110235528.1561679-1-seanjc@google.com/ 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 d3d0d74fef70..f6ad5ba5d518 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7762,6 +7762,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