aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorThomas Huth <thuth@linux.vnet.ibm.com>2014-02-03 04:42:30 -0500
committerChristian Borntraeger <borntraeger@de.ibm.com>2014-04-29 09:01:51 -0400
commit9a558ee3ccb8afcf43c8d9d4d206ab6de4aa30a2 (patch)
tree3abc6630eafe057d5bea90aab4edf2025424c571 /arch/s390
parent198c74f43f0f5473f99967aead30ddc622804bc1 (diff)
KVM: s390: Handle MVPG partial execution interception
When the guest executes the MVPG instruction with DAT disabled, and the source or destination page is not mapped in the host, the so-called partial execution interception occurs. We need to handle this event by setting up a mapping for the corresponding user pages. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/kvm/intercept.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 30e1c5eb726a..54313fe6e8d4 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * in-kernel handling for sie intercepts 2 * in-kernel handling for sie intercepts
3 * 3 *
4 * Copyright IBM Corp. 2008, 2009 4 * Copyright IBM Corp. 2008, 2014
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only) 7 * it under the terms of the GNU General Public License (version 2 only)
@@ -234,6 +234,58 @@ static int handle_instruction_and_prog(struct kvm_vcpu *vcpu)
234 return rc2; 234 return rc2;
235} 235}
236 236
237/**
238 * Handle MOVE PAGE partial execution interception.
239 *
240 * This interception can only happen for guests with DAT disabled and
241 * addresses that are currently not mapped in the host. Thus we try to
242 * set up the mappings for the corresponding user pages here (or throw
243 * addressing exceptions in case of illegal guest addresses).
244 */
245static int handle_mvpg_pei(struct kvm_vcpu *vcpu)
246{
247 unsigned long hostaddr, srcaddr, dstaddr;
248 psw_t *psw = &vcpu->arch.sie_block->gpsw;
249 struct mm_struct *mm = current->mm;
250 int reg1, reg2, rc;
251
252 kvm_s390_get_regs_rre(vcpu, &reg1, &reg2);
253 srcaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg2]);
254 dstaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg1]);
255
256 /* Make sure that the source is paged-in */
257 hostaddr = gmap_fault(srcaddr, vcpu->arch.gmap);
258 if (IS_ERR_VALUE(hostaddr))
259 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
260 down_read(&mm->mmap_sem);
261 rc = get_user_pages(current, mm, hostaddr, 1, 0, 0, NULL, NULL);
262 up_read(&mm->mmap_sem);
263 if (rc < 0)
264 return rc;
265
266 /* Make sure that the destination is paged-in */
267 hostaddr = gmap_fault(dstaddr, vcpu->arch.gmap);
268 if (IS_ERR_VALUE(hostaddr))
269 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
270 down_read(&mm->mmap_sem);
271 rc = get_user_pages(current, mm, hostaddr, 1, 1, 0, NULL, NULL);
272 up_read(&mm->mmap_sem);
273 if (rc < 0)
274 return rc;
275
276 psw->addr = __rewind_psw(*psw, 4);
277
278 return 0;
279}
280
281static int handle_partial_execution(struct kvm_vcpu *vcpu)
282{
283 if (vcpu->arch.sie_block->ipa == 0xb254) /* MVPG */
284 return handle_mvpg_pei(vcpu);
285
286 return -EOPNOTSUPP;
287}
288
237static const intercept_handler_t intercept_funcs[] = { 289static const intercept_handler_t intercept_funcs[] = {
238 [0x00 >> 2] = handle_noop, 290 [0x00 >> 2] = handle_noop,
239 [0x04 >> 2] = handle_instruction, 291 [0x04 >> 2] = handle_instruction,
@@ -245,6 +297,7 @@ static const intercept_handler_t intercept_funcs[] = {
245 [0x1C >> 2] = kvm_s390_handle_wait, 297 [0x1C >> 2] = kvm_s390_handle_wait,
246 [0x20 >> 2] = handle_validity, 298 [0x20 >> 2] = handle_validity,
247 [0x28 >> 2] = handle_stop, 299 [0x28 >> 2] = handle_stop,
300 [0x38 >> 2] = handle_partial_execution,
248}; 301};
249 302
250int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu) 303int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)