Skip to contentSkip to conversation

KVM: s390: Enable specification exception interpretation

PATCH Superseded Janis Schoetterl-Glausch 5 participants 15 messages Jul 6, 2021 – Jul 7, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: s390: Enable specification exception interpretation

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

 arch/s390/include/asm/kvm_host.h | 1 +
 arch/s390/kvm/kvm-s390.c         | 2 ++
 arch/s390/kvm/vsie.c             | 2 ++
 3 files changed, 5 insertions(+)
arch/s390/include/asm/kvm_host.h +1 -0
index 9b4473f76e56..3a5b5084cdbe 100644
@@ -244,6 +244,7 @@ struct kvm_s390_sie_block {
 	__u8	fpf;			/* 0x0060 */
 #define ECB_GS		0x40
 #define ECB_TE		0x10
+#define ECB_SPECI	0x08
 #define ECB_SRSI	0x04
 #define ECB_HOSTPROTINT	0x02
 	__u8	ecb;			/* 0x0061 */
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
 		vcpu->arch.sie_block->ecb |= ECB_SRSI;
 	if (test_kvm_facility(vcpu->kvm, 73))
 		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
 	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
 		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
arch/s390/kvm/vsie.c +2 -0
index 4002a24bc43a..acda4b6fc851 100644
@@ -510,6 +510,8 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 			prefix_unmapped(vsie_page);
 		scb_s->ecb |= ECB_TE;
 	}
+	/* specification exception interpretation */
+	scb_s->ecb |= scb_o->ecb & ECB_SPECI;
 	/* branch prediction */
 	if (test_kvm_facility(vcpu->kvm, 82))
 		scb_s->fpf |= scb_o->fpf & FPF_BPBC;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

 arch/s390/include/asm/kvm_host.h | 1 +
 arch/s390/kvm/kvm-s390.c         | 2 ++
 arch/s390/kvm/vsie.c             | 2 ++
 3 files changed, 5 insertions(+)

(...)

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
 		vcpu->arch.sie_block->ecb |= ECB_SRSI;
 	if (test_kvm_facility(vcpu->kvm, 73))
 		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Quoted 3 lines
arch/s390/kvm/kvm-s390.c +0 -0
 	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
 		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
#2 lore raw
Quoted 23 lines · Cornelia Huck
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

  arch/s390/include/asm/kvm_host.h | 1 +
  arch/s390/kvm/kvm-s390.c         | 2 ++
  arch/s390/kvm/vsie.c             | 2 ++
  3 files changed, 5 insertions(+)

(...)

Quoted 13 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		vcpu->arch.sie_block->ecb |= ECB_SRSI;
  	if (test_kvm_facility(vcpu->kvm, 73))
  		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Not for all hardware versions, but also no indication. The architecture says that the HW is free to do this or not. (which makes the vsie code simpler).

Quoted 5 lines
Quoted 4 lines
arch/s390/kvm/kvm-s390.c +0 -0
  	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
  		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
#3 lore raw
Quoted 40 lines · Christian Borntraeger
Quoted 23 lines · Cornelia Huck
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

   arch/s390/include/asm/kvm_host.h | 1 +
   arch/s390/kvm/kvm-s390.c         | 2 ++
   arch/s390/kvm/vsie.c             | 2 ++
   3 files changed, 5 insertions(+)

(...)

Quoted 13 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
   		vcpu->arch.sie_block->ecb |= ECB_SRSI;
   	if (test_kvm_facility(vcpu->kvm, 73))
   		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Quoted 3 lines

Not for all hardware versions, but also no indication. The architecture says that the HW is free to do this or not. (which makes the vsie code simpler).

I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.

(I though HW learned the lesson to always use proper feature indications along with new features)

Signature · 3 lines
Thanks,

David / dhildenb
#4 lore raw
Quoted 41 lines · David Hildenbrand
Quoted 40 lines · Christian Borntraeger
Quoted 36 lines · Cornelia Huck
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

   arch/s390/include/asm/kvm_host.h | 1 +
   arch/s390/kvm/kvm-s390.c         | 2 ++
   arch/s390/kvm/vsie.c             | 2 ++

   3 files changed, 5 insertions(+)

(...)

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
            vcpu->arch.sie_block->ecb |= ECB_SRSI;
        if (test_kvm_facility(vcpu->kvm, 73))
            vcpu->arch.sie_block->ecb |= ECB_TE;
+    if (!kvm_is_ucontrol(vcpu->kvm))
+        vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Quoted 5 lines
Quoted 3 lines

Not for all hardware versions, but also no indication. The architecture says that the HW is free to do this or not. (which makes the vsie code simpler).

