Skip to contentSkip to conversation

KVM: s390: vsie: Do not shadow CRYCB when no AP and no keys

PATCH Applied Pierre Morel 3 participants 6 messages Apr 26, 2019 – Apr 29, 2019

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

PATCH 1/1 KVM: s390: vsie: Do not shadow CRYCB when no AP and no keys

When the guest do not have AP instructions nor Key management we should return without shadowing the CRYCB.

We did not check correctly in the past.

Fixes b10bd9a256ae ("s390: vsie: Use effective CRYCBD.31 to check CRYCBD

validity")

Fixes 6ee74098201b ("KVM: s390: vsie: allow CRYCB FORMAT-0")
---
 arch/s390/kvm/vsie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
index c6983d9..ac411e9 100644
@@ -290,6 +290,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	u8 ecb3_flags;
 	u32 ecd_flags;
 	int apie_h;
+	int apie_s;
 	int key_msk = test_kvm_facility(vcpu->kvm, 76);
 	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
 	int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
@@ -298,7 +299,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	scb_s->crycbd = 0;
 
 	apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
-	if (!apie_h && (!key_msk || fmt_o == CRYCB_FORMAT0))
+	apie_s = apie_h & scb_o->eca;
+	if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
 		return 0;
 
 	if (!crycb_addr)
@@ -309,7 +311,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		    ((crycb_addr + 128) & PAGE_MASK))
 			return set_validity_icpt(scb_s, 0x003CU);
 
