]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Use local MMIO fragment variable to clean up emulator_read_write()
authorSean Christopherson <seanjc@google.com>
Wed, 25 Feb 2026 01:20:39 +0000 (17:20 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 3 Mar 2026 00:02:52 +0000 (16:02 -0800)
Grab the MMIO fragment used by emulator_read_write() to initiate an exit
to userspace in a local variable to make the code easier to read.

No functional change intended.

Tested-by: Tom Lendacky <thomas.lendacky@gmail.com>
Tested-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://patch.msgid.link/20260225012049.920665-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index e2cf5349d5939e0bc59994ce41b2f0f07c4e5ca6..d04f0a0383f37ba1f1c5797933ee906ce736508c 100644 (file)
@@ -8230,7 +8230,7 @@ static int emulator_read_write(struct x86_emulate_ctxt *ctxt,
                        const struct read_write_emulator_ops *ops)
 {
        struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
-       gpa_t gpa;
+       struct kvm_mmio_fragment *frag;
        int rc;
 
        if (WARN_ON_ONCE((bytes > 8u || !ops->write) && object_is_on_stack(val)))
@@ -8286,17 +8286,16 @@ static int emulator_read_write(struct x86_emulate_ctxt *ctxt,
        if (!vcpu->mmio_nr_fragments)
                return X86EMUL_CONTINUE;
 
-       gpa = vcpu->mmio_fragments[0].gpa;
-
        vcpu->mmio_needed = 1;
        vcpu->mmio_cur_fragment = 0;
 
-       vcpu->run->mmio.len = min(8u, vcpu->mmio_fragments[0].len);
+       frag = &vcpu->mmio_fragments[0];
+       vcpu->run->mmio.len = min(8u, frag->len);
        vcpu->run->mmio.is_write = vcpu->mmio_is_write = ops->write;
        vcpu->run->exit_reason = KVM_EXIT_MMIO;
-       vcpu->run->mmio.phys_addr = gpa;
+       vcpu->run->mmio.phys_addr = frag->gpa;
 
-       return ops->read_write_exit_mmio(vcpu, gpa, val, bytes);
+       return ops->read_write_exit_mmio(vcpu, frag->gpa, val, bytes);
 }
 
 static int emulator_read_emulated(struct x86_emulate_ctxt *ctxt,