From: Ingo Molnar Date: Fri, 2 May 2025 08:13:53 +0000 (+0200) Subject: x86/msr: Move the EAX_EDX_*() methods from to X-Git-Tag: v6.16-rc1~195^2~25^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdfda83a6b5988f1ac62cd0eaceb6c3b44dc2a31;p=thirdparty%2Fkernel%2Flinux.git x86/msr: Move the EAX_EDX_*() methods from to We are going to use them from multiple headers, and in any case, such register access wrapper macros are better in anyway. Signed-off-by: Ingo Molnar Cc: Andy Lutomirski Cc: Brian Gerst Cc: Juergen Gross Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Kees Cook Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Thomas Gleixner Cc: Josh Poimboeuf Cc: Uros Bizjak Cc: linux-kernel@vger.kernel.org --- diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index cc2881576c2cb..206e1342fc037 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -243,5 +243,24 @@ register unsigned long current_stack_pointer asm(_ASM_SP); #define _ASM_EXTABLE_FAULT(from, to) \ _ASM_EXTABLE_TYPE(from, to, EX_TYPE_FAULT) +/* + * Both i386 and x86_64 returns 64-bit values in edx:eax for certain + * instructions, but GCC's "A" constraint has different meanings. + * For i386, "A" means exactly edx:eax, while for x86_64 it + * means rax *or* rdx. + * + * These helpers wrapping these semantic differences save one instruction + * clearing the high half of 'low': + */ +#ifdef CONFIG_X86_64 +# define EAX_EDX_DECLARE_ARGS(val, low, high) unsigned long low, high +# define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32) +# define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) +#else +# define EAX_EDX_DECLARE_ARGS(val, low, high) u64 val +# define EAX_EDX_VAL(val, low, high) (val) +# define EAX_EDX_RET(val, low, high) "=A" (val) +#endif + #endif /* __KERNEL__ */ #endif /* _ASM_X86_ASM_H */ diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index d57a94c5e5953..856d660c926d0 100644 --- a/arch/x86/include/asm/msr.h +++ b/arch/x86/include/asm/msr.h @@ -36,25 +36,6 @@ struct saved_msrs { struct saved_msr *array; }; -/* - * Both i386 and x86_64 returns 64-bit values in edx:eax for certain - * instructions, but GCC's "A" constraint has different meanings. - * For i386, "A" means exactly edx:eax, while for x86_64 it - * means rax *or* rdx. - * - * These helpers wrapping these semantic differences save one instruction - * clearing the high half of 'low': - */ -#ifdef CONFIG_X86_64 -# define EAX_EDX_DECLARE_ARGS(val, low, high) unsigned long low, high -# define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32) -# define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) -#else -# define EAX_EDX_DECLARE_ARGS(val, low, high) u64 val -# define EAX_EDX_VAL(val, low, high) (val) -# define EAX_EDX_RET(val, low, high) "=A" (val) -#endif - /* * Be very careful with includes. This header is prone to include loops. */