* [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork
@ 2011-08-31 9:22 Ian Campbell
2011-08-31 9:22 ` [PATCH 1/2] x86: drop unnecessary kernel_eflags variable from 64 bit Ian Campbell
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ian Campbell @ 2011-08-31 9:22 UTC (permalink / raw)
To: linux-kernel
Cc: Cyrill Gorcunov, H. Peter Anvin, Peter Zijlstra, Pekka Enberg,
Andi Kleen
This fell off my radar but Cyrill kindly reminded me so here is a repost
of my short cleanup to remove the kernel_eflags variable from 64 bit and
to converge the ret_from_fork paths on 32 and 64 bit slightly.
This is unchanged from the last posting except I have rebased to current
tip/master and retested (it boots successfully on both 32 and 64 bit).
As previously discussed since the original posting I have switched to
converging on the 64 bit variant rather than the 32 bit variant.
Although I believe both variants are strictly speaking correct and
equivalent the 64 bit version seems to be more obviously so.
Ian.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] x86: drop unnecessary kernel_eflags variable from 64 bit.
2011-08-31 9:22 [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Ian Campbell
@ 2011-08-31 9:22 ` Ian Campbell
2011-08-31 9:22 ` [PATCH 2/2] x86: make 32 bit ret_from_fork a little more similar to " Ian Campbell
2011-08-31 9:31 ` [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Cyrill Gorcunov
2 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2011-08-31 9:22 UTC (permalink / raw)
To: linux-kernel
Cc: Cyrill Gorcunov, H. Peter Anvin, Peter Zijlstra, Pekka Enberg,
Andi Kleen, Ian Campbell, x86
On 64 bit x86 we save the current eflags in cpu_init for use in ret_from_fork.
Strictly speaking reserved bits in EFLAGS should be read as written but in
practise it is unlikely that EFLAGS could ever be extended in this way and the
kernel alread clears any undefined flags early on.
The equivalent 32 bit code simply hard codes 0x0202 as the new EFLAGS.
This change makes 64 bit use the same mechanism to setup the initial EFLAGS on
fork. Note that 64 bit resets EFLAGS before calling schedule_tail() as opposed
to 32 bit which calls schedule_tail() first. Therefore the correct value for
EFLAGS has opposite IF bit. This will be fixed in a subsequent patch.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: x86@kernel.org
---
arch/x86/include/asm/processor.h | 1 -
arch/x86/kernel/cpu/common.c | 4 ----
arch/x86/kernel/entry_64.S | 2 +-
3 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 0d1171c..3065557 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -398,7 +398,6 @@ DECLARE_INIT_PER_CPU(irq_stack_union);
DECLARE_PER_CPU(char *, irq_stack_ptr);
DECLARE_PER_CPU(unsigned int, irq_count);
-extern unsigned long kernel_eflags;
extern asmlinkage void ignore_sysret(void);
#else /* X86_64 */
#ifdef CONFIG_CC_STACKPROTECTOR
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index aa003b1..1a11da2 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1082,8 +1082,6 @@ void syscall_init(void)
X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
}
-unsigned long kernel_eflags;
-
/*
* Copies of the original ist values from the tss are only accessed during
* debugging, no special alignment required.
@@ -1236,8 +1234,6 @@ void __cpuinit cpu_init(void)
fpu_init();
xsave_init();
- raw_local_save_flags(kernel_eflags);
-
if (is_uv_system())
uv_cpu_init();
}
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 6419bb0..f0deb4e 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -396,7 +396,7 @@ ENTRY(ret_from_fork)
LOCK ; btr $TIF_FORK,TI_flags(%r8)
- pushq_cfi kernel_eflags(%rip)
+ pushq_cfi $0x0002
popfq_cfi # reset kernel eflags
call schedule_tail # rdi: 'prev' task parameter
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] x86: make 32 bit ret_from_fork a little more similar to 64 bit
2011-08-31 9:22 [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Ian Campbell
2011-08-31 9:22 ` [PATCH 1/2] x86: drop unnecessary kernel_eflags variable from 64 bit Ian Campbell
@ 2011-08-31 9:22 ` Ian Campbell
2011-08-31 9:31 ` [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Cyrill Gorcunov
2 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2011-08-31 9:22 UTC (permalink / raw)
To: linux-kernel
Cc: Cyrill Gorcunov, H. Peter Anvin, Peter Zijlstra, Pekka Enberg,
Andi Kleen, Ian Campbell, x86
The 64 bit version resets EFLAGS before calling schedule_tail() and
therefore leaves EFLAGS.IF clear. 32 bit resets EFLAGS after calling
schedule_tail() and therefore leaves EFLAGS.IF set.
Since the 64 bit version seems more obviously correct (although I think both
are actually right) make the 32 bit version look like that.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: x86@kernel.org
---
arch/x86/kernel/entry_32.S | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index f3f6f53..8b8794b 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -300,12 +300,12 @@
ENTRY(ret_from_fork)
CFI_STARTPROC
+ pushl_cfi $0x0002 # Reset kernel eflags
+ popfl_cfi
pushl_cfi %eax
call schedule_tail
GET_THREAD_INFO(%ebp)
popl_cfi %eax
- pushl_cfi $0x0202 # Reset kernel eflags
- popfl_cfi
jmp syscall_exit
CFI_ENDPROC
END(ret_from_fork)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork
2011-08-31 9:22 [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Ian Campbell
2011-08-31 9:22 ` [PATCH 1/2] x86: drop unnecessary kernel_eflags variable from 64 bit Ian Campbell
2011-08-31 9:22 ` [PATCH 2/2] x86: make 32 bit ret_from_fork a little more similar to " Ian Campbell
@ 2011-08-31 9:31 ` Cyrill Gorcunov
2 siblings, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2011-08-31 9:31 UTC (permalink / raw)
To: Ian Campbell
Cc: linux-kernel, H. Peter Anvin, Peter Zijlstra, Pekka Enberg,
Andi Kleen
On Wed, Aug 31, 2011 at 10:22:21AM +0100, Ian Campbell wrote:
> This fell off my radar but Cyrill kindly reminded me so here is a repost
> of my short cleanup to remove the kernel_eflags variable from 64 bit and
> to converge the ret_from_fork paths on 32 and 64 bit slightly.
>
Thanks Ian, I'll try to review them today.
Cyrill
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-31 9:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-31 9:22 [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Ian Campbell
2011-08-31 9:22 ` [PATCH 1/2] x86: drop unnecessary kernel_eflags variable from 64 bit Ian Campbell
2011-08-31 9:22 ` [PATCH 2/2] x86: make 32 bit ret_from_fork a little more similar to " Ian Campbell
2011-08-31 9:31 ` [PATCH 0/2] minor cleanups to EFLAGS initialisation in ret_from_fork Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox