All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander van Heukelum <heukelum@mailshack.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <andi@firstfloor.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Jan Beulich <jbeulich@novell.com>,
	Glauber Costa <gcosta@redhat.com>, Matt Mackall <mpm@selenic.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH] Split out some macro's and move common code to paranoid_exit
Date: Fri, 21 Nov 2008 16:44:28 +0100	[thread overview]
Message-ID: <20081121154428.GB13014@mailshack.com> (raw)
In-Reply-To: <20081121154318.GA13014@mailshack.com>

DISABLE_INTERRUPTS(CLBR_NONE)/TRACE_IRQS_OFF is now always
executed just before paranoid_exit. Move it there.

Split out paranoidzeroentry, paranoiderrorentry, and
paranoidzeroentry_ist to get more readable macro's.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
 arch/x86/kernel/entry_64.S |  102 ++++++++++++++++++++++----------------------
 1 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index fad777b..692c1da 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1026,6 +1026,39 @@ END(spurious_interrupt)
 	CFI_ENDPROC
 	.endm
 
+	.macro paranoidzeroentry sym
+	INTR_FRAME
+	PARAVIRT_ADJUST_EXCEPTION_FRAME
+	pushq $-1		/* ORIG_RAX: no syscall to restart */
+	CFI_ADJUST_CFA_OFFSET 8
+	subq $15*8, %rsp
+	call save_paranoid
+	TRACE_IRQS_OFF
+	movq %rsp,%rdi		/* pt_regs pointer */
+	xorl %esi,%esi		/* no error code */
+	call \sym
+	jmp paranoid_exit	/* %ebx: no swapgs flag */
+	CFI_ENDPROC
+	.endm
+
+	.macro paranoidzeroentry_ist sym ist
+ 	INTR_FRAME
+	PARAVIRT_ADJUST_EXCEPTION_FRAME
+	pushq $-1		/* ORIG_RAX: no syscall to restart */
+	CFI_ADJUST_CFA_OFFSET 8
+	subq $15*8, %rsp
+	call save_paranoid
+	TRACE_IRQS_OFF
+	movq %rsp,%rdi		/* pt_regs pointer */
+	xorl %esi,%esi		/* no error code */
+	movq %gs:pda_data_offset, %rbp
+	subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
+	call \sym
+	addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
+	jmp paranoid_exit	/* %ebx: no swapgs flag */
+	CFI_ENDPROC
+	.endm
+
 	.macro errorentry sym
 	XCPT_FRAME
 	PARAVIRT_ADJUST_EXCEPTION_FRAME
@@ -1042,27 +1075,20 @@ END(spurious_interrupt)
 	.endm
 
 	/* error code is on the stack already */
-	.macro paranoidentry sym ist=0
-	subq $15*8, %rsp
+	.macro paranoiderrorentry sym
+	XCPT_FRAME
+	PARAVIRT_ADJUST_EXCEPTION_FRAME
+	subq $15*8,%rsp
 	CFI_ADJUST_CFA_OFFSET 15*8
 	call save_paranoid
 	DEFAULT_FRAME 0
-	.if \ist
-	movq	%gs:pda_data_offset, %rbp
-	.endif
 	TRACE_IRQS_OFF
-	movq %rsp,%rdi
-	movq ORIG_RAX(%rsp),%rsi
-	movq $-1,ORIG_RAX(%rsp)
-	.if \ist
-	subq	$EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
-	.endif
+	movq %rsp,%rdi			/* pt_regs pointer */
+	movq ORIG_RAX(%rsp),%rsi	/* get error code */
+	movq $-1,ORIG_RAX(%rsp)		/* no syscall to restart */
 	call \sym
-	.if \ist
-	addq	$EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
-	.endif
-	DISABLE_INTERRUPTS(CLBR_NONE)
-	TRACE_IRQS_OFF
+	jmp paranoid_exit		/* %ebx: no swapgs flag */
+	CFI_ENDPROC
 	.endm
 
 	/*
@@ -1081,6 +1107,8 @@ END(spurious_interrupt)
 	/* ebx:	no swapgs flag */
 KPROBE_ENTRY(paranoid_exit)
 	INTR_FRAME
+	DISABLE_INTERRUPTS(CLBR_NONE)
+	TRACE_IRQS_OFF
 	testl %ebx,%ebx				/* swapgs needed? */
 	jnz paranoid_restore
 	testl $3,CS(%rsp)
@@ -1331,13 +1359,7 @@ END(device_not_available)
 
 	/* runs on exception stack */
 KPROBE_ENTRY(debug)
