Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp251188img; Mon, 25 Feb 2019 22:33:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IbDWgnLJLk1WZJe/rnzsL8yQk8n+Yyd3YCAhs2tmk5wnm/sBR8DnWtlWi2sCC3P94c2YKJa X-Received: by 2002:aa7:8508:: with SMTP id v8mr24355234pfn.14.1551162813030; Mon, 25 Feb 2019 22:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551162813; cv=none; d=google.com; s=arc-20160816; b=p7KUUlIFSemOhO0NqvcIdrOvNCbRS+Suqh6za+Yn2/Hts0VUSK+rTT0qg8El9n56lV B7OOwBN7awy30Kb5CHTgNgGvWWMdyAO3XWD1cuGWUVLoSsJO5D+45oSP1i8FUDT+kLUM ufKyuaWgACkx6+hWWUlrRPUVK6bpzUAoyIXPQ6480CVjId8vpUmL3kLrorlRjSDKB0EA 0y3abPrmgt+Vba2Ug811IANd8YlkGNoZ+V2VK53u4sKQEw5Od01asm3rnGktB/dNS/uZ FuRrPN02fe+Prv8XoLZSpR5jCAYsUJWMjJD0ISb674h7tHq58DwYsMfEJeWndg3plUl5 YTfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=szvRoru0T4Mzj8Kx1kYlDkpJrZxULnsm/Kzbm1LzQpM=; b=oGbrb74y8yx8/nN4K4O1jqOMt8uCWEcu6cpw8GBrlP7U3NPYv3VBRSNrpewFwejAZN c91CTDtrfOgxhq9gsTbResLqOJA2b7QoRreWbHyM+CGRUC/0957rIOQSb+JU84l3K6LM M612rRVe4Thuew5eOR3xr04zzNFFWbKvuamN5cDMuJ4864PCT3BvTOZAvNpUAsHvu2Wh 37QO9nTT4QU+KtVnxzaNJnBcXR/MlF8DJv8SpbIqzkp03JeODm4GgniZrDMp72gd9Evm 7Xn5SqzE41VR0VM6yC1+Y7lMR02HuJCYccJ8iNgZJmTTdKBwgwms4Co/0/u72KsnQxMT e9DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y17si13026515pfb.204.2019.02.25.22.33.18; Mon, 25 Feb 2019 22:33:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726627AbfBZGcu (ORCPT + 99 others); Tue, 26 Feb 2019 01:32:50 -0500 Received: from mga17.intel.com ([192.55.52.151]:18105 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbfBZGct (ORCPT ); Tue, 26 Feb 2019 01:32:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2019 22:32:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,414,1544515200"; d="scan'208";a="141666076" Received: from local-michael-cet-test.sh.intel.com ([10.239.159.128]) by orsmga001.jf.intel.com with ESMTP; 25 Feb 2019 22:32:46 -0800 From: Yang Weijiang To: pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, jmattson@google.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mst@redhat.com, yu-cheng.yu@intel.com Cc: Yang Weijiang , Zhang Yi Z Subject: [PATCH v3 2/8] KVM:CPUID: Define CET CPUID bits and CR4.CET master enable bit. Date: Mon, 25 Feb 2019 21:27:10 +0800 Message-Id: <20190225132716.6982-3-weijiang.yang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225132716.6982-1-weijiang.yang@intel.com> References: <20190225132716.6982-1-weijiang.yang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Guest queries CET SHSTK and IBT support by CPUID.(EAX=0x7,ECX=0), in return, ECX[bit 7] corresponds to SHSTK feature, and EDX[bit 20] corresponds to IBT feature. CR4.CET[bit 23] is CET master enable bit, it controls CET feature availability in guest OS. Note: Although SHSTK or IBT can be enabled independently, either of the features is controlled by CR4.CET. Signed-off-by: Zhang Yi Z Signed-off-by: Yang Weijiang --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/cpuid.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 55e51ff7e421..df002936088f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -90,7 +90,8 @@ | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \ | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \ | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \ - | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP)) + | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP \ + | X86_CR4_CET)) #define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 7bcfa61375c0..cb1aece25b17 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -406,12 +406,12 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ | F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) | F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) | - F(CLDEMOTE); + F(CLDEMOTE) | F(SHSTK); /* cpuid 7.0.edx*/ const u32 kvm_cpuid_7_0_edx_x86_features = F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | - F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES); + F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(IBT); /* all calls to cpuid_count() should be made on the same cpu */ get_cpu(); -- 2.17.1