Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631783 > unrolled thread

Re: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get segment descriptor base address

Started byRicardo Neri <ricardo.neri-calderon@linux.intel.com>
First post2017-04-27 01:00 +0200
Last post2017-05-12 04:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get  segment descriptor base address Ricardo Neri <ricardo.neri-calderon@linux.intel.com> - 2017-04-27 01:00 +0200
    Re: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get  segment descriptor base address Borislav Petkov <bp@suse.de> - 2017-05-05 19:40 +0200
      Re: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get  segment descriptor base address Ricardo Neri <ricardo.neri-calderon@linux.intel.com> - 2017-05-12 04:10 +0200

#1631783 — Re: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get segment descriptor base address

FromRicardo Neri <ricardo.neri-calderon@linux.intel.com>
Date2017-04-27 01:00 +0200
SubjectRe: [v6 PATCH 08/21] x86/insn-eval: Add utility function to get segment descriptor base address
Message-ID<tAE4F-mI-3@gated-at.bofh.it>
On Thu, 2017-04-20 at 10:25 +0200, Borislav Petkov wrote:
> > + * insn_get_seg_base() - Obtain base address contained in
> descriptor
> > + * @regs:    Set of registers containing the segment selector
> > + * @insn:    Instruction structure with selector override prefixes
> > + * @regoff:  Operand offset, in pt_regs, of which the selector is
> needed
> > + * @use_default_seg: Use the default segment instead of prefix
> overrides
> 
> I'm wondering whether you really need that bool or you can deduce this
> from pt_regs... I guess I'll see...

Probably insn_get_seg_base() itself can verify if there are segment
override prefixes in the struct insn. If yes, use them except for
specific cases such as CS.

On an unrelated note, I still have the problem of using DS vs ES for
string instructions. Perhaps instead of a use_default_seg flag, a
string_instruction flag that indicates how to determine the default
segment.

Thanks and BR,
Ricardo

[toc] | [next] | [standalone]


#1636512

FromBorislav Petkov <bp@suse.de>
Date2017-05-05 19:40 +0200
Message-ID<tDPmW-4Oe-11@gated-at.bofh.it>
In reply to#1631783
On Wed, Apr 26, 2017 at 03:52:41PM -0700, Ricardo Neri wrote:
> Probably insn_get_seg_base() itself can verify if there are segment
> override prefixes in the struct insn. If yes, use them except for
> specific cases such as CS.

... and depending on whether in long mode or not.

> On an unrelated note, I still have the problem of using DS vs ES for
> string instructions. Perhaps instead of a use_default_seg flag, a
> string_instruction flag that indicates how to determine the default
> segment.

... or you can look at the insn opcode directly. AFAICT, you need
to check whether the opcode is 0xa4 or 0xa5 and that the insn is a
single-byte opcode, i.e., not from the secondary map escaped with 0xf or
some of the other multi-byte opcode maps.

-- 
Regards/Gruss,
    Boris.

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

[toc] | [prev] | [next] | [standalone]


#1640118

FromRicardo Neri <ricardo.neri-calderon@linux.intel.com>
Date2017-05-12 04:10 +0200
Message-ID<tG8bM-64j-3@gated-at.bofh.it>
In reply to#1636512
On Fri, 2017-05-05 at 19:28 +0200, Borislav Petkov wrote:
> On Wed, Apr 26, 2017 at 03:52:41PM -0700, Ricardo Neri wrote:
> > Probably insn_get_seg_base() itself can verify if there are segment
> > override prefixes in the struct insn. If yes, use them except for
> > specific cases such as CS.
> 
> ... and depending on whether in long mode or not.

Yes, in my v7 I ignore the segment register if we are in long mode [1].
> 
> > On an unrelated note, I still have the problem of using DS vs ES for
> > string instructions. Perhaps instead of a use_default_seg flag, a
> > string_instruction flag that indicates how to determine the default
> > segment.
> 
> ... or you can look at the insn opcode directly. AFAICT, you need
> to check whether the opcode is 0xa4 or 0xa5 and that the insn is a
> single-byte opcode, i.e., not from the secondary map escaped with 0xf or
> some of the other multi-byte opcode maps.

In my v7, I have added a section my function resolve_seg_register() that
ignores
segment overrides if it sees string instructions and the register EDI
and defaults to ES. If the register is EIP, it defaults to CS. To
determine if an instruction is a string instruction I do check for the
size of the opcode and the opcodes that you mention plus others based on
the Intel Software Development Manual[2].

[1]. https://lkml.org/lkml/2017/5/5/405
[2]. https://lkml.org/lkml/2017/5/5/410

Thanks and BR,
Ricardo


> 
> -- 
> Regards/Gruss,
>     Boris.
> 
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web