- 	INTR_FRAME
-	PARAVIRT_ADJUST_EXCEPTION_FRAME
-	pushq $0
-	CFI_ADJUST_CFA_OFFSET 8
-	paranoidentry do_debug, DEBUG_STACK
-	jmp paranoid_exit
- 	CFI_ENDPROC
+	paranoidzeroentry_ist do_debug, DEBUG_STACK
 KPROBE_END(debug)
 
 	/* runs on exception stack */
@@ -1351,14 +1373,12 @@ KPROBE_ENTRY(nmi)
 	DEFAULT_FRAME 0
 	/* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
 	movq %rsp,%rdi
-	movq ORIG_RAX(%rsp),%rsi
-	movq $-1,ORIG_RAX(%rsp)
+	movq $-1,%rsi
 	call do_nmi
-	DISABLE_INTERRUPTS(CLBR_NONE)
 #ifdef CONFIG_TRACE_IRQFLAGS
 	/* paranoidexit; without TRACE_IRQS_OFF */
 	/* ebx:	no swapgs flag */
-nmi_exit:
+	DISABLE_INTERRUPTS(CLBR_NONE)
 	testl %ebx,%ebx				/* swapgs needed? */
 	jnz nmi_restore
 	testl $3,CS(%rsp)
@@ -1398,13 +1418,7 @@ nmi_schedule:
 KPROBE_END(nmi)
 
 KPROBE_ENTRY(int3)
- 	INTR_FRAME
-	PARAVIRT_ADJUST_EXCEPTION_FRAME
- 	pushq $0
- 	CFI_ADJUST_CFA_OFFSET 8
- 	paranoidentry do_int3, DEBUG_STACK
- 	jmp paranoid_exit
- 	CFI_ENDPROC
+	paranoidzeroentry_ist do_int3, DEBUG_STACK
 KPROBE_END(int3)
 
 ENTRY(overflow)
@@ -1425,11 +1439,7 @@ END(coprocessor_segment_overrun)
 
 	/* runs on exception stack */
 ENTRY(double_fault)
-	XCPT_FRAME
-	PARAVIRT_ADJUST_EXCEPTION_FRAME
-	paranoidentry do_double_fault
-	jmp paranoid_exit
-	CFI_ENDPROC
+	paranoiderrorentry do_double_fault
 END(double_fault)
 
 ENTRY(invalid_TSS)
@@ -1442,11 +1452,7 @@ END(segment_not_present)
 
 	/* runs on exception stack */
 ENTRY(stack_segment)
-	XCPT_FRAME
-	PARAVIRT_ADJUST_EXCEPTION_FRAME
-	paranoidentry do_stack_segment
-	jmp paranoid_exit
-	CFI_ENDPROC
+	paranoiderrorentry do_stack_segment
 END(stack_segment)
 
 KPROBE_ENTRY(general_protection)
@@ -1468,13 +1474,7 @@ END(spurious_interrupt_bug)
 #ifdef CONFIG_X86_MCE
 	/* runs on exception stack */
 ENTRY(machine_check)
-	INTR_FRAME
-	PARAVIRT_ADJUST_EXCEPTION_FRAME
-	pushq $0
-	CFI_ADJUST_CFA_OFFSET 8
-	paranoidentry do_machine_check
-	jmp paranoid_exit
-	CFI_ENDPROC
+	paranoidzeroentry do_machine_check
 END(machine_check)
 #endif
 
