Skip to contentSkip to conversation

SH-5: struct pt_regs:syscall_nr is unsigned.

PATCH In review Roel Kluin 2 participants 2 messages Apr 23, 2009 – Apr 27, 2009 SuperH

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 SH-5: struct pt_regs:syscall_nr is unsigned.

vi arch/sh/include/asm/ptrace.h +9
And note that struct pt_regs:syscall_nr is unsigned.

So I think something like the patch below is required, isn't it? As an alternative to the patch below, syscall_nr could become signed. what is preferred? --------------------------->8-------------8<------------------------------ In restore_sigcontext() syscall_nr is set to -1, but it is unsigned for SH-5.

---

arch/sh/include/asm/syscall_64.h +1 -1
index c3561ca..291fc86 100644
@@ -9,7 +9,7 @@
 static inline long syscall_get_nr(struct task_struct *task,
 				  struct pt_regs *regs)
 {
-	return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
+	return (regs->syscall_nr != -1) ? regs->regs[9] : -1L;
 }
 
 static inline void syscall_rollback(struct task_struct *task,
arch/sh/kernel/signal_64.c +2 -2
index 0663a0e..b851141 100644
@@ -51,7 +51,7 @@ static inline void
 handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
 {
 	/* If we're not from a syscall, bail out */
-	if (regs->syscall_nr < 0)
+	if (regs->syscall_nr = -1)
 		return;
 
 	/* check for system call restart.. */
@@ -127,7 +127,7 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
 
 no_signal:
 	/* Did we come from a system call? */
-	if (regs->syscall_nr >= 0) {
+	if (regs->syscall_nr != -1) {
 		/* Restart the system call - no handlers present */
 		switch (regs->regs[REG_RET]) {
 		case -ERESTARTNOHAND:
#1 lore raw
Quoted 11 lines · Roel Kluin

vi arch/sh/include/asm/ptrace.h +9
And note that struct pt_regs:syscall_nr is unsigned.

So I think something like the patch below is required, isn't it? As an alternative to the patch below, syscall_nr could become signed. what is preferred? --------------------------->8-------------8<------------------------------ In restore_sigcontext() syscall_nr is set to -1, but it is unsigned for SH-5.

syscall_nr should be signed, yes (the assembly code expects that as well). I've switched it over now, good spotting!