Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 SUSE Linux Products GmbH. All rights reserved. |
| 3 | * |
| 4 | * Authors: |
| 5 | * Alexander Graf <agraf@suse.de> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License, version 2, as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/kvm_host.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/kvm_para.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/of.h> |
| 26 | |
| 27 | #include <asm/reg.h> |
| 28 | #include <asm/kvm_ppc.h> |
| 29 | #include <asm/sections.h> |
| 30 | #include <asm/cacheflush.h> |
| 31 | #include <asm/disassemble.h> |
| 32 | |
Alexander Graf | d17051c | 2010-07-29 14:47:57 +0200 | [diff] [blame^] | 33 | #define KVM_MAGIC_PAGE (-4096L) |
| 34 | #define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x) |
| 35 | |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 36 | unsigned long kvm_hypercall(unsigned long *in, |
| 37 | unsigned long *out, |
| 38 | unsigned long nr) |
| 39 | { |
| 40 | unsigned long register r0 asm("r0"); |
| 41 | unsigned long register r3 asm("r3") = in[0]; |
| 42 | unsigned long register r4 asm("r4") = in[1]; |
| 43 | unsigned long register r5 asm("r5") = in[2]; |
| 44 | unsigned long register r6 asm("r6") = in[3]; |
| 45 | unsigned long register r7 asm("r7") = in[4]; |
| 46 | unsigned long register r8 asm("r8") = in[5]; |
| 47 | unsigned long register r9 asm("r9") = in[6]; |
| 48 | unsigned long register r10 asm("r10") = in[7]; |
| 49 | unsigned long register r11 asm("r11") = nr; |
| 50 | unsigned long register r12 asm("r12"); |
| 51 | |
| 52 | asm volatile("bl kvm_hypercall_start" |
| 53 | : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6), |
| 54 | "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11), |
| 55 | "=r"(r12) |
| 56 | : "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7), "r"(r8), |
| 57 | "r"(r9), "r"(r10), "r"(r11) |
| 58 | : "memory", "cc", "xer", "ctr", "lr"); |
| 59 | |
| 60 | out[0] = r4; |
| 61 | out[1] = r5; |
| 62 | out[2] = r6; |
| 63 | out[3] = r7; |
| 64 | out[4] = r8; |
| 65 | out[5] = r9; |
| 66 | out[6] = r10; |
| 67 | out[7] = r11; |
| 68 | |
| 69 | return r3; |
| 70 | } |
| 71 | EXPORT_SYMBOL_GPL(kvm_hypercall); |