Re: [RFC][PATCH 07/22] x86,extable: Extend extable functionality

From: Sean Christopherson
Date: Fri Nov 05 2021 - 18:30:37 EST


On Fri, Nov 05, 2021, Peter Zijlstra wrote:
> On Fri, Nov 05, 2021 at 09:15:57PM +0100, Peter Zijlstra wrote:
>
> > That's really unfortunate that is... 6.4.4.1 item 5 of the C99 spec
> > covers this gem :-( I suppose I'll go stick that (int) cast in the
> > EX_IMM_MASK definition or something.
>
> --- a/arch/x86/include/asm/extable_fixup_types.h
> +++ b/arch/x86/include/asm/extable_fixup_types.h
> @@ -2,10 +2,15 @@
> #ifndef _ASM_X86_EXTABLE_FIXUP_TYPES_H
> #define _ASM_X86_EXTABLE_FIXUP_TYPES_H
>
> +/*
> + * Our IMM is signed, as such it must live at the top end of the word. Also,
> + * since C99 hex constants are of ambigious type, force cast the mask to 'int'
> + * so that FIELD_GET() will DTRT and sign extend the value when it extracts it.
> + */
> #define EX_DATA_TYPE_MASK 0x000000FF
> #define EX_DATA_REG_MASK 0x00000F00
> #define EX_DATA_FLAG_MASK 0x0000F000
> -#define EX_DATA_IMM_MASK 0xFFFF0000
> +#define EX_DATA_IMM_MASK ((int)0xFFFF0000)
>
> #define EX_DATA_REG_SHIFT 8
> #define EX_DATA_FLAG_SHIFT 12

Works on my end, thanks!