Re: [PATCH v7 10/26] x86/insn-eval: Add utility functions to get segment selector

Borislav Petkov
2017-06-19T15:29:58Z

On Thu, Jun 15, 2017 at 12:04:21PM -0700, Ricardo Neri wrote:
> On Thu, 2017-06-15 at 11:37 -0700, Ricardo Neri wrote:
> > > Yuck, didn't we talk about this already?
> >
> > I am sorry Borislav. I thought you agreed that I could use the values
> > of
> > the segment override prefixes to identify the segment registers [1].

Yes, I agreed with that but...

> This time with the reference:
> [1]. https://lkml.org/lkml/2017/5/5/377

... this says it already: "... but you should call them what they are:
"enum seg_override_pfxs" or "enum seg_ovr_pfx" or..." IOW, those are
segment *override* prefixes and should be called such and not "enum
segment_register" as this way is misleading.

IOW, here's what I think you should do:

/* Segment override prefixes: */
#define SEG_CS_OVERRIDE 0x23
#define SEG_SS_OVERRIDE 0x36
#define SEG_DS_OVERRIDE 0x3e

... and so on...

and use the defines directly. The enum is fine and dandy but then you
need to return an error value too so you can just as well have the
function return an int simply and make sure you check the retval.

--
Regards/Gruss,
Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--