Skip to contentSkip to conversation

KVM: s390: vsie: Fix the initialization of the epoch extension (epdx) field

PATCH In review Thomas Huth 5 participants 7 messages Nov 23, 2022 – Nov 24, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: s390: vsie: Fix the initialization of the epoch extension (epdx) field

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")
---
 arch/s390/kvm/vsie.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +3 -1
index 94138f8f0c1c..ace2541ababd 100644
@@ -546,8 +546,10 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))
 		scb_s->eca |= scb_o->eca & ECA_CEI;
 	/* Epoch Extension */
-	if (test_kvm_facility(vcpu->kvm, 139))
+	if (test_kvm_facility(vcpu->kvm, 139)) {
 		scb_s->ecd |= scb_o->ecd & ECD_MEF;
+		scb_s->epdx = scb_o->epdx;
+	}
 
 	/* etoken */
 	if (test_kvm_facility(vcpu->kvm, 156))
Signature · 1 line
2.31.1
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · Thomas Huth

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")
---
  arch/s390/kvm/vsie.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +0 -0
index 94138f8f0c1c..ace2541ababd 100644
@@ -546,8 +546,10 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  	if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))

arch/s390/kvm/vsie.c static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) · line 555

Quoted 10 lines
arch/s390/kvm/vsie.c +3 -1
  		scb_s->eca |= scb_o->eca & ECA_CEI;
  	/* Epoch Extension */
-	if (test_kvm_facility(vcpu->kvm, 139))
+	if (test_kvm_facility(vcpu->kvm, 139)) {
  		scb_s->ecd |= scb_o->ecd & ECD_MEF;
+		scb_s->epdx = scb_o->epdx;
+	}
 
  	/* etoken */
  	if (test_kvm_facility(vcpu->kvm, 156))

Nice,

Signature · 3 lines
Thanks,

David / dhildenb
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 9 lines · On Wed, 23 Nov 2022 10:08:33 +0100 Thomas Huth <[email protected]> wrote:

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Quoted 3 lines
Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")
Quoted 9 lines
---
 arch/s390/kvm/vsie.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +0 -0
index 94138f8f0c1c..ace2541ababd 100644

arch/s390/kvm/vsie.c static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) · line 551

Quoted 7 lines
arch/s390/kvm/vsie.c +2 -1
@@ -546,8 +546,10 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))
 		scb_s->eca |= scb_o->eca & ECA_CEI;
 	/* Epoch Extension */
-	if (test_kvm_facility(vcpu->kvm, 139))
+	if (test_kvm_facility(vcpu->kvm, 139)) {
 		scb_s->ecd |= scb_o->ecd & ECD_MEF;
+		scb_s->epdx = scb_o->epdx;

looks quite straightforward

Quoted 4 lines
arch/s390/kvm/vsie.c +1 -0
+	}
 
 	/* etoken */
 	if (test_kvm_facility(vcpu->kvm, 156))
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Thomas Huth

Am 23.11.22 um 10:08 schrieb Thomas Huth:

Quoted 11 lines

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")

We might want to add cc stable, just in case.

Quoted 21 lines
---
  arch/s390/kvm/vsie.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +3 -1
index 94138f8f0c1c..ace2541ababd 100644
@@ -546,8 +546,10 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  	if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))
  		scb_s->eca |= scb_o->eca & ECA_CEI;
  	/* Epoch Extension */
-	if (test_kvm_facility(vcpu->kvm, 139))
+	if (test_kvm_facility(vcpu->kvm, 139)) {
  		scb_s->ecd |= scb_o->ecd & ECD_MEF;
+		scb_s->epdx = scb_o->epdx;
+	}
 
  	/* etoken */
  	if (test_kvm_facility(vcpu->kvm, 156))
maintainer Reviewed-by
#4 lore raw
Quoted 12 lines · Christian Borntraeger

Am 23.11.22 um 10:08 schrieb Thomas Huth:

Quoted 9 lines

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Quoted 4 lines
Quoted 2 lines
Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")

We might want to add cc stable, just in case.

I'm pushing this to devel for the CI with the following additions:

Quoted 25 lines
Quoted 21 lines
---
   arch/s390/kvm/vsie.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +3 -1
index 94138f8f0c1c..ace2541ababd 100644
@@ -546,8 +546,10 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
   	if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_CEI))
   		scb_s->eca |= scb_o->eca & ECA_CEI;
   	/* Epoch Extension */
-	if (test_kvm_facility(vcpu->kvm, 139))
+	if (test_kvm_facility(vcpu->kvm, 139)) {
   		scb_s->ecd |= scb_o->ecd & ECD_MEF;
+		scb_s->epdx = scb_o->epdx;
+	}
 
   	/* etoken */
   	if (test_kvm_facility(vcpu->kvm, 156))
maintainer
#5 lore raw
In reply to Thomas Huth
Quoted 9 lines · Thomas Huth

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Quoted 3 lines
Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")

Could you please add a test for this to the KVM unit tests?
I'd guess you might already have some code for it from your debugging sessions.

#6 lore raw
Quoted 10 lines · Janosch Frank
Quoted 9 lines · Thomas Huth

We recently experienced some weird huge time jumps in nested guests when rebooting them in certain cases. After adding some debug code to the epoch handling in vsie.c (thanks to David Hildenbrand for the idea!), it was obvious that the "epdx" field (the multi-epoch extension) did not get set to 0xff in case the "epoch" field was negative.
Seems like the code misses to copy the value from the epdx field from the guest to the shadow control block. By doing so, the weird time jumps are gone in our scenarios.

Quoted 6 lines
Quoted 3 lines
Fixes 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")

Could you please add a test for this to the KVM unit tests?
I'd guess you might already have some code for it from your debugging sessions.

I don't have some test code for this yet - I was only testing with the scenario that is described in the bugzilla ticket. But sure, I can have a try to come up with a k-u-t test.

Thomas