KVM: s390: Trace events support.
cover KVM: s390: Trace events support.
Avi, Marcelo,
here's a patch set that introduces trace events for kvm/s390.
It's split into two parts:
- Trace points for architecture-defined events, like intercepts. This patch calls into the disassembler via the interface provided by the first patch. These trace points show up under events/kvm/.
- Trace points for implementation-specific events like interrupt injection. These show up under a new trace system, kvm-s390.
Cornelia Huck (3):
s390/dis: Instruction decoding interface.
KVM: s390: Add architectural trace events.
KVM: s390: Add implementation-specific trace events.
arch/s390/include/asm/processor.h | 1 + arch/s390/kernel/dis.c | 27 +++ arch/s390/kvm/diag.c | 4 + arch/s390/kvm/intercept.c | 11 ++ arch/s390/kvm/interrupt.c | 23 +++ arch/s390/kvm/kvm-s390.c | 10 ++ arch/s390/kvm/priv.c | 9 +- arch/s390/kvm/sigp.c | 2 + arch/s390/kvm/trace-s390.h | 210 +++++++++++++++++++++++ arch/s390/kvm/trace.h | 341 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 637 insertions(+), 1 deletion(-) create mode 100644 arch/s390/kvm/trace-s390.h create mode 100644 arch/s390/kvm/trace.h
Signature · 1 line
1.7.11.2
PATCH 1/3 s390/dis: Instruction decoding interface.
Provide a new function, insn_to_mnemonic, by which e.g. kvm can obtain a human-readable decoding of an instruction's opcode.
--- arch/s390/include/asm/processor.h | 1 + arch/s390/kernel/dis.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)
arch/s390/include/asm/processor.h +1 -0
@@ -140,6 +140,7 @@ extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);extern unsigned long thread_saved_pc (struct task_struct *t);extern void show_code (struct pt_regs *regs); +extern int insn_to_mnemonic (unsigned char *instruction,char buf[8 ]);unsigned long get_wchan (struct task_struct *p);#define task_pt_regs (tsk) ((struct pt_regs *) \
arch/s390/kernel/dis.c +27 -0
@@ -1469,6 +1469,33 @@ static struct insn *find_insn(unsigned char *code)return NULL ; } +/** +* insn_to_mnemonic - decode an s390 instruction +* @instruction: instruction to decode +* @buf: buffer to fill with mnemonic +* +* Decode the instruction at @instruction and store the corresponding +* mnemonic into @buf. +* @buf is left unchanged if the instruction could not be decoded. +* Returns: +* %0 on success, %-ENOENT if the instruction was not found. +*/ +int insn_to_mnemonic (unsigned char *instruction,char buf[8 ]) +{ +struct insn *insn; + + insn =find_insn (instruction); +if (!insn) +return -ENOENT ; +if (insn->name[0 ] =='\0' ) +snprintf (buf,sizeof (buf),"%s" , + long_insn_name[(int ) insn->name[1 ]]); +else +snprintf (buf,sizeof (buf),"%.5s" , insn->name); +return 0 ; +} +EXPORT_SYMBOL_GPL (insn_to_mnemonic); +static int print_insn (char *buffer,unsigned char *code,unsigned long addr) {struct insn *insn;
Signature · 1 line
1.7.11.2
PATCH 2/3 KVM: s390: Add architectural trace events.
In reply to Cornelia HuckAdd trace events for several s390 architecture specifics:
- SIE entry/exit
- common intercepts
- common instructions (sigp/diagnose)
--- arch/s390/kvm/diag.c | 2 + arch/s390/kvm/intercept.c | 8 ++ arch/s390/kvm/kvm-s390.c | 7 + arch/s390/kvm/priv.c | 9 +- arch/s390/kvm/sigp.c | 2 + arch/s390/kvm/trace.h | 341 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 368 insertions(+), 1 deletion(-) create mode 100644 arch/s390/kvm/trace.h
arch/s390/kvm/diag.c +2 -0
@@ -14,6 +14,7 @@#include <linux/kvm.h> #include <linux/kvm_host.h> #include "kvm-s390.h" +#include "trace.h" static int diag_release_pages (struct kvm_vcpu *vcpu) {
@@ -105,6 +106,7 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) {int code = (vcpu->arch.sie_block->ipb &0xfff0000 ) >>16 ; +trace_kvm_s390_handle_diag (vcpu, code);switch (code) {case 0x10 :return diag_release_pages (vcpu);
arch/s390/kvm/intercept.c +8 -0
@@ -19,6 +19,7 @@#include "kvm-s390.h" #include "gaccess.h" +#include "trace.h" static int handle_lctlg (struct kvm_vcpu *vcpu) {
@@ -45,6 +46,7 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)VCPU_EVENT (vcpu,5 ,"lctlg r1:%x, r3:%x,b2:%x,d2:%x" , reg1, reg3, base2, disp2); +trace_kvm_s390_handle_lctl (vcpu,1 , reg1, reg3, useraddr); do { rc = get_guest_u64(vcpu, useraddr,
@@ -82,6 +84,7 @@ static int handle_lctl(struct kvm_vcpu *vcpu)VCPU_EVENT (vcpu,5 ,"lctl r1:%x, r3:%x,b2:%x,d2:%x" , reg1, reg3, base2, disp2); +trace_kvm_s390_handle_lctl (vcpu,0 , reg1, reg3, useraddr); reg = reg1; do {
@@ -171,6 +174,7 @@ static int handle_validity(struct kvm_vcpu *vcpu)int rc; vcpu->stat.exit_validity++; +trace_kvm_s390_intercept_validity (vcpu, viwhy);if (viwhy ==0x37 ) { vmaddr =gmap_fault (vcpu->arch.sie_block->prefix, vcpu->arch.gmap);
@@ -213,6 +217,9 @@ static int handle_instruction(struct kvm_vcpu *vcpu)intercept_handler_t handler; vcpu->stat.exit_instruction++; +trace_kvm_s390_intercept_instruction (vcpu, + vcpu->arch.sie_block->ipa, + vcpu->arch.sie_block->ipb); handler = instruction_handlers[vcpu->arch.sie_block->ipa >>8 ];if (handler)return handler (vcpu);
@@ -222,6 +229,7 @@ static int handle_instruction(struct kvm_vcpu *vcpu)static int handle_prog (struct kvm_vcpu *vcpu) { vcpu->stat.exit_program_interruption++; +trace_kvm_s390_intercept_prog (vcpu, vcpu->arch.sie_block->iprcc);return kvm_s390_inject_program_int (vcpu, vcpu->arch.sie_block->iprcc); }
arch/s390/kvm/kvm-s390.c +7 -0
@@ -32,6 +32,9 @@#include "kvm-s390.h" #include "gaccess.h" +#define CREATE_TRACE_POINTS +#include "trace.h" +#define VCPU_STAT (x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPUstruct kvm_stats_debugfs_item debugfs_entries[] = {
@@ -607,18 +610,22 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)local_irq_enable ();VCPU_EVENT (vcpu,6 ,"entering sie flags %x" ,atomic_read (&vcpu->arch.sie_block->cpuflags)); +trace_kvm_s390_sie_enter (vcpu, +atomic_read (&vcpu->arch.sie_block->cpuflags)); rc =sie64a (vcpu->arch.sie_block, vcpu->run->s.regs.gprs);if (rc) {if (kvm_is_ucontrol (vcpu->kvm)) { rc =SIE_INTERCEPT_UCONTROL ; }else {VCPU_EVENT (vcpu,3 ,"%s" ,"fault in sie instruction" ); +trace_kvm_s390_sie_fault (vcpu);kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); rc =0 ; } }VCPU_EVENT (vcpu,6 ,"exit sie icptcode %d" , vcpu->arch.sie_block->icptcode); +trace_kvm_s390_sie_exit (vcpu, vcpu->arch.sie_block->icptcode);local_irq_disable ();kvm_guest_exit ();local_irq_enable ();
arch/s390/kvm/priv.c +8 -1
@@ -20,6 +20,7 @@#include <asm/sysinfo.h> #include "gaccess.h" #include "kvm-s390.h" +#include "trace.h" static int handle_set_prefix (struct kvm_vcpu *vcpu) {
@@ -59,6 +60,7 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu)kvm_s390_set_prefix (vcpu, address);VCPU_EVENT (vcpu,5 ,"setting prefix to %x" , address); +trace_kvm_s390_handle_prefix (vcpu,1 , address); out:return 0 ; }
@@ -91,6 +93,7 @@ static int handle_store_prefix(struct kvm_vcpu *vcpu) }VCPU_EVENT (vcpu,5 ,"storing prefix to %x" , address); +trace_kvm_s390_handle_prefix (vcpu,0 , address); out:return 0 ; }
@@ -119,6 +122,7 @@ static int handle_store_cpu_address(struct kvm_vcpu *vcpu) }VCPU_EVENT (vcpu,5 ,"storing cpu address to %llx" , useraddr); +trace_kvm_s390_handle_stap (vcpu, useraddr); out:return 0 ; }
@@ -164,9 +168,11 @@ static int handle_stfl(struct kvm_vcpu *vcpu) &facility_list, sizeof(facility_list));if (rc == -EFAULT )kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); -else +else {VCPU_EVENT (vcpu,5 ,"store facility list value %x" , facility_list); +trace_kvm_s390_handle_stfl (vcpu, facility_list); + }return 0 ; }
@@ -278,6 +284,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); goto out_mem; } +trace_kvm_s390_handle_stsi (vcpu, fc, sel1, sel2, operand2);free_page (mem); vcpu->arch.sie_block->gpsw.mask &= ~(3ul <<44 ); vcpu->run->s.regs.gprs[0 ] =0 ;
arch/s390/kvm/sigp.c +2 -0
@@ -18,6 +18,7 @@#include <asm/sigp.h> #include "gaccess.h" #include "kvm-s390.h" +#include "trace.h" static int __sigp_sense (struct kvm_vcpu *vcpu,u16 cpu_addr,u64 *reg)
@@ -344,6 +345,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)else parameter = vcpu->run->s.regs.gprs[r1 +1 ]; +trace_kvm_s390_handle_sigp (vcpu, order_code, cpu_addr, parameter);switch (order_code) {case SIGP_SENSE : vcpu->stat.instruction_sigp_sense++;
arch/s390/kvm/trace.h new file +341 -0
341 lines not on this page · raw message
Signature · 1 line
1.7.11.2
PATCH 3/3 KVM: s390: Add implementation-specific trace events.
In reply to Cornelia HuckIntroduce a new trace system, kvm-s390, for some kvm/s390 specific trace points:
- injection of interrupts
- delivery of interrupts to the guest
- creation/destruction of kvm machines and vcpus
- stop actions for vcpus
- reset requests for userspace
--- arch/s390/kvm/diag.c | 2 + arch/s390/kvm/intercept.c | 3 + arch/s390/kvm/interrupt.c | 23 +++++ arch/s390/kvm/kvm-s390.c | 3 + arch/s390/kvm/trace-s390.h | 210 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 241 insertions(+) create mode 100644 arch/s390/kvm/trace-s390.h
arch/s390/kvm/diag.c +2 -0
@@ -15,6 +15,7 @@#include <linux/kvm_host.h> #include "kvm-s390.h" #include "trace.h" +#include "trace-s390.h" static int diag_release_pages (struct kvm_vcpu *vcpu) {
@@ -99,6 +100,7 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu) vcpu->run->exit_reason =KVM_EXIT_S390_RESET ;VCPU_EVENT (vcpu,3 ,"requesting userspace resets %llx" , vcpu->run->s390_reset_flags); +trace_kvm_s390_request_resets (vcpu->run->s390_reset_flags);return -EREMOTE ; }
arch/s390/kvm/intercept.c +3 -0
@@ -20,6 +20,7 @@#include "kvm-s390.h" #include "gaccess.h" #include "trace.h" +#include "trace-s390.h" static int handle_lctlg (struct kvm_vcpu *vcpu) {
@@ -138,6 +139,8 @@ static int handle_stop(struct kvm_vcpu *vcpu) vcpu->stat.exit_stop_request++;spin_lock_bh (&vcpu->arch.local_int.lock); +trace_kvm_s390_stop_request (vcpu->arch.local_int.action_bits); +if (vcpu->arch.local_int.action_bits &ACTION_RELOADVCPU_ON_STOP ) { vcpu->arch.local_int.action_bits &= ~ACTION_RELOADVCPU_ON_STOP ; rc =SIE_INTERCEPT_RERUNVCPU ;
arch/s390/kvm/interrupt.c +23 -0
@@ -19,6 +19,7 @@#include <asm/uaccess.h> #include "kvm-s390.h" #include "gaccess.h" +#include "trace-s390.h" static int psw_extint_disabled (struct kvm_vcpu *vcpu) {
@@ -130,6 +131,8 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,case KVM_S390_INT_EMERGENCY :VCPU_EVENT (vcpu,4 ,"%s" ,"interrupt: sigp emerg" ); vcpu->stat.deliver_emergency_signal++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, + inti->emerg.code,0 ); rc =put_guest_u16 (vcpu, __LC_EXT_INT_CODE,0x1201 );if (rc == -EFAULT ) exception =1 ;
@@ -152,6 +155,8 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,case KVM_S390_INT_EXTERNAL_CALL :VCPU_EVENT (vcpu,4 ,"%s" ,"interrupt: sigp ext call" ); vcpu->stat.deliver_external_call++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, + inti->extcall.code,0 ); rc =put_guest_u16 (vcpu, __LC_EXT_INT_CODE,0x1202 );if (rc == -EFAULT ) exception =1 ;
@@ -175,6 +180,8 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,VCPU_EVENT (vcpu,4 ,"interrupt: sclp parm:%x" , inti->ext.ext_params); vcpu->stat.deliver_service_signal++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, + inti->ext.ext_params,0 ); rc =put_guest_u16 (vcpu, __LC_EXT_INT_CODE,0x2401 );if (rc == -EFAULT ) exception =1 ;
@@ -198,6 +205,9 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,VCPU_EVENT (vcpu,4 ,"interrupt: virtio parm:%x,parm64:%llx" , inti->ext.ext_params, inti->ext.ext_params2); vcpu->stat.deliver_virtio_interrupt++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, + inti->ext.ext_params, + inti->ext.ext_params2); rc =put_guest_u16 (vcpu, __LC_EXT_INT_CODE,0x2603 );if (rc == -EFAULT ) exception =1 ;
@@ -229,6 +239,8 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,case KVM_S390_SIGP_STOP :VCPU_EVENT (vcpu,4 ,"%s" ,"interrupt: cpu stop" ); vcpu->stat.deliver_stop_signal++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, +0 ,0 );__set_intercept_indicator (vcpu, inti);break ;
@@ -236,12 +248,16 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,VCPU_EVENT (vcpu,4 ,"interrupt: set prefix to %x" , inti->prefix.address); vcpu->stat.deliver_prefix_signal++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, + inti->prefix.address,0 );kvm_s390_set_prefix (vcpu, inti->prefix.address);break ;case KVM_S390_RESTART :VCPU_EVENT (vcpu,4 ,"%s" ,"interrupt: cpu restart" ); vcpu->stat.deliver_restart_signal++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, +0 ,0 ); rc =copy_to_guest (vcpu, offsetof(struct _lowcore , restart_old_psw), &vcpu->arch.sie_block->gpsw,sizeof (psw_t));if (rc == -EFAULT )
@@ -259,6 +275,8 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, inti->pgm.code, table[vcpu->arch.sie_block->ipa >> 14]); vcpu->stat.deliver_program_int++; +trace_kvm_s390_deliver_interrupt (vcpu->vcpu_id, inti->type, + inti->pgm.code,0 ); rc =put_guest_u16 (vcpu, __LC_PGM_INT_CODE, inti->pgm.code);if (rc == -EFAULT ) exception =1 ;
@@ -515,6 +533,7 @@ int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code) inti->pgm.code = code;VCPU_EVENT (vcpu,3 ,"inject: program check %d (from kernel)" , code); +trace_kvm_s390_inject_vcpu (vcpu->vcpu_id, inti->type, code,0 ,1 );spin_lock_bh (&li->lock);list_add (&inti->list, &li->list);atomic_set (&li->active,1 );
@@ -556,6 +575,8 @@ int kvm_s390_inject_vm(struct kvm *kvm,kfree (inti);return -EINVAL ; } +trace_kvm_s390_inject_vm (s390int->type, s390int->parm, s390int->parm64, +2 );mutex_lock (&kvm->lock); fi = &kvm->arch.float_int;
@@ -621,6 +642,8 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,kfree (inti);return -EINVAL ; } +trace_kvm_s390_inject_vcpu (vcpu->vcpu_id, s390int->type, s390int->parm, + s390int->parm64,2 );mutex_lock (&vcpu->kvm->lock); li = &vcpu->arch.local_int;
arch/s390/kvm/kvm-s390.c +3 -0
@@ -34,6 +34,7 @@#define CREATE_TRACE_POINTS #include "trace.h" +#include "trace-s390.h" #define VCPU_STAT (x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
@@ -245,6 +246,7 @@ out_err:void kvm_arch_vcpu_destroy (struct kvm_vcpu *vcpu) {VCPU_EVENT (vcpu,3 ,"%s" ,"free cpu" ); +trace_kvm_s390_destroy_vcpu (vcpu->vcpu_id);if (!kvm_is_ucontrol (vcpu->kvm)) {clear_bit (63 - vcpu->vcpu_id, (unsigned long *) &vcpu->kvm->arch.sca->mcn);
@@ -420,6 +422,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, goto out_free_sie_block;VM_EVENT (kvm,3 ,"create cpu %d at %p, sie block at %p" , id, vcpu, vcpu->arch.sie_block); +trace_kvm_s390_create_vcpu (id, vcpu, vcpu->arch.sie_block);return vcpu; out_free_sie_block:
arch/s390/kvm/trace-s390.h new file +210 -0
210 lines not on this page · raw message
Signature · 1 line
1.7.11.2
Quoted 11 lines · Cornelia Huck
Avi, Marcelo,
here's a patch set that introduces trace events for kvm/s390.
It's split into two parts:
- Trace points for architecture-defined events, like intercepts. This patch calls into the disassembler via the interface provided by the first patch. These trace points show up under events/kvm/.
- Trace points for implementation-specific events like interrupt injection. These show up under a new trace system, kvm-s390.
I don't see what's the difference between the two types. Isn't interrupt injection architectural?
On x86, the implementation tracepoints are ones that may go away if the implementation changes significantly, while the architectural ones will not go away unless the architecture is changed. In fact creation and destruction of vcpus and reset requests are not only architectural, they're generic, you may as well add them to the arch independent trace code.
btw - why are vcpu creation and destruction useful events to trace?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 7 lines · On Thu, 26 Jul 2012 12:35:10 +0300 Avi Kivity <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Avi, Marcelo,
here's a patch set that introduces trace events for kvm/s390.
It's split into two parts:
Quoted 8 lines
Quoted 5 lines
- Trace points for architecture-defined events, like intercepts. This patch calls into the disassembler via the interface provided by the first patch. These trace points show up under events/kvm/.
- Trace points for implementation-specific events like interrupt injection. These show up under a new trace system, kvm-s390.I don't see what's the difference between the two types. Isn't interrupt injection architectural?
I don't think so. The details how we do that might change, it's nothing dictated by the architecture.
(It might be argued where interrupt delivery belongs, since parts of it are architectured, while other parts are made up by us.)
Quoted 4 lines
On x86, the implementation tracepoints are ones that may go away if the implementation changes significantly, while the architectural ones will not go away unless the architecture is changed.
That's what I tried to do here as well.
Quoted 4 lines
In fact creation and
destruction of vcpus and reset requests are not only architectural, they're generic, you may as well add them to the arch independent trace code.
The vpcu creation event also traces interesting information like the location of our sie control block (in fact, that's the most interesting information provided by the event).
The reset request traced is s390 specific (for diag 308 ipl).
Quoted 2 lines
btw - why are vcpu creation and destruction useful events to trace?
See above - mainly for the control block location.
Cornelia
Quoted 41 lines · Cornelia Huck
Quoted 7 lines · On Thu, 26 Jul 2012 12:35:10 +0300 Avi Kivity <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Avi, Marcelo,
here's a patch set that introduces trace events for kvm/s390.
It's split into two parts:
Quoted 8 lines
Quoted 5 lines
- Trace points for architecture-defined events, like intercepts. This patch calls into the disassembler via the interface provided by the first patch. These trace points show up under events/kvm/.
- Trace points for implementation-specific events like interrupt injection. These show up under a new trace system, kvm-s390.I don't see what's the difference between the two types. Isn't interrupt injection architectural?
I don't think so. The details how we do that might change, it's nothing dictated by the architecture.
(It might be argued where interrupt delivery belongs, since parts of it are architectured, while other parts are made up by us.)
Quoted 4 lines
On x86, the implementation tracepoints are ones that may go away if the implementation changes significantly, while the architectural ones will not go away unless the architecture is changed.
That's what I tried to do here as well.
Quoted 4 lines
In fact creation and
destruction of vcpus and reset requests are not only architectural, they're generic, you may as well add them to the arch independent trace code.The vpcu creation event also traces interesting information like the location of our sie control block (in fact, that's the most interesting information provided by the event).
Quoted 6 lines
The reset request traced is s390 specific (for diag 308 ipl).
Quoted 2 lines
btw - why are vcpu creation and destruction useful events to trace?
See above - mainly for the control block location.
Ok, thanks for the explanations. Applied all.
Signature · 1 line
error compiling committee.c: too many arguments to function