From nobody Sun Oct 5 14:31:47 2025 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 18A12946A; Sat, 2 Aug 2025 00:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093766; cv=none; b=lia9dveluDs3X8QzdOghdlNzRoYooSayeCyxuNlNb30p+M66MCrqEHCN3B2o3juVNbyPvj/yOnlKpG9YDUAV7PsZ82tguXsJDclWuz5BmSVw7wvDtTZcQh7/Fqkcn0Y4Jsh1eGNEijncoiwZD/HUaQGV7uJs2Pxx7n15TydCneI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093766; c=relaxed/simple; bh=YkaTqbIa0Lhu6eQvvxFvCSIWv25wLG3CI3TsmldTmkY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kQxFGxIt7gR+2NzQMvRYIVL5FxZTt9K2VKFuPHBVOhz1cgr0znVCoHEQWPmbDluhx6zdXx5zqX4Q8xJoFHcAcWfEK+EXB9/FLuINX3SFXkVWWMmmR0GfzsJrSlsn9REhYbZ3t6SdQnsh7VMGaypvlwhyczIxyJqJxGRMhJYPOqI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=JJyjY/O/; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="JJyjY/O/" 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.18.1/8.17.1) with ESMTPSA id 5720FKpG3142596 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 1 Aug 2025 17:15:28 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 5720FKpG3142596 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025072201; t=1754093728; bh=AtjLVGdDRTprzlOEJ8gLfOLK0WV5tl2DOGR7MTz83Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJyjY/O/5i/jdQiDEs0IRFT0+Ci3n+LUhBlr9VVD/duJAd/Ae4c1jDvT9lYD8iju2 s5lHmqRKgAq8x8dGxzgB0+7doiaYciq/vQI2FPIvH7iC7LDw1qmODdVjRBXyo4zvmf WlppOC/ds7HoYnqoKxyCeFACkmXlW4zzARWVKt/q6cp5xxQycKDZRV5QRQordwrQW7 CAUI3atVsn4uMQu5gLDIgR1u5YfC91JA+3DJPYf5rAxkOMzlv5tLKJjKT/jtij2RQl wj+/y2cKfAlx884YiNKLB0cjRRywJ3KMGSojnj/Jvr6FeD2P6aBjl0SBE+jl21fla1 VdJFjSX6W7Egg== From: "Xin Li (Intel)" To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, xin@zytor.com, chao.gao@intel.com Subject: [PATCH v2 1/4] x86/cpufeatures: Add a CPU feature bit for MSR immediate form instructions Date: Fri, 1 Aug 2025 17:15:17 -0700 Message-ID: <20250802001520.3142577-2-xin@zytor.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250802001520.3142577-1-xin@zytor.com> References: <20250802001520.3142577-1-xin@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The immediate form of MSR access instructions are primarily motivated by performance, not code size: by having the MSR number in an immediate, it is available *much* earlier in the pipeline, which allows the hardware much more leeway about how a particular MSR is handled. Use a scattered CPU feature bit for MSR immediate form instructions. Suggested-by: Borislav Petkov (AMD) Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index 286d509f9363..75b43bbe2a6d 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -491,6 +491,7 @@ #define X86_FEATURE_TSA_SQ_NO (21*32+11) /* AMD CPU not vulnerable to TSA= -SQ */ #define X86_FEATURE_TSA_L1_NO (21*32+12) /* AMD CPU not vulnerable to TSA= -L1 */ #define X86_FEATURE_CLEAR_CPU_BUF_VM (21*32+13) /* Clear CPU buffers using= VERW before VMRUN */ +#define X86_FEATURE_MSR_IMM (21*32+14) /* MSR immediate form instructions= */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index b4a1f6732a3a..5fe19bbe538e 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -27,6 +27,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_APERFMPERF, CPUID_ECX, 0, 0x00000006, 0 }, { X86_FEATURE_EPB, CPUID_ECX, 3, 0x00000006, 0 }, { X86_FEATURE_INTEL_PPIN, CPUID_EBX, 0, 0x00000007, 1 }, + { X86_FEATURE_MSR_IMM, CPUID_ECX, 5, 0x00000007, 1 }, { X86_FEATURE_APX, CPUID_EDX, 21, 0x00000007, 1 }, { X86_FEATURE_RRSBA_CTRL, CPUID_EDX, 2, 0x00000007, 2 }, { X86_FEATURE_BHI_CTRL, CPUID_EDX, 4, 0x00000007, 2 }, --=20 2.50.1 From nobody Sun Oct 5 14:31:47 2025 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 E49112E3709; Sat, 2 Aug 2025 00:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093766; cv=none; b=uajpfy6ibhbpHljNrwBikjVpvA1llt4qPnSL5As3rY5UDo4hwJwi9QWCs1c1buUyEHSxK26lanqzwlCdvg/iSQm7KeF/zMszh+Q2QfBLxx/3tqUm1BXTrVW1qZHyalTSYLya9bVbvu2Lm1zSmn6U2Rw0VzsJJho5PSdKGhvq+As= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093766; c=relaxed/simple; bh=MzIR2cLKl+HewSrrVNNYWp6ZXaV4THQEI6WWciSA0Fo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NGneZjAzTkro9QyxmdlO2+KsH2JQsaRGCQr122V7XJp+hK5sagOQBo9FztK9UIBNSg9mT75WjdroAP1E0Ahg5DOir8br33UJ2JVXqkx7wYCpPum7ucJ9V2BvNfCKHiBPQIZx7xVwaEYOofqDSzxBXZvlHs9GalQWKJCj/c2z6EU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=jJHmtdFo; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="jJHmtdFo" 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.18.1/8.17.1) with ESMTPSA id 5720FKpH3142596 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 1 Aug 2025 17:15:28 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 5720FKpH3142596 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025072201; t=1754093729; bh=ZOnNopfXBW3kal1VgoAIIJvAF0qNYDB5XZWEeAFc7wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJHmtdFotCafqqW7p4xxlaTv/iRTsrpjYv11WayotVMelMKK8U4rkRKC5rT+UE9J4 R0mmjJ2ha4++Mtyyoc1t5daH90Vg8IIJu+pmn0Xoyw0V9pTTdn85WtRJfy8qVK9JMA g1yS7iCVfpdegPJA7Q1c1VNJThmHjoyhW7jA0BymoiavTDRm+qvatXyXFBFqV0RHOi pXWnhRN3QZLFCie313459GwZQPqL9wY5xN1+9P5pzboiMD98KcmScnpzBEZMoSCmR7 Dk8AqbBuXpHE1bU7TTN0M927oB7Q3pRsF5lIpci6CDInMGwidOwdUBTHIk4yRCVszh 1s1Xy2tWZqqsg== From: "Xin Li (Intel)" To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, xin@zytor.com, chao.gao@intel.com Subject: [PATCH v2 2/4] KVM: VMX: Handle the immediate form of MSR instructions Date: Fri, 1 Aug 2025 17:15:18 -0700 Message-ID: <20250802001520.3142577-3-xin@zytor.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250802001520.3142577-1-xin@zytor.com> References: <20250802001520.3142577-1-xin@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Handle two newly introduced VM exit reasons associated with the immediate form of MSR instructions. For proper virtualization of the immediate form of MSR instructions, Intel VMX architecture adds the following changes: 1) The immediate form of RDMSR uses VM exit reason 84. 2) The immediate form of WRMSRNS uses VM exit reason 85. 3) For both VM exit reasons 84 and 85, the exit qualification is set to the MSR address causing the VM exit. 4) Bits 3 ~ 6 of the VM exit instruction information field represent the operand register used in the immediate form of MSR instruction. 5) The VM-exit instruction length field records the size of the immediate form of the MSR instruction. Add code to properly virtualize the immediate form of MSR instructions. While at it, add helper functions to centralize guest MSR read/write emulation, which consolidates the MSR emulation logic and makes it easier to extend support for new MSR-related VM exit reasons introduced with the immediate form of MSR instructions. Signed-off-by: Xin Li (Intel) --- Changes in v2: *) Added nested MSR bitmap check for the two new MSR-related VM exit reasons (Chao). *) Shortened function names that still convey enough information (Chao & Sean). *) Removed VCPU_EXREG_EDX_EAX as it unnecessarily exposes details of a specific flow across KVM (Sean). *) Implemented a separate userspace completion callback for the immediate form RDMSR (Sean). *) Passed MSR data directly to __kvm_emulate_wrmsr() instead of the encoded general-purpose register containing it (Sean). *) Merged modifications to x86.c and vmx.c within the same patch to facilitate easier code review (Sean). *) Moved fastpath support in a separate following patch (Sean). --- arch/x86/include/asm/kvm_host.h | 3 ++ arch/x86/include/uapi/asm/vmx.h | 6 ++- arch/x86/kvm/vmx/nested.c | 13 +++++- arch/x86/kvm/vmx/vmx.c | 21 ++++++++++ arch/x86/kvm/vmx/vmx.h | 5 +++ arch/x86/kvm/x86.c | 73 +++++++++++++++++++++++++-------- 6 files changed, 101 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index f19a76d3ca0e..c5d0082cf0a5 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -978,6 +978,7 @@ struct kvm_vcpu_arch { unsigned long guest_debug_dr7; u64 msr_platform_info; u64 msr_misc_features_enables; + u32 cui_rdmsr_imm_reg; =20 u64 mcg_cap; u64 mcg_status; @@ -2155,7 +2156,9 @@ int __kvm_get_msr(struct kvm_vcpu *vcpu, u32 index, u= 64 *data, bool host_initiat int kvm_get_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data); int kvm_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data); int kvm_emulate_rdmsr(struct kvm_vcpu *vcpu); +int kvm_emulate_rdmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int reg); int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu); +int kvm_emulate_wrmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int reg); int kvm_emulate_as_nop(struct kvm_vcpu *vcpu); int kvm_emulate_invd(struct kvm_vcpu *vcpu); int kvm_emulate_mwait(struct kvm_vcpu *vcpu); diff --git a/arch/x86/include/uapi/asm/vmx.h b/arch/x86/include/uapi/asm/vm= x.h index f0f4a4cf84a7..9792e329343e 100644 --- a/arch/x86/include/uapi/asm/vmx.h +++ b/arch/x86/include/uapi/asm/vmx.h @@ -94,6 +94,8 @@ #define EXIT_REASON_BUS_LOCK 74 #define EXIT_REASON_NOTIFY 75 #define EXIT_REASON_TDCALL 77 +#define EXIT_REASON_MSR_READ_IMM 84 +#define EXIT_REASON_MSR_WRITE_IMM 85 =20 #define VMX_EXIT_REASONS \ { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ @@ -158,7 +160,9 @@ { EXIT_REASON_TPAUSE, "TPAUSE" }, \ { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \ { EXIT_REASON_NOTIFY, "NOTIFY" }, \ - { EXIT_REASON_TDCALL, "TDCALL" } + { EXIT_REASON_TDCALL, "TDCALL" }, \ + { EXIT_REASON_MSR_READ_IMM, "MSR_READ_IMM" }, \ + { EXIT_REASON_MSR_WRITE_IMM, "MSR_WRITE_IMM" } =20 #define VMX_EXIT_REASON_FLAGS \ { VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" } diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index b8ea1969113d..4e6352ef9520 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -6216,19 +6216,26 @@ static bool nested_vmx_exit_handled_msr(struct kvm_= vcpu *vcpu, struct vmcs12 *vmcs12, union vmx_exit_reason exit_reason) { - u32 msr_index =3D kvm_rcx_read(vcpu); + u32 msr_index; gpa_t bitmap; =20 if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS)) return true; =20 + if (exit_reason.basic =3D=3D EXIT_REASON_MSR_READ_IMM || + exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE_IMM) + msr_index =3D vmx_get_exit_qual(vcpu); + else + msr_index =3D kvm_rcx_read(vcpu); + /* * The MSR_BITMAP page is divided into four 1024-byte bitmaps, * for the four combinations of read/write and low/high MSR numbers. * First we need to figure out which of the four to use: */ bitmap =3D vmcs12->msr_bitmap; - if (exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE) + if (exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE || + exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE_IMM) bitmap +=3D 2048; if (msr_index >=3D 0xc0000000) { msr_index -=3D 0xc0000000; @@ -6527,6 +6534,8 @@ static bool nested_vmx_l1_wants_exit(struct kvm_vcpu = *vcpu, return nested_cpu_has2(vmcs12, SECONDARY_EXEC_DESC); case EXIT_REASON_MSR_READ: case EXIT_REASON_MSR_WRITE: + case EXIT_REASON_MSR_READ_IMM: + case EXIT_REASON_MSR_WRITE_IMM: return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason); case EXIT_REASON_INVALID_STATE: return true; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index aa157fe5b7b3..c112595dfff9 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6003,6 +6003,23 @@ static int handle_notify(struct kvm_vcpu *vcpu) return 1; } =20 +static int vmx_get_msr_imm_reg(void) +{ + return vmx_get_instr_info_reg(vmcs_read32(VMX_INSTRUCTION_INFO)); +} + +static int handle_rdmsr_imm(struct kvm_vcpu *vcpu) +{ + return kvm_emulate_rdmsr_imm(vcpu, vmx_get_exit_qual(vcpu), + vmx_get_msr_imm_reg()); +} + +static int handle_wrmsr_imm(struct kvm_vcpu *vcpu) +{ + return kvm_emulate_wrmsr_imm(vcpu, vmx_get_exit_qual(vcpu), + vmx_get_msr_imm_reg()); +} + /* * The exit handlers return 1 if the exit was handled fully and guest exec= ution * may resume. Otherwise they set the kvm_run parameter to indicate what = needs @@ -6061,6 +6078,8 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu= *vcpu) =3D { [EXIT_REASON_ENCLS] =3D handle_encls, [EXIT_REASON_BUS_LOCK] =3D handle_bus_lock_vmexit, [EXIT_REASON_NOTIFY] =3D handle_notify, + [EXIT_REASON_MSR_READ_IMM] =3D handle_rdmsr_imm, + [EXIT_REASON_MSR_WRITE_IMM] =3D handle_wrmsr_imm, }; =20 static const int kvm_vmx_max_exit_handlers =3D @@ -6495,6 +6514,8 @@ static int __vmx_handle_exit(struct kvm_vcpu *vcpu, f= astpath_t exit_fastpath) #ifdef CONFIG_MITIGATION_RETPOLINE if (exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE) return kvm_emulate_wrmsr(vcpu); + else if (exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE_IMM) + return handle_wrmsr_imm(vcpu); else if (exit_reason.basic =3D=3D EXIT_REASON_PREEMPTION_TIMER) return handle_preemption_timer(vcpu); else if (exit_reason.basic =3D=3D EXIT_REASON_INTERRUPT_WINDOW) diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index d3389baf3ab3..24d65dac5e89 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -706,6 +706,11 @@ static inline bool vmx_guest_state_valid(struct kvm_vc= pu *vcpu) =20 void dump_vmcs(struct kvm_vcpu *vcpu); =20 +static inline int vmx_get_instr_info_reg(u32 vmx_instr_info) +{ + return (vmx_instr_info >> 3) & 0xf; +} + static inline int vmx_get_instr_info_reg2(u32 vmx_instr_info) { return (vmx_instr_info >> 28) & 0xf; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a1c49bc681c4..fe12aae7089c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1968,6 +1968,13 @@ static void complete_userspace_rdmsr(struct kvm_vcpu= *vcpu) } } =20 +static void complete_userspace_rdmsr_imm(struct kvm_vcpu *vcpu) +{ + if (!vcpu->run->msr.error) + kvm_register_write(vcpu, vcpu->arch.cui_rdmsr_imm_reg, + vcpu->run->msr.data); +} + static int complete_emulated_msr_access(struct kvm_vcpu *vcpu) { return complete_emulated_insn_gp(vcpu, vcpu->run->msr.error); @@ -1990,6 +1997,12 @@ static int complete_fast_rdmsr(struct kvm_vcpu *vcpu) return complete_fast_msr_access(vcpu); } =20 +static int complete_fast_rdmsr_imm(struct kvm_vcpu *vcpu) +{ + complete_userspace_rdmsr_imm(vcpu); + return complete_fast_msr_access(vcpu); +} + static u64 kvm_msr_reason(int r) { switch (r) { @@ -2024,56 +2037,82 @@ static int kvm_msr_user_space(struct kvm_vcpu *vcpu= , u32 index, return 1; } =20 -int kvm_emulate_rdmsr(struct kvm_vcpu *vcpu) +static int __kvm_emulate_rdmsr(struct kvm_vcpu *vcpu, u32 msr, int reg, + int (*complete_rdmsr)(struct kvm_vcpu *)) { - u32 ecx =3D kvm_rcx_read(vcpu); u64 data; int r; =20 - r =3D kvm_get_msr_with_filter(vcpu, ecx, &data); - + r =3D kvm_get_msr_with_filter(vcpu, msr, &data); if (!r) { - trace_kvm_msr_read(ecx, data); + trace_kvm_msr_read(msr, data); =20 - kvm_rax_write(vcpu, data & -1u); - kvm_rdx_write(vcpu, (data >> 32) & -1u); + if (reg < 0) { + kvm_rax_write(vcpu, data & -1u); + kvm_rdx_write(vcpu, (data >> 32) & -1u); + } else { + kvm_register_write(vcpu, reg, data); + } } else { /* MSR read failed? See if we should ask user space */ - if (kvm_msr_user_space(vcpu, ecx, KVM_EXIT_X86_RDMSR, 0, - complete_fast_rdmsr, r)) + if (kvm_msr_user_space(vcpu, msr, KVM_EXIT_X86_RDMSR, 0, + complete_rdmsr, r)) return 0; - trace_kvm_msr_read_ex(ecx); + trace_kvm_msr_read_ex(msr); } =20 return kvm_x86_call(complete_emulated_msr)(vcpu, r); } + +int kvm_emulate_rdmsr(struct kvm_vcpu *vcpu) +{ + return __kvm_emulate_rdmsr(vcpu, kvm_rcx_read(vcpu), -1, + complete_fast_rdmsr); +} EXPORT_SYMBOL_GPL(kvm_emulate_rdmsr); =20 -int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu) +int kvm_emulate_rdmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int reg) +{ + vcpu->arch.cui_rdmsr_imm_reg =3D reg; + + return __kvm_emulate_rdmsr(vcpu, msr, reg, complete_fast_rdmsr_imm); +} +EXPORT_SYMBOL_GPL(kvm_emulate_rdmsr_imm); + +static int __kvm_emulate_wrmsr(struct kvm_vcpu *vcpu, u32 msr, u64 data) { - u32 ecx =3D kvm_rcx_read(vcpu); - u64 data =3D kvm_read_edx_eax(vcpu); int r; =20 - r =3D kvm_set_msr_with_filter(vcpu, ecx, data); + r =3D kvm_set_msr_with_filter(vcpu, msr, data); =20 if (!r) { - trace_kvm_msr_write(ecx, data); + trace_kvm_msr_write(msr, data); } else { /* MSR write failed? See if we should ask user space */ - if (kvm_msr_user_space(vcpu, ecx, KVM_EXIT_X86_WRMSR, data, + if (kvm_msr_user_space(vcpu, msr, KVM_EXIT_X86_WRMSR, data, complete_fast_msr_access, r)) return 0; /* Signal all other negative errors to userspace */ if (r < 0) return r; - trace_kvm_msr_write_ex(ecx, data); + trace_kvm_msr_write_ex(msr, data); } =20 return kvm_x86_call(complete_emulated_msr)(vcpu, r); } + +int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu) +{ + return __kvm_emulate_wrmsr(vcpu, kvm_rcx_read(vcpu), kvm_read_edx_eax(vcp= u)); +} EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr); =20 +int kvm_emulate_wrmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int reg) +{ + return __kvm_emulate_wrmsr(vcpu, msr, kvm_register_read(vcpu, reg)); +} +EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr_imm); + int kvm_emulate_as_nop(struct kvm_vcpu *vcpu) { return kvm_skip_emulated_instruction(vcpu); --=20 2.50.1 From nobody Sun Oct 5 14:31:47 2025 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 A6F8E6FC3; Sat, 2 Aug 2025 00:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093767; cv=none; b=T/ESgAjQrf/FxyKKkKTL5xjva6X3n6ufFTb/ZLPrCDo1J7wXm3LIhVd9zG8CCmj/MVUr+xVRoCai+NbSoiANY4ueatHaJeD+DaVqQun98gQoUNOBth86p0k+R5tHD00GHvll531EfIb67EqKa+77VvpJt44TqIEqFYlTnxU5fVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093767; c=relaxed/simple; bh=AHwmC+gm7+qpdc3IAvsnVa4r2mizxUsEuxjacD0Nb4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LsP0nymtJvKofHRp/+dktbGJF1RDNKUobA5+E1YplVJleC1TYdOz0jo0nmlekIjg8LVfZSFJn/nAgvILtU3Xvl3PdoowtKs7M8cjNkRfWVeGJHr3vXTqF6K/4SGkv8ytJjShSG4KuEqMnvJBHmnlxpjcrfJBHC0soLO3pFG29G0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=LAUQuqS1; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="LAUQuqS1" 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.18.1/8.17.1) with ESMTPSA id 5720FKpI3142596 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 1 Aug 2025 17:15:29 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 5720FKpI3142596 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025072201; t=1754093730; bh=g0BFgLXFoLbPOU1iuB9rAuWpOPog/vwxok3IAd7sUD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAUQuqS1EXmaY2Gr8d2qPNDTcTpJVJ/Wizjb7L6uMIbvbePpwgi2Gj0pFLg0ZmjEV E4m745OJCV54KU2E15ha18uiBsplfCgsXmqCIjQ5+y5nwNsBm1QSohFA/GL3CPXBzq St6TObaGEbpMV1gklOrh4ayA/Nn7cy7sE6yU6Evv8DW/8Xh3JyEI4yqBvqV+w4OchG tA7g1swOFaXK+aSSjv5o4z/8RlMX/SihfnFyBpDC3imgiEAzmUBMJz8QTYYqTCHKAB 6Rm6ZcjBEqP/xjc8ekTORPZ6iaaykiaH4tXpci5hZp9ag1IkU5dOwo2ai95d+l4VWN USNTLQn1/NJIg== From: "Xin Li (Intel)" To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, xin@zytor.com, chao.gao@intel.com Subject: [PATCH v2 3/4] KVM: VMX: Support the immediate form WRMSRNS in fastpath Date: Fri, 1 Aug 2025 17:15:19 -0700 Message-ID: <20250802001520.3142577-4-xin@zytor.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250802001520.3142577-1-xin@zytor.com> References: <20250802001520.3142577-1-xin@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactored handle_fastpath_set_msr_irqoff() to accept MSR index and data directly via input arguments, enabling it to handle both implicit and immediate form WRMSRNS through appropriate wrappers. Also rename it to __handle_fastpath_wrmsr(). BTW, per Sean's suggestion, rename handle_fastpath_set_msr_irqoff() to handle_fastpath_wrmsr(). Signed-off-by: Xin Li (Intel) --- Change in v2: *) Moved fastpath support in a separate patch (Sean). --- arch/x86/kvm/svm/svm.c | 2 +- arch/x86/kvm/vmx/vmx.c | 5 ++++- arch/x86/kvm/x86.c | 19 +++++++++++++------ arch/x86/kvm/x86.h | 3 ++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index d9931c6c4bc6..4abc34b7c2c7 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4189,7 +4189,7 @@ static fastpath_t svm_exit_handlers_fastpath(struct k= vm_vcpu *vcpu) case SVM_EXIT_MSR: if (!svm->vmcb->control.exit_info_1) break; - return handle_fastpath_set_msr_irqoff(vcpu); + return handle_fastpath_wrmsr(vcpu); case SVM_EXIT_HLT: return handle_fastpath_hlt(vcpu); default: diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index c112595dfff9..2cd865e117a8 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7191,7 +7191,10 @@ static fastpath_t vmx_exit_handlers_fastpath(struct = kvm_vcpu *vcpu, =20 switch (vmx_get_exit_reason(vcpu).basic) { case EXIT_REASON_MSR_WRITE: - return handle_fastpath_set_msr_irqoff(vcpu); + return handle_fastpath_wrmsr(vcpu); + case EXIT_REASON_MSR_WRITE_IMM: + return handle_fastpath_wrmsr_imm(vcpu, vmx_get_exit_qual(vcpu), + vmx_get_msr_imm_reg()); case EXIT_REASON_PREEMPTION_TIMER: return handle_fastpath_preemption_timer(vcpu, force_immediate_exit); case EXIT_REASON_HLT: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index fe12aae7089c..9aede349b6ec 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2202,10 +2202,8 @@ static int handle_fastpath_set_tscdeadline(struct kv= m_vcpu *vcpu, u64 data) return 0; } =20 -fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu) +static fastpath_t __handle_fastpath_wrmsr(struct kvm_vcpu *vcpu, u32 msr, = u64 data) { - u32 msr =3D kvm_rcx_read(vcpu); - u64 data; fastpath_t ret; bool handled; =20 @@ -2213,11 +2211,9 @@ fastpath_t handle_fastpath_set_msr_irqoff(struct kvm= _vcpu *vcpu) =20 switch (msr) { case APIC_BASE_MSR + (APIC_ICR >> 4): - data =3D kvm_read_edx_eax(vcpu); handled =3D !handle_fastpath_set_x2apic_icr_irqoff(vcpu, data); break; case MSR_IA32_TSC_DEADLINE: - data =3D kvm_read_edx_eax(vcpu); handled =3D !handle_fastpath_set_tscdeadline(vcpu, data); break; default: @@ -2239,7 +2235,18 @@ fastpath_t handle_fastpath_set_msr_irqoff(struct kvm= _vcpu *vcpu) =20 return ret; } -EXPORT_SYMBOL_GPL(handle_fastpath_set_msr_irqoff); + +fastpath_t handle_fastpath_wrmsr(struct kvm_vcpu *vcpu) +{ + return __handle_fastpath_wrmsr(vcpu, kvm_rcx_read(vcpu), kvm_read_edx_eax= (vcpu)); +} +EXPORT_SYMBOL_GPL(handle_fastpath_wrmsr); + +fastpath_t handle_fastpath_wrmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int r= eg) +{ + return __handle_fastpath_wrmsr(vcpu, msr, kvm_register_read(vcpu, reg)); +} +EXPORT_SYMBOL_GPL(handle_fastpath_wrmsr_imm); =20 /* * Adapt set_msr() to msr_io()'s calling convention diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index bcfd9b719ada..de22c19b47fe 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -437,7 +437,8 @@ int x86_decode_emulated_instruction(struct kvm_vcpu *vc= pu, int emulation_type, void *insn, int insn_len); int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, int emulation_type, void *insn, int insn_len); -fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu); +fastpath_t handle_fastpath_wrmsr(struct kvm_vcpu *vcpu); +fastpath_t handle_fastpath_wrmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int r= eg); fastpath_t handle_fastpath_hlt(struct kvm_vcpu *vcpu); =20 extern struct kvm_caps kvm_caps; --=20 2.50.1 From nobody Sun Oct 5 14:31:47 2025 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 EB6C8AD5A; Sat, 2 Aug 2025 00:16:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093767; cv=none; b=Xy5mnjQ+RDnMs7o0Vo2BJTkVsQIOZDOtWTrrqKaLUMhnZ2wuFU0AbwkDs6hPPBnKV4gtqQRy/JG4XrqLYZWExn+kaMo+cdxLg+jk8ponrmrWazlbVMMSrPkTGcmpSxRTdWMRpzfXZg86Vx/ePv4innfKa/KpJp6lPec/7kGPsfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754093767; c=relaxed/simple; bh=m4mv9f3JoJDnlvqdbJAJf2RS/nXE7O/g/4cLPilXESQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mFzYWWpnJoSC83Ot2/XROVDR7CK1m5UCwI9avm/2bvw2QAGs0Alb2t4yJb06S7un/DHEHkqxa57rTlejb+0FssugTb7ORdTUkScpE2NqwQVR00XED4J51h/SAFYE6sb1mHs2bXpAZsbjQVqBZYGGlifD+Nf4ZdsD8fg1DnWEUzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=hV4sIAdy; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="hV4sIAdy" 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.18.1/8.17.1) with ESMTPSA id 5720FKpJ3142596 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 1 Aug 2025 17:15:30 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 5720FKpJ3142596 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025072201; t=1754093730; bh=EwOm5ekFj/uGCcPOwfD3nwFQMgDOLAgJ2zHWQhQh4jY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hV4sIAdybuo8GZYSsFU0MlcVLOEivweake7C7rxCmJO1UgioiLmFfDgrDK8ldCs7t nXKOrIha/+lnIigXHhlSpg1cErOyX8SFIFWZNiTkzxIh0AkgYIubpxKkeAeeNTcxJ1 Ez1pRPMWOXfhmooCJ8TuXkGeVfCl/OTP4zWaKRH6W98TqDe3+C+yP2JXztp3y4Ubta qBrMjWnboeqzu0fEg6m/IKD/CrahLqd/19VHiPjB71O1ihSrFbWyWtNyDOM6Qx7aho k1/t3RRbPm1Io9Sa7XxVrDI4px0B7ErXf7SeHCJmytcU/GKLnGYAhJeI2p5jAtiyK0 offhogwa9EEjg== From: "Xin Li (Intel)" To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, xin@zytor.com, chao.gao@intel.com Subject: [PATCH v2 4/4] KVM: x86: Advertise support for the immediate form of MSR instructions Date: Fri, 1 Aug 2025 17:15:20 -0700 Message-ID: <20250802001520.3142577-5-xin@zytor.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250802001520.3142577-1-xin@zytor.com> References: <20250802001520.3142577-1-xin@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Advertise support for the immediate form of MSR instructions to userspace if the instructions are supported by the underlying CPU. The immediate form of MSR access instructions are primarily motivated by performance, not code size: by having the MSR number in an immediate, it is available *much* earlier in the pipeline, which allows the hardware much more leeway about how a particular MSR is handled. Explicitly clear the capability in SVM, as its handling is only added for VMX. Signed-off-by: Xin Li (Intel) --- Change in v2: *) Cleared the capability in SVM (Sean). --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/cpuid.c | 6 +++++- arch/x86/kvm/reverse_cpuid.h | 5 +++++ arch/x86/kvm/svm/svm.c | 6 +++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index c5d0082cf0a5..2a7d0dcc1d70 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -771,6 +771,7 @@ enum kvm_only_cpuid_leafs { CPUID_7_2_EDX, CPUID_24_0_EBX, CPUID_8000_0021_ECX, + CPUID_7_1_ECX, NR_KVM_CPU_CAPS, =20 NKVMCAPINTS =3D NR_KVM_CPU_CAPS - NCAPINTS, diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index e2836a255b16..eaaa9203d4d9 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -985,6 +985,10 @@ void kvm_set_cpu_caps(void) F(LAM), ); =20 + kvm_cpu_cap_init(CPUID_7_1_ECX, + SCATTERED_F(MSR_IMM), + ); + kvm_cpu_cap_init(CPUID_7_1_EDX, F(AVX_VNNI_INT8), F(AVX_NE_CONVERT), @@ -1411,9 +1415,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_ar= ray *array, u32 function) goto out; =20 cpuid_entry_override(entry, CPUID_7_1_EAX); + cpuid_entry_override(entry, CPUID_7_1_ECX); cpuid_entry_override(entry, CPUID_7_1_EDX); entry->ebx =3D 0; - entry->ecx =3D 0; } if (max_idx >=3D 2) { entry =3D do_host_cpuid(array, function, 2); diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index c53b92379e6e..743ab25ba787 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -25,6 +25,9 @@ #define KVM_X86_FEATURE_SGX2 KVM_X86_FEATURE(CPUID_12_EAX, 1) #define KVM_X86_FEATURE_SGX_EDECCSSA KVM_X86_FEATURE(CPUID_12_EAX, 11) =20 +/* Intel-defined sub-features, CPUID level 0x00000007:1 (ECX) */ +#define KVM_X86_FEATURE_MSR_IMM KVM_X86_FEATURE(CPUID_7_1_ECX, 5) + /* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ #define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4) #define X86_FEATURE_AVX_NE_CONVERT KVM_X86_FEATURE(CPUID_7_1_EDX, 5) @@ -87,6 +90,7 @@ static const struct cpuid_reg reverse_cpuid[] =3D { [CPUID_7_2_EDX] =3D { 7, 2, CPUID_EDX}, [CPUID_24_0_EBX] =3D { 0x24, 0, CPUID_EBX}, [CPUID_8000_0021_ECX] =3D {0x80000021, 0, CPUID_ECX}, + [CPUID_7_1_ECX] =3D { 7, 1, CPUID_ECX}, }; =20 /* @@ -128,6 +132,7 @@ static __always_inline u32 __feature_translate(int x86_= feature) KVM_X86_TRANSLATE_FEATURE(BHI_CTRL); KVM_X86_TRANSLATE_FEATURE(TSA_SQ_NO); KVM_X86_TRANSLATE_FEATURE(TSA_L1_NO); + KVM_X86_TRANSLATE_FEATURE(MSR_IMM); default: return x86_feature; } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 4abc34b7c2c7..57bcd92125a3 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -5301,8 +5301,12 @@ static __init void svm_set_cpu_caps(void) /* CPUID 0x8000001F (SME/SEV features) */ sev_set_cpu_caps(); =20 - /* Don't advertise Bus Lock Detect to guest if SVM support is absent */ + /* + * Clear capabilities that are automatically configured by common code, + * but that require explicit SVM support (that isn't yet implemented). + */ kvm_cpu_cap_clear(X86_FEATURE_BUS_LOCK_DETECT); + kvm_cpu_cap_clear(X86_FEATURE_MSR_IMM); } =20 static __init int svm_hardware_setup(void) --=20 2.50.1