-	if (apie_h && (scb_o->eca & ECA_APIE)) {
+	if (apie_s) {
 		ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
 				 vcpu->kvm->arch.crypto.crycb,
 				 fmt_o, fmt_h);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Pierre Morel

When the guest do not have AP instructions nor Key management we should return without shadowing the CRYCB.

We did not check correctly in the past.

Fixes b10bd9a256ae ("s390: vsie: Use effective CRYCBD.31 to check CRYCBD

validity")

We should really try to pay more attention, commit b10bd9a256ae already was supposed to fix 6ee74098201b.

Unfortunately, I don't have access to documentation and can't verify.

Quoted 40 lines
Fixes 6ee74098201b ("KVM: s390: vsie: allow CRYCB FORMAT-0")
---
 arch/s390/kvm/vsie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
index c6983d9..ac411e9 100644
@@ -290,6 +290,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	u8 ecb3_flags;
 	u32 ecd_flags;
 	int apie_h;
+	int apie_s;
 	int key_msk = test_kvm_facility(vcpu->kvm, 76);
 	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
 	int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
@@ -298,7 +299,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	scb_s->crycbd = 0;
 
 	apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
-	if (!apie_h && (!key_msk || fmt_o == CRYCB_FORMAT0))
+	apie_s = apie_h & scb_o->eca;
+	if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
 		return 0;
 
 	if (!crycb_addr)
@@ -309,7 +311,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		    ((crycb_addr + 128) & PAGE_MASK))
 			return set_validity_icpt(scb_s, 0x003CU);
 
-	if (apie_h && (scb_o->eca & ECA_APIE)) {
+	if (apie_s) {
 		ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
 				 vcpu->kvm->arch.crypto.crycb,
 				 fmt_o, fmt_h);
Signature · 3 lines
Thanks,

David / dhildenb
#2 lore raw
Quoted 11 lines · David Hildenbrand
Quoted 7 lines · Pierre Morel

When the guest do not have AP instructions nor Key management we should return without shadowing the CRYCB.

We did not check correctly in the past.

Fixes b10bd9a256ae ("s390: vsie: Use effective CRYCBD.31 to check CRYCBD

validity")

We should really try to pay more attention, commit b10bd9a256ae already was supposed to fix 6ee74098201b.

yes, sorry for that.

Quoted 4 lines

Unfortunately, I don't have access to documentation and can't verify.

Thanks

Quoted 43 lines
Quoted 41 lines
Fixes 6ee74098201b ("KVM: s390: vsie: allow CRYCB FORMAT-0")
---
  arch/s390/kvm/vsie.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
index c6983d9..ac411e9 100644
@@ -290,6 +290,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  	u8 ecb3_flags;
  	u32 ecd_flags;
  	int apie_h;
+	int apie_s;
  	int key_msk = test_kvm_facility(vcpu->kvm, 76);
  	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
  	int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
@@ -298,7 +299,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  	scb_s->crycbd = 0;
 
  	apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
-	if (!apie_h && (!key_msk || fmt_o == CRYCB_FORMAT0))
+	apie_s = apie_h & scb_o->eca;
+	if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
  		return 0;
 
  	if (!crycb_addr)
@@ -309,7 +311,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  		    ((crycb_addr + 128) & PAGE_MASK))
  			return set_validity_icpt(scb_s, 0x003CU);
 
-	if (apie_h && (scb_o->eca & ECA_APIE)) {
+	if (apie_s) {
  		ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
  				 vcpu->kvm->arch.crypto.crycb,
  				 fmt_o, fmt_h);
Signature · 2 lines
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany
Tested-by Reviewed-by on v1 1/1
#3 lore raw
In reply to Pierre Morel
Quoted 11 lines · Pierre Morel

When the guest do not have AP instructions nor Key management we should return without shadowing the CRYCB.

We did not check correctly in the past.

Fixes b10bd9a256ae ("s390: vsie: Use effective CRYCBD.31 to check CRYCBD

validity")

Fixes 6ee74098201b ("KVM: s390: vsie: allow CRYCB FORMAT-0")
Quoted 36 lines
---
 arch/s390/kvm/vsie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
index c6983d9..ac411e9 100644
@@ -290,6 +290,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	u8 ecb3_flags;
 	u32 ecd_flags;
 	int apie_h;
+	int apie_s;
 	int key_msk = test_kvm_facility(vcpu->kvm, 76);
 	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
 	int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
@@ -298,7 +299,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	scb_s->crycbd = 0;
 
 	apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
-	if (!apie_h && (!key_msk || fmt_o == CRYCB_FORMAT0))
+	apie_s = apie_h & scb_o->eca;
+	if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
 		return 0;
 
 	if (!crycb_addr)
@@ -309,7 +311,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		    ((crycb_addr + 128) & PAGE_MASK))
 			return set_validity_icpt(scb_s, 0x003CU);
 
-	if (apie_h && (scb_o->eca & ECA_APIE)) {
+	if (apie_s) {
 		ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
 				 vcpu->kvm->arch.crypto.crycb,
 				 fmt_o, fmt_h);
#4 lore raw
Quoted 8 lines · Christian Borntraeger
Quoted 5 lines · Pierre Morel

When the guest do not have AP instructions nor Key management we should return without shadowing the CRYCB.

We did not check correctly in the past.

Quoted 8 lines
Quoted 6 lines
Fixes b10bd9a256ae ("s390: vsie: Use effective CRYCBD.31 to check CRYCBD

validity")

Fixes 6ee74098201b ("KVM: s390: vsie: allow CRYCB FORMAT-0")

Thanks,
It gives a better feeling on this patch.

Pierre

Quoted 37 lines
Quoted 37 lines
---
  arch/s390/kvm/vsie.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
index c6983d9..ac411e9 100644
@@ -290,6 +290,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  	u8 ecb3_flags;
  	u32 ecd_flags;
  	int apie_h;
+	int apie_s;
  	int key_msk = test_kvm_facility(vcpu->kvm, 76);
  	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
  	int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
@@ -298,7 +299,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  	scb_s->crycbd = 0;
 
  	apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
-	if (!apie_h && (!key_msk || fmt_o == CRYCB_FORMAT0))
+	apie_s = apie_h & scb_o->eca;
+	if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
  		return 0;
 
  	if (!crycb_addr)
@@ -309,7 +311,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
  		    ((crycb_addr + 128) & PAGE_MASK))
  			return set_validity_icpt(scb_s, 0x003CU);
 
-	if (apie_h && (scb_o->eca & ECA_APIE)) {
+	if (apie_s) {
  		ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
  				 vcpu->kvm->arch.crypto.crycb,
  				 fmt_o, fmt_h);
Signature · 2 lines
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany
#5 lore raw
In reply to Pierre Morel
Quoted 39 lines · Pierre Morel

When the guest do not have AP instructions nor Key management we should return without shadowing the CRYCB.

We did not check correctly in the past.

Fixes b10bd9a256ae ("s390: vsie: Use effective CRYCBD.31 to check CRYCBD

validity")

Fixes 6ee74098201b ("KVM: s390: vsie: allow CRYCB FORMAT-0")
---
 arch/s390/kvm/vsie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +3 -1
index c6983d9..ac411e9 100644
@@ -290,6 +290,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	u8 ecb3_flags;
 	u32 ecd_flags;
 	int apie_h;
+	int apie_s;
 	int key_msk = test_kvm_facility(vcpu->kvm, 76);
 	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
 	int fmt_h = vcpu->arch.sie_block->crycbd & CRYCB_FORMAT_MASK;
@@ -298,7 +299,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	scb_s->crycbd = 0;
 
 	apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
-	if (!apie_h && (!key_msk || fmt_o == CRYCB_FORMAT0))
+	apie_s = apie_h & scb_o->eca;
+	if (!apie_s && (!key_msk || (fmt_o == CRYCB_FORMAT0)))
 		return 0;
 
 	if (!crycb_addr)

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

Quoted 8 lines
arch/s390/kvm/vsie.c +1 -1
@@ -309,7 +311,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		    ((crycb_addr + 128) & PAGE_MASK))
 			return set_validity_icpt(scb_s, 0x003CU);
 
-	if (apie_h && (scb_o->eca & ECA_APIE)) {
+	if (apie_s) {
 		ret = setup_apcb(vcpu, &vsie_page->crycb, crycb_addr,
 				 vcpu->kvm->arch.crypto.crycb,
 				 fmt_o, fmt_h);

thanks applied.