booke.c (706fb730cb4f9db2e3de33391475dd0616c2c935) booke.c (24afa37b9c8f035d2fe2028e4824bc4e49bafe73)
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

--- 467 unchanged lines hidden (view full) ---

476
477 if (!vcpu->arch.sane) {
478 kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
479 return -EINVAL;
480 }
481
482 local_irq_disable();
483 if (kvmppc_prepare_to_enter(vcpu)) {
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

--- 467 unchanged lines hidden (view full) ---

476
477 if (!vcpu->arch.sane) {
478 kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
479 return -EINVAL;
480 }
481
482 local_irq_disable();
483 if (kvmppc_prepare_to_enter(vcpu)) {
484 local_irq_enable();
484 kvm_run->exit_reason = KVM_EXIT_INTR;
485 ret = -EINTR;
486 goto out;
487 }
488
489 kvm_guest_enter();
490
491#ifdef CONFIG_PPC_FPU

--- 15 unchanged lines hidden (view full) ---

507 */
508 vcpu->fpu_active = 1;
509
510 kvmppc_load_guest_fp(vcpu);
511#endif
512
513 ret = __kvmppc_vcpu_run(kvm_run, vcpu);
514
485 kvm_run->exit_reason = KVM_EXIT_INTR;
486 ret = -EINTR;
487 goto out;
488 }
489
490 kvm_guest_enter();
491
492#ifdef CONFIG_PPC_FPU

--- 15 unchanged lines hidden (view full) ---

508 */
509 vcpu->fpu_active = 1;
510
511 kvmppc_load_guest_fp(vcpu);
512#endif
513
514 ret = __kvmppc_vcpu_run(kvm_run, vcpu);
515
516 /* No need for kvm_guest_exit. It's done in handle_exit.
517 We also get here with interrupts enabled. */
518
515#ifdef CONFIG_PPC_FPU
516 kvmppc_save_guest_fp(vcpu);
517
518 vcpu->fpu_active = 0;
519
520 /* Save guest FPU state from thread */
521 memcpy(vcpu->arch.fpr, current->thread.fpr, sizeof(vcpu->arch.fpr));
522 vcpu->arch.fpscr = current->thread.fpscr.val;
523
524 /* Restore userspace FPU state from stack */
525 memcpy(current->thread.fpr, fpr, sizeof(current->thread.fpr));
526 current->thread.fpscr.val = fpscr;
527 current->thread.fpexc_mode = fpexc_mode;
528#endif
529
519#ifdef CONFIG_PPC_FPU
520 kvmppc_save_guest_fp(vcpu);
521
522 vcpu->fpu_active = 0;
523
524 /* Save guest FPU state from thread */
525 memcpy(vcpu->arch.fpr, current->thread.fpr, sizeof(vcpu->arch.fpr));
526 vcpu->arch.fpscr = current->thread.fpscr.val;
527
528 /* Restore userspace FPU state from stack */
529 memcpy(current->thread.fpr, fpr, sizeof(current->thread.fpr));
530 current->thread.fpscr.val = fpscr;
531 current->thread.fpexc_mode = fpexc_mode;
532#endif
533
530 kvm_guest_exit();
531
532out:
533 vcpu->mode = OUTSIDE_GUEST_MODE;
534 smp_wmb();
534out:
535 vcpu->mode = OUTSIDE_GUEST_MODE;
536 smp_wmb();
535 local_irq_enable();
536 return ret;
537}
538
539static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
540{
541 enum emulation_result er;
542
543 er = kvmppc_emulate_instruction(run, vcpu);

--- 398 unchanged lines hidden (view full) ---

942
943 /*
944 * To avoid clobbering exit_reason, only check for signals if we
945 * aren't already exiting to userspace for some other reason.
946 */
947 if (!(r & RESUME_HOST)) {
948 local_irq_disable();
949 if (kvmppc_prepare_to_enter(vcpu)) {
537 return ret;
538}
539
540static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
541{
542 enum emulation_result er;
543
544 er = kvmppc_emulate_instruction(run, vcpu);

--- 398 unchanged lines hidden (view full) ---

943
944 /*
945 * To avoid clobbering exit_reason, only check for signals if we
946 * aren't already exiting to userspace for some other reason.
947 */
948 if (!(r & RESUME_HOST)) {
949 local_irq_disable();
950 if (kvmppc_prepare_to_enter(vcpu)) {
951 local_irq_enable();
950 run->exit_reason = KVM_EXIT_INTR;
951 r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
952 kvmppc_account_exit(vcpu, SIGNAL_EXITS);
952 run->exit_reason = KVM_EXIT_INTR;
953 r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
954 kvmppc_account_exit(vcpu, SIGNAL_EXITS);
955 } else {
956 /* Going back to guest */
957 kvm_guest_enter();
953 }
954 }
955
958 }
959 }
960
956 kvm_guest_enter();
957
958 return r;
959}
960
961/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */
962int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
963{
964 int i;
965 int r;

--- 374 unchanged lines hidden ---
961 return r;
962}
963
964/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */
965int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
966{
967 int i;
968 int r;

--- 374 unchanged lines hidden ---