Re: [PATCH v3 3/5] KVM: x86: Use file_to_kvm_x86() in SEV
From: Steffen Eiden
Date: Fri Sep 25 2026 - 05:35:22 EST
On Fri, Sep 25, 2026 at 10:35:55AM +0200, Christian Borntraeger wrote:
>
>
> Am 24.09.26 um 10:58 schrieb Steffen Eiden:
> > Use the new arch-namespaced helper instead of open-coding the file
> ^ double space> check and private_data cast separately.
> >
> > Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> > Signed-off-by: Steffen Eiden <seiden@xxxxxxxxxxxxx>
> > ---
> > arch/x86/kvm/svm/sev.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index 5705723f1f41..6b0eacde4f06 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -2145,10 +2145,10 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd)
> > if (fd_empty(f))
> > return -EBADF;
> > - if (!file_is_kvm(fd_file(f)))
> > + source_kvm = file_to_kvm_x86(fd_file(f));
> > + if (!source_kvm)
> > return -EBADF;
> > - source_kvm = fd_file(f)->private_data;
> > ret = sev_lock_two_vms(kvm, source_kvm);
> > if (ret)
> > return ret;
> > @@ -2866,10 +2866,10 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd)
> > if (fd_empty(f))
> > return -EBADF;
> > - if (!file_is_kvm(fd_file(f)))
> > + source_kvm = file_to_kvm_x86(fd_file(f));
> > + if (!source_kvm)
> > return -EBADF;
> > - source_kvm = fd_file(f)->private_data;
> > ret = sev_lock_two_vms(kvm, source_kvm);
> > if (ret)
> > return ret;
> >
>
> There are no remaining callers of file_is_kvm(), correct?
>
> We could remove the declaration in include/linux/kvm_host.h and the
> definition plus EXPORT_SYMBOL_FOR_KVM_INTERNAL in virt/kvm/kvm_main.c
> here or in an add-on patch if we want.
>
>
Make sense. I'll add a patch for that.
Steffen