aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanosch Frank <frankja@linux.vnet.ibm.com>2017-12-04 06:19:11 -0500
committerChristian Borntraeger <borntraeger@de.ibm.com>2017-12-06 03:18:43 -0500
commitca76ec9ca871e67d8cd0b6caba24aca3d3ac4546 (patch)
tree9b18cd3ec7dd03b175d91a715b70d150b903cc54
parentbb64da9aba89765fee74b395967b18a7d6c364e9 (diff)
KVM: s390: Fix skey emulation permission check
All skey functions call skey_check_enable at their start, which checks if we are in the PSTATE and injects a privileged operation exception if we are. Unfortunately they continue processing afterwards and perform the operation anyhow as skey_check_enable does not deliver an error if the exception injection was successful. Let's move the PSTATE check into the skey functions and exit them on such an occasion, also we now do not enable skey handling anymore in such a case. Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Fixes: a7e19ab ("KVM: s390: handle missing storage-key facility") Cc: <stable@vger.kernel.org> # v4.8+ Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
-rw-r--r--arch/s390/kvm/priv.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 28b69ab56b7b..572496c688cc 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -232,8 +232,6 @@ static int try_handle_skey(struct kvm_vcpu *vcpu)
232 VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation"); 232 VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation");
233 return -EAGAIN; 233 return -EAGAIN;
234 } 234 }
235 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
236 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
237 return 0; 235 return 0;
238} 236}
239 237
@@ -244,6 +242,9 @@ static int handle_iske(struct kvm_vcpu *vcpu)
244 int reg1, reg2; 242 int reg1, reg2;
245 int rc; 243 int rc;
246 244
245 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
246 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
247
247 rc = try_handle_skey(vcpu); 248 rc = try_handle_skey(vcpu);
248 if (rc) 249 if (rc)
249 return rc != -EAGAIN ? rc : 0; 250 return rc != -EAGAIN ? rc : 0;
@@ -273,6 +274,9 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)
273 int reg1, reg2; 274 int reg1, reg2;
274 int rc; 275 int rc;
275 276
277 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
278 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
279
276 rc = try_handle_skey(vcpu); 280 rc = try_handle_skey(vcpu);
277 if (rc) 281 if (rc)
278 return rc != -EAGAIN ? rc : 0; 282 return rc != -EAGAIN ? rc : 0;
@@ -308,6 +312,9 @@ static int handle_sske(struct kvm_vcpu *vcpu)
308 int reg1, reg2; 312 int reg1, reg2;
309 int rc; 313 int rc;
310 314
315 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
316 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
317
311 rc = try_handle_skey(vcpu); 318 rc = try_handle_skey(vcpu);
312 if (rc) 319 if (rc)
313 return rc != -EAGAIN ? rc : 0; 320 return rc != -EAGAIN ? rc : 0;