[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87eco8bajg.fsf@redhat.com>
Date: Fri, 02 Jan 2026 10:58:59 +0100
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini
<pbonzini@...hat.com>, "K. Y. Srinivasan" <kys@...rosoft.com>, Haiyang
Zhang <haiyangz@...rosoft.com>, Wei Liu <wei.liu@...nel.org>, Dexuan Cui
<decui@...rosoft.com>, Long Li <longli@...rosoft.com>
Cc: kvm@...r.kernel.org, linux-hyperv@...r.kernel.org,
linux-kernel@...r.kernel.org, Jim Mattson <jmattson@...gle.com>, Yosry
Ahmed <yosry.ahmed@...ux.dev>
Subject: Re: [PATCH v2 8/8] KVM: SVM: Assert that Hyper-V's
HV_SVM_EXITCODE_ENL == SVM_EXIT_SW
Sean Christopherson <seanjc@...gle.com> writes:
> 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.
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
> arch/x86/kvm/svm/hyperv.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> 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;
Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>
Alternatively (or additionally?) to BUG_ON, I guess we could've
#define HV_SVM_EXITCODE_ENL SVM_EXIT_SW
unless including SVM's headers into include/hyperv/hvgdk.h is too big of
a mess.
--
Vitaly
Powered by blists - more mailing lists