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

From: Borislav Petkov
Date: Mon Jun 19 2017 - 11:59:02 EST

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].

... 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.


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