diff options
-rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 11 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 16 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke.c | 10 | ||||
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 4 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 16 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 40 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 15 |
7 files changed, 17 insertions, 95 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 21b701374f72..91760e80e268 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -725,8 +725,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
725 | int r; | 725 | int r; |
726 | sigset_t sigsaved; | 726 | sigset_t sigsaved; |
727 | 727 | ||
728 | vcpu_load(vcpu); | ||
729 | |||
730 | if (vcpu->sigset_active) | 728 | if (vcpu->sigset_active) |
731 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | 729 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); |
732 | 730 | ||
@@ -748,7 +746,6 @@ out: | |||
748 | if (vcpu->sigset_active) | 746 | if (vcpu->sigset_active) |
749 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 747 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |
750 | 748 | ||
751 | vcpu_put(vcpu); | ||
752 | return r; | 749 | return r; |
753 | } | 750 | } |
754 | 751 | ||
@@ -883,8 +880,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
883 | struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd); | 880 | struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd); |
884 | int i; | 881 | int i; |
885 | 882 | ||
886 | vcpu_load(vcpu); | ||
887 | |||
888 | for (i = 0; i < 16; i++) { | 883 | for (i = 0; i < 16; i++) { |
889 | vpd->vgr[i] = regs->vpd.vgr[i]; | 884 | vpd->vgr[i] = regs->vpd.vgr[i]; |
890 | vpd->vbgr[i] = regs->vpd.vbgr[i]; | 885 | vpd->vbgr[i] = regs->vpd.vbgr[i]; |
@@ -931,8 +926,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
931 | vcpu->arch.itc_offset = regs->saved_itc - kvm_get_itc(vcpu); | 926 | vcpu->arch.itc_offset = regs->saved_itc - kvm_get_itc(vcpu); |
932 | set_bit(KVM_REQ_RESUME, &vcpu->requests); | 927 | set_bit(KVM_REQ_RESUME, &vcpu->requests); |
933 | 928 | ||
934 | vcpu_put(vcpu); | ||
935 | |||
936 | return 0; | 929 | return 0; |
937 | } | 930 | } |
938 | 931 | ||
@@ -1967,9 +1960,7 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) | |||
1967 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | 1960 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, |
1968 | struct kvm_mp_state *mp_state) | 1961 | struct kvm_mp_state *mp_state) |
1969 | { | 1962 | { |
1970 | vcpu_load(vcpu); | ||
1971 | mp_state->mp_state = vcpu->arch.mp_state; | 1963 | mp_state->mp_state = vcpu->arch.mp_state; |
1972 | vcpu_put(vcpu); | ||
1973 | return 0; | 1964 | return 0; |
1974 | } | 1965 | } |
1975 | 1966 | ||
@@ -2000,10 +1991,8 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | |||
2000 | { | 1991 | { |
2001 | int r = 0; | 1992 | int r = 0; |
2002 | 1993 | ||
2003 | vcpu_load(vcpu); | ||
2004 | vcpu->arch.mp_state = mp_state->mp_state; | 1994 | vcpu->arch.mp_state = mp_state->mp_state; |
2005 | if (vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED) | 1995 | if (vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED) |
2006 | r = vcpu_reset(vcpu); | 1996 | r = vcpu_reset(vcpu); |
2007 | vcpu_put(vcpu); | ||
2008 | return r; | 1997 | return r; |
2009 | } | 1998 | } |
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index b998abf1a63d..f6eac2f337d9 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -1047,8 +1047,6 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
1047 | { | 1047 | { |
1048 | int i; | 1048 | int i; |
1049 | 1049 | ||
1050 | vcpu_load(vcpu); | ||
1051 | |||
1052 | regs->pc = kvmppc_get_pc(vcpu); | 1050 | regs->pc = kvmppc_get_pc(vcpu); |
1053 | regs->cr = kvmppc_get_cr(vcpu); | 1051 | regs->cr = kvmppc_get_cr(vcpu); |
1054 | regs->ctr = kvmppc_get_ctr(vcpu); | 1052 | regs->ctr = kvmppc_get_ctr(vcpu); |
@@ -1069,8 +1067,6 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
1069 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) | 1067 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) |
1070 | regs->gpr[i] = kvmppc_get_gpr(vcpu, i); | 1068 | regs->gpr[i] = kvmppc_get_gpr(vcpu, i); |
1071 | 1069 | ||
1072 | vcpu_put(vcpu); | ||
1073 | |||
1074 | return 0; | 1070 | return 0; |
1075 | } | 1071 | } |
1076 | 1072 | ||
@@ -1078,8 +1074,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
1078 | { | 1074 | { |
1079 | int i; | 1075 | int i; |
1080 | 1076 | ||
1081 | vcpu_load(vcpu); | ||
1082 | |||
1083 | kvmppc_set_pc(vcpu, regs->pc); | 1077 | kvmppc_set_pc(vcpu, regs->pc); |
1084 | kvmppc_set_cr(vcpu, regs->cr); | 1078 | kvmppc_set_cr(vcpu, regs->cr); |
1085 | kvmppc_set_ctr(vcpu, regs->ctr); | 1079 | kvmppc_set_ctr(vcpu, regs->ctr); |
@@ -1099,8 +1093,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
1099 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) | 1093 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) |
1100 | kvmppc_set_gpr(vcpu, i, regs->gpr[i]); | 1094 | kvmppc_set_gpr(vcpu, i, regs->gpr[i]); |
1101 | 1095 | ||
1102 | vcpu_put(vcpu); | ||
1103 | |||
1104 | return 0; | 1096 | return 0; |
1105 | } | 1097 | } |
1106 | 1098 | ||
@@ -1110,8 +1102,6 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
1110 | struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); | 1102 | struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); |
1111 | int i; | 1103 | int i; |
1112 | 1104 | ||
1113 | vcpu_load(vcpu); | ||
1114 | |||
1115 | sregs->pvr = vcpu->arch.pvr; | 1105 | sregs->pvr = vcpu->arch.pvr; |
1116 | 1106 | ||
1117 | sregs->u.s.sdr1 = to_book3s(vcpu)->sdr1; | 1107 | sregs->u.s.sdr1 = to_book3s(vcpu)->sdr1; |
@@ -1131,8 +1121,6 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
1131 | } | 1121 | } |
1132 | } | 1122 | } |
1133 | 1123 | ||
1134 | vcpu_put(vcpu); | ||
1135 | |||
1136 | return 0; | 1124 | return 0; |
1137 | } | 1125 | } |
1138 | 1126 | ||
@@ -1142,8 +1130,6 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
1142 | struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); | 1130 | struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); |
1143 | int i; | 1131 | int i; |
1144 | 1132 | ||
1145 | vcpu_load(vcpu); | ||
1146 | |||
1147 | kvmppc_set_pvr(vcpu, sregs->pvr); | 1133 | kvmppc_set_pvr(vcpu, sregs->pvr); |
1148 | 1134 | ||
1149 | vcpu3s->sdr1 = sregs->u.s.sdr1; | 1135 | vcpu3s->sdr1 = sregs->u.s.sdr1; |
@@ -1171,8 +1157,6 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
1171 | /* Flush the MMU after messing with the segments */ | 1157 | /* Flush the MMU after messing with the segments */ |
1172 | kvmppc_mmu_pte_flush(vcpu, 0, 0); | 1158 | kvmppc_mmu_pte_flush(vcpu, 0, 0); |
1173 | 1159 | ||
1174 | vcpu_put(vcpu); | ||
1175 | |||
1176 | return 0; | 1160 | return 0; |
1177 | } | 1161 | } |
1178 | 1162 | ||
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index a33ab8cc2ccc..b687f430f8c0 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -485,8 +485,6 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
485 | { | 485 | { |
486 | int i; | 486 | int i; |
487 | 487 | ||
488 | vcpu_load(vcpu); | ||
489 | |||
490 | regs->pc = vcpu->arch.pc; | 488 | regs->pc = vcpu->arch.pc; |
491 | regs->cr = kvmppc_get_cr(vcpu); | 489 | regs->cr = kvmppc_get_cr(vcpu); |
492 | regs->ctr = vcpu->arch.ctr; | 490 | regs->ctr = vcpu->arch.ctr; |
@@ -507,8 +505,6 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
507 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) | 505 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) |
508 | regs->gpr[i] = kvmppc_get_gpr(vcpu, i); | 506 | regs->gpr[i] = kvmppc_get_gpr(vcpu, i); |
509 | 507 | ||
510 | vcpu_put(vcpu); | ||
511 | |||
512 | return 0; | 508 | return 0; |
513 | } | 509 | } |
514 | 510 | ||
@@ -516,8 +512,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
516 | { | 512 | { |
517 | int i; | 513 | int i; |
518 | 514 | ||
519 | vcpu_load(vcpu); | ||
520 | |||
521 | vcpu->arch.pc = regs->pc; | 515 | vcpu->arch.pc = regs->pc; |
522 | kvmppc_set_cr(vcpu, regs->cr); | 516 | kvmppc_set_cr(vcpu, regs->cr); |
523 | vcpu->arch.ctr = regs->ctr; | 517 | vcpu->arch.ctr = regs->ctr; |
@@ -537,8 +531,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
537 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) | 531 | for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) |
538 | kvmppc_set_gpr(vcpu, i, regs->gpr[i]); | 532 | kvmppc_set_gpr(vcpu, i, regs->gpr[i]); |
539 | 533 | ||
540 | vcpu_put(vcpu); | ||
541 | |||
542 | return 0; | 534 | return 0; |
543 | } | 535 | } |
544 | 536 | ||
@@ -569,9 +561,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, | |||
569 | { | 561 | { |
570 | int r; | 562 | int r; |
571 | 563 | ||
572 | vcpu_load(vcpu); | ||
573 | r = kvmppc_core_vcpu_translate(vcpu, tr); | 564 | r = kvmppc_core_vcpu_translate(vcpu, tr); |
574 | vcpu_put(vcpu); | ||
575 | return r; | 565 | return r; |
576 | } | 566 | } |
577 | 567 | ||
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 9b8683f39e05..e0fae7a618ca 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -423,8 +423,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) | |||
423 | int r; | 423 | int r; |
424 | sigset_t sigsaved; | 424 | sigset_t sigsaved; |
425 | 425 | ||
426 | vcpu_load(vcpu); | ||
427 | |||
428 | if (vcpu->sigset_active) | 426 | if (vcpu->sigset_active) |
429 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | 427 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); |
430 | 428 | ||
@@ -456,8 +454,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) | |||
456 | if (vcpu->sigset_active) | 454 | if (vcpu->sigset_active) |
457 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 455 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |
458 | 456 | ||
459 | vcpu_put(vcpu); | ||
460 | |||
461 | return r; | 457 | return r; |
462 | } | 458 | } |
463 | 459 | ||
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index ae3705816878..0d0e0add0201 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -371,55 +371,43 @@ static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu) | |||
371 | 371 | ||
372 | int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | 372 | int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) |
373 | { | 373 | { |
374 | vcpu_load(vcpu); | ||
375 | memcpy(&vcpu->arch.guest_gprs, ®s->gprs, sizeof(regs->gprs)); | 374 | memcpy(&vcpu->arch.guest_gprs, ®s->gprs, sizeof(regs->gprs)); |
376 | vcpu_put(vcpu); | ||
377 | return 0; | 375 | return 0; |
378 | } | 376 | } |
379 | 377 | ||
380 | int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | 378 | int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) |
381 | { | 379 | { |
382 | vcpu_load(vcpu); | ||
383 | memcpy(®s->gprs, &vcpu->arch.guest_gprs, sizeof(regs->gprs)); | 380 | memcpy(®s->gprs, &vcpu->arch.guest_gprs, sizeof(regs->gprs)); |
384 | vcpu_put(vcpu); | ||
385 | return 0; | 381 | return 0; |
386 | } | 382 | } |
387 | 383 | ||
388 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | 384 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, |
389 | struct kvm_sregs *sregs) | 385 | struct kvm_sregs *sregs) |
390 | { | 386 | { |
391 | vcpu_load(vcpu); | ||
392 | memcpy(&vcpu->arch.guest_acrs, &sregs->acrs, sizeof(sregs->acrs)); | 387 | memcpy(&vcpu->arch.guest_acrs, &sregs->acrs, sizeof(sregs->acrs)); |
393 | memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs)); | 388 | memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs)); |
394 | vcpu_put(vcpu); | ||
395 | return 0; | 389 | return 0; |
396 | } | 390 | } |
397 | 391 | ||
398 | int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | 392 | int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, |
399 | struct kvm_sregs *sregs) | 393 | struct kvm_sregs *sregs) |
400 | { | 394 | { |
401 | vcpu_load(vcpu); | ||
402 | memcpy(&sregs->acrs, &vcpu->arch.guest_acrs, sizeof(sregs->acrs)); | 395 | memcpy(&sregs->acrs, &vcpu->arch.guest_acrs, sizeof(sregs->acrs)); |
403 | memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs)); | 396 | memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs)); |
404 | vcpu_put(vcpu); | ||
405 | return 0; | 397 | return 0; |
406 | } | 398 | } |
407 | 399 | ||
408 | int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | 400 | int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) |
409 | { | 401 | { |
410 | vcpu_load(vcpu); | ||
411 | memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs)); | 402 | memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs)); |
412 | vcpu->arch.guest_fpregs.fpc = fpu->fpc; | 403 | vcpu->arch.guest_fpregs.fpc = fpu->fpc; |
413 | vcpu_put(vcpu); | ||
414 | return 0; | 404 | return 0; |
415 | } | 405 | } |
416 | 406 | ||
417 | int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | 407 | int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) |
418 | { | 408 | { |
419 | vcpu_load(vcpu); | ||
420 | memcpy(&fpu->fprs, &vcpu->arch.guest_fpregs.fprs, sizeof(fpu->fprs)); | 409 | memcpy(&fpu->fprs, &vcpu->arch.guest_fpregs.fprs, sizeof(fpu->fprs)); |
421 | fpu->fpc = vcpu->arch.guest_fpregs.fpc; | 410 | fpu->fpc = vcpu->arch.guest_fpregs.fpc; |
422 | vcpu_put(vcpu); | ||
423 | return 0; | 411 | return 0; |
424 | } | 412 | } |
425 | 413 | ||
@@ -498,8 +486,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
498 | int rc; | 486 | int rc; |
499 | sigset_t sigsaved; | 487 | sigset_t sigsaved; |
500 | 488 | ||
501 | vcpu_load(vcpu); | ||
502 | |||
503 | rerun_vcpu: | 489 | rerun_vcpu: |
504 | if (vcpu->requests) | 490 | if (vcpu->requests) |
505 | if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) | 491 | if (test_and_clear_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) |
@@ -568,8 +554,6 @@ rerun_vcpu: | |||
568 | if (vcpu->sigset_active) | 554 | if (vcpu->sigset_active) |
569 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 555 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |
570 | 556 | ||
571 | vcpu_put(vcpu); | ||
572 | |||
573 | vcpu->stat.exit_userspace++; | 557 | vcpu->stat.exit_userspace++; |
574 | return rc; | 558 | return rc; |
575 | } | 559 | } |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b05321adfd2f..5acd21245fc7 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4773,8 +4773,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
4773 | int r; | 4773 | int r; |
4774 | sigset_t sigsaved; | 4774 | sigset_t sigsaved; |
4775 | 4775 | ||
4776 | vcpu_load(vcpu); | ||
4777 | |||
4778 | if (vcpu->sigset_active) | 4776 | if (vcpu->sigset_active) |
4779 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | 4777 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); |
4780 | 4778 | ||
@@ -4815,14 +4813,11 @@ out: | |||
4815 | if (vcpu->sigset_active) | 4813 | if (vcpu->sigset_active) |
4816 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 4814 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |
4817 | 4815 | ||
4818 | vcpu_put(vcpu); | ||
4819 | return r; | 4816 | return r; |
4820 | } | 4817 | } |
4821 | 4818 | ||
4822 | int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | 4819 | int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) |
4823 | { | 4820 | { |
4824 | vcpu_load(vcpu); | ||
4825 | |||
4826 | regs->rax = kvm_register_read(vcpu, VCPU_REGS_RAX); | 4821 | regs->rax = kvm_register_read(vcpu, VCPU_REGS_RAX); |
4827 | regs->rbx = kvm_register_read(vcpu, VCPU_REGS_RBX); | 4822 | regs->rbx = kvm_register_read(vcpu, VCPU_REGS_RBX); |
4828 | regs->rcx = kvm_register_read(vcpu, VCPU_REGS_RCX); | 4823 | regs->rcx = kvm_register_read(vcpu, VCPU_REGS_RCX); |
@@ -4845,15 +4840,11 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
4845 | regs->rip = kvm_rip_read(vcpu); | 4840 | regs->rip = kvm_rip_read(vcpu); |
4846 | regs->rflags = kvm_get_rflags(vcpu); | 4841 | regs->rflags = kvm_get_rflags(vcpu); |
4847 | 4842 | ||
4848 | vcpu_put(vcpu); | ||
4849 | |||
4850 | return 0; | 4843 | return 0; |
4851 | } | 4844 | } |
4852 | 4845 | ||
4853 | int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | 4846 | int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) |
4854 | { | 4847 | { |
4855 | vcpu_load(vcpu); | ||
4856 | |||
4857 | kvm_register_write(vcpu, VCPU_REGS_RAX, regs->rax); | 4848 | kvm_register_write(vcpu, VCPU_REGS_RAX, regs->rax); |
4858 | kvm_register_write(vcpu, VCPU_REGS_RBX, regs->rbx); | 4849 | kvm_register_write(vcpu, VCPU_REGS_RBX, regs->rbx); |
4859 | kvm_register_write(vcpu, VCPU_REGS_RCX, regs->rcx); | 4850 | kvm_register_write(vcpu, VCPU_REGS_RCX, regs->rcx); |
@@ -4878,8 +4869,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) | |||
4878 | 4869 | ||
4879 | vcpu->arch.exception.pending = false; | 4870 | vcpu->arch.exception.pending = false; |
4880 | 4871 | ||
4881 | vcpu_put(vcpu); | ||
4882 | |||
4883 | return 0; | 4872 | return 0; |
4884 | } | 4873 | } |
4885 | 4874 | ||
@@ -4898,8 +4887,6 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
4898 | { | 4887 | { |
4899 | struct desc_ptr dt; | 4888 | struct desc_ptr dt; |
4900 | 4889 | ||
4901 | vcpu_load(vcpu); | ||
4902 | |||
4903 | kvm_get_segment(vcpu, &sregs->cs, VCPU_SREG_CS); | 4890 | kvm_get_segment(vcpu, &sregs->cs, VCPU_SREG_CS); |
4904 | kvm_get_segment(vcpu, &sregs->ds, VCPU_SREG_DS); | 4891 | kvm_get_segment(vcpu, &sregs->ds, VCPU_SREG_DS); |
4905 | kvm_get_segment(vcpu, &sregs->es, VCPU_SREG_ES); | 4892 | kvm_get_segment(vcpu, &sregs->es, VCPU_SREG_ES); |
@@ -4931,26 +4918,20 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
4931 | set_bit(vcpu->arch.interrupt.nr, | 4918 | set_bit(vcpu->arch.interrupt.nr, |
4932 | (unsigned long *)sregs->interrupt_bitmap); | 4919 | (unsigned long *)sregs->interrupt_bitmap); |
4933 | 4920 | ||
4934 | vcpu_put(vcpu); | ||
4935 | |||
4936 | return 0; | 4921 | return 0; |
4937 | } | 4922 | } |
4938 | 4923 | ||
4939 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | 4924 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, |
4940 | struct kvm_mp_state *mp_state) | 4925 | struct kvm_mp_state *mp_state) |
4941 | { | 4926 | { |
4942 | vcpu_load(vcpu); | ||
4943 | mp_state->mp_state = vcpu->arch.mp_state; | 4927 | mp_state->mp_state = vcpu->arch.mp_state; |
4944 | vcpu_put(vcpu); | ||
4945 | return 0; | 4928 | return 0; |
4946 | } | 4929 | } |
4947 | 4930 | ||
4948 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | 4931 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, |
4949 | struct kvm_mp_state *mp_state) | 4932 | struct kvm_mp_state *mp_state) |
4950 | { | 4933 | { |
4951 | vcpu_load(vcpu); | ||
4952 | vcpu->arch.mp_state = mp_state->mp_state; | 4934 | vcpu->arch.mp_state = mp_state->mp_state; |
4953 | vcpu_put(vcpu); | ||
4954 | return 0; | 4935 | return 0; |
4955 | } | 4936 | } |
4956 | 4937 | ||
@@ -4996,8 +4977,6 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
4996 | int pending_vec, max_bits; | 4977 | int pending_vec, max_bits; |
4997 | struct desc_ptr dt; | 4978 | struct desc_ptr dt; |
4998 | 4979 | ||
4999 | vcpu_load(vcpu); | ||
5000 | |||
5001 | dt.size = sregs->idt.limit; | 4980 | dt.size = sregs->idt.limit; |
5002 | dt.address = sregs->idt.base; | 4981 | dt.address = sregs->idt.base; |
5003 | kvm_x86_ops->set_idt(vcpu, &dt); | 4982 | kvm_x86_ops->set_idt(vcpu, &dt); |
@@ -5057,8 +5036,6 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
5057 | !is_protmode(vcpu)) | 5036 | !is_protmode(vcpu)) |
5058 | vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; | 5037 | vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; |
5059 | 5038 | ||
5060 | vcpu_put(vcpu); | ||
5061 | |||
5062 | return 0; | 5039 | return 0; |
5063 | } | 5040 | } |
5064 | 5041 | ||
@@ -5068,12 +5045,10 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, | |||
5068 | unsigned long rflags; | 5045 | unsigned long rflags; |
5069 | int i, r; | 5046 | int i, r; |
5070 | 5047 | ||
5071 | vcpu_load(vcpu); | ||
5072 | |||
5073 | if (dbg->control & (KVM_GUESTDBG_INJECT_DB | KVM_GUESTDBG_INJECT_BP)) { | 5048 | if (dbg->control & (KVM_GUESTDBG_INJECT_DB | KVM_GUESTDBG_INJECT_BP)) { |
5074 | r = -EBUSY; | 5049 | r = -EBUSY; |
5075 | if (vcpu->arch.exception.pending) | 5050 | if (vcpu->arch.exception.pending) |
5076 | goto unlock_out; | 5051 | goto out; |
5077 | if (dbg->control & KVM_GUESTDBG_INJECT_DB) | 5052 | if (dbg->control & KVM_GUESTDBG_INJECT_DB) |
5078 | kvm_queue_exception(vcpu, DB_VECTOR); | 5053 | kvm_queue_exception(vcpu, DB_VECTOR); |
5079 | else | 5054 | else |
@@ -5115,8 +5090,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, | |||
5115 | 5090 | ||
5116 | r = 0; | 5091 | r = 0; |
5117 | 5092 | ||
5118 | unlock_out: | 5093 | out: |
5119 | vcpu_put(vcpu); | ||
5120 | 5094 | ||
5121 | return r; | 5095 | return r; |
5122 | } | 5096 | } |
@@ -5152,7 +5126,6 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, | |||
5152 | gpa_t gpa; | 5126 | gpa_t gpa; |
5153 | int idx; | 5127 | int idx; |
5154 | 5128 | ||
5155 | vcpu_load(vcpu); | ||
5156 | idx = srcu_read_lock(&vcpu->kvm->srcu); | 5129 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
5157 | gpa = kvm_mmu_gva_to_gpa_system(vcpu, vaddr, NULL); | 5130 | gpa = kvm_mmu_gva_to_gpa_system(vcpu, vaddr, NULL); |
5158 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | 5131 | srcu_read_unlock(&vcpu->kvm->srcu, idx); |
@@ -5160,7 +5133,6 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, | |||
5160 | tr->valid = gpa != UNMAPPED_GVA; | 5133 | tr->valid = gpa != UNMAPPED_GVA; |
5161 | tr->writeable = 1; | 5134 | tr->writeable = 1; |
5162 | tr->usermode = 0; | 5135 | tr->usermode = 0; |
5163 | vcpu_put(vcpu); | ||
5164 | 5136 | ||
5165 | return 0; | 5137 | return 0; |
5166 | } | 5138 | } |
@@ -5169,8 +5141,6 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | |||
5169 | { | 5141 | { |
5170 | struct fxsave *fxsave = (struct fxsave *)&vcpu->arch.guest_fx_image; | 5142 | struct fxsave *fxsave = (struct fxsave *)&vcpu->arch.guest_fx_image; |
5171 | 5143 | ||
5172 | vcpu_load(vcpu); | ||
5173 | |||
5174 | memcpy(fpu->fpr, fxsave->st_space, 128); | 5144 | memcpy(fpu->fpr, fxsave->st_space, 128); |
5175 | fpu->fcw = fxsave->cwd; | 5145 | fpu->fcw = fxsave->cwd; |
5176 | fpu->fsw = fxsave->swd; | 5146 | fpu->fsw = fxsave->swd; |
@@ -5180,8 +5150,6 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | |||
5180 | fpu->last_dp = fxsave->rdp; | 5150 | fpu->last_dp = fxsave->rdp; |
5181 | memcpy(fpu->xmm, fxsave->xmm_space, sizeof fxsave->xmm_space); | 5151 | memcpy(fpu->xmm, fxsave->xmm_space, sizeof fxsave->xmm_space); |
5182 | 5152 | ||
5183 | vcpu_put(vcpu); | ||
5184 | |||
5185 | return 0; | 5153 | return 0; |
5186 | } | 5154 | } |
5187 | 5155 | ||
@@ -5189,8 +5157,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | |||
5189 | { | 5157 | { |
5190 | struct fxsave *fxsave = (struct fxsave *)&vcpu->arch.guest_fx_image; | 5158 | struct fxsave *fxsave = (struct fxsave *)&vcpu->arch.guest_fx_image; |
5191 | 5159 | ||
5192 | vcpu_load(vcpu); | ||
5193 | |||
5194 | memcpy(fxsave->st_space, fpu->fpr, 128); | 5160 | memcpy(fxsave->st_space, fpu->fpr, 128); |
5195 | fxsave->cwd = fpu->fcw; | 5161 | fxsave->cwd = fpu->fcw; |
5196 | fxsave->swd = fpu->fsw; | 5162 | fxsave->swd = fpu->fsw; |
@@ -5200,8 +5166,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | |||
5200 | fxsave->rdp = fpu->last_dp; | 5166 | fxsave->rdp = fpu->last_dp; |
5201 | memcpy(fxsave->xmm_space, fpu->xmm, sizeof fxsave->xmm_space); | 5167 | memcpy(fxsave->xmm_space, fpu->xmm, sizeof fxsave->xmm_space); |
5202 | 5168 | ||
5203 | vcpu_put(vcpu); | ||
5204 | |||
5205 | return 0; | 5169 | return 0; |
5206 | } | 5170 | } |
5207 | 5171 | ||
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 187aa8d984a7..e0fb0988a3fe 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1392,6 +1392,18 @@ static long kvm_vcpu_ioctl(struct file *filp, | |||
1392 | 1392 | ||
1393 | if (vcpu->kvm->mm != current->mm) | 1393 | if (vcpu->kvm->mm != current->mm) |
1394 | return -EIO; | 1394 | return -EIO; |
1395 | |||
1396 | #if defined(CONFIG_S390) || defined(CONFIG_PPC) | ||
1397 | /* | ||
1398 | * Special cases: vcpu ioctls that are asynchronous to vcpu execution, | ||
1399 | * so vcpu_load() would break it. | ||
1400 | */ | ||
1401 | if (ioctl == KVM_S390_INTERRUPT || ioctl == KVM_INTERRUPT) | ||
1402 | return kvm_arch_vcpu_ioctl(filp, ioctl, arg); | ||
1403 | #endif | ||
1404 | |||
1405 | |||
1406 | vcpu_load(vcpu); | ||
1395 | switch (ioctl) { | 1407 | switch (ioctl) { |
1396 | case KVM_RUN: | 1408 | case KVM_RUN: |
1397 | r = -EINVAL; | 1409 | r = -EINVAL; |
@@ -1566,9 +1578,12 @@ out_free2: | |||
1566 | break; | 1578 | break; |
1567 | } | 1579 | } |
1568 | default: | 1580 | default: |
1581 | vcpu_put(vcpu); | ||
1569 | r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); | 1582 | r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); |
1583 | vcpu_load(vcpu); | ||
1570 | } | 1584 | } |
1571 | out: | 1585 | out: |
1586 | vcpu_put(vcpu); | ||
1572 | kfree(fpu); | 1587 | kfree(fpu); |
1573 | kfree(kvm_sregs); | 1588 | kfree(kvm_sregs); |
1574 | return r; | 1589 | return r; |