lkml.org 
[lkml]   [2020]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/70] x86/umip: Factor out instruction fetch
On Thu, Mar 19, 2020 at 10:13:03AM +0100, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
>
> Factor out the code to fetch the instruction from user-space to a helper
> function.

Add "No functional changes." here.

> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
> arch/x86/include/asm/insn-eval.h | 2 ++
> arch/x86/kernel/umip.c | 26 +++++-----------------
> arch/x86/lib/insn-eval.c | 38 ++++++++++++++++++++++++++++++++
> 3 files changed, 46 insertions(+), 20 deletions(-)

...

> +int insn_fetch_from_user(struct pt_regs *regs,
> + unsigned char buf[MAX_INSN_SIZE])

No need for that linebreak - fits in 80 cols.

> +{
> + unsigned long seg_base = 0;
> + int not_copied;
> +
> + /*
> + * If not in user-space long mode, a custom code segment could be in
> + * use. This is true in protected mode (if the process defined a local
> + * descriptor table), or virtual-8086 mode. In most of the cases
> + * seg_base will be zero as in USER_CS.
> + */
> + if (!user_64bit_mode(regs))
> + seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
> +
> + if (seg_base == -1L)
> + return 0;

This reads strange: seg_base is changed only inside that if test so I
guess we could test it there too:

if (!user_64bit_mode(regs)) {
seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
if (seg_base == -1L)
return 0;
}

which is a small enough change to not require a separate patch.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

\
 
 \ /
  Last update: 2020-03-26 18:23    [W:0.345 / U:6.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site