Re: [tip:x86/asm] x86, processor-flags: Fix the datatypes and addbit number defines

From: Borislav Petkov
Date: Tue Jun 25 2013 - 19:07:35 EST


On Tue, Jun 25, 2013 at 03:54:56PM -0700, tip-bot for H. Peter Anvin wrote:
> Commit-ID: 5d378644340de4c43dd3a50ed3a03e916c840d17
> Gitweb: http://git.kernel.org/tip/5d378644340de4c43dd3a50ed3a03e916c840d17
> Author: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
> AuthorDate: Sat, 27 Apr 2013 16:11:17 -0700
> Committer: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
> CommitDate: Tue, 25 Jun 2013 15:50:05 -0700
>
> x86, processor-flags: Fix the datatypes and add bit number defines
>
> The control registers are unsigned long (32 bits on i386, 64 bits on
> x86-64), and so make that manifest in the data type for the various
> constants. Add defines with a _BIT suffix which defines the bit
> number, as opposed to the bit mask.
>
> This should resolve some issues with ~bitmask that Linus discovered.
>
> Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
> Link: http://lkml.kernel.org/n/tip-cwckhbrib2aux1qbteaebij0@xxxxxxxxxxxxxx
> ---
> arch/x86/include/uapi/asm/processor-flags.h | 154 +++++++++++++++++++---------
> 1 file changed, 104 insertions(+), 50 deletions(-)
>
> diff --git a/arch/x86/include/uapi/asm/processor-flags.h b/arch/x86/include/uapi/asm/processor-flags.h
> index 1b34df5..180a0c3 100644
> --- a/arch/x86/include/uapi/asm/processor-flags.h
> +++ b/arch/x86/include/uapi/asm/processor-flags.h
> @@ -2,75 +2,129 @@
> #define _UAPI_ASM_X86_PROCESSOR_FLAGS_H
> /* Various flags defined: can be included from assembler. */
>
> +#include <linux/const.h>
> +
> /*
> * EFLAGS bits
> */
> -#define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
> -#define X86_EFLAGS_FIXED 0x00000002 /* Bit 1 - always on */
> -#define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
> -#define X86_EFLAGS_AF 0x00000010 /* Auxiliary carry Flag */
> -#define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
> -#define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
> -#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
> -#define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
> -#define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
> -#define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
> -#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
> -#define X86_EFLAGS_NT 0x00004000 /* Nested Task */
> -#define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
> -#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
> -#define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
> -#define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
> -#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
> -#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
> +#define X86_EFLAGS_CF_BIT 0 /* Carry Flag */
> +#define X86_EFLAGS_CF _BITUL(X86_EFLAGS_CF_BIT)

Btw, are you going to need those _BIT defines anywhere else?

Because if no, you could simply do:

#define X86_EFLAGS_CF _BITUL(0) /* Carry Flag */

and so on, and drop the _BIT defines.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/