diff options
author | Andy Lutomirski <luto@kernel.org> | 2020-11-02 11:54:02 -0800 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2021-01-12 12:31:28 +0100 |
commit | 9297e602adf8d5587d83941c48e4dbae46c8df5f (patch) | |
tree | 3979ae10b279b2028c8f72d4b84417df37dd4df2 /tools/testing/selftests/x86 | |
parent | 4b2d8ca9208be636b30e924b1cbcb267b0740c93 (diff) | |
download | linux-stable-9297e602adf8d5587d83941c48e4dbae46c8df5f.tar.gz linux-stable-9297e602adf8d5587d83941c48e4dbae46c8df5f.tar.bz2 linux-stable-9297e602adf8d5587d83941c48e4dbae46c8df5f.zip |
selftests/x86: Use __builtin_ia32_read/writeeflags
The asm to read and write EFLAGS from userspace is horrible. The
compiler builtins are now available on all supported compilers, so
use them instead.
(The compiler builtins are also unnecessarily ugly, but that's a
more manageable level of ugliness.)
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/aee4b1cdfc56083eb779ce927b7d3459aad2af76.1604346818.git.luto@kernel.org
Diffstat (limited to 'tools/testing/selftests/x86')
-rw-r--r-- | tools/testing/selftests/x86/helpers.h | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/tools/testing/selftests/x86/helpers.h b/tools/testing/selftests/x86/helpers.h index f5ff2a2615df..4ef42c4559a9 100644 --- a/tools/testing/selftests/x86/helpers.h +++ b/tools/testing/selftests/x86/helpers.h @@ -6,36 +6,20 @@ static inline unsigned long get_eflags(void) { - unsigned long eflags; - - asm volatile ( #ifdef __x86_64__ - "subq $128, %%rsp\n\t" - "pushfq\n\t" - "popq %0\n\t" - "addq $128, %%rsp" + return __builtin_ia32_readeflags_u64(); #else - "pushfl\n\t" - "popl %0" + return __builtin_ia32_readeflags_u32(); #endif - : "=r" (eflags) :: "memory"); - - return eflags; } static inline void set_eflags(unsigned long eflags) { - asm volatile ( #ifdef __x86_64__ - "subq $128, %%rsp\n\t" - "pushq %0\n\t" - "popfq\n\t" - "addq $128, %%rsp" + __builtin_ia32_writeeflags_u64(eflags); #else - "pushl %0\n\t" - "popfl" + __builtin_ia32_writeeflags_u32(eflags); #endif - :: "r" (eflags) : "flags", "memory"); } #endif /* __SELFTESTS_X86_HELPERS_H */ |