Skip to content

Commit b339874

Browse files
committed
x86/msr: Improve the comments of the DECLARE_ARGS()/EAX_EDX_VAL()/EAX_EDX_RET() facility
JIRA: https://issues.redhat.com/browse/RHEL-118444 commit 76deb54 Author: Ingo Molnar <mingo@kernel.org> Date: Fri May 2 10:07:59 2025 +0200 x86/msr: Improve the comments of the DECLARE_ARGS()/EAX_EDX_VAL()/EAX_EDX_RET() facility 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 Signed-off-by: David Arcari <darcari@redhat.com>
1 parent f9a894c commit b339874

File tree

1 file changed

+13
-11
lines changed
  • arch/x86/include/asm

1 file changed

+13
-11
lines changed

arch/x86/include/asm/msr.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ struct saved_msrs {
3535
};
3636

3737
/*
38-
* both i386 and x86_64 returns 64-bit value in edx:eax, but gcc's "A"
39-
* constraint has different meanings. For i386, "A" means exactly
40-
* edx:eax, while for x86_64 it doesn't mean rdx:rax or edx:eax. Instead,
41-
* it means rax *or* rdx.
38+
* Both i386 and x86_64 returns 64-bit values in edx:eax for certain
39+
* instructions, but GCC's "A" constraint has different meanings.
40+
* For i386, "A" means exactly edx:eax, while for x86_64 it
41+
* means rax *or* rdx.
42+
*
43+
* These helpers wrapping these semantic differences save one instruction
44+
* clearing the high half of 'low':
4245
*/
4346
#ifdef CONFIG_X86_64
44-
/* Using 64-bit values saves one instruction clearing the high half of low */
45-
#define DECLARE_ARGS(val, low, high) unsigned long low, high
46-
#define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32)
47-
#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
47+
# define DECLARE_ARGS(val, low, high) unsigned long low, high
48+
# define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32)
49+
# define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
4850
#else
49-
#define DECLARE_ARGS(val, low, high) u64 val
50-
#define EAX_EDX_VAL(val, low, high) (val)
51-
#define EAX_EDX_RET(val, low, high) "=A" (val)
51+
# define DECLARE_ARGS(val, low, high) u64 val
52+
# define EAX_EDX_VAL(val, low, high) (val)
53+
# define EAX_EDX_RET(val, low, high) "=A" (val)
5254
#endif
5355

5456
/*

0 commit comments

Comments
 (0)