I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.

I can confirm that this bit will be ignored on older machines. The notion of never setting undefined bits comes from "you never know what this bit will change in future machines". Now we know :-)

#5 lore raw
Quoted 48 lines · Christian Borntraeger
Quoted 45 lines · David Hildenbrand
Quoted 43 lines · Christian Borntraeger
Quoted 23 lines · Cornelia Huck
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

    arch/s390/include/asm/kvm_host.h | 1 +
    arch/s390/kvm/kvm-s390.c         | 2 ++
    arch/s390/kvm/vsie.c             | 2 ++
    3 files changed, 5 insertions(+)

(...)

Quoted 13 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
            vcpu->arch.sie_block->ecb |= ECB_SRSI;
        if (test_kvm_facility(vcpu->kvm, 73))
            vcpu->arch.sie_block->ecb |= ECB_TE;
+    if (!kvm_is_ucontrol(vcpu->kvm))
+        vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Not for all hardware versions, but also no indication. The architecture says that the HW is free to do this or not. (which makes the vsie code simpler).

Quoted 5 lines
Quoted 1 line

I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.

I can confirm that this bit will be ignored on older machines. The notion of never setting undefined bits comes from "you never know what this bit will change in future machines". Now we know :-)

Well, okay then :)

So the plan for vSIE is to always keep it disabled? IIUC, one could similarly always forward the bit of set.

Signature · 3 lines
Thanks,

David / dhildenb
#6 lore raw
Quoted 51 lines · David Hildenbrand
Quoted 50 lines · Christian Borntraeger
Quoted 46 lines · David Hildenbrand
Quoted 40 lines · Christian Borntraeger
Quoted 23 lines · Cornelia Huck
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

    arch/s390/include/asm/kvm_host.h | 1 +
    arch/s390/kvm/kvm-s390.c         | 2 ++
    arch/s390/kvm/vsie.c             | 2 ++

    3 files changed, 5 insertions(+)

(...)

Quoted 13 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
             vcpu->arch.sie_block->ecb |= ECB_SRSI;
         if (test_kvm_facility(vcpu->kvm, 73))
             vcpu->arch.sie_block->ecb |= ECB_TE;
+    if (!kvm_is_ucontrol(vcpu->kvm))
+        vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Quoted 3 lines

Not for all hardware versions, but also no indication. The architecture says that the HW is free to do this or not. (which makes the vsie code simpler).

I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.

Quoted 7 lines
Quoted 3 lines

I can confirm that this bit will be ignored on older machines. The notion of never setting undefined bits comes from "you never know what this bit will change in future machines". Now we know :-)

Well, okay then :)

So the plan for vSIE is to always keep it disabled? IIUC, one could similarly always forward the bit of set.

The bit does get copied for vSIE.

Reviewed-by
#7 lore raw
Quoted 56 lines · Janis Schoetterl-Glausch
Quoted 55 lines · David Hildenbrand
Quoted 53 lines · Christian Borntraeger
Quoted 41 lines · David Hildenbrand
Quoted 40 lines · Christian Borntraeger
Quoted 36 lines · Cornelia Huck
Quoted 18 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

     arch/s390/include/asm/kvm_host.h | 1 +
     arch/s390/kvm/kvm-s390.c         | 2 ++
     arch/s390/kvm/vsie.c             | 2 ++
     3 files changed, 5 insertions(+)

(...)

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3204

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
             vcpu->arch.sie_block->ecb |= ECB_SRSI;
         if (test_kvm_facility(vcpu->kvm, 73))
             vcpu->arch.sie_block->ecb |= ECB_TE;
+    if (!kvm_is_ucontrol(vcpu->kvm))
+        vcpu->arch.sie_block->ecb |= ECB_SPECI;

Does this exist for any hardware version (i.e. not guarded by a cpu feature?)

Quoted 5 lines
Quoted 3 lines

Not for all hardware versions, but also no indication. The architecture says that the HW is free to do this or not. (which makes the vsie code simpler).

I remember the architecture said at some point to never set undefined bits - and this bit is undefined on older HW generations. I might be wrong, though.

I can confirm that this bit will be ignored on older machines. The notion of never setting undefined bits comes from "you never know what this bit will change in future machines". Now we know :-)

Quoted 5 lines
Quoted 3 lines

Well, okay then :)

So the plan for vSIE is to always keep it disabled? IIUC, one could similarly always forward the bit of set.

The bit does get copied for vSIE.

... and I missed that hunk :)

LGTM then

Signature · 3 lines
Thanks,

David / dhildenb
#8 lore raw
In reply to Janis Schoetterl-Glausch
Quoted 50 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

