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) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (C) IBM Corporation, 2011
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Authors: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *          Anton Blanchard <anton@au.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/hardirq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/switch_to.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/asm-prototypes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) int enter_vmx_usercopy(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	if (in_interrupt())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	preempt_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	 * We need to disable page faults as they can call schedule and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	 * thus make us lose the VMX context. So on page faults, we just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	 * fail which will cause a fallback to the normal non-vmx copy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	pagefault_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	enable_kernel_altivec();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	return 1;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  * This function must return 0 because we tail call optimise when calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)  * from __copy_tofrom_user_power7 which returns 0 on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int exit_vmx_usercopy(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	disable_kernel_altivec();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	pagefault_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	preempt_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int enter_vmx_ops(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (in_interrupt())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	preempt_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	enable_kernel_altivec();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)  * All calls to this function will be optimised into tail calls. We are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)  * passed a pointer to the destination which we return as required by a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)  * memcpy implementation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void *exit_vmx_ops(void *dest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	disable_kernel_altivec();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	preempt_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	return dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }