[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171012163141.mekj5hemwtkpxh32@pd.tnic>
Date: Thu, 12 Oct 2017 18:31:41 +0200
From: Borislav Petkov <bp@...e.de>
To: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
Cc: Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Brian Gerst <brgerst@...il.com>,
Chris Metcalf <cmetcalf@...lanox.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Huang Rui <ray.huang@....com>, Jiri Slaby <jslaby@...e.cz>,
Jonathan Corbet <corbet@....net>,
"Michael S. Tsirkin" <mst@...hat.com>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Vlastimil Babka <vbabka@...e.cz>,
Chen Yucong <slaoub@...il.com>,
"Ravi V. Shankar" <ravi.v.shankar@...el.com>,
Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org,
x86@...nel.org, ricardo.neri@...el.com,
Adam Buchbinder <adam.buchbinder@...il.com>,
Colin Ian King <colin.king@...onical.com>,
Lorenzo Stoakes <lstoakes@...il.com>,
Qiaowei Ren <qiaowei.ren@...el.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Kees Cook <keescook@...omium.org>,
Thomas Garnier <thgarnie@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [PATCH v9 16/29] x86/insn-eval: Add function to get default
params of code segment
On Tue, Oct 03, 2017 at 08:54:19PM -0700, Ricardo Neri wrote:
> Obtain the default values of the address and operand sizes as specified in
> the D and L bits of the the segment descriptor selected by the register
> CS. The function can be used for both protected and long modes.
> For virtual-8086 mode, the default address and operand sizes are always 2
> bytes.
>
> The returned parameters are encoded in a signed 8-bit data type. Auxiliar
> macros are provided to encode and decode such values.
>
> Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: Adam Buchbinder <adam.buchbinder@...il.com>
> Cc: Colin Ian King <colin.king@...onical.com>
> Cc: Lorenzo Stoakes <lstoakes@...il.com>
> Cc: Qiaowei Ren <qiaowei.ren@...el.com>
> Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Cc: Adrian Hunter <adrian.hunter@...el.com>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Thomas Garnier <thgarnie@...gle.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Borislav Petkov <bp@...e.de>
> Cc: Dmitry Vyukov <dvyukov@...gle.com>
> Cc: Ravi V. Shankar <ravi.v.shankar@...el.com>
> Cc: x86@...nel.org
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
> ---
> arch/x86/include/asm/insn-eval.h | 5 ++++
> arch/x86/lib/insn-eval.c | 64 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 69 insertions(+)
Some cleanups ontop:
---
diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c
index 64924b7d5fff..3352b9d5164f 100644
--- a/arch/x86/lib/insn-eval.c
+++ b/arch/x86/lib/insn-eval.c
@@ -614,14 +614,14 @@ static unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)
}
/**
- * insn_get_code_seg_defaults() - Obtain code segment default parameters
+ * insn_get_code_seg_params() - Obtain code segment parameters
* @regs: Structure with register values as seen when entering kernel mode
*
- * Obtain the default parameters of the code segment: address and operand sizes.
- * The code segment is obtained from the selector contained in the CS register
- * in regs. In protected mode, the default address is determined by inspecting
- * the L and D bits of the segment descriptor. In virtual-8086 mode, the default
- * is always two bytes for both address and operand sizes.
+ * Obtain address and operand sizes of the code segment. It is obtained from the
+ * selector contained in the CS register in regs. In protected mode, the default
+ * address is determined by inspecting the L and D bits of the segment descriptor.
+ * In virtual-8086 mode, the default is always two bytes for both address and
+ * operand sizes.
*
* Returns:
*
@@ -629,7 +629,7 @@ static unsigned long get_seg_limit(struct pt_regs *regs, int seg_reg_idx)
*
* -EINVAL on error.
*/
-char insn_get_code_seg_defaults(struct pt_regs *regs)
+char insn_get_code_seg_params(struct pt_regs *regs)
{
struct desc_struct *desc;
short sel;
@@ -640,7 +640,7 @@ char insn_get_code_seg_defaults(struct pt_regs *regs)
sel = get_segment_selector(regs, INAT_SEG_REG_CS);
if (sel < 0)
- return -1L;
+ return sel;
desc = get_desc(sel);
if (!desc)
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
Powered by blists - more mailing lists