---
I'll additionally send kvm-unit-tests for testing this feature.

  arch/s390/include/asm/kvm_host.h | 1 +
  arch/s390/kvm/kvm-s390.c         | 2 ++
  arch/s390/kvm/vsie.c             | 2 ++
  3 files changed, 5 insertions(+)
arch/s390/include/asm/kvm_host.h +1 -0
index 9b4473f76e56..3a5b5084cdbe 100644
@@ -244,6 +244,7 @@ struct kvm_s390_sie_block {
  	__u8	fpf;			/* 0x0060 */
  #define ECB_GS		0x40
  #define ECB_TE		0x10
+#define ECB_SPECI	0x08
  #define ECB_SRSI	0x04
  #define ECB_HOSTPROTINT	0x02
  	__u8	ecb;			/* 0x0061 */
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		vcpu->arch.sie_block->ecb |= ECB_SRSI;
  	if (test_kvm_facility(vcpu->kvm, 73))
  		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
  	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
  		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
arch/s390/kvm/vsie.c +0 -0
index 4002a24bc43a..acda4b6fc851 100644

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

Quoted 8 lines
arch/s390/kvm/vsie.c +2 -0
@@ -510,6 +510,8 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  			prefix_unmapped(vsie_page);
  		scb_s->ecb |= ECB_TE;
  	}
+	/* specification exception interpretation */
+	scb_s->ecb |= scb_o->ecb & ECB_SPECI;
  	/* branch prediction */
  	if (test_kvm_facility(vcpu->kvm, 82))
  		scb_s->fpf |= scb_o->fpf & FPF_BPBC;

I assume this is a new CPU feature, right? If so

a) How can we check whether we can actually safely enable it. (which facility do we have to check)
b) Do we have to handle vSIE? Do we have to indicate a CPU feature that unlocks this feature?

Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 1/1
#9 lore raw
In reply to Janis Schoetterl-Glausch
Quoted 9 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

I think I will add

There is no indication if this feature is available or not and the hardware is free to interpret or not. So we can simply set this bit and if the hardware ignores it we fall back to intercept 8 handling.

With that

Quoted 49 lines

---
I'll additionally send kvm-unit-tests for testing this feature.

  arch/s390/include/asm/kvm_host.h | 1 +
  arch/s390/kvm/kvm-s390.c         | 2 ++
  arch/s390/kvm/vsie.c             | 2 ++
  3 files changed, 5 insertions(+)
arch/s390/include/asm/kvm_host.h +1 -0
index 9b4473f76e56..3a5b5084cdbe 100644
@@ -244,6 +244,7 @@ struct kvm_s390_sie_block {
  	__u8	fpf;			/* 0x0060 */
  #define ECB_GS		0x40
  #define ECB_TE		0x10
+#define ECB_SPECI	0x08
  #define ECB_SRSI	0x04
  #define ECB_HOSTPROTINT	0x02
  	__u8	ecb;			/* 0x0061 */
arch/s390/kvm/kvm-s390.c +2 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		vcpu->arch.sie_block->ecb |= ECB_SRSI;
  	if (test_kvm_facility(vcpu->kvm, 73))
  		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
  	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
  		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
arch/s390/kvm/vsie.c +2 -0
index 4002a24bc43a..acda4b6fc851 100644
@@ -510,6 +510,8 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  			prefix_unmapped(vsie_page);
  		scb_s->ecb |= ECB_TE;
  	}
+	/* specification exception interpretation */
+	scb_s->ecb |= scb_o->ecb & ECB_SPECI;
  	/* branch prediction */
  	if (test_kvm_facility(vcpu->kvm, 82))
  		scb_s->fpf |= scb_o->fpf & FPF_BPBC;
Reviewed-by
#10 lore raw
Quoted 8 lines · Christian Borntraeger
Quoted 7 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Quoted 8 lines
Quoted 2 lines

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

I think I will add

There is no indication if this feature is available or not and the hardware is free to interpret or not. So we can simply set this bit and if the hardware ignores it we fall back to intercept 8 handling.

Sounds good.

Quoted 14 lines

With that

Quoted 9 lines

---
I'll additionally send kvm-unit-tests for testing this feature.

  arch/s390/include/asm/kvm_host.h | 1 +
  arch/s390/kvm/kvm-s390.c         | 2 ++
  arch/s390/kvm/vsie.c             | 2 ++
  3 files changed, 5 insertions(+)

(...)

Quoted 8 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3202

