x86/msr: Move the EAX_EDX_*() methods from <asm/msr.h> to <asm/asm.h>

We are going to use them from multiple headers, and in any case,
such register access wrapper macros are better in <asm/asm.h>
anyway.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Uros Bizjak <ubizjak@gmail.com>
Cc: linux-kernel@vger.kernel.org
This commit is contained in:
Ingo Molnar
2025-05-02 10:13:53 +02:00
parent c9d8ea9d53
commit bdfda83a6b
2 changed files with 19 additions and 19 deletions

View File

@@ -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 */

View File

@@ -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.
*/