Skip to content
Permalink
Browse files

arch/x86: used fixed initial EFLAGS on thread creation

Previously the existing EFLAGS was used as a base which was
then manipulated accordingly. This is unnecessary as the bits
preserved contain no useful state related to the new thread.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
  • Loading branch information...
Charles E. Youse authored and andrewboie committed Jun 23, 2019
1 parent 01b5729 commit 2835c22985e04845560550a59463646d24803080
Showing with 3 additions and 29 deletions.
  1. +1 −2 arch/x86/core/ia32/thread.c
  2. +0 −20 arch/x86/include/asm_inline_gcc.h
  3. +2 −7 arch/x86/include/kernel_arch_data.h
@@ -97,8 +97,7 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
initial_frame->p1 = parameter1;
initial_frame->p2 = parameter2;
initial_frame->p3 = parameter3;
/* initial EFLAGS; only modify IF and IOPL bits */
initial_frame->eflags = (EflagsGet() & ~EFLAGS_MASK) | EFLAGS_INITIAL;
initial_frame->eflags = EFLAGS_INITIAL;
#ifdef CONFIG_X86_USERSPACE
if ((options & K_USER) != 0U) {
#ifdef _THREAD_WRAPPER_REQUIRED
@@ -20,26 +20,6 @@ extern "C" {

#ifndef _ASMLANGUAGE

/**
*
* @brief Return the current value of the EFLAGS register
*
* @return the EFLAGS register.
*/
static inline unsigned int EflagsGet(void)
{
unsigned int eflags; /* EFLAGS register contents */

__asm__ volatile(
"pushfl;\n\t"
"popl %0;\n\t"
: "=r"(eflags)
: );

return eflags;
}


#ifdef CONFIG_LAZY_FP_SHARING

/**
@@ -98,15 +98,10 @@
#define IV_INTEL_RESERVED_END 31

/*
* EFLAGS value to utilize for the initial context:
*
* IF (Interrupt Enable Flag) = 1
* IOPL bits = 0
* All other "flags" = Don't change state
* EFLAGS value to utilize for the initial context: IF=1.
*/

#define EFLAGS_INITIAL 0x00000200LLU
#define EFLAGS_MASK 0x00003200ULL
#define EFLAGS_INITIAL 0x00000200U

/* Enable paging and write protection */
#define CR0_PG_WP_ENABLE 0x80010000

0 comments on commit 2835c22

Please sign in to comment.
You can’t perform that action at this time.