Skip to contentSkip to conversation

KVM: s390: vsie: BUG correction by shadow_crycb

PATCH In review Pierre Morel 4 participants 7 messages Aug 21, 2018

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

PATCH 1/1 KVM: s390: vsie: BUG correction by shadow_crycb

Copy the key mask to the right offset inside the shadow CRYCB

---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +2 -1
index 63844b9..a2b28cd 100644
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · On Tue, 21 Aug 2018 16:19:38 +0200 Pierre Morel <[email protected]> wrote:

Copy the key mask to the right offset inside the shadow CRYCB

---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +0 -0
index 63844b9..a2b28cd 100644

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

Quoted 6 lines
arch/s390/kvm/vsie.c +2 -1
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))

Don't you need the address here?

Quoted 3 lines
arch/s390/kvm/vsie.c +0 -0
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;
Reviewed-by on v1 1/1
#4 lore raw
In reply to Pierre Morel
Quoted 1 line · Pierre Morel

Copy the key mask to the right offset inside the shadow CRYCB

"KVM: s390: vsie: copy wrapping keys to right place"

Indeed, we're writing it into the apcb0 mask (which is ignored). Luckily, the xor-ing with the g2 keys seems to work.

Quoted 21 lines
---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +2 -1
index 63844b9..a2b28cd 100644
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;
Signature · 3 lines
Thanks,

David / dhildenb
#2 lore raw
In reply to Cornelia Huck
Quoted 17 lines · Cornelia Huck
Quoted 14 lines · On Tue, 21 Aug 2018 16:19:38 +0200 Pierre Morel <[email protected]> wrote:

Copy the key mask to the right offset inside the shadow CRYCB

---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +0 -0
index 63844b9..a2b28cd 100644
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
Quoted 6 lines

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

Quoted 4 lines
arch/s390/kvm/vsie.c +2 -1
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))

Don't you need the address here?

As it is defined as an array, the address would result in the same value.

(&vsie_page->crycb.dea_wrapping_key_mask[0])

Quoted 5 lines
Quoted 4 lines
arch/s390/kvm/vsie.c +0 -0
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by
#3 lore raw
Quoted 25 lines · On Tue, 21 Aug 2018 16:36:19 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 17 lines · Cornelia Huck
Quoted 14 lines · On Tue, 21 Aug 2018 16:19:38 +0200 Pierre Morel <[email protected]> wrote:

Copy the key mask to the right offset inside the shadow CRYCB

---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +0 -0
index 63844b9..a2b28cd 100644
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
Quoted 6 lines

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

Quoted 4 lines
arch/s390/kvm/vsie.c +2 -1
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))  

Don't you need the address here?

Quoted 3 lines

As it is defined as an array, the address would result in the same value.

(&vsie_page->crycb.dea_wrapping_key_mask[0])

/me looks...

Indeed, it just looks a bit odd.

With the changed subject

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
arch/s390/kvm/vsie.c +0 -0
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;  
maintainer Reviewed-by on v1 1/1
#5 lore raw
In reply to Pierre Morel
Quoted 13 lines · Pierre Morel

Copy the key mask to the right offset inside the shadow CRYCB

---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +0 -0
index 63844b9..a2b28cd 100644

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

Quoted 9 lines
arch/s390/kvm/vsie.c +2 -1
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;

Are we able to use offsetof and sizeof here? I'd rather have a few more characters than magic offsets.
What about CC stable?

#6 lore raw
Quoted 21 lines · Janosch Frank
Quoted 20 lines · Pierre Morel

Copy the key mask to the right offset inside the shadow CRYCB

---
 arch/s390/kvm/vsie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kvm/vsie.c +2 -1
index 63844b9..a2b28cd 100644
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0039U);
 
 	/* copy only the wrapping keys */
-	if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56))
+	if (read_guest_real(vcpu, crycb_addr + 72,
+			    vsie_page->crycb.dea_wrapping_key_mask, 56))
 		return set_validity_icpt(scb_s, 0x0035U);
 
Quoted 6 lines

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

Quoted 2 lines
arch/s390/kvm/vsie.c +0 -0
 	scb_s->ecb3 |= ecb3_flags;

Are we able to use offsetof and sizeof here? I'd rather have a few more characters than magic offsets.
What about CC stable?

Thought about both things, too.

1. offsetof and sizeof will most likely make sense (although will most likely make this very ugly due to the long names involved)

2. I am not sure about wrapping keys. We never had migration problems, so I assume this does not break migration (maybe it will break once we fix it on one side :) ). As we xor with the g2 keys, we will never match the g2 keys. HW will xor with our keys either way, so it cannot match our keys.

But two g3 guests will now have the same wrapping keys, I assume that's bad?

I guess we'll have to wait for Christian, I remember he was one of the people that understood what wrapping keys are actually good for (and the real key used in HW can simply, silently change, e.g. when migrating to another system - due to the xoring).

Not having understood/looked into the details, I guess this should be stable material.

Quoted 4 lines
Signature · 3 lines
Thanks,

David / dhildenb