Skip to contentSkip to conversation

KVM: s390: consider epoch index on TOD clock syncs

RFC PATCH Christian Borntraeger 1 participant 1 message Feb 20, 2018 1 message not in the archive s390

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Christian Borntraeger

author Reviewed-by
#1 lore raw
Quoted 49 lines · David Hildenbrand
Quoted 27 lines · Christian Borntraeger
Quoted 24 lines · David Hildenbrand

For now, we don't take care of over/underflows. Especially underflows are critical:

Assume the epoch is currently 0 and we get a sync request for delta=1, meaning the TOD is moved forward by 1 and we have to fix it up by subtracting 1 from the epoch. Right now, this will leave the epoch index untouched, resulting in epoch=-1, epoch_idx=0, which is wrong.

We have to take care of over and underflows, also for the VSIE case. So let's factor out calculation into a separate function.

---
 arch/s390/kvm/kvm-s390.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
arch/s390/kvm/kvm-s390.c +0 -0
index d007b737cd4d..c2b62379049e 100644
@@ -179,6 +179,28 @@ int kvm_arch_hardware_enable(void)
 static void kvm_gmap_notifier(struct gmap *gmap, unsigned long start,
 			      unsigned long end);
 
Quoted 5 lines

arch/s390/kvm/kvm-s390.c int kvm_arch_hardware_enable(void) · line 184

Quoted 3 lines
arch/s390/kvm/kvm-s390.c +3 -0
+static void kvm_clock_sync_scb(struct kvm_s390_sie_block *scb, u64 delta)
+{
+	u64 delta_idx = 0;

we only add it to epdx, so should it be u8?

Indeed, this should be u8.

Quoted 4 lines
Quoted 4 lines
arch/s390/kvm/kvm-s390.c +4 -0
+
+	/*
+	 * The TOD jumps by delta, we have to compensate this by adding
+	 * -delta to the epoch.
Quoted 8 lines

arch/s390/kvm/kvm-s390.c int kvm_arch_hardware_enable(void) · line 194

Quoted 6 lines
arch/s390/kvm/kvm-s390.c +6 -0
+	 */
+	delta = -delta;
+
+	/* sign-extension - we're adding to signed values below */
+	if ((s64)delta < 0)
+		delta_idx = 0xff;

and -1 then here?

Quoted 1 line

Yes, thanks!

with that

applied and changed to u8.

In plan to submit patch 1,3 and 4 for 4.16