Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * KVM/MIPS: Hypercall handling.
0007  *
0008  * Copyright (C) 2015  Imagination Technologies Ltd.
0009  */
0010 
0011 #include <linux/kernel.h>
0012 #include <linux/kvm_host.h>
0013 #include <linux/kvm_para.h>
0014 
0015 #define MAX_HYPCALL_ARGS    4
0016 
0017 enum emulation_result kvm_mips_emul_hypcall(struct kvm_vcpu *vcpu,
0018                         union mips_instruction inst)
0019 {
0020     unsigned int code = (inst.co_format.code >> 5) & 0x3ff;
0021 
0022     kvm_debug("[%#lx] HYPCALL %#03x\n", vcpu->arch.pc, code);
0023 
0024     switch (code) {
0025     case 0:
0026         return EMULATE_HYPERCALL;
0027     default:
0028         return EMULATE_FAIL;
0029     };
0030 }
0031 
0032 static int kvm_mips_hypercall(struct kvm_vcpu *vcpu, unsigned long num,
0033                   const unsigned long *args, unsigned long *hret)
0034 {
0035     /* Report unimplemented hypercall to guest */
0036     *hret = -KVM_ENOSYS;
0037     return RESUME_GUEST;
0038 }
0039 
0040 int kvm_mips_handle_hypcall(struct kvm_vcpu *vcpu)
0041 {
0042     unsigned long num, args[MAX_HYPCALL_ARGS];
0043 
0044     /* read hypcall number and arguments */
0045     num = vcpu->arch.gprs[2];   /* v0 */
0046     args[0] = vcpu->arch.gprs[4];   /* a0 */
0047     args[1] = vcpu->arch.gprs[5];   /* a1 */
0048     args[2] = vcpu->arch.gprs[6];   /* a2 */
0049     args[3] = vcpu->arch.gprs[7];   /* a3 */
0050 
0051     return kvm_mips_hypercall(vcpu, num,
0052                   args, &vcpu->arch.gprs[2] /* v0 */);
0053 }