aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2011-08-08 11:26:24 -0400
committerAvi Kivity <avi@redhat.com>2011-09-25 12:52:25 -0400
commita668f2bd3f14ce7f92e119f4b5d9b50cdc59e855 (patch)
tree5ab8be22ed07e3b997c96d4393b25c8f5f2fca26 /arch/powerpc
parentaacf9aa3a7762a878c40fddef6e68262b9f9f383 (diff)
KVM: PPC: Support SC1 hypercalls for PAPR in PR mode
PAPR defines hypercalls as SC1 instructions. Using these, the guest modifies page tables and does other privileged operations that it wouldn't be allowed to do in supervisor mode. This patch adds support for PR KVM to trap these instructions and route them through the same PAPR hypercall interface that we already use for HV style KVM. Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kvm/book3s_pr.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 78dcf659e120..48558f6176e9 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -648,7 +648,27 @@ program_interrupt:
648 break; 648 break;
649 } 649 }
650 case BOOK3S_INTERRUPT_SYSCALL: 650 case BOOK3S_INTERRUPT_SYSCALL:
651 if (vcpu->arch.osi_enabled && 651 if (vcpu->arch.papr_enabled &&
652 (kvmppc_get_last_inst(vcpu) == 0x44000022) &&
653 !(vcpu->arch.shared->msr & MSR_PR)) {
654 /* SC 1 papr hypercalls */
655 ulong cmd = kvmppc_get_gpr(vcpu, 3);
656 int i;
657
658 if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE) {
659 r = RESUME_GUEST;
660 break;
661 }
662
663 run->papr_hcall.nr = cmd;
664 for (i = 0; i < 9; ++i) {
665 ulong gpr = kvmppc_get_gpr(vcpu, 4 + i);
666 run->papr_hcall.args[i] = gpr;
667 }
668 run->exit_reason = KVM_EXIT_PAPR_HCALL;
669 vcpu->arch.hcall_needed = 1;
670 r = RESUME_HOST;
671 } else if (vcpu->arch.osi_enabled &&
652 (((u32)kvmppc_get_gpr(vcpu, 3)) == OSI_SC_MAGIC_R3) && 672 (((u32)kvmppc_get_gpr(vcpu, 3)) == OSI_SC_MAGIC_R3) &&
653 (((u32)kvmppc_get_gpr(vcpu, 4)) == OSI_SC_MAGIC_R4)) { 673 (((u32)kvmppc_get_gpr(vcpu, 4)) == OSI_SC_MAGIC_R4)) {
654 /* MOL hypercalls */ 674 /* MOL hypercalls */