Skip to content

Commit e634d8f

Browse files
author
H. Peter Anvin
committed
x86-64: merge the standard and compat start_thread() functions
The only thing left that differs between the standard and compat start_thread functions is the actual segment numbers and the prototype, so have a single common function which contains the guts and two very small wrappers. Signed-off-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Suresh Siddha <suresh.b.siddha@intel.com>
1 parent a6f05a6 commit e634d8f

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

arch/x86/kernel/process_64.c

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -344,45 +344,40 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
344344
return err;
345345
}
346346

347-
void
348-
start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
347+
static void
348+
start_thread_common(struct pt_regs *regs, unsigned long new_ip,
349+
unsigned long new_sp,
350+
unsigned int _cs, unsigned int _ss, unsigned int _ds)
349351
{
350352
loadsegment(fs, 0);
351-
loadsegment(es, 0);
352-
loadsegment(ds, 0);
353+
loadsegment(es, _ds);
354+
loadsegment(ds, _ds);
353355
load_gs_index(0);
354356
regs->ip = new_ip;
355357
regs->sp = new_sp;
356358
percpu_write(old_rsp, new_sp);
357-
regs->cs = __USER_CS;
358-
regs->ss = __USER_DS;
359+
regs->cs = _cs;
360+
regs->ss = _ss;
359361
regs->flags = X86_EFLAGS_IF;
360362
set_fs(USER_DS);
361363
/*
362364
* Free the old FP and other extended state
363365
*/
364366
free_thread_xstate(current);
365367
}
366-
EXPORT_SYMBOL_GPL(start_thread);
368+
369+
void
370+
start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
371+
{
372+
start_thread_common(regs, new_ip, new_sp,
373+
__USER_CS, __USER_DS, 0);
374+
}
367375

368376
#ifdef CONFIG_IA32_EMULATION
369377
void start_thread_ia32(struct pt_regs *regs, u32 new_ip, u32 new_sp)
370378
{
371-
loadsegment(fs, 0);
372-
loadsegment(ds, __USER32_DS);
373-
loadsegment(es, __USER32_DS);
374-
load_gs_index(0);
375-
regs->ip = new_ip;
376-
regs->sp = new_sp;
377-
percpu_write(old_rsp, new_sp);
378-
regs->cs = __USER32_CS;
379-
regs->ss = __USER32_DS;
380-
regs->flags = X86_EFLAGS_IF;
381-
set_fs(USER_DS);
382-
/*
383-
* Free the old FP and other extended state
384-
*/
385-
free_thread_xstate(current);
379+
start_thread_common(regs, new_ip, new_sp,
380+
__USER32_CS, __USER32_DS, __USER32_DS);
386381
}
387382
#endif
388383

0 commit comments

Comments
 (0)