public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: nSVM: Expose SVM DecodeAssists to guest hypervisors
@ 2026-01-15 13:17 Alejandro Vallejo
  2026-01-15 16:43 ` [kvm-unit-tests] x86: Add #PF test case for the SVM DecodeAssists feature Alejandro Vallejo
  2026-01-28 23:15 ` [PATCH] KVM: nSVM: Expose SVM DecodeAssists to guest hypervisors Jim Mattson
  0 siblings, 2 replies; 8+ messages in thread
From: Alejandro Vallejo @ 2026-01-15 13:17 UTC (permalink / raw)
  To: kvm; +Cc: Alejandro Vallejo, Christopherson, Paolo Bonzini

Enable exposing DecodeAssists to guests. Performs a copyout of
the insn_len and insn_bytes fields of the VMCB when the vCPU has
the feature enabled.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
---
I wrote a little smoke test for kvm-unit-tests too. I'll send it shortly in
reply to this email.
---
 arch/x86/kvm/cpuid.c      | 1 +
 arch/x86/kvm/svm/nested.c | 6 ++++++
 arch/x86/kvm/svm/svm.c    | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 88a5426674a10..da9a63c8289e5 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1181,6 +1181,7 @@ void kvm_set_cpu_caps(void)
 		VENDOR_F(FLUSHBYASID),
 		VENDOR_F(NRIPS),
 		VENDOR_F(TSCRATEMSR),
+		VENDOR_F(DECODEASSISTS),
 		VENDOR_F(V_VMSAVE_VMLOAD),
 		VENDOR_F(LBRV),
 		VENDOR_F(PAUSEFILTER),
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index ba0f11c68372b..dc8a8e67a22c2 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -1128,6 +1128,12 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
 		vmcb12->save.ssp	= vmcb02->save.ssp;
 	}
 
+	if (guest_cpu_cap_has(vcpu, X86_FEATURE_DECODEASSISTS)) {
+		memcpy(vmcb12->control.insn_bytes, vmcb02->control.insn_bytes,
+		       ARRAY_SIZE(vmcb12->control.insn_bytes));
+		vmcb12->control.insn_len = vmcb02->control.insn_len;
+	}
+
 	vmcb12->control.int_state         = vmcb02->control.int_state;
 	vmcb12->control.exit_code         = vmcb02->control.exit_code;
 	vmcb12->control.exit_code_hi      = vmcb02->control.exit_code_hi;
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 24d59ccfa40d9..8cf6d7904030e 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -5223,6 +5223,9 @@ static __init void svm_set_cpu_caps(void)
 		if (nrips)
 			kvm_cpu_cap_set(X86_FEATURE_NRIPS);
 
+		if (boot_cpu_has(X86_FEATURE_DECODEASSISTS))
+			kvm_cpu_cap_set(X86_FEATURE_DECODEASSISTS);
+
 		if (npt_enabled)
 			kvm_cpu_cap_set(X86_FEATURE_NPT);
 

base-commit: 0499add8efd72456514c6218c062911ccc922a99
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-29 18:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 13:17 [PATCH] KVM: nSVM: Expose SVM DecodeAssists to guest hypervisors Alejandro Vallejo
2026-01-15 16:43 ` [kvm-unit-tests] x86: Add #PF test case for the SVM DecodeAssists feature Alejandro Vallejo
2026-01-15 18:32   ` Sean Christopherson
2026-01-16 12:59     ` Alejandro Vallejo
2026-01-16 13:03       ` Alejandro Vallejo
2026-01-28 23:15 ` [PATCH] KVM: nSVM: Expose SVM DecodeAssists to guest hypervisors Jim Mattson
2026-01-29 16:53   ` Alejandro Vallejo
2026-01-29 18:08     ` Jim Mattson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox