Re: [PATCH 14/14] KVM: x86: Add helpers to prepare kvm_run for userspace MMIO exit

From: Sean Christopherson

Date: Wed Feb 25 2026 - 14:23:29 EST


On Wed, Feb 25, 2026, Rick P Edgecombe wrote:
> On Tue, 2026-02-24 at 17:20 -0800, Sean Christopherson wrote:
> > +static inline void __kvm_prepare_emulated_mmio_exit(struct kvm_vcpu *vcpu,
> > +     gpa_t gpa, unsigned int len,
> > +     const void *data,
> > +     bool is_write)
> > +{
> > + struct kvm_run *run = vcpu->run;
> > +
> > + run->mmio.len = min(8u, len);
>
> I would think to extract this to a local var so it can be used twice.

Ya, either way works for me. The copy+paste is a little gross, but it's also
unlikely that anyone is going to modify this code (or if they did, that any goofs
wouldn't be immediately disastrous).

> > + run->mmio.is_write = is_write;
> > + run->exit_reason = KVM_EXIT_MMIO;
> > + run->mmio.phys_addr = gpa;
> > + if (is_write)
> > + memcpy(run->mmio.data, data, min(8u, len));
> > +}
> > +
>