Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

authored by

Andre Przywara and committed by
Marc Zyngier
5100f983 849260c7

+9 -6
+9 -6
arch/arm/kvm/mmio.c
··· 187 187 } 188 188 189 189 rt = vcpu->arch.mmio_decode.rt; 190 - data = vcpu_data_guest_to_host(vcpu, *vcpu_reg(vcpu, rt), mmio.len); 191 190 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); 196 194 197 - if (mmio.is_write) 195 + trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, mmio.len, 196 + fault_ipa, data); 198 197 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 + } 199 202 200 203 if (vgic_handle_mmio(vcpu, run, &mmio)) 201 204 return 1;