KVM: s390: introduce kvm_s390_vcpu_{start,stop}
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Fri, 14 Mar 2014 09:59:29 +0000 (10:59 +0100)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 29 Apr 2014 13:01:54 +0000 (15:01 +0200)
This patch introduces two new functions to set/clear the CPUSTAT_STOPPED bit and
makes use of it at all applicable places. These functions prepare the additional
execution of code when starting/stopping a vcpu.

The CPUSTAT_STOPPED bit should not be touched outside of these functions.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/kvm/diag.c
arch/s390/kvm/intercept.c
arch/s390/kvm/interrupt.c
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/kvm-s390.h
arch/s390/kvm/trace-s390.h

index 5521ace8b60d1901c3dea9b80abcf7b1c2dc131d..004d385d9519e3dec901460c6775d311006b999f 100644 (file)
@@ -176,7 +176,7 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu)
                return -EOPNOTSUPP;
        }
 
-       atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
+       kvm_s390_vcpu_stop(vcpu);
        vcpu->run->s390_reset_flags |= KVM_S390_RESET_SUBSYSTEM;
        vcpu->run->s390_reset_flags |= KVM_S390_RESET_IPL;
        vcpu->run->s390_reset_flags |= KVM_S390_RESET_CPU_INIT;
index 54313fe6e8d4a1c059363cfe86d76760f39a35f9..99e4b76e3487b5e18756e72d55fb90cafaa919a2 100644 (file)
@@ -65,8 +65,7 @@ static int handle_stop(struct kvm_vcpu *vcpu)
        trace_kvm_s390_stop_request(vcpu->arch.local_int.action_bits);
 
        if (vcpu->arch.local_int.action_bits & ACTION_STOP_ON_STOP) {
-               atomic_set_mask(CPUSTAT_STOPPED,
-                               &vcpu->arch.sie_block->cpuflags);
+               kvm_s390_vcpu_stop(vcpu);
                vcpu->arch.local_int.action_bits &= ~ACTION_STOP_ON_STOP;
                VCPU_EVENT(vcpu, 3, "%s", "cpu stopped");
                rc = -EOPNOTSUPP;
index 077e4738ebdc45cfc80cf408d3210d97018bfda2..d9526bb291945c8c1275faa198eff1144d1b50b0 100644 (file)
@@ -413,7 +413,7 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
                rc |= read_guest_lc(vcpu, offsetof(struct _lowcore, restart_psw),
                                    &vcpu->arch.sie_block->gpsw,
                                    sizeof(psw_t));
-               atomic_clear_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
+               kvm_s390_vcpu_start(vcpu);
                break;
        case KVM_S390_PROGRAM_INT:
                VCPU_EVENT(vcpu, 4, "interrupt: pgm check code:%x, ilc:%x",
index b32c42cbc7063d9298a5484b672485ea3b5f04b0..6c972d229ace8ec84ed711c3a804ac6ec1031ab8 100644 (file)
@@ -592,7 +592,7 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
        vcpu->arch.sie_block->pp = 0;
        vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID;
        kvm_clear_async_pf_completion_queue(vcpu);
-       atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
+       kvm_s390_vcpu_stop(vcpu);
        kvm_s390_clear_local_irqs(vcpu);
 }
 
@@ -1235,7 +1235,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        if (vcpu->sigset_active)
                sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
 
-       atomic_clear_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
+       kvm_s390_vcpu_start(vcpu);
 
        switch (kvm_run->exit_reason) {
        case KVM_EXIT_S390_SIEIC:
@@ -1362,6 +1362,18 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
        return kvm_s390_store_status_unloaded(vcpu, addr);
 }
 
+void kvm_s390_vcpu_start(struct kvm_vcpu *vcpu)
+{
+       trace_kvm_s390_vcpu_start_stop(vcpu->vcpu_id, 1);
+       atomic_clear_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
+}
+
+void kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu)
+{
+       trace_kvm_s390_vcpu_start_stop(vcpu->vcpu_id, 0);
+       atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
+}
+
 static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
                                     struct kvm_enable_cap *cap)
 {
index 9b5680d1f6cc637bc87f0f65078c6a6aa47e6299..c28423a3acc0863cc62d8d3b94779041d4aa40a2 100644 (file)
@@ -157,6 +157,8 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu);
 /* implemented in kvm-s390.c */
 int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr);
 int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr);
+void kvm_s390_vcpu_start(struct kvm_vcpu *vcpu);
+void kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu);
 void s390_vcpu_block(struct kvm_vcpu *vcpu);
 void s390_vcpu_unblock(struct kvm_vcpu *vcpu);
 void exit_sie(struct kvm_vcpu *vcpu);
index 13f30f58a2df7d94ba8f91d8113f49c8d7938d27..34d4f8af3a1daecd4ce35616e9f163303c9950f9 100644 (file)
@@ -67,6 +67,27 @@ TRACE_EVENT(kvm_s390_destroy_vcpu,
            TP_printk("destroy cpu %d", __entry->id)
        );
 
+/*
+ * Trace point for start and stop of vpcus.
+ */
+TRACE_EVENT(kvm_s390_vcpu_start_stop,
+           TP_PROTO(unsigned int id, int state),
+           TP_ARGS(id, state),
+
+           TP_STRUCT__entry(
+                   __field(unsigned int, id)
+                   __field(int, state)
+                   ),
+
+           TP_fast_assign(
+                   __entry->id = id;
+                   __entry->state = state;
+                   ),
+
+           TP_printk("%s cpu %d", __entry->state ? "starting" : "stopping",
+                     __entry->id)
+       );
+
 /*
  * Trace points for injection of interrupts, either per machine or
  * per vcpu.