diff options
| author | Sean Christopherson <seanjc@google.com> | 2025-12-31 00:13:47 +0300 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-01-14 04:37:03 +0300 |
| commit | d6c20d19f7d3de14d02b47221988cdb19504bb84 (patch) | |
| tree | 0932ee338e4972adbf39377d4cedf2a3b62fd2bf | |
| parent | 1e3dddafeceeb8d2cd182b78456cb9ca9d042a01 (diff) | |
| download | linux-d6c20d19f7d3de14d02b47221988cdb19504bb84.tar.xz | |
KVM: SVM: Assert that Hyper-V's HV_SVM_EXITCODE_ENL == SVM_EXIT_SW
Add a build-time assertiont that Hyper-V's "enlightened" exit code is that,
same as the AMD-defined "Reserved for Host" exit code, mostly to help
readers connect the dots and understand why synthesizing a software-defined
exit code is safe/ok.
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://patch.msgid.link/20251230211347.4099600-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
| -rw-r--r-- | arch/x86/kvm/svm/hyperv.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm/hyperv.c b/arch/x86/kvm/svm/hyperv.c index 3ec580d687f5..4f24dcb45116 100644 --- a/arch/x86/kvm/svm/hyperv.c +++ b/arch/x86/kvm/svm/hyperv.c @@ -10,6 +10,12 @@ void svm_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); + /* + * The exit code used by Hyper-V for software-defined exits is reserved + * by AMD specifically for such use cases. + */ + BUILD_BUG_ON(HV_SVM_EXITCODE_ENL != SVM_EXIT_SW); + svm->vmcb->control.exit_code = HV_SVM_EXITCODE_ENL; svm->vmcb->control.exit_info_1 = HV_SVM_ENL_EXITCODE_TRAP_AFTER_FLUSH; svm->vmcb->control.exit_info_2 = 0; |