-- 
1.5.4.3


  reply	other threads:[~2008-11-21 15:48 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-16 14:29 [PATCH] trivial, entry_64: remove whitespace at end of lines Alexander van Heukelum
2008-11-16 14:29 ` [RFC] x86: save_args out of line Alexander van Heukelum
2008-11-17 12:14   ` Glauber Costa
2008-11-17 15:13     ` Alexander van Heukelum
2008-11-17 12:53   ` Andi Kleen
2008-11-17 15:37     ` Alexander van Heukelum
2008-11-17 18:23       ` Andi Kleen
2008-11-17 19:22         ` Cyrill Gorcunov
2008-11-17 19:29           ` Cyrill Gorcunov
2008-11-17 19:49             ` Alexander van Heukelum
2008-11-17 19:54               ` Cyrill Gorcunov
2008-11-17 19:43           ` Alexander van Heukelum
2008-11-17 19:49             ` Cyrill Gorcunov
2008-11-17 17:52   ` [RFC,v2] x86_64: " Alexander van Heukelum
2008-11-18  8:09     ` Jan Beulich
2008-11-18 11:16       ` Alexander van Heukelum
2008-11-18 12:51         ` Jan Beulich
2008-11-18 14:03           ` Ingo Molnar
2008-11-18 14:52             ` Jan Beulich
2008-11-18 15:00               ` Ingo Molnar
2008-11-18 22:53                 ` Roland McGrath
2008-11-18 23:35                   ` Andi Kleen
2008-11-18 23:36                     ` Jeremy Fitzhardinge
2008-11-18 23:44                       ` H. Peter Anvin
2008-11-19  0:08                         ` Jeremy Fitzhardinge
2008-11-18 23:45                     ` Roland McGrath
2008-11-19  0:06                       ` Andi Kleen
2008-11-19  0:01                         ` H. Peter Anvin
2008-11-19 10:34                   ` Ingo Molnar
2008-11-19 20:09                     ` Ingo Molnar
2008-11-19  0:18     ` [PATCH/RFC] Move entry_64.S register saving out of the macros Alexander van Heukelum
2008-11-19 17:54       ` H. Peter Anvin
2008-11-19 20:16         ` Ingo Molnar
2008-11-20 13:40       ` [PATCH] x86: clean up after: move " Alexander van Heukelum
2008-11-20 14:01         ` Andi Kleen
2008-11-20 15:04         ` Ingo Molnar
2008-11-20 15:26           ` Alexander van Heukelum
2008-11-20 15:39             ` Ingo Molnar
2008-11-20 15:50               ` [PATCH] x86: clean up after: move entry_64.S register savingout " Jan Beulich
2008-11-20 15:57               ` [PATCH] x86: clean up after: move entry_64.S register saving out " Alexander van Heukelum
2008-11-20 16:07                 ` Cyrill Gorcunov
2008-11-20 16:29                 ` Alexander van Heukelum
2008-11-20 17:24                 ` Ingo Molnar
2008-11-21 15:41               ` [PATCH] x86: Introduce save_rest and restructure the PTREGSCALL macro in entry_64.S Alexander van Heukelum
2008-11-21 15:43                 ` [PATCH] x86: entry_64.S: Factor out save_paranoid and paranoid_exit Alexander van Heukelum
2008-11-21 15:44                   ` Alexander van Heukelum [this message]
2008-11-21 16:06                     ` [PATCH] Split out some macro's and move common code to paranoid_exit Ingo Molnar
2008-11-23  9:08                       ` [PATCH] x86: include ENTRY/END in entry handlers in entry_64.S Alexander van Heukelum
2008-11-23  9:15                         ` [PATCH] x86: KPROBE_ENTRY should be paired wth KPROBE_END Alexander van Heukelum
2008-11-23 13:27                           ` Ingo Molnar
2008-11-23 13:51                             ` Cyrill Gorcunov
2008-11-23 14:12                               ` Cyrill Gorcunov
2008-11-23 14:55                                 ` Ingo Molnar
2008-11-23 15:04                                   ` Cyrill Gorcunov
2008-11-23 15:04                                 ` Alexander van Heukelum
2008-11-23 15:12                                   ` Cyrill Gorcunov
2008-11-23 15:31                                     ` Ingo Molnar
2008-11-23 15:41                                       ` Cyrill Gorcunov
2008-11-23 15:37                                   ` Cyrill Gorcunov
2008-11-23 16:29                                     ` Ingo Molnar
2008-11-24  9:17                           ` Jan Beulich
2008-11-24 10:26                             ` Alexander van Heukelum
2008-11-24 10:35                               ` Jan Beulich
2008-11-24 12:24                                 ` [PATCH] x86_64: get rid of the use of KPROBE_ENTRY / KPROBE_END Alexander van Heukelum
2008-11-24 13:33                                   ` Jan Beulich
2008-11-24 14:38                                     ` [PATCH] i386: " Alexander van Heukelum
2008-11-23  9:21                         ` [PATCH] x86: include ENTRY/END in entry handlers in entry_64.S Cyrill Gorcunov
2008-11-23 11:23                           ` Alexander van Heukelum
2008-11-23 11:35                             ` Cyrill Gorcunov
2008-11-23 20:13                             ` H. Peter Anvin
2008-11-24 10:06                               ` Alexander van Heukelum
2008-11-24 18:07                                 ` H. Peter Anvin
2008-11-23 13:23                         ` Ingo Molnar
2008-11-17  9:47 ` [PATCH] trivial, entry_64: remove whitespace at end of lines Ingo Molnar
2008-11-17 15:14   ` Alexander van Heukelum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081121154428.GB13014@mailshack.com \
    --to=heukelum@mailshack.com \
    --cc=andi@firstfloor.org \
    --cc=gcosta@redhat.com \
    --cc=gorcunov@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mpm@selenic.com \
    --cc=nickpiggin@yahoo.com.au \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.