Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * KVM/MIPS: Hypercall handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Copyright (C) 2015  Imagination Technologies Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kvm_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kvm_para.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define MAX_HYPCALL_ARGS	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) enum emulation_result kvm_mips_emul_hypcall(struct kvm_vcpu *vcpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 					    union mips_instruction inst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	unsigned int code = (inst.co_format.code >> 5) & 0x3ff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	kvm_debug("[%#lx] HYPCALL %#03x\n", vcpu->arch.pc, code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	switch (code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		return EMULATE_HYPERCALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		return EMULATE_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static int kvm_mips_hypercall(struct kvm_vcpu *vcpu, unsigned long num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 			      const unsigned long *args, unsigned long *hret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	/* Report unimplemented hypercall to guest */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	*hret = -KVM_ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	return RESUME_GUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int kvm_mips_handle_hypcall(struct kvm_vcpu *vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	unsigned long num, args[MAX_HYPCALL_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	/* read hypcall number and arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	num = vcpu->arch.gprs[2];	/* v0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	args[0] = vcpu->arch.gprs[4];	/* a0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	args[1] = vcpu->arch.gprs[5];	/* a1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	args[2] = vcpu->arch.gprs[6];	/* a2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	args[3] = vcpu->arch.gprs[7];	/* a3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	return kvm_mips_hypercall(vcpu, num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 				  args, &vcpu->arch.gprs[2] /* v0 */);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }