On Mon, Jan 15, 2018 at 07:59:37PM +0100, Borislav Petkov wrote:
> Right,
> 
> I've been putting away extending struct alt_instr for a long time now,
> trying to be conservative about it but I guess this might be the right
> time to change that. How about:
> 
> struct alt_instr {
>         s32 instr_offset;       /* original instruction */
>         s32 repl_offset;        /* offset to replacement instruction */
>         u16 cpuid;              /* cpuid bit set for replacement */
>         u8  instrlen;           /* length of original instruction */
>         u8  replacementlen;     /* length of new instruction */
>         u8  padlen;             /* length of build-time padding */
>       u64 flags;              /* alternative flags, see <some enum> */
> } __packed;
> 
> This way we have 64 settings. So we could do:
> 
> ...
>       .flags  = ALT_FLAGS_STATIC_CPU_HAS,
> 
> or something like that and then we can do additional processing/matching
> for the alternatives.
> 
> Or, we can do
> 
> struct alt_instr {
>         s32 instr_offset;       /* original instruction */
>         s32 repl_offset;        /* offset to replacement instruction */
>         u16 cpuid;              /* cpuid bit set for replacement */
>         u8  instrlen;           /* length of original instruction */
>         u8  replacementlen;     /* length of new instruction */
>         u8  padlen;             /* length of build-time padding */
>       u8 type;                /* types */
> } __packed;
> 
> and have 256 types but that would be limiting as we won't be able to set
> more than one.
> 
> Hmmm?

That might be a good idea, but here we also need to annotate jump
labels.  So unless you want to make alternatives broad enough to
encompass jump labels, I don't think it solves this particular problem.

-- 
Josh

Reply via email to