From patchwork Wed Aug 7 08:18:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Li X-Patchwork-Id: 1969863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2024071601 header.b=Gep/dezn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wf3461ZGmz1ybS for ; Wed, 7 Aug 2024 18:19:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbbsf-0000aR-32; Wed, 07 Aug 2024 04:18:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbbsO-0000Hf-HC for qemu-devel@nongnu.org; Wed, 07 Aug 2024 04:18:32 -0400 Received: from torg.zytor.com ([2607:7c80:54:3::138] helo=mail.zytor.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbbsM-0006ui-Hd for qemu-devel@nongnu.org; Wed, 07 Aug 2024 04:18:32 -0400 Received: from terminus.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3:0:0:0:136]) (authenticated bits=0) by mail.zytor.com (8.17.2/8.17.1) with ESMTPSA id 4778IDpf735187 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 7 Aug 2024 01:18:17 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 4778IDpf735187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2024071601; t=1723018698; bh=cLhnhzRXZr2FwWzd1KskHfPSIS/PzC+PgX/l/u713kQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gep/dezni3c9dR93wP+dHZQLqT7/iiAfYrsPWP0XIPXKjUCApLLbKv4Ub3vji4RhG 33G8hWTvIclV4SyF7d4BjVsBXlcnzov6hXRenxF5BWAq3WuPAJoOl0t9gHNCCGCRCi 5J4P2d5oET4Plkep/VsQLAuwF2EXHKm6izGni4I7Vfb6OKWNwiM+UHEHT6h8WS5ZVv QPkp31Qq5uXz2C5x1ZTmarCEQjRwYRKQag2+xLxQy7hmMQDJ73e2FnP9F1J7Sdo9TD ynUyBxto59MRp7eeSyE7SW9pz231WUj2ps11Vo/QB+lytD8rgHaWlx6iaMXgWpwZFt a2skGF4qaFRSA== From: "Xin Li (Intel)" To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, lei4.wang@intel.com, zhao1.liu@intel.com, xin3.li@intel.com Subject: [PATCH v1 1/3] target/i386: Delete duplicated macro definition CR4_FRED_MASK Date: Wed, 7 Aug 2024 01:18:10 -0700 Message-ID: <20240807081813.735158-2-xin@zytor.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807081813.735158-1-xin@zytor.com> References: <20240807081813.735158-1-xin@zytor.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:7c80:54:3::138; envelope-from=xin@zytor.com; helo=mail.zytor.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Macro CR4_FRED_MASK is defined twice, delete one. Signed-off-by: Xin Li (Intel) Reviewed-by: Zhao Liu --- target/i386/cpu.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c6cc035df3..118ef9cb68 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -267,12 +267,6 @@ typedef enum X86Seg { #define CR4_FRED_MASK 0 #endif -#ifdef TARGET_X86_64 -#define CR4_FRED_MASK (1ULL << 32) -#else -#define CR4_FRED_MASK 0 -#endif - #define CR4_RESERVED_MASK \ (~(target_ulong)(CR4_VME_MASK | CR4_PVI_MASK | CR4_TSD_MASK \ | CR4_DE_MASK | CR4_PSE_MASK | CR4_PAE_MASK \ From patchwork Wed Aug 7 08:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Li X-Patchwork-Id: 1969862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2024071601 header.b=FGgfm22Z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wf33l0Pjjz1ybS for ; Wed, 7 Aug 2024 18:18:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbbsU-0000JT-1n; Wed, 07 Aug 2024 04:18:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbbsO-0000Hg-Js for qemu-devel@nongnu.org; Wed, 07 Aug 2024 04:18:32 -0400 Received: from torg.zytor.com ([2607:7c80:54:3::138] helo=mail.zytor.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbbsM-0006ug-HZ for qemu-devel@nongnu.org; Wed, 07 Aug 2024 04:18:32 -0400 Received: from terminus.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3:0:0:0:136]) (authenticated bits=0) by mail.zytor.com (8.17.2/8.17.1) with ESMTPSA id 4778IDpg735187 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 7 Aug 2024 01:18:18 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 4778IDpg735187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2024071601; t=1723018698; bh=EOqBLubJw/7uH1jzE2oM60mOC+Vpg7yytT9MIukUwio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FGgfm22Zyqc7Xt/cCdycWRchwzr+/6Pb2R1bnyWAlzygeorN7rDYVwPYKeb9NmV5k RrP9szGswvjaWAYAolNdkKs4odIqMCn2m4Vae9vfKUfUOhO8hnmdd9OeCAiMVP8uG8 vmb4A8F8HlKomKPXcPrtzJUNvVJplUZxf0bWloaVstCuQXA7rGCNLfffuUR0r5BNLu jOFKPVNTbJZ/Dh9DEmNKGSoMvVmyC12tegVnv6Sukn588R1AuQFgXBh2rkASEvGXt0 PXX5suiINPt3xcNWxZOS6PMtmGqUUamxjSUydcOB8IUKtU+5dKOBYwhFtT5BLBYS9+ glGw8sV/2bmfg== From: "Xin Li (Intel)" To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, lei4.wang@intel.com, zhao1.liu@intel.com, xin3.li@intel.com Subject: [PATCH v1 2/3] target/i386: Add VMX control bits for nested FRED support Date: Wed, 7 Aug 2024 01:18:11 -0700 Message-ID: <20240807081813.735158-3-xin@zytor.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807081813.735158-1-xin@zytor.com> References: <20240807081813.735158-1-xin@zytor.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:7c80:54:3::138; envelope-from=xin@zytor.com; helo=mail.zytor.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add definitions of 1) VM-exit activate secondary controls bit 2) VM-entry load FRED bit which are required to enable nested FRED. Reviewed-by: Zhao Liu Signed-off-by: Xin Li (Intel) --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 85ef7452c0..31f287cae0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1435,7 +1435,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { "vmx-exit-save-efer", "vmx-exit-load-efer", "vmx-exit-save-preemption-timer", "vmx-exit-clear-bndcfgs", NULL, "vmx-exit-clear-rtit-ctl", NULL, NULL, - NULL, "vmx-exit-load-pkrs", NULL, NULL, + NULL, "vmx-exit-load-pkrs", NULL, "vmx-exit-secondary-ctls", }, .msr = { .index = MSR_IA32_VMX_TRUE_EXIT_CTLS, @@ -1450,7 +1450,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { NULL, "vmx-entry-ia32e-mode", NULL, NULL, NULL, "vmx-entry-load-perf-global-ctrl", "vmx-entry-load-pat", "vmx-entry-load-efer", "vmx-entry-load-bndcfgs", NULL, "vmx-entry-load-rtit-ctl", NULL, - NULL, NULL, "vmx-entry-load-pkrs", NULL, + NULL, NULL, "vmx-entry-load-pkrs", "vmx-entry-load-fred", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, From patchwork Wed Aug 7 08:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Li X-Patchwork-Id: 1969864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2024071601 header.b=Cd6jmI6j; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wf36Q2lDJz1yfC for ; Wed, 7 Aug 2024 18:21:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbbua-0001Bf-AT; Wed, 07 Aug 2024 04:20:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbbuY-00015N-FM for qemu-devel@nongnu.org; Wed, 07 Aug 2024 04:20:46 -0400 Received: from torg.zytor.com ([2607:7c80:54:3::138] helo=mail.zytor.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbbuW-0007G4-5b for qemu-devel@nongnu.org; Wed, 07 Aug 2024 04:20:46 -0400 Received: from terminus.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3:0:0:0:136]) (authenticated bits=0) by mail.zytor.com (8.17.2/8.17.1) with ESMTPSA id 4778IDph735187 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 7 Aug 2024 01:18:19 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 4778IDph735187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2024071601; t=1723018699; bh=0zoLZBu6i+pYaksTM9d8A0bq3H7+OisO3/x/5JiQ+a4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cd6jmI6jkkbczXYlJZfYrW4d/1FOSL7BVPwDsAPiM4xkgGx04hou99Sw8KMcyJPLL OA9EwbwD1lFNOJst6T9Vn37YrEjIiw5hEBl5SZfU5JpHu0YpnlUsI7CEMHYiMV5DSJ zsntBo3SQU/fZOkiK7qnRdpoBvibSxAXSTjbmY05W4MRQLOyCkm44Ob8ftUZ4+zMW5 hUCIWS5+4X6j7PziOhkv31zrHggoi4/ur3oi0JfCPpRUvr3rkS13pDm3GG53WB4EVS 5fPhAJJxc7QJWf2u+m4b8A4jYbVMfcJbAojvTm7OMI6XKWlkzrrVGl9XMOJTlNwZHX 1Cj7vk/cuDvNg== From: "Xin Li (Intel)" To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, lei4.wang@intel.com, zhao1.liu@intel.com, xin3.li@intel.com Subject: [PATCH v1 3/3] target/i386: Raise the highest index value used for any VMCS encoding Date: Wed, 7 Aug 2024 01:18:12 -0700 Message-ID: <20240807081813.735158-4-xin@zytor.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807081813.735158-1-xin@zytor.com> References: <20240807081813.735158-1-xin@zytor.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:7c80:54:3::138; envelope-from=xin@zytor.com; helo=mail.zytor.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Lei Wang Because the index value of the VMCS field encoding of FRED injected-event data (one of the newly added VMCS fields for FRED transitions), 0x52, is larger than any existing index value, raise the highest index value used for any VMCS encoding to 0x52. Because the index value of the VMCS field encoding of Secondary VM-exit controls, 0x44, is larger than any existing index value, raise the highest index value used for any VMCS encoding to 0x44. Co-developed-by: Xin Li Signed-off-by: Xin Li Signed-off-by: Lei Wang Signed-off-by: Xin Li (Intel) --- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 118ef9cb68..62324c3dcd 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1186,6 +1186,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w); #define VMX_VM_EXIT_PT_CONCEAL_PIP 0x01000000 #define VMX_VM_EXIT_CLEAR_IA32_RTIT_CTL 0x02000000 #define VMX_VM_EXIT_LOAD_IA32_PKRS 0x20000000 +#define VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS 0x80000000 #define VMX_VM_ENTRY_LOAD_DEBUG_CONTROLS 0x00000004 #define VMX_VM_ENTRY_IA32E_MODE 0x00000200 diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 31f149c990..fac5990274 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3694,7 +3694,14 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f) kvm_msr_entry_add(cpu, MSR_IA32_VMX_CR4_FIXED0, CR4_VMXE_MASK); - if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) { + if (f[FEAT_7_1_EAX] & CPUID_7_1_EAX_FRED) { + /* FRED injected-event data (0x2052). */ + kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x52); + } else if (f[FEAT_VMX_EXIT_CTLS] & + VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS) { + /* Secondary VM-exit controls (0x2044). */ + kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x44); + } else if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) { /* TSC multiplier (0x2032). */ kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x32); } else {