From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: <linux-arch@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <arnd@arndb.de>, Vineet Gupta <Vineet.Gupta1@synopsys.com>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: [PATCH v3 21/71] ARC: [Review] Preparing to fix incorrect syscall restarts due to signals
Date: Thu, 24 Jan 2013 16:20:23 +0530 [thread overview]
Message-ID: <1359024639-21915-10-git-send-email-vgupta@synopsys.com> (raw)
In-Reply-To: <1359024639-21915-1-git-send-email-vgupta@synopsys.com>
To avoid multiple syscall restarts (multiple signals) or no restart at
all (sigreturn), we need just an extra bit of state "literally 1 bit" in
struct pt_regs. orig_r8 is the best place to do this, however given the
way it is encoded currently, we can't add anything simplistically.
Current orig_r8:
* syscalls -> 1 to NR_SYSCALLS
* Exceptions -> NR_SYSCALLS + 1
* Break-point-> NR_SYSCALLS + 2
In new scheme it is a bit-field
* lower short word contains the exact event type (and a new bit to represent
restart semantics : if syscall was already / can't be restarted)
* upper short word optionally containing the syscall num - needed by
likes of tracehooks etc
This patch only changes how orig_r8 is organised and nothing should
change behaviourily.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
---
arch/arc/include/asm/entry.h | 29 +++++++++++++++++------------
arch/arc/include/asm/ptrace.h | 20 ++++++++++++++++----
arch/arc/kernel/entry.S | 4 ++--
3 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h
index 6b42bf5..9eada5b 100644
--- a/arch/arc/include/asm/entry.h
+++ b/arch/arc/include/asm/entry.h
@@ -343,18 +343,12 @@
*-------------------------------------------------------------*/
.macro SAVE_ALL_EXCEPTION marker
+ st \marker, [sp, 8]
+ st r0, [sp, 4] /* orig_r0, needed only for sys calls */
+
/* Restore r9 used to code the early prologue */
EXCPN_PROLOG_RESTORE_REG r9
- /* Save the complete regfile now */
-
- /* orig_r8 marker:
- * syscalls -> 1 to NR_SYSCALLS
- * Exceptions -> NR_SYSCALLS + 1
- * Break-point-> NR_SYSCALLS + 2
- */
- st \marker, [sp, 8]
- st r0, [sp, 4] /* orig_r0, needed only for sys calls */
SAVE_CALLER_SAVED
st.a r26, [sp, -4] /* gp */
st.a fp, [sp, -4]
@@ -384,14 +378,25 @@
* Save scratch regs for exceptions
*-------------------------------------------------------------*/
.macro SAVE_ALL_SYS
- SAVE_ALL_EXCEPTION (NR_syscalls + 1)
+ SAVE_ALL_EXCEPTION orig_r8_IS_EXCPN
.endm
/*--------------------------------------------------------------
* Save scratch regs for sys calls
*-------------------------------------------------------------*/
.macro SAVE_ALL_TRAP
- SAVE_ALL_EXCEPTION r8
+ /*
+ * Setup pt_regs->orig_r8.
+ * Encode syscall number (r8) in upper short word of event type (r9)
+ * N.B. #1: This is already endian safe (see ptrace.h)
+ * #2: Only r9 can be used as scratch as it is already clobbered
+ * and it's contents are no longer needed by the latter part
+ * of exception prologue
+ */
+ lsl r9, r8, 16
+ or r9, r9, orig_r8_IS_SCALL
+
+ SAVE_ALL_EXCEPTION r9
.endm
/*--------------------------------------------------------------
@@ -442,7 +447,7 @@
ld r9, [@int1_saved_reg]
/* now we are ready to save the remaining context :) */
- st -1, [sp, 8] /* orig_r8, -1 for interuppt level one */
+ st orig_r8_IS_IRQ1, [sp, 8] /* Event Type */
st 0, [sp, 4] /* orig_r0 , N/A for IRQ */
SAVE_CALLER_SAVED
st.a r26, [sp, -4] /* gp */
diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index 72754a2..1711d56 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -81,7 +81,13 @@ struct pt_regs {
long r0;
long sp; /* user/kernel sp depending on where we came from */
long orig_r0;
- long orig_r8; /*to distinguish bet excp, sys call, int1 or int2 */
+ /*to distinguish bet excp, syscall, irq */
+#ifdef CONFIG_CPU_BIG_ENDIAN
+ /* so that assembly code is same for LE/BE */
+ unsigned long orig_r8:16, event:16;
+#else
+ unsigned long event:16, orig_r8:16;
+#endif
};
/* Callee saved registers - need to be saved only when you are scheduled out */
@@ -126,9 +132,8 @@ struct user_regs_struct {
sp; \
})
-/* return 1 if in syscall, 0 if Intr or Exception */
-#define in_syscall(regs) (((regs->orig_r8) >= 0 && \
- (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
+#define in_syscall(regs) (regs->event & orig_r8_IS_SCALL)
+#define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT)
#define current_pt_regs() \
({ \
@@ -140,6 +145,13 @@ struct user_regs_struct {
#endif /* !__ASSEMBLY__ */
+#define orig_r8_IS_SCALL 0x0001
+#define orig_r8_IS_SCALL_RESTARTED 0x0002
+#define orig_r8_IS_BRKPT 0x0004
+#define orig_r8_IS_EXCPN 0x0004
+#define orig_r8_IS_IRQ1 0x0010
+#define orig_r8_IS_IRQ2 0x0020
+
#endif /* __KERNEL__ */
#endif /* __ASM_PTRACE_H */
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index d625b77..ce8670d 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -350,8 +350,8 @@ ARC_EXIT EV_Extension
trap_with_param:
- ;make sure orig_r8 is a positive value
- st NR_syscalls + 2, [sp, PT_orig_r8]
+ ; stop_pc info by gdb needs this info
+ st orig_r8_IS_BRKPT, [sp, PT_orig_r8]
mov r0, r12
lr r1, [efa]
--
1.7.4.1
next prev parent reply other threads:[~2013-01-24 10:56 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-24 10:50 [PATCH v3 00/71] Synopsys ARC Linux kernel Port (Part #1) Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 01/71] ARC: Generic Headers Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 02/71] ARC: Build system: Makefiles, Kconfig, Linker script Vineet Gupta
2013-01-28 6:29 ` Vineet Gupta
2013-01-28 18:44 ` Sam Ravnborg
2013-01-29 13:45 ` Vineet Gupta
2013-01-29 17:52 ` Sam Ravnborg
2013-02-11 11:29 ` James Hogan
2013-02-11 11:44 ` Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 06/71] ARC: uaccess friends Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 11/71] ARC: Fundamental ARCH data-types/defines Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 17/71] ARC: Syscall support (no-legacy-syscall ABI) Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 18/71] ARC: Process-creation/scheduling/idle-loop Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 19/71] ARC: Timers/counters/delay management Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 20/71] ARC: Signal handling Vineet Gupta
2013-02-11 7:26 ` pt_regs leak into userspace (was Re: [PATCH v3 20/71] ARC: Signal handling) Vineet Gupta
2013-02-11 9:36 ` Jonas Bonn
2013-02-11 10:13 ` Vineet Gupta
2013-02-11 10:28 ` James Hogan
2013-02-11 10:53 ` Jonas Bonn
2013-02-11 10:57 ` James Hogan
2013-02-11 11:01 ` James Hogan
2013-02-11 11:22 ` Vineet Gupta
2013-02-11 12:12 ` Jonas Bonn
2013-02-11 12:37 ` Vineet Gupta
2013-02-11 13:02 ` Jonas Bonn
2013-02-11 13:08 ` Vineet Gupta
2013-02-11 10:30 ` Jonas Bonn
2013-02-11 14:07 ` Al Viro
2013-02-15 7:23 ` Jonas Bonn
2013-02-15 7:35 ` Vineet Gupta
2013-01-24 10:50 ` Vineet Gupta [this message]
2013-01-24 10:50 ` [PATCH v3 22/71] ARC: [Review] Prevent incorrect syscall restarts Vineet Gupta
2013-01-28 7:42 ` Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 23/71] ARC: Cache Flush Management Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 29/71] ARC: I/O and DMA Mappings Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 30/71] ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 32/71] ARC: [DeviceTree] Basic support Vineet Gupta
2013-01-28 7:40 ` Vineet Gupta
2013-01-28 10:21 ` James Hogan
2013-01-29 9:53 ` Vineet Gupta
2013-01-29 10:06 ` James Hogan
2013-01-29 13:25 ` Rob Herring
2013-01-29 13:39 ` Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 33/71] ARC: [DeviceTree] Convert some Kconfig items to runtime values Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 34/71] ARC: [plat-arcfpga]: Enabling DeviceTree for Angel4 board Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 42/71] ARC: Module support Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 44/71] ARC: SMP support Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 48/71] ARC: kprobes support Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 57/71] ARC: Hostlink Pseudo-Driver for Metaware Debugger Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 58/71] ARC: UAPI Disintegrate arch/arc/include/asm Vineet Gupta
2013-01-28 7:36 ` Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 59/71] ARC: Add support for ioremap_prot API Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 62/71] ARC: [Review] Multi-platform image #2: Board callback Infrastructure Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 69/71] ARC: [plat-arcfpga] defconfig for fully loaded ARC Linux Vineet Gupta
2013-01-24 10:50 ` [PATCH v3 70/71] ARC: Provide a default serial.h for uart drivers needing BASE_BAUD Vineet Gupta
2013-01-24 11:01 ` [PATCH v3 45/71] ARC: DWARF2 .debug_frame based stack unwinder Vineet Gupta
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=1359024639-21915-10-git-send-email-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).