Quoted 8 lines
arch/s390/kvm/kvm-s390.c +0 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		vcpu->arch.sie_block->ecb |= ECB_SRSI;
  	if (test_kvm_facility(vcpu->kvm, 73))
  		vcpu->arch.sie_block->ecb |= ECB_TE;

Maybe add

/* no facility bit, but safe as the hardware may ignore it */

or something like that, so that we don't stumble over that in the future?

Quoted 5 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3207

Quoted 5 lines
arch/s390/kvm/kvm-s390.c +2 -0
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
  	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
  		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
#11 lore raw

On 7/7/21 10:54 AM, Cornelia Huck wrote:

[...]

Quoted 12 lines
Quoted 9 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3202

Quoted 9 lines
arch/s390/kvm/kvm-s390.c +0 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		vcpu->arch.sie_block->ecb |= ECB_SRSI;
  	if (test_kvm_facility(vcpu->kvm, 73))
  		vcpu->arch.sie_block->ecb |= ECB_TE;

Maybe add

Quoted 3 lines

/* no facility bit, but safe as the hardware may ignore it */

or something like that, so that we don't stumble over that in the future?

Well, the hardware being allowed to ignore the bit makes its introduction without an indication forward compatible because it does not require vSIE to be adapted. The reserved bits are implicitly set to 0 which means new features are disabled by default and one observes all the interception one expects.

Maybe this:

/* no facility bit, can opt in because we do not need
to observe specification exception intercepts */

?

Quoted 9 lines
Quoted 6 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3207

Quoted 6 lines
arch/s390/kvm/kvm-s390.c +2 -0
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
  	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
  		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
#12 lore raw
Quoted 25 lines · Janis Schoetterl-Glausch

On 7/7/21 10:54 AM, Cornelia Huck wrote:

[...]

Quoted 12 lines
Quoted 9 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3202

Quoted 9 lines
arch/s390/kvm/kvm-s390.c +0 -0
index b655a7d82bf0..aadd589a3755 100644
@@ -3200,6 +3200,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		vcpu->arch.sie_block->ecb |= ECB_SRSI;
  	if (test_kvm_facility(vcpu->kvm, 73))
  		vcpu->arch.sie_block->ecb |= ECB_TE;

Maybe add

Quoted 3 lines

/* no facility bit, but safe as the hardware may ignore it */

or something like that, so that we don't stumble over that in the future?

Well, the hardware being allowed to ignore the bit makes its introduction without an indication forward compatible because it does not require vSIE to be adapted. The reserved bits are implicitly set to 0 which means new features are disabled by default and one observes all the interception one expects.

Quoted 6 lines

Maybe this:

/* no facility bit, can opt in because we do not need
to observe specification exception intercepts */

?

Works for me as well.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

arch/s390/kvm/kvm-s390.c static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) · line 3207

Quoted 7 lines
arch/s390/kvm/kvm-s390.c +2 -0
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
  	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
  		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
#13 lore raw
In reply to Christian Borntraeger
Quoted 10 lines · Christian Borntraeger
Quoted 7 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Quoted 8 lines
Quoted 2 lines

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

I think I will add

There is no indication if this feature is available or not and the hardware is free to interpret or not. So we can simply set this bit and if the hardware ignores it we fall back to intercept 8 handling.

Might also mention vSIE and/or incorporate into first paragraph:

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions, but it is not required to. There is no indication if this feature is available or not, so we can simply set this bit and if the hardware ignores it we fall back to intercept 8 handling.
The same applies to vSIE, we forward the guest hypervisor's bit and fall back to injection if interpretation does not occur.

Quoted 5 lines

With that

[...]

#14 lore raw
Quoted 22 lines · Janis Schoetterl-Glausch
Quoted 10 lines · Christian Borntraeger
Quoted 7 lines · Janis Schoetterl-Glausch

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions.

This benefits (test) programs that generate a lot of specification exceptions (roughly 4x increase in exceptions/sec).

Quoted 8 lines
Quoted 2 lines

Interceptions will occur as before if ICTL_PINT is set, i.e. if guest debug is enabled.

I think I will add

There is no indication if this feature is available or not and the hardware is free to interpret or not. So we can simply set this bit and if the hardware ignores it we fall back to intercept 8 handling.

Might also mention vSIE and/or incorporate into first paragraph:

Quoted 8 lines

When this feature is enabled the hardware is free to interpret specification exceptions generated by the guest, instead of causing program interruption interceptions, but it is not required to. There is no indication if this feature is available or not, so we can simply set this bit and if the hardware ignores it we fall back to intercept 8 handling.
The same applies to vSIE, we forward the guest hypervisor's bit and fall back to injection if interpretation does not occur.

Can you maybe resend a v2 with all comments (and RBs) added?