The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Alexander Kuleshov <kuleshovmail@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Andy Lutomirski <luto@kernel.org>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Borislav Petkov <bp@suse.de>,
	linux-kernel@vger.kernel.org,
	Alexander Kuleshov <kuleshovmail@gmail.com>
Subject: [PATCH v2] x86/entry_64.S: introduce prepare_error_code macro
Date: Sun, 17 Jan 2016 13:41:18 +0600	[thread overview]
Message-ID: <1453016478-10760-1-git-send-email-kuleshovmail@gmail.com> (raw)

We need to put an error code to the %rsi if an exception provides
it, before the call of an exception handler. We do it in the idtentry
macro in two places.

This patch introduces prepare_error_code macro which will check existence
of an error code and put it to %rsi from ORIG_RAX if it exists, or just
clears %esi if an error code does not exist to prevent code duplication
in the idtentry macro.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---

v2: indentation fixed

 arch/x86/entry/entry_64.S | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 9d34d3c..e2b1e79 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -722,6 +722,15 @@ apicinterrupt IRQ_WORK_VECTOR			irq_work_interrupt		smp_irq_work_interrupt
  */
 #define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
 
+	.macro prepare_error_code has_error_code:req
+	.if \has_error_code
+	movq	ORIG_RAX(%rsp), %rsi		/* get error code */
+	movq	$-1, ORIG_RAX(%rsp)		/* no syscall to restart */
+	.else
+	xorl	%esi, %esi			/* no error code */
+	.endif
+	.endm
+
 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
 ENTRY(\sym)
 	/* Sanity check */
@@ -759,12 +768,7 @@ ENTRY(\sym)
 
 	movq	%rsp, %rdi			/* pt_regs pointer */
 
-	.if \has_error_code
-	movq	ORIG_RAX(%rsp), %rsi		/* get error code */
-	movq	$-1, ORIG_RAX(%rsp)		/* no syscall to restart */
-	.else
-	xorl	%esi, %esi			/* no error code */
-	.endif
+	prepare_error_code \has_error_code      /* %rsi -> error code */
 
 	.if \shift_ist != -1
 	subq	$EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
@@ -799,13 +803,7 @@ ENTRY(\sym)
 
 	movq	%rsp, %rdi			/* pt_regs pointer */
 
-	.if \has_error_code
-	movq	ORIG_RAX(%rsp), %rsi		/* get error code */
-	movq	$-1, ORIG_RAX(%rsp)		/* no syscall to restart */
-	.else
-	xorl	%esi, %esi			/* no error code */
-	.endif
-
+	prepare_error_code \has_error_code      /* %rsi -> error code */
 	call	\do_sym
 
 	jmp	error_exit			/* %ebx: no swapgs flag */
-- 
2.7.0.25.gfc10eb5

             reply	other threads:[~2016-01-17  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-17  7:41 Alexander Kuleshov [this message]
2016-01-17  9:47 ` [PATCH v2] x86/entry_64.S: introduce prepare_error_code macro Borislav Petkov

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=1453016478-10760-1-git-send-email-kuleshovmail@gmail.com \
    --to=kuleshovmail@gmail.com \
    --cc=bp@suse.de \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox