KVM: arm64: Add tracepoint for MMIO accesses where ISV==0
PATCH v2 1/1 KVM: arm64: Add tracepoint for MMIO accesses where ISV==0
It is a pretty well known fact that KVM does not support MMIO emulation without valid instruction syndrome information (ESR_EL2.ISV == 0). The current kvm_pr_unimpl() is pretty useless, as it contains zero context to relate the event to a vCPU.
Replace it with a precise tracepoint that dumps the relevant context so the user can make sense of what the guest is doing.
---
v1: https://lore.kernel.org/kvmarm/[email protected]/
v1 -> v2:
- Add a tracepoint to improve debuggability (Marc)
Tested with the page_fault_test selftest, which does pre-indexed accesses outside of a memslot.
arch/arm64/kvm/mmio.c | 4 +++- arch/arm64/kvm/trace_arm.h | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-)
arch/arm64/kvm/mmio.c +3 -1
@@ -135,6 +135,9 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)* volunteered to do so, and bail out otherwise. */ if (!kvm_vcpu_dabt_isvalid (vcpu)) { +trace_kvm_mmio_nisv (*vcpu_pc (vcpu),kvm_vcpu_get_esr (vcpu), +kvm_vcpu_get_hfar (vcpu), fault_ipa); +if (test_bit (KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER , &vcpu->kvm->arch.flags)) { run->exit_reason =KVM_EXIT_ARM_NISV ;
@@ -143,7 +146,6 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)return 0 ; } -kvm_pr_unimpl ("Data abort outside memslots with no valid syndrome info\n" );return -ENOSYS ; }
arch/arm64/kvm/trace_arm.h +25 -0
@@ -136,6 +136,31 @@ TRACE_EVENT(kvm_mmio_emulate, __entry->vcpu_pc, __entry->instr, __entry->cpsr) ); +TRACE_EVENT (kvm_mmio_nisv, + TP_PROTO(unsigned long vcpu_pc, unsigned long esr, + unsigned long far, unsigned long ipa), +TP_ARGS (vcpu_pc, esr, far, ipa), + +TP_STRUCT__entry ( + __field( unsigned long, vcpu_pc ) + __field( unsigned long, esr ) + __field( unsigned long, far ) + __field( unsigned long, ipa ) + ), + +TP_fast_assign ( + __entry->vcpu_pc = vcpu_pc; + __entry->esr = esr; + __entry->far = far; + __entry->ipa = ipa; + ), + +TP_printk ("ipa %#016lx, esr %#016lx, far %#016lx, pc %#016lx" , + __entry->ipa, __entry->esr, + __entry->far, __entry->vcpu_pc) +); + + TRACE_EVENT(kvm_set_way_flush, TP_PROTO(unsigned long vcpu_pc, bool cache), TP_ARGS(vcpu_pc, cache),
base-commit: 6465e260f48790807eef06b583b38ca9789b6072
Signature · 1 line
2.42.0.820.g83a721a137-goog
Quoted 9 lines · Oliver Upton
It is a pretty well known fact that KVM does not support MMIO emulation without valid instruction syndrome information (ESR_EL2.ISV == 0). The current
kvm_pr_unimpl()is pretty useless, as it contains zero context to relate the event to a vCPU.Replace it with a precise tracepoint that dumps the relevant context so the user can make sense of what the guest is doing.
Signed-off-by Oliver Upton <[email protected]>
Quoted 10 lines · Oliver Upton
It is a pretty well known fact that KVM does not support MMIO emulation without valid instruction syndrome information (ESR_EL2.ISV == 0). The current
kvm_pr_unimpl()is pretty useless, as it contains zero context to relate the event to a vCPU.Replace it with a precise tracepoint that dumps the relevant context so the user can make sense of what the guest is doing.
Signed-off-by Oliver Upton <[email protected]>
Thanks for going the extra mile on this!
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Oliver Upton
AppliedQuoted 9 lines · Oliver Upton
It is a pretty well known fact that KVM does not support MMIO emulation without valid instruction syndrome information (ESR_EL2.ISV == 0). The current
kvm_pr_unimpl()is pretty useless, as it contains zero context to relate the event to a vCPU.Replace it with a precise tracepoint that dumps the relevant context so the user can make sense of what the guest is doing.
[...]
Applied to kvmarm/next, thanks!
[1/1] KVM: arm64: Add tracepoint for MMIO accesses where ISV==0
https://git.kernel.org/kvmarm/kvmarm/c/9ec605adafbd
--
Best,
Oliver