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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * x86 FPU bug checks:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <asm/fpu/internal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Boot time CPU/FPU FDIV bug detection code:
^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) static double __initdata x = 4195835.0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static double __initdata y = 3145727.0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * This used to check for exceptions..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * However, it turns out that to support that,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * the XMM trap handlers basically had to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * be buggy. So let's have a correct XMM trap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * handler, and forget about printing out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  * some status at boot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * We should really only care about bugs here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  * anyway. Not features.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) void __init fpu__init_check_bugs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	s32 fdiv_bug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	/* kernel_fpu_begin/end() relies on patched alternative instructions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	if (!boot_cpu_has(X86_FEATURE_FPU))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	kernel_fpu_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	 * trap_init() enabled FXSR and company _before_ testing for FP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	 * problems here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	 * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	__asm__("fninit\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		"fldl %1\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		"fdivl %2\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		"fmull %2\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		"fldl %1\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		"fsubp %%st,%%st(1)\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		"fistpl %0\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		"fwait\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		"fninit"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		: "=m" (*&fdiv_bug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		: "m" (*&x), "m" (*&y));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	kernel_fpu_end();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	if (fdiv_bug) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		pr_warn("Hmm, FPU with FDIV bug\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }