Skip to content

Commit 5100f98

Browse files
Andre-ARMMarc Zyngier
authored andcommitted
arm/arm64: KVM: avoid unnecessary guest register mangling on MMIO read
Currently we mangle the endianness of the guest's register even on an MMIO _read_, where it is completely useless, because we will not use the value of that register. Rework the io_mem_abort() function to clearly separate between reads and writes and only do the endianness mangling on MMIO writes. Signed-off-by: Andre Przywara <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 849260c commit 5100f98

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

arch/arm/kvm/mmio.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,18 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
187187
}
188188

189189
rt = vcpu->arch.mmio_decode.rt;
190-
data = vcpu_data_guest_to_host(vcpu, *vcpu_reg(vcpu, rt), mmio.len);
191190

192-
trace_kvm_mmio((mmio.is_write) ? KVM_TRACE_MMIO_WRITE :
193-
KVM_TRACE_MMIO_READ_UNSATISFIED,
194-
mmio.len, fault_ipa,
195-
(mmio.is_write) ? data : 0);
191+
if (mmio.is_write) {
192+
data = vcpu_data_guest_to_host(vcpu, *vcpu_reg(vcpu, rt),
193+
mmio.len);
196194

197-
if (mmio.is_write)
195+
trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, mmio.len,
196+
fault_ipa, data);
198197
mmio_write_buf(mmio.data, mmio.len, data);
198+
} else {
199+
trace_kvm_mmio(KVM_TRACE_MMIO_READ_UNSATISFIED, mmio.len,
200+
fault_ipa, 0);
201+
}
199202

200203
if (vgic_handle_mmio(vcpu, run, &mmio))
201204
return 1;

0 commit comments

Comments
 (0)