]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: s390: vsie: correctly set and handle guest TOD
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Thu, 29 Oct 2015 09:30:36 +0000 (10:30 +0100)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 21 Jun 2016 07:43:46 +0000 (09:43 +0200)
Guest 2 sets up the epoch of guest 3 from his point of view. Therefore,
we have to add the guest 2 epoch to the guest 3 epoch. We also have to take
care of guest 2 epoch changes on STP syncs. This will work just fine by
also updating the guest 3 epoch when a vsie_block has been set for a VCPU.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/vsie.c

index 8ba7a98a50cfbf09a6ec543e9c56ae153a4daede..6fdf1f7647d7c9cb362b0221bba80a33dd7654b4 100644 (file)
@@ -176,6 +176,8 @@ static int kvm_clock_sync(struct notifier_block *notifier, unsigned long val,
                        vcpu->arch.sie_block->epoch -= *delta;
                        if (vcpu->arch.cputm_enabled)
                                vcpu->arch.cputm_start += *delta;
+                       if (vcpu->arch.vsie_block)
+                               vcpu->arch.vsie_block->epoch -= *delta;
                }
        }
        return NOTIFY_OK;
index 90781ba528030541d90d2d12487fd8819f7130e8..6895e7b3be123767d4829072ff3ba39b53350cac 100644 (file)
@@ -843,12 +843,21 @@ static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
 static void register_shadow_scb(struct kvm_vcpu *vcpu,
                                struct vsie_page *vsie_page)
 {
+       struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
+
        WRITE_ONCE(vcpu->arch.vsie_block, &vsie_page->scb_s);
        /*
         * External calls have to lead to a kick of the vcpu and
         * therefore the vsie -> Simulate Wait state.
         */
        atomic_or(CPUSTAT_WAIT, &vcpu->arch.sie_block->cpuflags);
+       /*
+        * We have to adjust the g3 epoch by the g2 epoch. The epoch will
+        * automatically be adjusted on tod clock changes via kvm_sync_clock.
+        */
+       preempt_disable();
+       scb_s->epoch += vcpu->kvm->arch.epoch;
+       preempt_enable();
 }
 
 /*