dd165a658d901 lib/raid6/x86.h (Thomas Gleixner 2019-05-20 19:08:13 +0200 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 2) /* ----------------------------------------------------------------------- *
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 3) *
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 4) * Copyright 2002-2004 H. Peter Anvin - All Rights Reserved
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 5) *
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 6) * ----------------------------------------------------------------------- */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 7)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 8) /*
a8e026c785b3f lib/raid6/x86.h (NeilBrown 2010-08-12 06:44:54 +1000 9) * raid6/x86.h
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 10) *
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 11) * Definitions common to x86 and x86-64 RAID-6 code only
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 12) */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 13)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 14) #ifndef LINUX_RAID_RAID6X86_H
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 15) #define LINUX_RAID_RAID6X86_H
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 16)
ca5cd877ae699 drivers/md/raid6x86.h (Al Viro 2007-10-29 04:31:16 +0000 17) #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 18)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 19) #ifdef __KERNEL__ /* Real code */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 20)
df6b35f409af0 lib/raid6/x86.h (Ingo Molnar 2015-04-24 02:46:00 +0200 21) #include <asm/fpu/api.h>
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 22)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 23) #else /* Dummy code for user space testing */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 24)
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 25) static inline void kernel_fpu_begin(void)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 26) {
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 27) }
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 28)
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 29) static inline void kernel_fpu_end(void)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 30) {
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 31) }
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 32)
2dbf708448c83 lib/raid6/x86.h (Jim Kukunas 2012-05-22 13:54:23 +1000 33) #define __aligned(x) __attribute__((aligned(x)))
2dbf708448c83 lib/raid6/x86.h (Jim Kukunas 2012-05-22 13:54:23 +1000 34)
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 35) #define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 36) #define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 37) * (fast save and restore) */
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 38) #define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 39) #define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
2dbf708448c83 lib/raid6/x86.h (Jim Kukunas 2012-05-22 13:54:23 +1000 40) #define X86_FEATURE_XMM3 (4*32+ 0) /* "pni" SSE-3 */
2dbf708448c83 lib/raid6/x86.h (Jim Kukunas 2012-05-22 13:54:23 +1000 41) #define X86_FEATURE_SSSE3 (4*32+ 9) /* Supplemental SSE-3 */
2dbf708448c83 lib/raid6/x86.h (Jim Kukunas 2012-05-22 13:54:23 +1000 42) #define X86_FEATURE_AVX (4*32+28) /* Advanced Vector Extensions */
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 43) #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 44) #define X86_FEATURE_AVX512F (9*32+16) /* AVX-512 Foundation */
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 45) #define X86_FEATURE_AVX512DQ (9*32+17) /* AVX-512 DQ (Double/Quad granular)
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 46) * Instructions
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 47) */
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 48) #define X86_FEATURE_AVX512BW (9*32+30) /* AVX-512 BW (Byte/Word granular)
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 49) * Instructions
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 50) */
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 51) #define X86_FEATURE_AVX512VL (9*32+31) /* AVX-512 VL (128/256 Vector Length)
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 52) * Extensions
e0a491c129687 lib/raid6/x86.h (Gayatri Kammela 2016-08-12 18:03:19 -0700 53) */
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 54) #define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 55)
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 56) /* Should work well enough on modern CPUs for testing */
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 57) static inline int boot_cpu_has(int flag)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 58) {
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 59) u32 eax, ebx, ecx, edx;
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 60)
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 61) eax = (flag & 0x100) ? 7 :
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 62) (flag & 0x20) ? 0x80000001 : 1;
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 63) ecx = 0;
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 64)
a723406c4aeed drivers/md/raid6x86.h (H. Peter Anvin 2007-02-28 20:11:25 -0800 65) asm volatile("cpuid"
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 66) : "+a" (eax), "=b" (ebx), "=d" (edx), "+c" (ecx));
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 67)
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 68) return ((flag & 0x100 ? ebx :
7056741fd9fc1 lib/raid6/x86.h (Jim Kukunas 2012-11-08 13:47:44 -0800 69) (flag & 0x80) ? ecx : edx) >> (flag & 31)) & 1;
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 70) }
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 71)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 72) #endif /* ndef __KERNEL__ */
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 73)
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 74) #endif
^1da177e4c3f4 drivers/md/raid6x86.h (Linus Torvalds 2005-04-16 15:20:36 -0700 75) #endif