[PATCH 2/4] UML - Remove unused sigcontext accessors

2008-02-12 Thread Jeff Dike
The macros which extract registers from a struct sigcontext are no
longer needed and can be removed.  They are starting not to build
anyway, given the removal of the 'e' and 'r' from register names
during the x86 merge.

Cc: Jiri Olsa <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/sys-i386/user-offsets.c   |   27 ---
 arch/um/sys-x86_64/user-offsets.c |   28 
 2 files changed, 55 deletions(-)

Index: linux-2.6.22/arch/um/sys-i386/user-offsets.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/user-offsets.c   2007-11-14 
10:33:29.0 -0500
+++ linux-2.6.22/arch/um/sys-i386/user-offsets.c2008-02-11 
20:10:56.0 -0500
@@ -17,36 +17,9 @@
 
 void foo(void)
 {
-   OFFSET(HOST_SC_IP, sigcontext, eip);
-   OFFSET(HOST_SC_SP, sigcontext, esp);
-   OFFSET(HOST_SC_FS, sigcontext, fs);
-   OFFSET(HOST_SC_GS, sigcontext, gs);
-   OFFSET(HOST_SC_DS, sigcontext, ds);
-   OFFSET(HOST_SC_ES, sigcontext, es);
-   OFFSET(HOST_SC_SS, sigcontext, ss);
-   OFFSET(HOST_SC_CS, sigcontext, cs);
-   OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
-   OFFSET(HOST_SC_EAX, sigcontext, eax);
-   OFFSET(HOST_SC_EBX, sigcontext, ebx);
-   OFFSET(HOST_SC_ECX, sigcontext, ecx);
-   OFFSET(HOST_SC_EDX, sigcontext, edx);
-   OFFSET(HOST_SC_EDI, sigcontext, edi);
-   OFFSET(HOST_SC_ESI, sigcontext, esi);
-   OFFSET(HOST_SC_EBP, sigcontext, ebp);
OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
OFFSET(HOST_SC_ERR, sigcontext, err);
OFFSET(HOST_SC_CR2, sigcontext, cr2);
-   OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate);
-   OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
-   OFFSET(HOST_SC_FP_CW, _fpstate, cw);
-   OFFSET(HOST_SC_FP_SW, _fpstate, sw);
-   OFFSET(HOST_SC_FP_TAG, _fpstate, tag);
-   OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff);
-   OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel);
-   OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff);
-   OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel);
-   OFFSET(HOST_SC_FP_ST, _fpstate, _st);
-   OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
 
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fpxregs_struct));
Index: linux-2.6.22/arch/um/sys-x86_64/user-offsets.c
===
--- linux-2.6.22.orig/arch/um/sys-x86_64/user-offsets.c 2007-11-14 
10:33:29.0 -0500
+++ linux-2.6.22/arch/um/sys-x86_64/user-offsets.c  2008-02-11 
19:21:27.0 -0500
@@ -19,37 +19,9 @@
 
 void foo(void)
 {
-   OFFSET(HOST_SC_RBX, sigcontext, rbx);
-   OFFSET(HOST_SC_RCX, sigcontext, rcx);
-   OFFSET(HOST_SC_RDX, sigcontext, rdx);
-   OFFSET(HOST_SC_RSI, sigcontext, rsi);
-   OFFSET(HOST_SC_RDI, sigcontext, rdi);
-   OFFSET(HOST_SC_RBP, sigcontext, rbp);
-   OFFSET(HOST_SC_RAX, sigcontext, rax);
-   OFFSET(HOST_SC_R8, sigcontext, r8);
-   OFFSET(HOST_SC_R9, sigcontext, r9);
-   OFFSET(HOST_SC_R10, sigcontext, r10);
-   OFFSET(HOST_SC_R11, sigcontext, r11);
-   OFFSET(HOST_SC_R12, sigcontext, r12);
-   OFFSET(HOST_SC_R13, sigcontext, r13);
-   OFFSET(HOST_SC_R14, sigcontext, r14);
-   OFFSET(HOST_SC_R15, sigcontext, r15);
-   OFFSET(HOST_SC_IP, sigcontext, rip);
-   OFFSET(HOST_SC_SP, sigcontext, rsp);
OFFSET(HOST_SC_CR2, sigcontext, cr2);
OFFSET(HOST_SC_ERR, sigcontext, err);
OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
-   OFFSET(HOST_SC_CS, sigcontext, cs);
-   OFFSET(HOST_SC_FS, sigcontext, fs);
-   OFFSET(HOST_SC_GS, sigcontext, gs);
-   OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
-   OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
-#if 0
-   OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax);
-   OFFSET(HOST_SC_DS, sigcontext, ds);
-   OFFSET(HOST_SC_ES, sigcontext, es);
-   OFFSET(HOST_SC_SS, sigcontext, ss);
-#endif
 
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
DEFINE(HOST_XFP_SIZE, 0);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Add !UML dependencies

2007-11-28 Thread Jeff Dike
From: Al Viro <[EMAIL PROTECTED]>

That's not enough, unfortunately.  If we go that way, we need to add
dependencies on !UML for several options.

[ jdike - "not enough" refers to my patch which enables X86_32 and
RWSEM_XCHGADD_ALGORITHM in UML's Kconfig.i386 ]

Signed-off-by: Al Viro <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 drivers/crypto/Kconfig |2 +-
 kernel/Kconfig.instrumentation |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6.22/drivers/crypto/Kconfig
===
--- linux-2.6.22.orig/drivers/crypto/Kconfig2007-11-21 11:49:37.0 
-0500
+++ linux-2.6.22/drivers/crypto/Kconfig 2007-11-26 11:54:18.0 -0500
@@ -12,7 +12,7 @@ if CRYPTO_HW
 
 config CRYPTO_DEV_PADLOCK
tristate "Support for VIA PadLock ACE"
-   depends on X86_32
+   depends on X86_32 && !UML
select CRYPTO_ALGAPI
help
  Some VIA processors come with an integrated crypto engine
Index: linux-2.6.22/kernel/Kconfig.instrumentation
===
--- linux-2.6.22.orig/kernel/Kconfig.instrumentation2007-11-14 
10:33:42.0 -0500
+++ linux-2.6.22/kernel/Kconfig.instrumentation 2007-11-26 11:54:18.0 
-0500
@@ -21,7 +21,7 @@ config PROFILING
 config OPROFILE
tristate "OProfile system profiling (EXPERIMENTAL)"
depends on PROFILING
-   depends on ALPHA || ARM || BLACKFIN || X86_32 || IA64 || M32R || MIPS 
|| PARISC || PPC || S390 || SUPERH || SPARC || X86_64
+   depends on (ALPHA || ARM || BLACKFIN || X86_32 || IA64 || M32R || MIPS 
|| PARISC || PPC || S390 || SUPERH || SPARC || X86_64) && !UML
help
  OProfile is a profiling system capable of profiling the
  whole system, include the kernel, kernel modules, libraries,
@@ -32,7 +32,7 @@ config OPROFILE
 config KPROBES
bool "Kprobes"
depends on KALLSYMS && MODULES
-   depends on X86_32 || IA64 || PPC || S390 || SPARC64 || X86_64 || AVR32
+   depends on (X86_32 || IA64 || PPC || S390 || SPARC64 || X86_64 || 
AVR32) && !UML
help
  Kprobes allows you to trap at almost any kernel address and
  execute a callback function.  register_kprobe() establishes
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Add !UML dependencies

2007-11-28 Thread Jeff Dike
From: Al Viro [EMAIL PROTECTED]

That's not enough, unfortunately.  If we go that way, we need to add
dependencies on !UML for several options.

[ jdike - not enough refers to my patch which enables X86_32 and
RWSEM_XCHGADD_ALGORITHM in UML's Kconfig.i386 ]

Signed-off-by: Al Viro [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 drivers/crypto/Kconfig |2 +-
 kernel/Kconfig.instrumentation |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6.22/drivers/crypto/Kconfig
===
--- linux-2.6.22.orig/drivers/crypto/Kconfig2007-11-21 11:49:37.0 
-0500
+++ linux-2.6.22/drivers/crypto/Kconfig 2007-11-26 11:54:18.0 -0500
@@ -12,7 +12,7 @@ if CRYPTO_HW
 
 config CRYPTO_DEV_PADLOCK
tristate Support for VIA PadLock ACE
-   depends on X86_32
+   depends on X86_32  !UML
select CRYPTO_ALGAPI
help
  Some VIA processors come with an integrated crypto engine
Index: linux-2.6.22/kernel/Kconfig.instrumentation
===
--- linux-2.6.22.orig/kernel/Kconfig.instrumentation2007-11-14 
10:33:42.0 -0500
+++ linux-2.6.22/kernel/Kconfig.instrumentation 2007-11-26 11:54:18.0 
-0500
@@ -21,7 +21,7 @@ config PROFILING
 config OPROFILE
tristate OProfile system profiling (EXPERIMENTAL)
depends on PROFILING
-   depends on ALPHA || ARM || BLACKFIN || X86_32 || IA64 || M32R || MIPS 
|| PARISC || PPC || S390 || SUPERH || SPARC || X86_64
+   depends on (ALPHA || ARM || BLACKFIN || X86_32 || IA64 || M32R || MIPS 
|| PARISC || PPC || S390 || SUPERH || SPARC || X86_64)  !UML
help
  OProfile is a profiling system capable of profiling the
  whole system, include the kernel, kernel modules, libraries,
@@ -32,7 +32,7 @@ config OPROFILE
 config KPROBES
bool Kprobes
depends on KALLSYMS  MODULES
-   depends on X86_32 || IA64 || PPC || S390 || SPARC64 || X86_64 || AVR32
+   depends on (X86_32 || IA64 || PPC || S390 || SPARC64 || X86_64 || 
AVR32)  !UML
help
  Kprobes allows you to trap at almost any kernel address and
  execute a callback function.  register_kprobe() establishes
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - use ptrace directly in libc code

2007-11-20 Thread Jeff Dike
Some register accessor cleanups -
userspace() was calling restore_registers and save_registers for no
reason, since userspace() is on the libc side of the house, and these
add no value over calling ptrace directly
init_thread_registers and get_safe_registers were the same thing,
so init_thread_registers is gone

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/registers.h |1 -
 arch/um/kernel/process.c|2 +-
 arch/um/os-Linux/registers.c|   13 -
 arch/um/os-Linux/skas/process.c |9 +++--
 4 files changed, 12 insertions(+), 13 deletions(-)

Index: linux-2.6.22/arch/um/os-Linux/skas/process.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/skas/process.c   2007-11-20 
13:05:22.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/skas/process.c2007-11-20 
13:05:45.0 -0500
@@ -298,7 +298,9 @@ void userspace(struct uml_pt_regs *regs)
nsecs += os_nsecs();
 
while (1) {
-   restore_registers(pid, regs);
+   if (ptrace(PTRACE_SETREGS, pid, 0, regs->gp))
+   panic("userspace - PTRACE_SETREGS failed, "
+ "errno = %d\n", errno);
 
/* Now we set local_using_sysemu to be used for one loop */
local_using_sysemu = get_using_sysemu();
@@ -318,7 +320,10 @@ void userspace(struct uml_pt_regs *regs)
  errno);
 
regs->is_user = 1;
-   save_registers(pid, regs);
+   if (ptrace(PTRACE_GETREGS, pid, 0, regs->gp))
+   panic("userspace - saving registers failed, "
+ "errno = %d\n", errno);
+
UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */
 
if (WIFSTOPPED(status)) {
@@ -341,7 +346,7 @@ void userspace(struct uml_pt_regs *regs)
break;
case SIGVTALRM:
now = os_nsecs();
-   if(now < nsecs)
+   if (now < nsecs)
break;
block_signals();
(*sig_info[sig])(sig, regs);
Index: linux-2.6.22/arch/um/kernel/process.c
===
--- linux-2.6.22.orig/arch/um/kernel/process.c  2007-11-20 13:05:20.0 
-0500
+++ linux-2.6.22/arch/um/kernel/process.c   2007-11-20 13:05:24.0 
-0500
@@ -200,7 +200,7 @@ int copy_thread(int nr, unsigned long cl
arch_copy_thread(>thread.arch, >thread.arch);
}
else {
-   init_thread_registers(>thread.regs.regs);
+   get_safe_registers(p->thread.regs.regs.gp);
p->thread.request.u.thread = current->thread.request.u.thread;
handler = new_thread_handler;
}
Index: linux-2.6.22/arch/um/os-Linux/registers.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/registers.c  2007-11-20 
13:05:20.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/registers.c   2007-11-20 13:05:24.0 
-0500
@@ -10,15 +10,6 @@
 #include "sysdep/ptrace.h"
 #include "user.h"
 
-/* This is set once at boot time and not changed thereafter */
-
-static unsigned long exec_regs[MAX_REG_NR];
-
-void init_thread_registers(struct uml_pt_regs *to)
-{
-   memcpy(to->gp, exec_regs, sizeof(to->gp));
-}
-
 void save_registers(int pid, struct uml_pt_regs *regs)
 {
int err;
@@ -39,6 +30,10 @@ void restore_registers(int pid, struct u
  "errno = %d\n", errno);
 }
 
+/* This is set once at boot time and not changed thereafter */
+
+static unsigned long exec_regs[MAX_REG_NR];
+
 void init_registers(int pid)
 {
int err;
Index: linux-2.6.22/arch/um/include/registers.h
===
--- linux-2.6.22.orig/arch/um/include/registers.h   2007-11-20 
13:05:20.0 -0500
+++ linux-2.6.22/arch/um/include/registers.h2007-11-20 13:05:24.0 
-0500
@@ -9,7 +9,6 @@
 #include "sysdep/ptrace.h"
 #include "sysdep/archsetjmp.h"
 
-extern void init_thread_registers(struct uml_pt_regs *to);
 extern int save_fp_registers(int pid, unsigned long *fp_regs);
 extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - use ptrace directly in libc code

2007-11-20 Thread Jeff Dike
Some register accessor cleanups -
userspace() was calling restore_registers and save_registers for no
reason, since userspace() is on the libc side of the house, and these
add no value over calling ptrace directly
init_thread_registers and get_safe_registers were the same thing,
so init_thread_registers is gone

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/include/registers.h |1 -
 arch/um/kernel/process.c|2 +-
 arch/um/os-Linux/registers.c|   13 -
 arch/um/os-Linux/skas/process.c |9 +++--
 4 files changed, 12 insertions(+), 13 deletions(-)

Index: linux-2.6.22/arch/um/os-Linux/skas/process.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/skas/process.c   2007-11-20 
13:05:22.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/skas/process.c2007-11-20 
13:05:45.0 -0500
@@ -298,7 +298,9 @@ void userspace(struct uml_pt_regs *regs)
nsecs += os_nsecs();
 
while (1) {
-   restore_registers(pid, regs);
+   if (ptrace(PTRACE_SETREGS, pid, 0, regs-gp))
+   panic(userspace - PTRACE_SETREGS failed, 
+ errno = %d\n, errno);
 
/* Now we set local_using_sysemu to be used for one loop */
local_using_sysemu = get_using_sysemu();
@@ -318,7 +320,10 @@ void userspace(struct uml_pt_regs *regs)
  errno);
 
regs-is_user = 1;
-   save_registers(pid, regs);
+   if (ptrace(PTRACE_GETREGS, pid, 0, regs-gp))
+   panic(userspace - saving registers failed, 
+ errno = %d\n, errno);
+
UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */
 
if (WIFSTOPPED(status)) {
@@ -341,7 +346,7 @@ void userspace(struct uml_pt_regs *regs)
break;
case SIGVTALRM:
now = os_nsecs();
-   if(now  nsecs)
+   if (now  nsecs)
break;
block_signals();
(*sig_info[sig])(sig, regs);
Index: linux-2.6.22/arch/um/kernel/process.c
===
--- linux-2.6.22.orig/arch/um/kernel/process.c  2007-11-20 13:05:20.0 
-0500
+++ linux-2.6.22/arch/um/kernel/process.c   2007-11-20 13:05:24.0 
-0500
@@ -200,7 +200,7 @@ int copy_thread(int nr, unsigned long cl
arch_copy_thread(current-thread.arch, p-thread.arch);
}
else {
-   init_thread_registers(p-thread.regs.regs);
+   get_safe_registers(p-thread.regs.regs.gp);
p-thread.request.u.thread = current-thread.request.u.thread;
handler = new_thread_handler;
}
Index: linux-2.6.22/arch/um/os-Linux/registers.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/registers.c  2007-11-20 
13:05:20.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/registers.c   2007-11-20 13:05:24.0 
-0500
@@ -10,15 +10,6 @@
 #include sysdep/ptrace.h
 #include user.h
 
-/* This is set once at boot time and not changed thereafter */
-
-static unsigned long exec_regs[MAX_REG_NR];
-
-void init_thread_registers(struct uml_pt_regs *to)
-{
-   memcpy(to-gp, exec_regs, sizeof(to-gp));
-}
-
 void save_registers(int pid, struct uml_pt_regs *regs)
 {
int err;
@@ -39,6 +30,10 @@ void restore_registers(int pid, struct u
  errno = %d\n, errno);
 }
 
+/* This is set once at boot time and not changed thereafter */
+
+static unsigned long exec_regs[MAX_REG_NR];
+
 void init_registers(int pid)
 {
int err;
Index: linux-2.6.22/arch/um/include/registers.h
===
--- linux-2.6.22.orig/arch/um/include/registers.h   2007-11-20 
13:05:20.0 -0500
+++ linux-2.6.22/arch/um/include/registers.h2007-11-20 13:05:24.0 
-0500
@@ -9,7 +9,6 @@
 #include sysdep/ptrace.h
 #include sysdep/archsetjmp.h
 
-extern void init_thread_registers(struct uml_pt_regs *to);
 extern int save_fp_registers(int pid, unsigned long *fp_regs);
 extern int restore_fp_registers(int pid, unsigned long *fp_regs);
 extern int save_fpx_registers(int pid, unsigned long *fp_regs);
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4] UML - Remove unused variables in the context switcher

2007-11-15 Thread Jeff Dike
On Thu, Nov 15, 2007 at 04:15:21PM -0800, Andrew Morton wrote:
> I assumed from the above that Karol was the author of this patch.  Please
> let me know if that was wrong.

He is - I forgot the From line...

Jeff

-- 
Work email - jdike at linux dot intel dot com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4] UML - Remove unused variables in the context switcher

2007-11-15 Thread Andrew Morton
On Wed, 14 Nov 2007 14:20:49 -0500
Jeff Dike <[EMAIL PROTECTED]> wrote:

> This patch removes a variable which was not used in two functions.
> Yet another code cleanup, nothing really significant.
> 
> Please note that I could not test this on x86_64. I don't have the
> hardware for it.
> 
> [ jdike - Bits of tidying around the affected code.  Also, it's fine on
> x86_64 ]
> 
> Signed-off-by: Karol Swietlicki <[EMAIL PROTECTED]>
> Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>

I assumed from the above that Karol was the author of this patch.  Please
let me know if that was wrong.

We communicate authorship by putting a From: line at the very start of the
changelog.  If that line is not present then we use the From: from the
email headers.

Thanks.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4] UML - Remove unused variables in the context switcher

2007-11-15 Thread Andrew Morton
On Wed, 14 Nov 2007 14:20:49 -0500
Jeff Dike [EMAIL PROTECTED] wrote:

 This patch removes a variable which was not used in two functions.
 Yet another code cleanup, nothing really significant.
 
 Please note that I could not test this on x86_64. I don't have the
 hardware for it.
 
 [ jdike - Bits of tidying around the affected code.  Also, it's fine on
 x86_64 ]
 
 Signed-off-by: Karol Swietlicki [EMAIL PROTECTED]
 Signed-off-by: Jeff Dike [EMAIL PROTECTED]

I assumed from the above that Karol was the author of this patch.  Please
let me know if that was wrong.

We communicate authorship by putting a From: line at the very start of the
changelog.  If that line is not present then we use the From: from the
email headers.

Thanks.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4] UML - Remove unused variables in the context switcher

2007-11-15 Thread Jeff Dike
On Thu, Nov 15, 2007 at 04:15:21PM -0800, Andrew Morton wrote:
 I assumed from the above that Karol was the author of this patch.  Please
 let me know if that was wrong.

He is - I forgot the From line...

Jeff

-- 
Work email - jdike at linux dot intel dot com
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Remove unused variables in the context switcher

2007-11-14 Thread Jeff Dike
This patch removes a variable which was not used in two functions.
Yet another code cleanup, nothing really significant.

Please note that I could not test this on x86_64. I don't have the
hardware for it.

[ jdike - Bits of tidying around the affected code.  Also, it's fine on
x86_64 ]

Signed-off-by: Karol Swietlicki <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/kernel/process.c  |   19 ---
 arch/um/sys-i386/ptrace.c |6 +++---
 arch/um/sys-i386/tls.c|2 +-
 arch/um/sys-x86_64/syscalls.c |2 +-
 4 files changed, 13 insertions(+), 16 deletions(-)

Index: linux-2.6.22/arch/um/kernel/process.c
===
--- linux-2.6.22.orig/arch/um/kernel/process.c  2007-11-14 13:29:51.0 
-0500
+++ linux-2.6.22/arch/um/kernel/process.c   2007-11-14 13:38:36.0 
-0500
@@ -82,12 +82,12 @@ static inline void set_current(struct ta
{ external_pid(task), task });
 }
 
-extern void arch_switch_to(struct task_struct *from, struct task_struct *to);
+extern void arch_switch_to(struct task_struct *to);
 
 void *_switch_to(void *prev, void *next, void *last)
 {
struct task_struct *from = prev;
-   struct task_struct *to= next;
+   struct task_struct *to = next;
 
to->thread.prev_sched = from;
set_current(to);
@@ -95,16 +95,15 @@ void *_switch_to(void *prev, void *next,
do {
current->thread.saved_task = NULL;
 
-   switch_threads(>thread.switch_buf,
-  >thread.switch_buf);
+   switch_threads(>thread.switch_buf, 
>thread.switch_buf);
 
-   arch_switch_to(current->thread.prev_sched, current);
+   arch_switch_to(current);
 
if (current->thread.saved_task)
show_regs(&(current->thread.regs));
-   next= current->thread.saved_task;
-   prev= current;
-   } while(current->thread.saved_task);
+   next = current->thread.saved_task;
+   prev = current;
+   } while (current->thread.saved_task);
 
return current->thread.prev_sched;
 
@@ -162,8 +161,6 @@ void new_thread_handler(void)
 void fork_handler(void)
 {
force_flush_all();
-   if (current->thread.prev_sched == NULL)
-   panic("blech");
 
schedule_tail(current->thread.prev_sched);
 
@@ -172,7 +169,7 @@ void fork_handler(void)
 * arch_switch_to isn't needed. We could want to apply this to
 * improve performance. -bb
 */
-   arch_switch_to(current->thread.prev_sched, current);
+   arch_switch_to(current);
 
current->thread.prev_sched = NULL;
 
Index: linux-2.6.22/arch/um/sys-i386/ptrace.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/ptrace.c 2007-11-14 13:29:51.0 
-0500
+++ linux-2.6.22/arch/um/sys-i386/ptrace.c  2007-11-14 13:37:30.0 
-0500
@@ -8,11 +8,11 @@
 #include "asm/uaccess.h"
 #include "skas.h"
 
-extern int arch_switch_tls(struct task_struct *from, struct task_struct *to);
+extern int arch_switch_tls(struct task_struct *to);
 
-void arch_switch_to(struct task_struct *from, struct task_struct *to)
+void arch_switch_to(struct task_struct *to)
 {
-   int err = arch_switch_tls(from, to);
+   int err = arch_switch_tls(to);
if (!err)
return;
 
Index: linux-2.6.22/arch/um/sys-i386/tls.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/tls.c2007-11-14 13:29:51.0 
-0500
+++ linux-2.6.22/arch/um/sys-i386/tls.c 2007-11-14 13:37:30.0 -0500
@@ -172,7 +172,7 @@ void clear_flushed_tls(struct task_struc
  * SKAS patch.
  */
 
-int arch_switch_tls(struct task_struct *from, struct task_struct *to)
+int arch_switch_tls(struct task_struct *to)
 {
if (!host_supports_tls)
return 0;
Index: linux-2.6.22/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.22.orig/arch/um/sys-x86_64/syscalls.c 2007-11-14 
13:29:51.0 -0500
+++ linux-2.6.22/arch/um/sys-x86_64/syscalls.c  2007-11-14 13:37:30.0 
-0500
@@ -105,7 +105,7 @@ long sys_clone(unsigned long clone_flags
return ret;
 }
 
-void arch_switch_to(struct task_struct *from, struct task_struct *to)
+void arch_switch_to(struct task_struct *to)
 {
if ((to->thread.arch.fs == 0) || (to->mm == NULL))
return;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Remove unused variables in the context switcher

2007-11-14 Thread Jeff Dike
This patch removes a variable which was not used in two functions.
Yet another code cleanup, nothing really significant.

Please note that I could not test this on x86_64. I don't have the
hardware for it.

[ jdike - Bits of tidying around the affected code.  Also, it's fine on
x86_64 ]

Signed-off-by: Karol Swietlicki [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/kernel/process.c  |   19 ---
 arch/um/sys-i386/ptrace.c |6 +++---
 arch/um/sys-i386/tls.c|2 +-
 arch/um/sys-x86_64/syscalls.c |2 +-
 4 files changed, 13 insertions(+), 16 deletions(-)

Index: linux-2.6.22/arch/um/kernel/process.c
===
--- linux-2.6.22.orig/arch/um/kernel/process.c  2007-11-14 13:29:51.0 
-0500
+++ linux-2.6.22/arch/um/kernel/process.c   2007-11-14 13:38:36.0 
-0500
@@ -82,12 +82,12 @@ static inline void set_current(struct ta
{ external_pid(task), task });
 }
 
-extern void arch_switch_to(struct task_struct *from, struct task_struct *to);
+extern void arch_switch_to(struct task_struct *to);
 
 void *_switch_to(void *prev, void *next, void *last)
 {
struct task_struct *from = prev;
-   struct task_struct *to= next;
+   struct task_struct *to = next;
 
to-thread.prev_sched = from;
set_current(to);
@@ -95,16 +95,15 @@ void *_switch_to(void *prev, void *next,
do {
current-thread.saved_task = NULL;
 
-   switch_threads(from-thread.switch_buf,
-  to-thread.switch_buf);
+   switch_threads(from-thread.switch_buf, 
to-thread.switch_buf);
 
-   arch_switch_to(current-thread.prev_sched, current);
+   arch_switch_to(current);
 
if (current-thread.saved_task)
show_regs((current-thread.regs));
-   next= current-thread.saved_task;
-   prev= current;
-   } while(current-thread.saved_task);
+   next = current-thread.saved_task;
+   prev = current;
+   } while (current-thread.saved_task);
 
return current-thread.prev_sched;
 
@@ -162,8 +161,6 @@ void new_thread_handler(void)
 void fork_handler(void)
 {
force_flush_all();
-   if (current-thread.prev_sched == NULL)
-   panic(blech);
 
schedule_tail(current-thread.prev_sched);
 
@@ -172,7 +169,7 @@ void fork_handler(void)
 * arch_switch_to isn't needed. We could want to apply this to
 * improve performance. -bb
 */
-   arch_switch_to(current-thread.prev_sched, current);
+   arch_switch_to(current);
 
current-thread.prev_sched = NULL;
 
Index: linux-2.6.22/arch/um/sys-i386/ptrace.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/ptrace.c 2007-11-14 13:29:51.0 
-0500
+++ linux-2.6.22/arch/um/sys-i386/ptrace.c  2007-11-14 13:37:30.0 
-0500
@@ -8,11 +8,11 @@
 #include asm/uaccess.h
 #include skas.h
 
-extern int arch_switch_tls(struct task_struct *from, struct task_struct *to);
+extern int arch_switch_tls(struct task_struct *to);
 
-void arch_switch_to(struct task_struct *from, struct task_struct *to)
+void arch_switch_to(struct task_struct *to)
 {
-   int err = arch_switch_tls(from, to);
+   int err = arch_switch_tls(to);
if (!err)
return;
 
Index: linux-2.6.22/arch/um/sys-i386/tls.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/tls.c2007-11-14 13:29:51.0 
-0500
+++ linux-2.6.22/arch/um/sys-i386/tls.c 2007-11-14 13:37:30.0 -0500
@@ -172,7 +172,7 @@ void clear_flushed_tls(struct task_struc
  * SKAS patch.
  */
 
-int arch_switch_tls(struct task_struct *from, struct task_struct *to)
+int arch_switch_tls(struct task_struct *to)
 {
if (!host_supports_tls)
return 0;
Index: linux-2.6.22/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.22.orig/arch/um/sys-x86_64/syscalls.c 2007-11-14 
13:29:51.0 -0500
+++ linux-2.6.22/arch/um/sys-x86_64/syscalls.c  2007-11-14 13:37:30.0 
-0500
@@ -105,7 +105,7 @@ long sys_clone(unsigned long clone_flags
return ret;
 }
 
-void arch_switch_to(struct task_struct *from, struct task_struct *to)
+void arch_switch_to(struct task_struct *to)
 {
if ((to-thread.arch.fs == 0) || (to-mm == NULL))
return;
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Fix kernel vs libc symbols clash

2007-11-01 Thread Jeff Dike
commit 2a772652c3971745228a2e40e6575ae594c88365
Author: Jeff Dike <[EMAIL PROTECTED]>
Date:   Tue Oct 16 01:26:45 2007 -0700

uml: fix an IPV6 libc vs kernel symbol clash

On some systems, with IPV6 configured, there is a clash between the kernel's
in6addr_any and the one in libc.

This is handled in the usual (gross) way of defining the kernel symbol out 
of
the way on the gcc command line.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 arch/um/Makefile |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index 989224f..c3a399e 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -60,7 +60,8 @@ SYS_DIR   := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 
 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\"   \
$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap  \
-   -Din6addr_loopback=kernel_in6addr_loopback
+   -Din6addr_loopback=kernel_in6addr_loopback \
+   -Din6addr_any=kernel_in6addr_any
 
 AFLAGS += $(ARCH_INCLUDE)
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Fix kernel vs libc symbols clash

2007-11-01 Thread Jeff Dike
commit 2a772652c3971745228a2e40e6575ae594c88365
Author: Jeff Dike [EMAIL PROTECTED]
Date:   Tue Oct 16 01:26:45 2007 -0700

uml: fix an IPV6 libc vs kernel symbol clash

On some systems, with IPV6 configured, there is a clash between the kernel's
in6addr_any and the one in libc.

This is handled in the usual (gross) way of defining the kernel symbol out 
of
the way on the gcc command line.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 arch/um/Makefile |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index 989224f..c3a399e 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -60,7 +60,8 @@ SYS_DIR   := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 
 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\$(SUBARCH)\   \
$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap  \
-   -Din6addr_loopback=kernel_in6addr_loopback
+   -Din6addr_loopback=kernel_in6addr_loopback \
+   -Din6addr_any=kernel_in6addr_any
 
 AFLAGS += $(ARCH_INCLUDE)
 

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Remove last include of libc asm/page.h

2007-10-31 Thread Jeff Dike
asm/page.h is disappearing from the libc headers and we don't need it anyway.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/kernel/skas/clone.c |1 -
 1 file changed, 1 deletion(-)

Index: linux-2.6.22/arch/um/kernel/skas/clone.c
===
--- linux-2.6.22.orig/arch/um/kernel/skas/clone.c   2007-10-12 
12:09:00.0 -0400
+++ linux-2.6.22/arch/um/kernel/skas/clone.c2007-10-23 12:09:33.0 
-0400
@@ -3,7 +3,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "as-layout.h"
 #include "ptrace_user.h"
 #include "skas.h"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Remove last include of libc asm/page.h

2007-10-31 Thread Jeff Dike
asm/page.h is disappearing from the libc headers and we don't need it anyway.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/kernel/skas/clone.c |1 -
 1 file changed, 1 deletion(-)

Index: linux-2.6.22/arch/um/kernel/skas/clone.c
===
--- linux-2.6.22.orig/arch/um/kernel/skas/clone.c   2007-10-12 
12:09:00.0 -0400
+++ linux-2.6.22/arch/um/kernel/skas/clone.c2007-10-23 12:09:33.0 
-0400
@@ -3,7 +3,6 @@
 #include sys/mman.h
 #include sys/time.h
 #include asm/unistd.h
-#include asm/page.h
 #include as-layout.h
 #include ptrace_user.h
 #include skas.h
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Code tidying under arch/um/os-Linux

2007-10-30 Thread Jeff Dike
From: WANG Cong <[EMAIL PROTECTED]>

This patch contains varied fixes and improvements for some files under
arch/um/os-Linux/, such as a typo fix in a perror message, a missing
argument fix for a printf, some constifying for pointers and so on.

[ jdike - made sigprocmask failure return -errno instead of -1 ]

Signed-off-by: WANG Cong <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/os.h|   12 ++--
 arch/um/os-Linux/file.c |   14 +++---
 arch/um/os-Linux/main.c |   12 
 arch/um/os-Linux/mem.c  |5 -
 arch/um/os-Linux/signal.c   |3 ++-
 arch/um/os-Linux/start_up.c |2 +-
 6 files changed, 28 insertions(+), 20 deletions(-)

Index: linux-2.6.22/arch/um/include/os.h
===
--- linux-2.6.22.orig/arch/um/include/os.h  2007-10-29 12:51:14.0 
-0400
+++ linux-2.6.22/arch/um/include/os.h   2007-10-29 12:56:18.0 -0400
@@ -137,24 +137,24 @@ extern int os_set_owner(int fd, int pid)
 extern int os_mode_fd(int fd, int mode);
 
 extern int os_seek_file(int fd, unsigned long long offset);
-extern int os_open_file(char *file, struct openflags flags, int mode);
+extern int os_open_file(const char *file, struct openflags flags, int mode);
 extern int os_read_file(int fd, void *buf, int len);
 extern int os_write_file(int fd, const void *buf, int count);
-extern int os_file_size(char *file, unsigned long long *size_out);
-extern int os_file_modtime(char *file, unsigned long *modtime);
+extern int os_file_size(const char *file, unsigned long long *size_out);
+extern int os_file_modtime(const char *file, unsigned long *modtime);
 extern int os_pipe(int *fd, int stream, int close_on_exec);
 extern int os_set_fd_async(int fd, int owner);
 extern int os_clear_fd_async(int fd);
 extern int os_set_fd_block(int fd, int blocking);
 extern int os_accept_connection(int fd);
-extern int os_create_unix_socket(char *file, int len, int close_on_exec);
+extern int os_create_unix_socket(const char *file, int len, int close_on_exec);
 extern int os_shutdown_socket(int fd, int r, int w);
 extern void os_close_file(int fd);
 extern int os_rcv_fd(int fd, int *helper_pid_out);
 extern int create_unix_socket(char *file, int len, int close_on_exec);
-extern int os_connect_socket(char *name);
+extern int os_connect_socket(const char *name);
 extern int os_file_type(char *file);
-extern int os_file_mode(char *file, struct openflags *mode_out);
+extern int os_file_mode(const char *file, struct openflags *mode_out);
 extern int os_lock_file(int fd, int excl);
 extern void os_flush_stdout(void);
 extern int os_stat_filesystem(char *path, long *bsize_out,
Index: linux-2.6.22/arch/um/os-Linux/file.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/file.c   2007-10-29 12:51:14.0 
-0400
+++ linux-2.6.22/arch/um/os-Linux/file.c2007-10-29 12:56:18.0 
-0400
@@ -19,7 +19,7 @@
 #include "user.h"
 #include "kern_util.h"
 
-static void copy_stat(struct uml_stat *dst, struct stat64 *src)
+static void copy_stat(struct uml_stat *dst, const struct stat64 *src)
 {
*dst = ((struct uml_stat) {
.ust_dev = src->st_dev, /* device */
@@ -168,7 +168,7 @@ int os_file_type(char *file)
else return OS_TYPE_FILE;
 }
 
-int os_file_mode(char *file, struct openflags *mode_out)
+int os_file_mode(const char *file, struct openflags *mode_out)
 {
int err;
 
@@ -189,7 +189,7 @@ int os_file_mode(char *file, struct open
return err;
 }
 
-int os_open_file(char *file, struct openflags flags, int mode)
+int os_open_file(const char *file, struct openflags flags, int mode)
 {
int fd, err, f = 0;
 
@@ -216,7 +216,7 @@ int os_open_file(char *file, struct open
return fd;
 }
 
-int os_connect_socket(char *name)
+int os_connect_socket(const char *name)
 {
struct sockaddr_un sock;
int fd, err;
@@ -277,7 +277,7 @@ int os_write_file(int fd, const void *bu
return n;
 }
 
-int os_file_size(char *file, unsigned long long *size_out)
+int os_file_size(const char *file, unsigned long long *size_out)
 {
struct uml_stat buf;
int err;
@@ -314,7 +314,7 @@ int os_file_size(char *file, unsigned lo
return 0;
 }
 
-int os_file_modtime(char *file, unsigned long *modtime)
+int os_file_modtime(const char *file, unsigned long *modtime)
 {
struct uml_stat buf;
int err;
@@ -515,7 +515,7 @@ int os_rcv_fd(int fd, int *helper_pid_ou
return new;
 }
 
-int os_create_unix_socket(char *file, int len, int close_on_exec)
+int os_create_unix_socket(const char *file, int len, int close_on_exec)
 {
struct sockaddr_un addr;
int sock, err;
Index: linux-2.6.22/arch/um/os-Linux/main.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/main.c   2007-10-29 

[PATCH 2/4] UML - Code tidying under arch/um/os-Linux

2007-10-30 Thread Jeff Dike
From: WANG Cong [EMAIL PROTECTED]

This patch contains varied fixes and improvements for some files under
arch/um/os-Linux/, such as a typo fix in a perror message, a missing
argument fix for a printf, some constifying for pointers and so on.

[ jdike - made sigprocmask failure return -errno instead of -1 ]

Signed-off-by: WANG Cong [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/include/os.h|   12 ++--
 arch/um/os-Linux/file.c |   14 +++---
 arch/um/os-Linux/main.c |   12 
 arch/um/os-Linux/mem.c  |5 -
 arch/um/os-Linux/signal.c   |3 ++-
 arch/um/os-Linux/start_up.c |2 +-
 6 files changed, 28 insertions(+), 20 deletions(-)

Index: linux-2.6.22/arch/um/include/os.h
===
--- linux-2.6.22.orig/arch/um/include/os.h  2007-10-29 12:51:14.0 
-0400
+++ linux-2.6.22/arch/um/include/os.h   2007-10-29 12:56:18.0 -0400
@@ -137,24 +137,24 @@ extern int os_set_owner(int fd, int pid)
 extern int os_mode_fd(int fd, int mode);
 
 extern int os_seek_file(int fd, unsigned long long offset);
-extern int os_open_file(char *file, struct openflags flags, int mode);
+extern int os_open_file(const char *file, struct openflags flags, int mode);
 extern int os_read_file(int fd, void *buf, int len);
 extern int os_write_file(int fd, const void *buf, int count);
-extern int os_file_size(char *file, unsigned long long *size_out);
-extern int os_file_modtime(char *file, unsigned long *modtime);
+extern int os_file_size(const char *file, unsigned long long *size_out);
+extern int os_file_modtime(const char *file, unsigned long *modtime);
 extern int os_pipe(int *fd, int stream, int close_on_exec);
 extern int os_set_fd_async(int fd, int owner);
 extern int os_clear_fd_async(int fd);
 extern int os_set_fd_block(int fd, int blocking);
 extern int os_accept_connection(int fd);
-extern int os_create_unix_socket(char *file, int len, int close_on_exec);
+extern int os_create_unix_socket(const char *file, int len, int close_on_exec);
 extern int os_shutdown_socket(int fd, int r, int w);
 extern void os_close_file(int fd);
 extern int os_rcv_fd(int fd, int *helper_pid_out);
 extern int create_unix_socket(char *file, int len, int close_on_exec);
-extern int os_connect_socket(char *name);
+extern int os_connect_socket(const char *name);
 extern int os_file_type(char *file);
-extern int os_file_mode(char *file, struct openflags *mode_out);
+extern int os_file_mode(const char *file, struct openflags *mode_out);
 extern int os_lock_file(int fd, int excl);
 extern void os_flush_stdout(void);
 extern int os_stat_filesystem(char *path, long *bsize_out,
Index: linux-2.6.22/arch/um/os-Linux/file.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/file.c   2007-10-29 12:51:14.0 
-0400
+++ linux-2.6.22/arch/um/os-Linux/file.c2007-10-29 12:56:18.0 
-0400
@@ -19,7 +19,7 @@
 #include user.h
 #include kern_util.h
 
-static void copy_stat(struct uml_stat *dst, struct stat64 *src)
+static void copy_stat(struct uml_stat *dst, const struct stat64 *src)
 {
*dst = ((struct uml_stat) {
.ust_dev = src-st_dev, /* device */
@@ -168,7 +168,7 @@ int os_file_type(char *file)
else return OS_TYPE_FILE;
 }
 
-int os_file_mode(char *file, struct openflags *mode_out)
+int os_file_mode(const char *file, struct openflags *mode_out)
 {
int err;
 
@@ -189,7 +189,7 @@ int os_file_mode(char *file, struct open
return err;
 }
 
-int os_open_file(char *file, struct openflags flags, int mode)
+int os_open_file(const char *file, struct openflags flags, int mode)
 {
int fd, err, f = 0;
 
@@ -216,7 +216,7 @@ int os_open_file(char *file, struct open
return fd;
 }
 
-int os_connect_socket(char *name)
+int os_connect_socket(const char *name)
 {
struct sockaddr_un sock;
int fd, err;
@@ -277,7 +277,7 @@ int os_write_file(int fd, const void *bu
return n;
 }
 
-int os_file_size(char *file, unsigned long long *size_out)
+int os_file_size(const char *file, unsigned long long *size_out)
 {
struct uml_stat buf;
int err;
@@ -314,7 +314,7 @@ int os_file_size(char *file, unsigned lo
return 0;
 }
 
-int os_file_modtime(char *file, unsigned long *modtime)
+int os_file_modtime(const char *file, unsigned long *modtime)
 {
struct uml_stat buf;
int err;
@@ -515,7 +515,7 @@ int os_rcv_fd(int fd, int *helper_pid_ou
return new;
 }
 
-int os_create_unix_socket(char *file, int len, int close_on_exec)
+int os_create_unix_socket(const char *file, int len, int close_on_exec)
 {
struct sockaddr_un addr;
int sock, err;
Index: linux-2.6.22/arch/um/os-Linux/main.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/main.c   2007-10-29 12:51:31.0 
-0400

[PATCH 2/4] UML - Tidy recently-moved code

2007-07-30 Thread Jeff Dike
Now that the generic console operations are in a userspace file, we
can do the following:
directly call into libc instead of through the os_* wrappers
eliminate os_window_size since it has only one user

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/chan_user.c |   30 +++---
 arch/um/include/os.h|1 -
 arch/um/os-Linux/file.c |   13 -
 3 files changed, 15 insertions(+), 29 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/chan_user.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_user.c2007-07-27 
11:42:55.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_user.c 2007-07-27 11:46:09.0 
-0400
@@ -23,43 +23,43 @@
 
 void generic_close(int fd, void *unused)
 {
-   os_close_file(fd);
+   close(fd);
 }
 
 int generic_read(int fd, char *c_out, void *unused)
 {
int n;
 
-   n = os_read_file(fd, c_out, sizeof(*c_out));
-
-   if(n == -EAGAIN)
+   n = read(fd, c_out, sizeof(*c_out));
+   if (n > 0)
+   return n;
+   else if (errno == EAGAIN)
return 0;
-   else if(n == 0)
+   else if (n == 0)
return -EIO;
-   return n;
+   return -errno;
 }
 
-/* XXX Trivial wrapper around os_write_file */
+/* XXX Trivial wrapper around write */
 
 int generic_write(int fd, const char *buf, int n, void *unused)
 {
-   return os_write_file(fd, buf, n);
+   return write(fd, buf, n);
 }
 
 int generic_window_size(int fd, void *unused, unsigned short *rows_out,
unsigned short *cols_out)
 {
-   int rows, cols;
+   struct winsize size;
int ret;
 
-   ret = os_window_size(fd, , );
-   if(ret < 0)
-   return ret;
+   if(ioctl(fd, TIOCGWINSZ, ) < 0)
+   return -errno;
 
-   ret = ((*rows_out != rows) || (*cols_out != cols));
+   ret = ((*rows_out != size.ws_row) || (*cols_out != size.ws_col));
 
-   *rows_out = rows;
-   *cols_out = cols;
+   *rows_out = size.ws_row;
+   *cols_out = size.ws_col;
 
return ret;
 }
Index: linux-2.6.21-mm/arch/um/include/os.h
===
--- linux-2.6.21-mm.orig/arch/um/include/os.h   2007-07-27 11:42:27.0 
-0400
+++ linux-2.6.21-mm/arch/um/include/os.h2007-07-27 11:46:18.0 
-0400
@@ -134,7 +134,6 @@ extern void os_print_error(int error, co
 extern int os_get_exec_close(int fd, int *close_on_exec);
 extern int os_set_exec_close(int fd, int close_on_exec);
 extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
-extern int os_window_size(int fd, int *rows, int *cols);
 extern int os_new_tty_pgrp(int fd, int pid);
 extern int os_get_ifname(int fd, char *namebuf);
 extern int os_set_slip(int fd);
Index: linux-2.6.21-mm/arch/um/os-Linux/file.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/file.c2007-07-27 
11:42:27.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/file.c 2007-07-27 11:46:18.0 
-0400
@@ -101,19 +101,6 @@ int os_ioctl_generic(int fd, unsigned in
return err;
 }
 
-int os_window_size(int fd, int *rows, int *cols)
-{
-   struct winsize size;
-
-   if(ioctl(fd, TIOCGWINSZ, ) < 0)
-   return -errno;
-
-   *rows = size.ws_row;
-   *cols = size.ws_col;
-
-   return 0;
-}
-
 int os_new_tty_pgrp(int fd, int pid)
 {
if(ioctl(fd, TIOCSCTTY, 0) < 0)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Tidy recently-moved code

2007-07-30 Thread Jeff Dike
Now that the generic console operations are in a userspace file, we
can do the following:
directly call into libc instead of through the os_* wrappers
eliminate os_window_size since it has only one user

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/chan_user.c |   30 +++---
 arch/um/include/os.h|1 -
 arch/um/os-Linux/file.c |   13 -
 3 files changed, 15 insertions(+), 29 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/chan_user.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_user.c2007-07-27 
11:42:55.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_user.c 2007-07-27 11:46:09.0 
-0400
@@ -23,43 +23,43 @@
 
 void generic_close(int fd, void *unused)
 {
-   os_close_file(fd);
+   close(fd);
 }
 
 int generic_read(int fd, char *c_out, void *unused)
 {
int n;
 
-   n = os_read_file(fd, c_out, sizeof(*c_out));
-
-   if(n == -EAGAIN)
+   n = read(fd, c_out, sizeof(*c_out));
+   if (n  0)
+   return n;
+   else if (errno == EAGAIN)
return 0;
-   else if(n == 0)
+   else if (n == 0)
return -EIO;
-   return n;
+   return -errno;
 }
 
-/* XXX Trivial wrapper around os_write_file */
+/* XXX Trivial wrapper around write */
 
 int generic_write(int fd, const char *buf, int n, void *unused)
 {
-   return os_write_file(fd, buf, n);
+   return write(fd, buf, n);
 }
 
 int generic_window_size(int fd, void *unused, unsigned short *rows_out,
unsigned short *cols_out)
 {
-   int rows, cols;
+   struct winsize size;
int ret;
 
-   ret = os_window_size(fd, rows, cols);
-   if(ret  0)
-   return ret;
+   if(ioctl(fd, TIOCGWINSZ, size)  0)
+   return -errno;
 
-   ret = ((*rows_out != rows) || (*cols_out != cols));
+   ret = ((*rows_out != size.ws_row) || (*cols_out != size.ws_col));
 
-   *rows_out = rows;
-   *cols_out = cols;
+   *rows_out = size.ws_row;
+   *cols_out = size.ws_col;
 
return ret;
 }
Index: linux-2.6.21-mm/arch/um/include/os.h
===
--- linux-2.6.21-mm.orig/arch/um/include/os.h   2007-07-27 11:42:27.0 
-0400
+++ linux-2.6.21-mm/arch/um/include/os.h2007-07-27 11:46:18.0 
-0400
@@ -134,7 +134,6 @@ extern void os_print_error(int error, co
 extern int os_get_exec_close(int fd, int *close_on_exec);
 extern int os_set_exec_close(int fd, int close_on_exec);
 extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
-extern int os_window_size(int fd, int *rows, int *cols);
 extern int os_new_tty_pgrp(int fd, int pid);
 extern int os_get_ifname(int fd, char *namebuf);
 extern int os_set_slip(int fd);
Index: linux-2.6.21-mm/arch/um/os-Linux/file.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/file.c2007-07-27 
11:42:27.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/file.c 2007-07-27 11:46:18.0 
-0400
@@ -101,19 +101,6 @@ int os_ioctl_generic(int fd, unsigned in
return err;
 }
 
-int os_window_size(int fd, int *rows, int *cols)
-{
-   struct winsize size;
-
-   if(ioctl(fd, TIOCGWINSZ, size)  0)
-   return -errno;
-
-   *rows = size.ws_row;
-   *cols = size.ws_col;
-
-   return 0;
-}
-
 int os_new_tty_pgrp(int fd, int pid)
 {
if(ioctl(fd, TIOCSCTTY, 0)  0)
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Send pointers instead of structures to I/O thread

2007-04-11 Thread Jeff Dike
Instead of writing entire structures between UML and the I/O thread,
we send pointers.  This cuts down on the amount of data being copied
and possibly allows more requests to be pending between the two.

This requires that the requests be kmalloced and freed instead of
living on the stack.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/ubd_kern.c |   41 ++---
 1 file changed, 26 insertions(+), 15 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-04-10 
10:59:03.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c  2007-04-10 10:59:17.0 
-0400
@@ -503,7 +503,7 @@ static struct list_head restart = LIST_H
 /* Called without dev->lock held, and only in interrupt context. */
 static void ubd_handler(void)
 {
-   struct io_thread_req req;
+   struct io_thread_req *req;
struct request *rq;
struct ubd *ubd;
struct list_head *list, *next_ele;
@@ -511,7 +511,8 @@ static void ubd_handler(void)
int n;
 
while(1){
-   n = os_read_file_k(thread_fd, , sizeof(req));
+   n = os_read_file_k(thread_fd, ,
+  sizeof(struct io_thread_req *));
if(n != sizeof(req)){
if(n == -EAGAIN)
break;
@@ -520,10 +521,11 @@ static void ubd_handler(void)
return;
}
 
-   rq = req.req;
-   rq->nr_sectors -= req.length >> 9;
+   rq = req->req;
+   rq->nr_sectors -= req->length >> 9;
if(rq->nr_sectors == 0)
ubd_finish(rq, rq->hard_nr_sectors << 9);
+   kfree(req);
}
reactivate_fd(thread_fd, UBD_IRQ);
 
@@ -1078,7 +1080,7 @@ static void prepare_request(struct reque
 /* Called with dev->lock held */
 static void do_ubd_request(request_queue_t *q)
 {
-   struct io_thread_req io_req;
+   struct io_thread_req *io_req;
struct request *req;
int n;
 
@@ -1099,13 +1101,20 @@ static void do_ubd_request(request_queue
while(dev->start_sg < dev->end_sg){
struct scatterlist *sg = >sg[dev->start_sg];
 
-   prepare_request(req, _req,
+   io_req = kmalloc(sizeof(struct io_thread_req),
+GFP_KERNEL | GFP_ATOMIC);
+   if(io_req == NULL){
+   if(list_empty(>restart))
+   list_add(>restart, );
+   return;
+   }
+   prepare_request(req, io_req,
(unsigned long long) req->sector << 9,
sg->offset, sg->length, sg->page);
 
-   n = os_write_file_k(thread_fd, (char *) _req,
-   sizeof(io_req));
-   if(n != sizeof(io_req)){
+   n = os_write_file_k(thread_fd, _req,
+   sizeof(struct io_thread_req *));
+   if(n != sizeof(struct io_thread_req *)){
if(n != -EAGAIN)
printk("write to io thread failed, "
   "errno = %d\n", -n);
@@ -1437,13 +1446,14 @@ static int io_count = 0;
 
 int io_thread(void *arg)
 {
-   struct io_thread_req req;
+   struct io_thread_req *req;
int n;
 
ignore_sigwinch_sig();
while(1){
-   n = os_read_file_k(kernel_fd, , sizeof(req));
-   if(n != sizeof(req)){
+   n = os_read_file_k(kernel_fd, ,
+sizeof(struct io_thread_req *));
+   if(n != sizeof(struct io_thread_req *)){
if(n < 0)
printk("io_thread - read failed, fd = %d, "
   "err = %d\n", kernel_fd, -n);
@@ -1454,9 +1464,10 @@ int io_thread(void *arg)
continue;
}
io_count++;
-   do_io();
-   n = os_write_file_k(kernel_fd, , sizeof(req));
-   if(n != sizeof(req))
+   do_io(req);
+   n = os_write_file_k(kernel_fd, ,
+ sizeof(struct io_thread_req *));
+   if(n != sizeof(struct io_thread_req *))
printk("io_thread - write failed, fd = %d, err = %d\n",
   kernel_fd, -n);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  

[PATCH 2/4] UML - Send pointers instead of structures to I/O thread

2007-04-11 Thread Jeff Dike
Instead of writing entire structures between UML and the I/O thread,
we send pointers.  This cuts down on the amount of data being copied
and possibly allows more requests to be pending between the two.

This requires that the requests be kmalloced and freed instead of
living on the stack.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/ubd_kern.c |   41 ++---
 1 file changed, 26 insertions(+), 15 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-04-10 
10:59:03.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c  2007-04-10 10:59:17.0 
-0400
@@ -503,7 +503,7 @@ static struct list_head restart = LIST_H
 /* Called without dev-lock held, and only in interrupt context. */
 static void ubd_handler(void)
 {
-   struct io_thread_req req;
+   struct io_thread_req *req;
struct request *rq;
struct ubd *ubd;
struct list_head *list, *next_ele;
@@ -511,7 +511,8 @@ static void ubd_handler(void)
int n;
 
while(1){
-   n = os_read_file_k(thread_fd, req, sizeof(req));
+   n = os_read_file_k(thread_fd, req,
+  sizeof(struct io_thread_req *));
if(n != sizeof(req)){
if(n == -EAGAIN)
break;
@@ -520,10 +521,11 @@ static void ubd_handler(void)
return;
}
 
-   rq = req.req;
-   rq-nr_sectors -= req.length  9;
+   rq = req-req;
+   rq-nr_sectors -= req-length  9;
if(rq-nr_sectors == 0)
ubd_finish(rq, rq-hard_nr_sectors  9);
+   kfree(req);
}
reactivate_fd(thread_fd, UBD_IRQ);
 
@@ -1078,7 +1080,7 @@ static void prepare_request(struct reque
 /* Called with dev-lock held */
 static void do_ubd_request(request_queue_t *q)
 {
-   struct io_thread_req io_req;
+   struct io_thread_req *io_req;
struct request *req;
int n;
 
@@ -1099,13 +1101,20 @@ static void do_ubd_request(request_queue
while(dev-start_sg  dev-end_sg){
struct scatterlist *sg = dev-sg[dev-start_sg];
 
-   prepare_request(req, io_req,
+   io_req = kmalloc(sizeof(struct io_thread_req),
+GFP_KERNEL | GFP_ATOMIC);
+   if(io_req == NULL){
+   if(list_empty(dev-restart))
+   list_add(dev-restart, restart);
+   return;
+   }
+   prepare_request(req, io_req,
(unsigned long long) req-sector  9,
sg-offset, sg-length, sg-page);
 
-   n = os_write_file_k(thread_fd, (char *) io_req,
-   sizeof(io_req));
-   if(n != sizeof(io_req)){
+   n = os_write_file_k(thread_fd, io_req,
+   sizeof(struct io_thread_req *));
+   if(n != sizeof(struct io_thread_req *)){
if(n != -EAGAIN)
printk(write to io thread failed, 
   errno = %d\n, -n);
@@ -1437,13 +1446,14 @@ static int io_count = 0;
 
 int io_thread(void *arg)
 {
-   struct io_thread_req req;
+   struct io_thread_req *req;
int n;
 
ignore_sigwinch_sig();
while(1){
-   n = os_read_file_k(kernel_fd, req, sizeof(req));
-   if(n != sizeof(req)){
+   n = os_read_file_k(kernel_fd, req,
+sizeof(struct io_thread_req *));
+   if(n != sizeof(struct io_thread_req *)){
if(n  0)
printk(io_thread - read failed, fd = %d, 
   err = %d\n, kernel_fd, -n);
@@ -1454,9 +1464,10 @@ int io_thread(void *arg)
continue;
}
io_count++;
-   do_io(req);
-   n = os_write_file_k(kernel_fd, req, sizeof(req));
-   if(n != sizeof(req))
+   do_io(req);
+   n = os_write_file_k(kernel_fd, req,
+ sizeof(struct io_thread_req *));
+   if(n != sizeof(struct io_thread_req *))
printk(io_thread - write failed, fd = %d, err = %d\n,
   kernel_fd, -n);
}
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  

[PATCH 2/4] UML - Start fixing os_read_file and os_write_file

2007-04-09 Thread Jeff Dike
This patch starts the removal of a very old, very broken piece of
code.  This stems from the problem of passing a userspace buffer into
read() or write() on the host.  If that buffer had not yet been faulted
in, read and write will return -EFAULT.

To avoid this problem, the solution was to fault the buffer in before
the system call by touching the pages that hold the buffer by doing a
copy-user of a byte to each page.  This is obviously bogus, but it
does usually work, in tt mode, since the kernel and process are in the
same address space and userspace addresses can be accessed directly in
the kernel.

In skas mode, where the kernel and process are in separate address
spaces, it is completely bogus because the userspace address, which is
invalid in the kernel, is passed into the system call instead of the
corresponding physical address, which would be valid.  Here, it
appears that this code, on every host read() or write(), tries to
fault in a random process page.  This doesn't seem to cause any
correctness problems, but there is a performance impact.  This patch,
and the ones following, result in a 10-15% performance gain on a
kernel build.

This code can't be immediately tossed out because when it is, you
can't log in.  Apparently, there is some code in the console driver
which depends on this somehow.

However, we can start removing it by switching the code which does I/O
using kernel addresses to using plain read() and write().  This patch
introduces os_read_file_k and os_write_file_k for use with kernel
buffers and converts all call locations which use obvious kernel
buffers to use them.  These include I/O using buffers which are local
variables which are on the stack or kmalloc-ed.  Later patches will
handle the less obvious cases, followed by a mass conversion back to
the original interface.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/chan_user.c   |   10 +-
 arch/um/drivers/daemon_user.c |4 ++--
 arch/um/drivers/harddog_user.c|4 ++--
 arch/um/drivers/hostaudio_kern.c  |4 ++--
 arch/um/drivers/net_user.c|2 +-
 arch/um/drivers/port_kern.c   |2 +-
 arch/um/drivers/random.c  |2 +-
 arch/um/drivers/ubd_kern.c|   17 -
 arch/um/include/os.h  |2 ++
 arch/um/kernel/ksyms.c|2 ++
 arch/um/kernel/physmem.c  |2 +-
 arch/um/kernel/sigio.c|2 +-
 arch/um/kernel/smp.c  |   12 ++--
 arch/um/kernel/tt/process_kern.c  |7 ---
 arch/um/kernel/tt/ptproxy/proxy.c |9 +
 arch/um/kernel/tt/tracer.c|2 +-
 arch/um/os-Linux/file.c   |   10 ++
 arch/um/sys-i386/bugs.c   |2 +-
 arch/um/sys-i386/ldt.c|2 +-
 19 files changed, 56 insertions(+), 41 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-04-09 
13:03:08.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c  2007-04-09 13:10:41.0 
-0400
@@ -504,7 +504,7 @@ static void ubd_handler(void)
struct ubd *dev;
int n;
 
-   n = os_read_file(thread_fd, , sizeof(req));
+   n = os_read_file_k(thread_fd, , sizeof(req));
if(n != sizeof(req)){
printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
   "err = %d\n", os_getpid(), -n);
@@ -1092,8 +1092,7 @@ static void do_ubd_request(request_queue
err = prepare_request(req, _req);
if(!err){
dev->active = 1;
-   n = os_write_file(thread_fd, (char *) _req,
-sizeof(io_req));
+   n = os_write_file_k(thread_fd, _req, sizeof(io_req));
if(n != sizeof(io_req))
printk("write to io thread failed, "
   "errno = %d\n", -n);
@@ -1336,8 +1335,8 @@ static int update_bitmap(struct io_threa
return(1);
}
 
-   n = os_write_file(req->fds[1], >bitmap_words,
- sizeof(req->bitmap_words));
+   n = os_write_file_k(req->fds[1], >bitmap_words,
+   sizeof(req->bitmap_words));
if(n != sizeof(req->bitmap_words)){
printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
   req->fds[1]);
@@ -1381,7 +1380,7 @@ void do_io(struct io_thread_req *req)
do {
buf = [n];
len -= n;
-   n = os_read_file(req->fds[bit], buf, len);
+   n = os_read_file_k(req->fds[bit], buf, len);
if (n < 0) {
printk("do_io - read failed, err = %d 

[PATCH 2/4] UML - Start fixing os_read_file and os_write_file

2007-04-09 Thread Jeff Dike
This patch starts the removal of a very old, very broken piece of
code.  This stems from the problem of passing a userspace buffer into
read() or write() on the host.  If that buffer had not yet been faulted
in, read and write will return -EFAULT.

To avoid this problem, the solution was to fault the buffer in before
the system call by touching the pages that hold the buffer by doing a
copy-user of a byte to each page.  This is obviously bogus, but it
does usually work, in tt mode, since the kernel and process are in the
same address space and userspace addresses can be accessed directly in
the kernel.

In skas mode, where the kernel and process are in separate address
spaces, it is completely bogus because the userspace address, which is
invalid in the kernel, is passed into the system call instead of the
corresponding physical address, which would be valid.  Here, it
appears that this code, on every host read() or write(), tries to
fault in a random process page.  This doesn't seem to cause any
correctness problems, but there is a performance impact.  This patch,
and the ones following, result in a 10-15% performance gain on a
kernel build.

This code can't be immediately tossed out because when it is, you
can't log in.  Apparently, there is some code in the console driver
which depends on this somehow.

However, we can start removing it by switching the code which does I/O
using kernel addresses to using plain read() and write().  This patch
introduces os_read_file_k and os_write_file_k for use with kernel
buffers and converts all call locations which use obvious kernel
buffers to use them.  These include I/O using buffers which are local
variables which are on the stack or kmalloc-ed.  Later patches will
handle the less obvious cases, followed by a mass conversion back to
the original interface.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/chan_user.c   |   10 +-
 arch/um/drivers/daemon_user.c |4 ++--
 arch/um/drivers/harddog_user.c|4 ++--
 arch/um/drivers/hostaudio_kern.c  |4 ++--
 arch/um/drivers/net_user.c|2 +-
 arch/um/drivers/port_kern.c   |2 +-
 arch/um/drivers/random.c  |2 +-
 arch/um/drivers/ubd_kern.c|   17 -
 arch/um/include/os.h  |2 ++
 arch/um/kernel/ksyms.c|2 ++
 arch/um/kernel/physmem.c  |2 +-
 arch/um/kernel/sigio.c|2 +-
 arch/um/kernel/smp.c  |   12 ++--
 arch/um/kernel/tt/process_kern.c  |7 ---
 arch/um/kernel/tt/ptproxy/proxy.c |9 +
 arch/um/kernel/tt/tracer.c|2 +-
 arch/um/os-Linux/file.c   |   10 ++
 arch/um/sys-i386/bugs.c   |2 +-
 arch/um/sys-i386/ldt.c|2 +-
 19 files changed, 56 insertions(+), 41 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-04-09 
13:03:08.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c  2007-04-09 13:10:41.0 
-0400
@@ -504,7 +504,7 @@ static void ubd_handler(void)
struct ubd *dev;
int n;
 
-   n = os_read_file(thread_fd, req, sizeof(req));
+   n = os_read_file_k(thread_fd, req, sizeof(req));
if(n != sizeof(req)){
printk(KERN_ERR Pid %d - spurious interrupt in ubd_handler, 
   err = %d\n, os_getpid(), -n);
@@ -1092,8 +1092,7 @@ static void do_ubd_request(request_queue
err = prepare_request(req, io_req);
if(!err){
dev-active = 1;
-   n = os_write_file(thread_fd, (char *) io_req,
-sizeof(io_req));
+   n = os_write_file_k(thread_fd, io_req, sizeof(io_req));
if(n != sizeof(io_req))
printk(write to io thread failed, 
   errno = %d\n, -n);
@@ -1336,8 +1335,8 @@ static int update_bitmap(struct io_threa
return(1);
}
 
-   n = os_write_file(req-fds[1], req-bitmap_words,
- sizeof(req-bitmap_words));
+   n = os_write_file_k(req-fds[1], req-bitmap_words,
+   sizeof(req-bitmap_words));
if(n != sizeof(req-bitmap_words)){
printk(do_io - bitmap update failed, err = %d fd = %d\n, -n,
   req-fds[1]);
@@ -1381,7 +1380,7 @@ void do_io(struct io_thread_req *req)
do {
buf = buf[n];
len -= n;
-   n = os_read_file(req-fds[bit], buf, len);
+   n = os_read_file_k(req-fds[bit], buf, len);
if (n  0) {
printk(do_io - read failed, err = %d 
  

[PATCH 2/4] UML - Delete HOST_FRAME_SIZE

2007-04-05 Thread Jeff Dike
HOST_FRAME_SIZE isn't used any more.  It has been replaced with MAX_REG_NR.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/sys-i386/user-offsets.c   |1 -
 arch/um/sys-x86_64/user-offsets.c |1 -
 2 files changed, 2 deletions(-)

Index: linux-2.6.21-mm/arch/um/sys-i386/user-offsets.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-i386/user-offsets.c2007-04-05 
12:38:56.0 -0400
+++ linux-2.6.21-mm/arch/um/sys-i386/user-offsets.c 2007-04-05 
12:39:12.0 -0400
@@ -47,7 +47,6 @@ void foo(void)
OFFSET(HOST_SC_FP_ST, _fpstate, _st);
OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
 
-   DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct));
DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct));
 
Index: linux-2.6.21-mm/arch/um/sys-x86_64/user-offsets.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-x86_64/user-offsets.c  2007-04-05 
12:38:43.0 -0400
+++ linux-2.6.21-mm/arch/um/sys-x86_64/user-offsets.c   2007-04-05 
12:39:12.0 -0400
@@ -57,7 +57,6 @@ void foo(void)
OFFSET(HOST_SC_SS, sigcontext, ss);
 #endif
 
-   DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE);
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
DEFINE(HOST_XFP_SIZE, 0);
DEFINE_LONGS(HOST_RBX, RBX);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uml-devel] [PATCH 2/4] UML - tidy process.c

2007-04-05 Thread Jeff Dike
On Tue, Apr 03, 2007 at 07:50:16PM +0200, Blaisorblade wrote:
> Please, simply include uml-config.h and use just UML_CONFIG_MODE_TT.

okok :-)

Jeff



Use only one ifdef to mark stack_sp as being tt mode only.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/kern_util.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.21-mm/arch/um/include/kern_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/kern_util.h2007-04-03 
13:14:38.0 -0400
+++ linux-2.6.21-mm/arch/um/include/kern_util.h 2007-04-05 12:24:36.0 
-0400
@@ -8,6 +8,7 @@
 
 #include "sysdep/ptrace.h"
 #include "sysdep/faultinfo.h"
+#include "uml-config.h"
 
 typedef void (*kern_hndl)(int, union uml_pt_regs *);
 
@@ -33,7 +34,7 @@ extern int nsyscalls;
UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
 
 extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
-#if defined(CONFIG_MODE_TT) || defined(UML_CONFIG_MODE_TT)
+#ifdef UML_CONFIG_MODE_TT
 extern unsigned long stack_sp(unsigned long page);
 #endif
 extern int kernel_thread_proc(void *data);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Delete HOST_FRAME_SIZE

2007-04-05 Thread Jeff Dike
HOST_FRAME_SIZE isn't used any more.  It has been replaced with MAX_REG_NR.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/sys-i386/user-offsets.c   |1 -
 arch/um/sys-x86_64/user-offsets.c |1 -
 2 files changed, 2 deletions(-)

Index: linux-2.6.21-mm/arch/um/sys-i386/user-offsets.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-i386/user-offsets.c2007-04-05 
12:38:56.0 -0400
+++ linux-2.6.21-mm/arch/um/sys-i386/user-offsets.c 2007-04-05 
12:39:12.0 -0400
@@ -47,7 +47,6 @@ void foo(void)
OFFSET(HOST_SC_FP_ST, _fpstate, _st);
OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
 
-   DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct));
DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct));
 
Index: linux-2.6.21-mm/arch/um/sys-x86_64/user-offsets.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-x86_64/user-offsets.c  2007-04-05 
12:38:43.0 -0400
+++ linux-2.6.21-mm/arch/um/sys-x86_64/user-offsets.c   2007-04-05 
12:39:12.0 -0400
@@ -57,7 +57,6 @@ void foo(void)
OFFSET(HOST_SC_SS, sigcontext, ss);
 #endif
 
-   DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE);
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
DEFINE(HOST_XFP_SIZE, 0);
DEFINE_LONGS(HOST_RBX, RBX);
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uml-devel] [PATCH 2/4] UML - tidy process.c

2007-04-05 Thread Jeff Dike
On Tue, Apr 03, 2007 at 07:50:16PM +0200, Blaisorblade wrote:
 Please, simply include uml-config.h and use just UML_CONFIG_MODE_TT.

okok :-)

Jeff



Use only one ifdef to mark stack_sp as being tt mode only.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/kern_util.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.21-mm/arch/um/include/kern_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/kern_util.h2007-04-03 
13:14:38.0 -0400
+++ linux-2.6.21-mm/arch/um/include/kern_util.h 2007-04-05 12:24:36.0 
-0400
@@ -8,6 +8,7 @@
 
 #include sysdep/ptrace.h
 #include sysdep/faultinfo.h
+#include uml-config.h
 
 typedef void (*kern_hndl)(int, union uml_pt_regs *);
 
@@ -33,7 +34,7 @@ extern int nsyscalls;
UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
 
 extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
-#if defined(CONFIG_MODE_TT) || defined(UML_CONFIG_MODE_TT)
+#ifdef UML_CONFIG_MODE_TT
 extern unsigned long stack_sp(unsigned long page);
 #endif
 extern int kernel_thread_proc(void *data);
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ PATCH 2/4] UML - Kernel segfaults should dump proper registers

2007-04-04 Thread Jeff Dike
If there's a segfault inside the kernel, we want a dump of the registers
at the point of the segfault, not the registers at the point of
calling panic or the last userspace registers.

sig_handler_common_skas now uses a static register set in the case
of a SIGSEGV to avoid messing up the process registers if the
segfault turns out to be non-fatal.

The architecture sigcontext-to-pt_regs copying code was repurposed
to copy data out of the SEGV stack frame.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/common-offsets.h |2 +
 arch/um/include/kern_util.h  |2 +
 arch/um/kernel/trap.c|   10 ++---
 arch/um/os-Linux/skas/trap.c |   15 --
 arch/um/sys-i386/signal.c|   41 ++-
 arch/um/sys-x86_64/signal.c  |   30 
 6 files changed, 78 insertions(+), 22 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/trap.c  2007-04-02 12:19:04.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/trap.c   2007-04-02 12:19:07.0 
-0400
@@ -170,8 +170,10 @@ unsigned long segv(struct faultinfo fi, 
flush_tlb_kernel_vm();
return 0;
}
-   else if(current->mm == NULL)
-   panic("Segfault with no mm");
+   else if(current->mm == NULL) {
+   show_regs(container_of(regs, struct pt_regs, regs));
+   panic("Segfault with no mm");
+   }
 
if (SEGV_IS_FIXABLE() || SEGV_MAYBE_FIXABLE())
err = handle_page_fault(address, ip, is_write, is_user, 
_code);
@@ -194,9 +196,11 @@ unsigned long segv(struct faultinfo fi, 
else if(!is_user && arch_fixup(ip, regs))
return 0;
 
-   if(!is_user)
+   if(!is_user) {
+   show_regs(container_of(regs, struct pt_regs, regs));
panic("Kernel mode fault at addr 0x%lx, ip 0x%lx",
  address, ip);
+   }
 
if (err == -EACCES) {
si.si_signo = SIGBUS;
Index: linux-2.6.21-mm/arch/um/include/kern_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/kern_util.h2007-04-02 
12:19:04.0 -0400
+++ linux-2.6.21-mm/arch/um/include/kern_util.h 2007-04-02 12:19:07.0 
-0400
@@ -116,4 +116,6 @@ extern void log_info(char *fmt, ...) __a
 extern int __cant_sleep(void);
 extern void sigio_handler(int sig, union uml_pt_regs *regs);
 
+extern void copy_sc(union uml_pt_regs *regs, void *from);
+
 #endif
Index: linux-2.6.21-mm/arch/um/include/common-offsets.h
===
--- linux-2.6.21-mm.orig/arch/um/include/common-offsets.h   2007-04-02 
12:18:49.0 -0400
+++ linux-2.6.21-mm/arch/um/include/common-offsets.h2007-04-02 
12:19:07.0 -0400
@@ -24,5 +24,7 @@ DEFINE(UM_ELF_CLASS, ELF_CLASS);
 DEFINE(UM_ELFCLASS32, ELFCLASS32);
 DEFINE(UM_ELFCLASS64, ELFCLASS64);
 
+DEFINE(UM_NR_CPUS, NR_CPUS);
+
 /* For crypto assembler code. */
 DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/trap.c   2007-04-02 
12:19:04.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c2007-04-02 
12:19:07.0 -0400
@@ -15,6 +15,8 @@
 #include "sysdep/ptrace_user.h"
 #include "os.h"
 
+static union uml_pt_regs ksig_regs[UM_NR_CPUS];
+
 void sig_handler_common_skas(int sig, void *sc_ptr)
 {
struct sigcontext *sc = sc_ptr;
@@ -27,10 +29,19 @@ void sig_handler_common_skas(int sig, vo
 * the process will die.
 * XXX Figure out why this is better than SA_NODEFER
 */
-   if(sig == SIGSEGV)
+   if(sig == SIGSEGV) {
change_sig(SIGSEGV, 1);
+   /* For segfaults, we want the data from the
+* sigcontext.  In this case, we don't want to mangle
+* the process registers, so use a static set of
+* registers.  For other signals, the process
+* registers are OK.
+*/
+   r = _regs[cpu()];
+   copy_sc(r, sc_ptr);
+   }
+   else r = TASK_REGS(get_current());
 
-   r = TASK_REGS(get_current());
save_user = r->skas.is_user;
r->skas.is_user = 0;
if ( sig == SIGFPE || sig == SIGSEGV ||
Index: linux-2.6.21-mm/arch/um/sys-i386/signal.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-i386/signal.c  2007-04-02 
12:19:04.0 -0400
+++ linux-2.6.21-mm/arch/um/sys-i386/signal.c   2007-04-02 12:19:07.0 
-0400
@@ -18,6 +18,28 @@
 
 #include "skas.h"
 
+void copy_sc(union uml_pt_regs 

[ PATCH 2/4] UML - Kernel segfaults should dump proper registers

2007-04-04 Thread Jeff Dike
If there's a segfault inside the kernel, we want a dump of the registers
at the point of the segfault, not the registers at the point of
calling panic or the last userspace registers.

sig_handler_common_skas now uses a static register set in the case
of a SIGSEGV to avoid messing up the process registers if the
segfault turns out to be non-fatal.

The architecture sigcontext-to-pt_regs copying code was repurposed
to copy data out of the SEGV stack frame.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/common-offsets.h |2 +
 arch/um/include/kern_util.h  |2 +
 arch/um/kernel/trap.c|   10 ++---
 arch/um/os-Linux/skas/trap.c |   15 --
 arch/um/sys-i386/signal.c|   41 ++-
 arch/um/sys-x86_64/signal.c  |   30 
 6 files changed, 78 insertions(+), 22 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/trap.c  2007-04-02 12:19:04.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/trap.c   2007-04-02 12:19:07.0 
-0400
@@ -170,8 +170,10 @@ unsigned long segv(struct faultinfo fi, 
flush_tlb_kernel_vm();
return 0;
}
-   else if(current-mm == NULL)
-   panic(Segfault with no mm);
+   else if(current-mm == NULL) {
+   show_regs(container_of(regs, struct pt_regs, regs));
+   panic(Segfault with no mm);
+   }
 
if (SEGV_IS_FIXABLE(fi) || SEGV_MAYBE_FIXABLE(fi))
err = handle_page_fault(address, ip, is_write, is_user, 
si.si_code);
@@ -194,9 +196,11 @@ unsigned long segv(struct faultinfo fi, 
else if(!is_user  arch_fixup(ip, regs))
return 0;
 
-   if(!is_user)
+   if(!is_user) {
+   show_regs(container_of(regs, struct pt_regs, regs));
panic(Kernel mode fault at addr 0x%lx, ip 0x%lx,
  address, ip);
+   }
 
if (err == -EACCES) {
si.si_signo = SIGBUS;
Index: linux-2.6.21-mm/arch/um/include/kern_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/kern_util.h2007-04-02 
12:19:04.0 -0400
+++ linux-2.6.21-mm/arch/um/include/kern_util.h 2007-04-02 12:19:07.0 
-0400
@@ -116,4 +116,6 @@ extern void log_info(char *fmt, ...) __a
 extern int __cant_sleep(void);
 extern void sigio_handler(int sig, union uml_pt_regs *regs);
 
+extern void copy_sc(union uml_pt_regs *regs, void *from);
+
 #endif
Index: linux-2.6.21-mm/arch/um/include/common-offsets.h
===
--- linux-2.6.21-mm.orig/arch/um/include/common-offsets.h   2007-04-02 
12:18:49.0 -0400
+++ linux-2.6.21-mm/arch/um/include/common-offsets.h2007-04-02 
12:19:07.0 -0400
@@ -24,5 +24,7 @@ DEFINE(UM_ELF_CLASS, ELF_CLASS);
 DEFINE(UM_ELFCLASS32, ELFCLASS32);
 DEFINE(UM_ELFCLASS64, ELFCLASS64);
 
+DEFINE(UM_NR_CPUS, NR_CPUS);
+
 /* For crypto assembler code. */
 DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/trap.c   2007-04-02 
12:19:04.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c2007-04-02 
12:19:07.0 -0400
@@ -15,6 +15,8 @@
 #include sysdep/ptrace_user.h
 #include os.h
 
+static union uml_pt_regs ksig_regs[UM_NR_CPUS];
+
 void sig_handler_common_skas(int sig, void *sc_ptr)
 {
struct sigcontext *sc = sc_ptr;
@@ -27,10 +29,19 @@ void sig_handler_common_skas(int sig, vo
 * the process will die.
 * XXX Figure out why this is better than SA_NODEFER
 */
-   if(sig == SIGSEGV)
+   if(sig == SIGSEGV) {
change_sig(SIGSEGV, 1);
+   /* For segfaults, we want the data from the
+* sigcontext.  In this case, we don't want to mangle
+* the process registers, so use a static set of
+* registers.  For other signals, the process
+* registers are OK.
+*/
+   r = ksig_regs[cpu()];
+   copy_sc(r, sc_ptr);
+   }
+   else r = TASK_REGS(get_current());
 
-   r = TASK_REGS(get_current());
save_user = r-skas.is_user;
r-skas.is_user = 0;
if ( sig == SIGFPE || sig == SIGSEGV ||
Index: linux-2.6.21-mm/arch/um/sys-i386/signal.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-i386/signal.c  2007-04-02 
12:19:04.0 -0400
+++ linux-2.6.21-mm/arch/um/sys-i386/signal.c   2007-04-02 12:19:07.0 
-0400
@@ -18,6 +18,28 @@
 
 #include skas.h
 
+void copy_sc(union uml_pt_regs *regs, 

Re: [uml-devel] [PATCH 2/4] UML - tidy process.c

2007-04-03 Thread Blaisorblade
On lunedì 2 aprile 2007, Jeff Dike wrote:
> Clean up arch/um/kernel/process.c -
>   lots of return(x); -> return x; conversions
>   a number of the small functions are either unused, in which
> case they are gone, along any declarations in a header, or could be
> made static.

>   current_pid is ifdefed on CONFIG_MODE_TT and its declaration
> is ifdefed on both CONFIG_MODE_TT and UML_CONFIG_MODE_TT because we
> don't know whether it's being used in a userspace or kernel file.

Please, simply include uml-config.h and use just UML_CONFIG_MODE_TT.

> Index: linux-2.6.21-mm/arch/um/include/kern_util.h
> ===
> --- linux-2.6.21-mm.orig/arch/um/include/kern_util.h  2007-03-30
> 16:01:21.0 -0400 +++
> linux-2.6.21-mm/arch/um/include/kern_util.h   2007-04-02 12:07:48.0
> -0400 @@ -33,7 +33,9 @@ extern int nsyscalls;
>   UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
>
>  extern int kernel_fork(unsigned long flags, int (*fn)(void *), void *
> arg); +#if defined(CONFIG_MODE_TT) || defined(UML_CONFIG_MODE_TT)
>  extern unsigned long stack_sp(unsigned long page);
> +#endif
>  extern int kernel_thread_proc(void *data);
>  extern void syscall_segv(int sig);
>  extern int current_pid(void);



-- 
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uml-devel] [PATCH 2/4] UML - tidy process.c

2007-04-03 Thread Blaisorblade
On lunedì 2 aprile 2007, Jeff Dike wrote:
 Clean up arch/um/kernel/process.c -
   lots of return(x); - return x; conversions
   a number of the small functions are either unused, in which
 case they are gone, along any declarations in a header, or could be
 made static.

   current_pid is ifdefed on CONFIG_MODE_TT and its declaration
 is ifdefed on both CONFIG_MODE_TT and UML_CONFIG_MODE_TT because we
 don't know whether it's being used in a userspace or kernel file.

Please, simply include uml-config.h and use just UML_CONFIG_MODE_TT.

 Index: linux-2.6.21-mm/arch/um/include/kern_util.h
 ===
 --- linux-2.6.21-mm.orig/arch/um/include/kern_util.h  2007-03-30
 16:01:21.0 -0400 +++
 linux-2.6.21-mm/arch/um/include/kern_util.h   2007-04-02 12:07:48.0
 -0400 @@ -33,7 +33,9 @@ extern int nsyscalls;
   UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)

  extern int kernel_fork(unsigned long flags, int (*fn)(void *), void *
 arg); +#if defined(CONFIG_MODE_TT) || defined(UML_CONFIG_MODE_TT)
  extern unsigned long stack_sp(unsigned long page);
 +#endif
  extern int kernel_thread_proc(void *data);
  extern void syscall_segv(int sig);
  extern int current_pid(void);



-- 
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - tidy process.c

2007-04-02 Thread Jeff Dike
Clean up arch/um/kernel/process.c -
lots of return(x); -> return x; conversions
a number of the small functions are either unused, in which
case they are gone, along any declarations in a header, or could be
made static.
current_pid is ifdefed on CONFIG_MODE_TT and its declaration
is ifdefed on both CONFIG_MODE_TT and UML_CONFIG_MODE_TT because we
don't know whether it's being used in a userspace or kernel file.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/kern_util.h |6 --
 arch/um/include/tt/uaccess-tt.h |2 
 arch/um/include/um_malloc.h |1 
 arch/um/kernel/process.c|  118 +++-
 4 files changed, 37 insertions(+), 90 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/process.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/process.c   2007-04-02 
10:58:51.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/process.c2007-04-02 12:01:44.0 
-0400
@@ -54,11 +54,9 @@
  */
 struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
 
-int external_pid(void *t)
+static inline int external_pid(struct task_struct *task)
 {
-   struct task_struct *task = t ? t : current;
-
-   return(CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task));
+   return CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task);
 }
 
 int pid_to_processor_id(int pid)
@@ -66,9 +64,10 @@ int pid_to_processor_id(int pid)
int i;
 
for(i = 0; i < ncpus; i++){
-   if(cpu_tasks[i].pid == pid) return(i);
+   if(cpu_tasks[i].pid == pid)
+   return i;
}
-   return(-1);
+   return -1;
 }
 
 void free_stack(unsigned long stack, int order)
@@ -85,9 +84,9 @@ unsigned long alloc_stack(int order, int
flags = GFP_ATOMIC;
page = __get_free_pages(flags, order);
if(page == 0)
-   return(0);
+   return 0;
stack_protections(page);
-   return(page);
+   return page;
 }
 
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
@@ -100,13 +99,11 @@ int kernel_thread(int (*fn)(void *), voi
  >thread.regs, 0, NULL, NULL);
if(pid < 0)
panic("do_fork failed in kernel_thread, errno = %d", pid);
-   return(pid);
+   return pid;
 }
 
-void set_current(void *t)
+static inline void set_current(struct task_struct *task)
 {
-   struct task_struct *task = t;
-
cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task)
{ external_pid(task), task });
 }
@@ -128,14 +125,16 @@ void *_switch_to(void *prev, void *next,
prev= current;
} while(current->thread.saved_task);
 
-   return(current->thread.prev_sched);
+   return current->thread.prev_sched;
 
 }
 
 void interrupt_end(void)
 {
-   if(need_resched()) schedule();
-   if(test_tsk_thread_flag(current, TIF_SIGPENDING)) do_signal();
+   if(need_resched())
+   schedule();
+   if(test_tsk_thread_flag(current, TIF_SIGPENDING))
+   do_signal();
 }
 
 void release_thread(struct task_struct *task)
@@ -150,7 +149,7 @@ void exit_thread(void)
 
 void *get_current(void)
 {
-   return(current);
+   return current;
 }
 
 int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
@@ -188,15 +187,12 @@ void initial_thread_cb(void (*proc)(void
kmalloc_ok = save_kmalloc_ok;
 }
 
+#ifdef CONFIG_MODE_TT
 unsigned long stack_sp(unsigned long page)
 {
-   return(page + PAGE_SIZE - sizeof(void *));
-}
-
-int current_pid(void)
-{
-   return(current->pid);
+   return page + PAGE_SIZE - sizeof(void *);
 }
+#endif
 
 void default_idle(void)
 {
@@ -223,7 +219,7 @@ void cpu_idle(void)
 
 int page_size(void)
 {
-   return(PAGE_SIZE);
+   return PAGE_SIZE;
 }
 
 void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
@@ -236,68 +232,43 @@ void *um_virt_to_phys(struct task_struct
pte_t ptent;
 
if(task->mm == NULL)
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
pgd = pgd_offset(task->mm, addr);
if(!pgd_present(*pgd))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
pud = pud_offset(pgd, addr);
if(!pud_present(*pud))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
pmd = pmd_offset(pud, addr);
if(!pmd_present(*pmd))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
pte = pte_offset_kernel(pmd, addr);
ptent = *pte;
if(!pte_present(ptent))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
if(pte_out != NULL)
*pte_out = ptent;
-   return((void *) (pte_val(ptent) & PAGE_MASK) + (addr & 

[PATCH 2/4] UML - tidy process.c

2007-04-02 Thread Jeff Dike
Clean up arch/um/kernel/process.c -
lots of return(x); - return x; conversions
a number of the small functions are either unused, in which
case they are gone, along any declarations in a header, or could be
made static.
current_pid is ifdefed on CONFIG_MODE_TT and its declaration
is ifdefed on both CONFIG_MODE_TT and UML_CONFIG_MODE_TT because we
don't know whether it's being used in a userspace or kernel file.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/kern_util.h |6 --
 arch/um/include/tt/uaccess-tt.h |2 
 arch/um/include/um_malloc.h |1 
 arch/um/kernel/process.c|  118 +++-
 4 files changed, 37 insertions(+), 90 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/process.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/process.c   2007-04-02 
10:58:51.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/process.c2007-04-02 12:01:44.0 
-0400
@@ -54,11 +54,9 @@
  */
 struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
 
-int external_pid(void *t)
+static inline int external_pid(struct task_struct *task)
 {
-   struct task_struct *task = t ? t : current;
-
-   return(CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task));
+   return CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task);
 }
 
 int pid_to_processor_id(int pid)
@@ -66,9 +64,10 @@ int pid_to_processor_id(int pid)
int i;
 
for(i = 0; i  ncpus; i++){
-   if(cpu_tasks[i].pid == pid) return(i);
+   if(cpu_tasks[i].pid == pid)
+   return i;
}
-   return(-1);
+   return -1;
 }
 
 void free_stack(unsigned long stack, int order)
@@ -85,9 +84,9 @@ unsigned long alloc_stack(int order, int
flags = GFP_ATOMIC;
page = __get_free_pages(flags, order);
if(page == 0)
-   return(0);
+   return 0;
stack_protections(page);
-   return(page);
+   return page;
 }
 
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
@@ -100,13 +99,11 @@ int kernel_thread(int (*fn)(void *), voi
  current-thread.regs, 0, NULL, NULL);
if(pid  0)
panic(do_fork failed in kernel_thread, errno = %d, pid);
-   return(pid);
+   return pid;
 }
 
-void set_current(void *t)
+static inline void set_current(struct task_struct *task)
 {
-   struct task_struct *task = t;
-
cpu_tasks[task_thread_info(task)-cpu] = ((struct cpu_task)
{ external_pid(task), task });
 }
@@ -128,14 +125,16 @@ void *_switch_to(void *prev, void *next,
prev= current;
} while(current-thread.saved_task);
 
-   return(current-thread.prev_sched);
+   return current-thread.prev_sched;
 
 }
 
 void interrupt_end(void)
 {
-   if(need_resched()) schedule();
-   if(test_tsk_thread_flag(current, TIF_SIGPENDING)) do_signal();
+   if(need_resched())
+   schedule();
+   if(test_tsk_thread_flag(current, TIF_SIGPENDING))
+   do_signal();
 }
 
 void release_thread(struct task_struct *task)
@@ -150,7 +149,7 @@ void exit_thread(void)
 
 void *get_current(void)
 {
-   return(current);
+   return current;
 }
 
 int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
@@ -188,15 +187,12 @@ void initial_thread_cb(void (*proc)(void
kmalloc_ok = save_kmalloc_ok;
 }
 
+#ifdef CONFIG_MODE_TT
 unsigned long stack_sp(unsigned long page)
 {
-   return(page + PAGE_SIZE - sizeof(void *));
-}
-
-int current_pid(void)
-{
-   return(current-pid);
+   return page + PAGE_SIZE - sizeof(void *);
 }
+#endif
 
 void default_idle(void)
 {
@@ -223,7 +219,7 @@ void cpu_idle(void)
 
 int page_size(void)
 {
-   return(PAGE_SIZE);
+   return PAGE_SIZE;
 }
 
 void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
@@ -236,68 +232,43 @@ void *um_virt_to_phys(struct task_struct
pte_t ptent;
 
if(task-mm == NULL)
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
pgd = pgd_offset(task-mm, addr);
if(!pgd_present(*pgd))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
pud = pud_offset(pgd, addr);
if(!pud_present(*pud))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
pmd = pmd_offset(pud, addr);
if(!pmd_present(*pmd))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
pte = pte_offset_kernel(pmd, addr);
ptent = *pte;
if(!pte_present(ptent))
-   return(ERR_PTR(-EINVAL));
+   return ERR_PTR(-EINVAL);
 
if(pte_out != NULL)
*pte_out = ptent;
-   return((void *) (pte_val(ptent)  PAGE_MASK) + (addr  

[PATCH 2/4] UML - improve checking and diagnostics of ethernet MACs

2007-03-28 Thread Jeff Dike
From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>

Improve checking and diagnostics for broadcast and multicast Ethernet MAC
addresses, and distinguish between those cases in output; also make sure the   
device is assigned a MAC address valid only locally to avoid collisions.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/net_kern.c  |   38 +-
 include/linux/etherdevice.h |   12 
 2 files changed, 41 insertions(+), 9 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/net_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/net_kern.c 2007-03-21 
13:43:12.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/net_kern.c  2007-03-21 13:43:42.0 
-0400
@@ -283,7 +283,7 @@ void uml_net_user_timer_expire(unsigned 
 #endif
 }
 
-static void setup_etheraddr(char *str, unsigned char *addr)
+static void setup_etheraddr(char *str, unsigned char *addr, char *name)
 {
char *end;
int i;
@@ -302,15 +302,32 @@ static void setup_etheraddr(char *str, u
}
str = end + 1;
}
-   if(addr[0] & 1){
+   if (is_multicast_ether_addr(addr)) {
printk(KERN_ERR
-  "Attempt to assign a broadcast ethernet address to a "
+  "Attempt to assign a multicast ethernet address to a "
   "device disallowed\n");
goto random;
}
+   if (!is_valid_ether_addr(addr)) {
+   printk(KERN_ERR
+  "Attempt to assign an invalid ethernet address to a "
+  "device disallowed\n");
+   goto random;
+   }
+   if (!is_local_ether_addr(addr)) {
+   printk(KERN_WARNING
+  "Warning: attempt to assign a globally valid ethernet 
address to a "
+  "device\n");
+   printk(KERN_WARNING "You should better enable the 2nd rightmost 
bit "
+ "in the first byte of the MAC, i.e. "
+ "%02x:%02x:%02x:%02x:%02x:%02x\n",
+ addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], 
addr[5]);
+   }
return;
 
 random:
+   printk(KERN_INFO
+  "Choosing a random ethernet address for device %s\n", name);
random_ether_addr(addr);
 }
 
@@ -331,6 +348,7 @@ static void eth_configure(int n, void *i
struct net_device *dev;
struct uml_net_private *lp;
int save, err, size;
+   char name[sizeof(dev->name)];
 
size = transport->private_size + sizeof(struct uml_net_private) +
sizeof(((struct uml_net_private *) 0)->user);
@@ -344,7 +362,13 @@ static void eth_configure(int n, void *i
INIT_LIST_HEAD(>list);
device->index = n;
 
-   setup_etheraddr(mac, device->mac);
+   /* If this name ends up conflicting with an existing registered
+* netdevice, that is OK, register_netdev{,ice}() will notice this
+* and fail.
+*/
+   snprintf(name, sizeof(name), "eth%d", n);
+
+   setup_etheraddr(mac, device->mac, name);
 
printk(KERN_INFO "Netdevice %d ", n);
printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
@@ -375,11 +399,7 @@ static void eth_configure(int n, void *i
goto out_free_netdev;
SET_NETDEV_DEV(dev,>pdev.dev);
 
-   /* If this name ends up conflicting with an existing registered
-* netdevice, that is OK, register_netdev{,ice}() will notice this
-* and fail.
-*/
-   snprintf(dev->name, sizeof(dev->name), "eth%d", n);
+   strcpy(dev->name, name);
device->dev = dev;
 
/*
Index: linux-2.6.21-mm/include/linux/etherdevice.h
===
--- linux-2.6.21-mm.orig/include/linux/etherdevice.h2007-03-20 
15:41:35.0 -0400
+++ linux-2.6.21-mm/include/linux/etherdevice.h 2007-03-21 13:43:42.0 
-0400
@@ -71,6 +71,18 @@ static inline int is_multicast_ether_add
 }
 
 /**
+ * is_local_ether_addr - Determine if the Ethernet address is locally-assigned
+ * one (IEEE 802).
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is a local address.
+ */
+static inline int is_local_ether_addr(const u8 *addr)
+{
+   return (0x02 & addr[0]);
+}
+
+/**
  * is_broadcast_ether_addr - Determine if the Ethernet address is broadcast
  * @addr: Pointer to a six-byte array containing the Ethernet address
  *
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - improve checking and diagnostics of ethernet MACs

2007-03-28 Thread Jeff Dike
From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]

Improve checking and diagnostics for broadcast and multicast Ethernet MAC
addresses, and distinguish between those cases in output; also make sure the   
device is assigned a MAC address valid only locally to avoid collisions.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/net_kern.c  |   38 +-
 include/linux/etherdevice.h |   12 
 2 files changed, 41 insertions(+), 9 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/net_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/net_kern.c 2007-03-21 
13:43:12.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/net_kern.c  2007-03-21 13:43:42.0 
-0400
@@ -283,7 +283,7 @@ void uml_net_user_timer_expire(unsigned 
 #endif
 }
 
-static void setup_etheraddr(char *str, unsigned char *addr)
+static void setup_etheraddr(char *str, unsigned char *addr, char *name)
 {
char *end;
int i;
@@ -302,15 +302,32 @@ static void setup_etheraddr(char *str, u
}
str = end + 1;
}
-   if(addr[0]  1){
+   if (is_multicast_ether_addr(addr)) {
printk(KERN_ERR
-  Attempt to assign a broadcast ethernet address to a 
+  Attempt to assign a multicast ethernet address to a 
   device disallowed\n);
goto random;
}
+   if (!is_valid_ether_addr(addr)) {
+   printk(KERN_ERR
+  Attempt to assign an invalid ethernet address to a 
+  device disallowed\n);
+   goto random;
+   }
+   if (!is_local_ether_addr(addr)) {
+   printk(KERN_WARNING
+  Warning: attempt to assign a globally valid ethernet 
address to a 
+  device\n);
+   printk(KERN_WARNING You should better enable the 2nd rightmost 
bit 
+ in the first byte of the MAC, i.e. 
+ %02x:%02x:%02x:%02x:%02x:%02x\n,
+ addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], 
addr[5]);
+   }
return;
 
 random:
+   printk(KERN_INFO
+  Choosing a random ethernet address for device %s\n, name);
random_ether_addr(addr);
 }
 
@@ -331,6 +348,7 @@ static void eth_configure(int n, void *i
struct net_device *dev;
struct uml_net_private *lp;
int save, err, size;
+   char name[sizeof(dev-name)];
 
size = transport-private_size + sizeof(struct uml_net_private) +
sizeof(((struct uml_net_private *) 0)-user);
@@ -344,7 +362,13 @@ static void eth_configure(int n, void *i
INIT_LIST_HEAD(device-list);
device-index = n;
 
-   setup_etheraddr(mac, device-mac);
+   /* If this name ends up conflicting with an existing registered
+* netdevice, that is OK, register_netdev{,ice}() will notice this
+* and fail.
+*/
+   snprintf(name, sizeof(name), eth%d, n);
+
+   setup_etheraddr(mac, device-mac, name);
 
printk(KERN_INFO Netdevice %d , n);
printk((%02x:%02x:%02x:%02x:%02x:%02x) ,
@@ -375,11 +399,7 @@ static void eth_configure(int n, void *i
goto out_free_netdev;
SET_NETDEV_DEV(dev,device-pdev.dev);
 
-   /* If this name ends up conflicting with an existing registered
-* netdevice, that is OK, register_netdev{,ice}() will notice this
-* and fail.
-*/
-   snprintf(dev-name, sizeof(dev-name), eth%d, n);
+   strcpy(dev-name, name);
device-dev = dev;
 
/*
Index: linux-2.6.21-mm/include/linux/etherdevice.h
===
--- linux-2.6.21-mm.orig/include/linux/etherdevice.h2007-03-20 
15:41:35.0 -0400
+++ linux-2.6.21-mm/include/linux/etherdevice.h 2007-03-21 13:43:42.0 
-0400
@@ -71,6 +71,18 @@ static inline int is_multicast_ether_add
 }
 
 /**
+ * is_local_ether_addr - Determine if the Ethernet address is locally-assigned
+ * one (IEEE 802).
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is a local address.
+ */
+static inline int is_local_ether_addr(const u8 *addr)
+{
+   return (0x02  addr[0]);
+}
+
+/**
  * is_broadcast_ether_addr - Determine if the Ethernet address is broadcast
  * @addr: Pointer to a six-byte array containing the Ethernet address
  *
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Fix formatting violations in signal delivery code

2007-03-05 Thread Jeff Dike
Fix a few formatting bugs in the signal code.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/kernel/signal.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: test/arch/um/kernel/signal.c
===
--- test.orig/arch/um/kernel/signal.c   2007-03-05 15:07:53.0 -0500
+++ test/arch/um/kernel/signal.c2007-03-05 15:07:54.0 -0500
@@ -161,12 +161,12 @@ static int kern_do_signal(struct pt_regs
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, >saved_sigmask, NULL);
}
-   return(handled_sig);
+   return handled_sig;
 }
 
 int do_signal(void)
 {
-   return(kern_do_signal(>thread.regs));
+   return kern_do_signal(>thread.regs);
 }
 
 /*
@@ -189,5 +189,5 @@ long sys_sigsuspend(int history0, int hi
 
 long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
 {
-   return(do_sigaltstack(uss, uoss, PT_REGS_SP(>thread.regs)));
+   return do_sigaltstack(uss, uoss, PT_REGS_SP(>thread.regs));
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Fix formatting violations in signal delivery code

2007-03-05 Thread Jeff Dike
Fix a few formatting bugs in the signal code.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/kernel/signal.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: test/arch/um/kernel/signal.c
===
--- test.orig/arch/um/kernel/signal.c   2007-03-05 15:07:53.0 -0500
+++ test/arch/um/kernel/signal.c2007-03-05 15:07:54.0 -0500
@@ -161,12 +161,12 @@ static int kern_do_signal(struct pt_regs
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, current-saved_sigmask, NULL);
}
-   return(handled_sig);
+   return handled_sig;
 }
 
 int do_signal(void)
 {
-   return(kern_do_signal(current-thread.regs));
+   return kern_do_signal(current-thread.regs);
 }
 
 /*
@@ -189,5 +189,5 @@ long sys_sigsuspend(int history0, int hi
 
 long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
 {
-   return(do_sigaltstack(uss, uoss, PT_REGS_SP(current-thread.regs)));
+   return do_sigaltstack(uss, uoss, PT_REGS_SP(current-thread.regs));
 }

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - formatting fixes

2007-02-21 Thread Jeff Dike
Formatting fixes -
style violations
whitespace breakage
emacs formatting comment removal

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/kernel/um_arch.c  |   51 +--
 arch/um/os-Linux/main.c   |   11 +
 arch/um/sys-i386/bugs.c   |   54 --
 arch/um/sys-x86_64/bugs.c |   34 ++--
 4 files changed, 67 insertions(+), 83 deletions(-)

Index: linux-2.6.17/arch/um/kernel/um_arch.c
===
--- linux-2.6.17.orig/arch/um/kernel/um_arch.c  2007-02-19 11:39:10.0 
-0500
+++ linux-2.6.17/arch/um/kernel/um_arch.c   2007-02-19 12:53:54.0 
-0500
@@ -64,8 +64,8 @@ struct cpuinfo_um boot_cpu_data = { 
 
 unsigned long thread_saved_pc(struct task_struct *task)
 {
-   return(os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
- task)));
+   return os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
+ task));
 }
 
 static int show_cpuinfo(struct seq_file *m, void *v)
@@ -87,7 +87,7 @@ static int show_cpuinfo(struct seq_file 
   loops_per_jiffy/(50/HZ),
   (loops_per_jiffy/(5000/HZ)) % 100);
 
-   return(0);
+   return 0;
 }
 
 static void *c_start(struct seq_file *m, loff_t *pos)
@@ -213,12 +213,12 @@ __uml_setup("debug", no_skas_debug_setup
 #ifdef CONFIG_SMP
 static int __init uml_ncpus_setup(char *line, int *add)
 {
-   if (!sscanf(line, "%d", )) {
-   printf("Couldn't parse [%s]\n", line);
-   return -1;
-   }
+   if (!sscanf(line, "%d", )) {
+   printf("Couldn't parse [%s]\n", line);
+   return -1;
+   }
 
-   return 0;
+   return 0;
 }
 
 __uml_setup("ncpus=", uml_ncpus_setup,
@@ -235,7 +235,7 @@ static int force_tt = 0;
 static int __init mode_tt_setup(char *line, int *add)
 {
force_tt = 1;
-   return(0);
+   return 0;
 }
 
 #else
@@ -246,7 +246,7 @@ static int __init mode_tt_setup(char *li
 static int __init mode_tt_setup(char *line, int *add)
 {
printf("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
-   return(0);
+   return 0;
 }
 
 #else
@@ -257,7 +257,7 @@ static int __init mode_tt_setup(char *li
 static int __init mode_tt_setup(char *line, int *add)
 {
printf("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
-   return(0);
+   return 0;
 }
 
 #endif
@@ -275,16 +275,15 @@ int mode_tt = DEFAULT_TT;
 
 static int __init Usage(char *line, int *add)
 {
-   const char **p;
+   const char **p;
 
printf(usage_string, init_utsname()->release);
-   p = &__uml_help_start;
-   while (p < &__uml_help_end) {
-   printf("%s", *p);
-   p++;
-   }
+   p = &__uml_help_start;
+   while (p < &__uml_help_end) {
+   printf("%s", *p);
+   p++;
+   }
exit(0);
-
return 0;
 }
 
@@ -380,8 +379,8 @@ int linux_main(int argc, char **argv)
  set_task_sizes_skas, _size);
 
/*
-* Setting up handlers to 'sig_info' struct
-*/
+* Setting up handlers to 'sig_info' struct
+*/
os_fill_handlinfo(handlinfo_kern);
 
brk_start = (unsigned long) sbrk(0);
@@ -408,7 +407,7 @@ int linux_main(int argc, char **argv)
argv1_begin = argv[1];
argv1_end = [1][strlen(argv[1])];
 #endif
-  
+
highmem = 0;
iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC;
@@ -450,12 +449,12 @@ int linux_main(int argc, char **argv)
printf("Kernel virtual memory size shrunk to %lu bytes\n",
   virtmem_size);
 
-   uml_postsetup();
+   uml_postsetup();
 
task_protections((unsigned long) _thread_info);
os_flush_stdout();
 
-   return(CHOOSE_MODE(start_uml_tt(), start_uml_skas()));
+   return CHOOSE_MODE(start_uml_tt(), start_uml_skas());
 }
 
 extern int uml_exitcode;
@@ -468,7 +467,7 @@ static int panic_exit(struct notifier_bl
bust_spinlocks(0);
uml_exitcode = 1;
machine_halt();
-   return(0);
+   return 0;
 }
 
 static struct notifier_block panic_exit_notifier = {
@@ -483,14 +482,14 @@ void __init setup_arch(char **cmdline_p)
_exit_notifier);
paging_init();
 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
-   *cmdline_p = command_line;
+   *cmdline_p = command_line;
setup_hostinfo();
 }
 
 void __init check_bugs(void)
 {
arch_check_bugs();
-   os_check_bugs();
+   os_check_bugs();
 }
 
 void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
Index: 

[PATCH 2/4] UML - formatting fixes

2007-02-21 Thread Jeff Dike
Formatting fixes -
style violations
whitespace breakage
emacs formatting comment removal

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/kernel/um_arch.c  |   51 +--
 arch/um/os-Linux/main.c   |   11 +
 arch/um/sys-i386/bugs.c   |   54 --
 arch/um/sys-x86_64/bugs.c |   34 ++--
 4 files changed, 67 insertions(+), 83 deletions(-)

Index: linux-2.6.17/arch/um/kernel/um_arch.c
===
--- linux-2.6.17.orig/arch/um/kernel/um_arch.c  2007-02-19 11:39:10.0 
-0500
+++ linux-2.6.17/arch/um/kernel/um_arch.c   2007-02-19 12:53:54.0 
-0500
@@ -64,8 +64,8 @@ struct cpuinfo_um boot_cpu_data = { 
 
 unsigned long thread_saved_pc(struct task_struct *task)
 {
-   return(os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
- task)));
+   return os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
+ task));
 }
 
 static int show_cpuinfo(struct seq_file *m, void *v)
@@ -87,7 +87,7 @@ static int show_cpuinfo(struct seq_file 
   loops_per_jiffy/(50/HZ),
   (loops_per_jiffy/(5000/HZ)) % 100);
 
-   return(0);
+   return 0;
 }
 
 static void *c_start(struct seq_file *m, loff_t *pos)
@@ -213,12 +213,12 @@ __uml_setup(debug, no_skas_debug_setup
 #ifdef CONFIG_SMP
 static int __init uml_ncpus_setup(char *line, int *add)
 {
-   if (!sscanf(line, %d, ncpus)) {
-   printf(Couldn't parse [%s]\n, line);
-   return -1;
-   }
+   if (!sscanf(line, %d, ncpus)) {
+   printf(Couldn't parse [%s]\n, line);
+   return -1;
+   }
 
-   return 0;
+   return 0;
 }
 
 __uml_setup(ncpus=, uml_ncpus_setup,
@@ -235,7 +235,7 @@ static int force_tt = 0;
 static int __init mode_tt_setup(char *line, int *add)
 {
force_tt = 1;
-   return(0);
+   return 0;
 }
 
 #else
@@ -246,7 +246,7 @@ static int __init mode_tt_setup(char *li
 static int __init mode_tt_setup(char *line, int *add)
 {
printf(CONFIG_MODE_TT disabled - 'mode=tt' ignored\n);
-   return(0);
+   return 0;
 }
 
 #else
@@ -257,7 +257,7 @@ static int __init mode_tt_setup(char *li
 static int __init mode_tt_setup(char *line, int *add)
 {
printf(CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n);
-   return(0);
+   return 0;
 }
 
 #endif
@@ -275,16 +275,15 @@ int mode_tt = DEFAULT_TT;
 
 static int __init Usage(char *line, int *add)
 {
-   const char **p;
+   const char **p;
 
printf(usage_string, init_utsname()-release);
-   p = __uml_help_start;
-   while (p  __uml_help_end) {
-   printf(%s, *p);
-   p++;
-   }
+   p = __uml_help_start;
+   while (p  __uml_help_end) {
+   printf(%s, *p);
+   p++;
+   }
exit(0);
-
return 0;
 }
 
@@ -380,8 +379,8 @@ int linux_main(int argc, char **argv)
  set_task_sizes_skas, task_size);
 
/*
-* Setting up handlers to 'sig_info' struct
-*/
+* Setting up handlers to 'sig_info' struct
+*/
os_fill_handlinfo(handlinfo_kern);
 
brk_start = (unsigned long) sbrk(0);
@@ -408,7 +407,7 @@ int linux_main(int argc, char **argv)
argv1_begin = argv[1];
argv1_end = argv[1][strlen(argv[1])];
 #endif
-  
+
highmem = 0;
iomem_size = (iomem_size + PAGE_SIZE - 1)  PAGE_MASK;
max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC;
@@ -450,12 +449,12 @@ int linux_main(int argc, char **argv)
printf(Kernel virtual memory size shrunk to %lu bytes\n,
   virtmem_size);
 
-   uml_postsetup();
+   uml_postsetup();
 
task_protections((unsigned long) init_thread_info);
os_flush_stdout();
 
-   return(CHOOSE_MODE(start_uml_tt(), start_uml_skas()));
+   return CHOOSE_MODE(start_uml_tt(), start_uml_skas());
 }
 
 extern int uml_exitcode;
@@ -468,7 +467,7 @@ static int panic_exit(struct notifier_bl
bust_spinlocks(0);
uml_exitcode = 1;
machine_halt();
-   return(0);
+   return 0;
 }
 
 static struct notifier_block panic_exit_notifier = {
@@ -483,14 +482,14 @@ void __init setup_arch(char **cmdline_p)
panic_exit_notifier);
paging_init();
 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
-   *cmdline_p = command_line;
+   *cmdline_p = command_line;
setup_hostinfo();
 }
 
 void __init check_bugs(void)
 {
arch_check_bugs();
-   os_check_bugs();
+   os_check_bugs();
 }
 
 void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
Index: 

[PATCH 2/4] UML - Include asm/page.h in order to get PAGE_SHIFT

2006-12-04 Thread Jeff Dike
Include the proper header to get a definition of PAGE_SHIFT.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>

Index: linux-2.6.17/arch/um/include/sysdep-i386/stub.h
===
--- linux-2.6.17.orig/arch/um/include/sysdep-i386/stub.h2006-06-17 
21:49:35.0 -0400
+++ linux-2.6.17/arch/um/include/sysdep-i386/stub.h 2006-11-13 
16:41:37.0 -0500
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "stub-data.h"
 #include "kern_constants.h"
 #include "uml-config.h"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Include asm/page.h in order to get PAGE_SHIFT

2006-12-04 Thread Jeff Dike
Include the proper header to get a definition of PAGE_SHIFT.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]

Index: linux-2.6.17/arch/um/include/sysdep-i386/stub.h
===
--- linux-2.6.17.orig/arch/um/include/sysdep-i386/stub.h2006-06-17 
21:49:35.0 -0400
+++ linux-2.6.17/arch/um/include/sysdep-i386/stub.h 2006-11-13 
16:41:37.0 -0500
@@ -9,6 +9,7 @@
 #include sys/mman.h
 #include asm/ptrace.h
 #include asm/unistd.h
+#include asm/page.h
 #include stub-data.h
 #include kern_constants.h
 #include uml-config.h

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML -

2005-08-15 Thread Jeff Dike
>From Al Viro:

Fix a macro typo which could break if the macro is passed arguments with
side-effects.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>

Index: linux-2.6.13-rc6/arch/um/include/sysdep-x86_64/ptrace.h
===
--- linux-2.6.13-rc6.orig/arch/um/include/sysdep-x86_64/ptrace.h
2005-06-17 15:48:29.0 -0400
+++ linux-2.6.13-rc6/arch/um/include/sysdep-x86_64/ptrace.h 2005-08-15 
13:32:57.0 -0400
@@ -227,7 +227,7 @@
 panic("Bad register in UPT_SET : %d\n", reg);  \
break; \
 } \
-val; \
+__upt_val; \
 })
 
 #define UPT_SET_SYSCALL_RETURN(r, res) \

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML -

2005-08-15 Thread Jeff Dike
From Al Viro:

Fix a macro typo which could break if the macro is passed arguments with
side-effects.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]

Index: linux-2.6.13-rc6/arch/um/include/sysdep-x86_64/ptrace.h
===
--- linux-2.6.13-rc6.orig/arch/um/include/sysdep-x86_64/ptrace.h
2005-06-17 15:48:29.0 -0400
+++ linux-2.6.13-rc6/arch/um/include/sysdep-x86_64/ptrace.h 2005-08-15 
13:32:57.0 -0400
@@ -227,7 +227,7 @@
 panic(Bad register in UPT_SET : %d\n, reg);  \
break; \
 } \
-val; \
+__upt_val; \
 })
 
 #define UPT_SET_SYSCALL_RETURN(r, res) \

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 2/4] Uml support: reorganize PTRACE_SYSEMU support

2005-07-27 Thread blaisorblade

From: Bodo Stroesser <[EMAIL PROTECTED]>

With this patch, we change the way we handle switching from PTRACE_SYSEMU to
PTRACE_{SINGLESTEP,SYSCALL}, to free TIF_SYSCALL_EMU from double use as a
preparation for PTRACE_SYSEMU_SINGLESTEP extension, without changing the
behavior of the host kernel.

Signed-off-by: Bodo Stroesser <[EMAIL PROTECTED]>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
---

 linux-2.6.git-paolo/arch/i386/kernel/entry.S  |8 
 linux-2.6.git-paolo/arch/i386/kernel/ptrace.c |   43 --
 2 files changed, 21 insertions(+), 30 deletions(-)

diff -puN arch/i386/kernel/entry.S~sysemu-reorganize arch/i386/kernel/entry.S
--- linux-2.6.git/arch/i386/kernel/entry.S~sysemu-reorganize2005-07-26 
20:25:58.0 +0200
+++ linux-2.6.git-paolo/arch/i386/kernel/entry.S2005-07-26 
20:25:58.0 +0200
@@ -339,12 +339,18 @@ syscall_trace_entry:
xorl %edx,%edx
call do_syscall_trace
cmpl $0, %eax
-   jne syscall_exit# ret != 0 -> running under 
PTRACE_SYSEMU,
+   jne syscall_skip# ret != 0 -> running under 
PTRACE_SYSEMU,
# so must skip actual syscall
movl ORIG_EAX(%esp), %eax
cmpl $(nr_syscalls), %eax
jnae syscall_call
jmp syscall_exit
+syscall_skip:
+   cli # make sure we don't miss an interrupt
+   # setting need_resched or sigpending
+   # between sampling and the iret
+   movl TI_flags(%ebp), %ecx
+   jmp work_pending
 
# perform syscall exit tracing
ALIGN
diff -puN arch/i386/kernel/ptrace.c~sysemu-reorganize arch/i386/kernel/ptrace.c
--- linux-2.6.git/arch/i386/kernel/ptrace.c~sysemu-reorganize   2005-07-26 
20:25:58.0 +0200
+++ linux-2.6.git-paolo/arch/i386/kernel/ptrace.c   2005-07-26 
20:39:57.0 +0200
@@ -515,21 +515,14 @@ asmlinkage int sys_ptrace(long request, 
ret = -EIO;
if (!valid_signal(data))
break;
-   /* If we came here with PTRACE_SYSEMU and now continue with
-* PTRACE_SYSCALL, entry.S used to intercept the syscall return.
-* But it shouldn't!
-* So we don't clear TIF_SYSCALL_EMU, which is always unused in
-* this special case, to remember, we came from SYSEMU. That
-* flag will be cleared by do_syscall_trace().
-*/
if (request == PTRACE_SYSEMU) {
set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
-   } else if (request == PTRACE_CONT) {
-   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
-   }
-   if (request == PTRACE_SYSCALL) {
+   clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+   } else if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
} else {
+   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
}
child->exit_code = data;
@@ -558,8 +551,7 @@ asmlinkage int sys_ptrace(long request, 
ret = -EIO;
if (!valid_signal(data))
break;
-   /*See do_syscall_trace to know why we don't clear
-* TIF_SYSCALL_EMU.*/
+   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
set_singlestep(child);
child->exit_code = data;
@@ -694,7 +686,7 @@ void send_sigtrap(struct task_struct *ts
 __attribute__((regparm(3)))
 int do_syscall_trace(struct pt_regs *regs, int entryexit)
 {
-   int is_sysemu, is_systrace, is_singlestep, ret = 0;
+   int is_sysemu, is_singlestep, ret = 0;
/* do the secure computing check first */
secure_computing(regs->orig_eax);
 
@@ -705,25 +697,13 @@ int do_syscall_trace(struct pt_regs *reg
goto out;
 
is_sysemu = test_thread_flag(TIF_SYSCALL_EMU);
-   is_systrace = test_thread_flag(TIF_SYSCALL_TRACE);
is_singlestep = test_thread_flag(TIF_SINGLESTEP);
 
-   /* We can detect the case of coming from PTRACE_SYSEMU and now running
-* with PTRACE_SYSCALL or PTRACE_SINGLESTEP, by TIF_SYSCALL_EMU being
-* set additionally.
-* If so let's reset the flag and return without action (no singlestep
-* nor syscall tracing, since no actual step has been executed).
-*/
-   if (is_sysemu && (is_systrace || is_singlestep)) {
-   clear_thread_flag(TIF_SYSCALL_EMU);
-   goto out;
-   }
-
/* Fake 

[patch 2/4] Uml support: reorganize PTRACE_SYSEMU support

2005-07-27 Thread blaisorblade

From: Bodo Stroesser [EMAIL PROTECTED]

With this patch, we change the way we handle switching from PTRACE_SYSEMU to
PTRACE_{SINGLESTEP,SYSCALL}, to free TIF_SYSCALL_EMU from double use as a
preparation for PTRACE_SYSEMU_SINGLESTEP extension, without changing the
behavior of the host kernel.

Signed-off-by: Bodo Stroesser [EMAIL PROTECTED]
Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
---

 linux-2.6.git-paolo/arch/i386/kernel/entry.S  |8 
 linux-2.6.git-paolo/arch/i386/kernel/ptrace.c |   43 --
 2 files changed, 21 insertions(+), 30 deletions(-)

diff -puN arch/i386/kernel/entry.S~sysemu-reorganize arch/i386/kernel/entry.S
--- linux-2.6.git/arch/i386/kernel/entry.S~sysemu-reorganize2005-07-26 
20:25:58.0 +0200
+++ linux-2.6.git-paolo/arch/i386/kernel/entry.S2005-07-26 
20:25:58.0 +0200
@@ -339,12 +339,18 @@ syscall_trace_entry:
xorl %edx,%edx
call do_syscall_trace
cmpl $0, %eax
-   jne syscall_exit# ret != 0 - running under 
PTRACE_SYSEMU,
+   jne syscall_skip# ret != 0 - running under 
PTRACE_SYSEMU,
# so must skip actual syscall
movl ORIG_EAX(%esp), %eax
cmpl $(nr_syscalls), %eax
jnae syscall_call
jmp syscall_exit
+syscall_skip:
+   cli # make sure we don't miss an interrupt
+   # setting need_resched or sigpending
+   # between sampling and the iret
+   movl TI_flags(%ebp), %ecx
+   jmp work_pending
 
# perform syscall exit tracing
ALIGN
diff -puN arch/i386/kernel/ptrace.c~sysemu-reorganize arch/i386/kernel/ptrace.c
--- linux-2.6.git/arch/i386/kernel/ptrace.c~sysemu-reorganize   2005-07-26 
20:25:58.0 +0200
+++ linux-2.6.git-paolo/arch/i386/kernel/ptrace.c   2005-07-26 
20:39:57.0 +0200
@@ -515,21 +515,14 @@ asmlinkage int sys_ptrace(long request, 
ret = -EIO;
if (!valid_signal(data))
break;
-   /* If we came here with PTRACE_SYSEMU and now continue with
-* PTRACE_SYSCALL, entry.S used to intercept the syscall return.
-* But it shouldn't!
-* So we don't clear TIF_SYSCALL_EMU, which is always unused in
-* this special case, to remember, we came from SYSEMU. That
-* flag will be cleared by do_syscall_trace().
-*/
if (request == PTRACE_SYSEMU) {
set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
-   } else if (request == PTRACE_CONT) {
-   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
-   }
-   if (request == PTRACE_SYSCALL) {
+   clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+   } else if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
} else {
+   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
}
child-exit_code = data;
@@ -558,8 +551,7 @@ asmlinkage int sys_ptrace(long request, 
ret = -EIO;
if (!valid_signal(data))
break;
-   /*See do_syscall_trace to know why we don't clear
-* TIF_SYSCALL_EMU.*/
+   clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
set_singlestep(child);
child-exit_code = data;
@@ -694,7 +686,7 @@ void send_sigtrap(struct task_struct *ts
 __attribute__((regparm(3)))
 int do_syscall_trace(struct pt_regs *regs, int entryexit)
 {
-   int is_sysemu, is_systrace, is_singlestep, ret = 0;
+   int is_sysemu, is_singlestep, ret = 0;
/* do the secure computing check first */
secure_computing(regs-orig_eax);
 
@@ -705,25 +697,13 @@ int do_syscall_trace(struct pt_regs *reg
goto out;
 
is_sysemu = test_thread_flag(TIF_SYSCALL_EMU);
-   is_systrace = test_thread_flag(TIF_SYSCALL_TRACE);
is_singlestep = test_thread_flag(TIF_SINGLESTEP);
 
-   /* We can detect the case of coming from PTRACE_SYSEMU and now running
-* with PTRACE_SYSCALL or PTRACE_SINGLESTEP, by TIF_SYSCALL_EMU being
-* set additionally.
-* If so let's reset the flag and return without action (no singlestep
-* nor syscall tracing, since no actual step has been executed).
-*/
-   if (is_sysemu  (is_systrace || is_singlestep)) {
-   clear_thread_flag(TIF_SYSCALL_EMU);
-   goto out;
-   }
-
/* Fake a debug trap 

[PATCH 2/4] UML - Add skas0 command-line option

2005-07-26 Thread Jeff Dike
From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>

This adds the "skas0" parameter to force skas0 operation on SKAS3 host and
shows which operating mode has been selected.

Not intrusive, much more trivial than Bodo's patch, to merge for 2.6.13.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>

Index: linux-2.6.12/arch/um/kernel/process.c
===
--- linux-2.6.12.orig/arch/um/kernel/process.c  2005-07-23 09:27:27.0 
-0400
+++ linux-2.6.12/arch/um/kernel/process.c   2005-07-23 10:56:54.0 
-0400
@@ -212,12 +212,26 @@
 
 static int force_sysemu_disabled = 0;
 
+int ptrace_faultinfo = 1;
+int proc_mm = 1;
+
+static int __init skas0_cmd_param(char *str, int* add)
+{
+   ptrace_faultinfo = proc_mm = 0;
+   return 0;
+}
+
 static int __init nosysemu_cmd_param(char *str, int* add)
 {
force_sysemu_disabled = 1;
return 0;
 }
 
+__uml_setup("skas0", skas0_cmd_param,
+   "skas0\n"
+   "Disables SKAS3 usage, so that SKAS0 is used, unless you \n"
+   "specify mode=tt.\n\n");
+
 __uml_setup("nosysemu", nosysemu_cmd_param,
"nosysemu\n"
"Turns off syscall emulation patch for ptrace (SYSEMU) 
on.\n"
@@ -359,12 +373,10 @@
kill(target, SIGIO);
 }
 
-int ptrace_faultinfo = 0;
-int proc_mm = 1;
-
 extern void *__syscall_stub_start, __syscall_stub_end;
 
 #ifdef UML_CONFIG_MODE_SKAS
+
 static inline void check_skas3_ptrace_support(void)
 {
struct ptrace_faultinfo fi;
@@ -375,6 +387,7 @@
 
n = ptrace(PTRACE_FAULTINFO, pid, 0, );
if (n < 0) {
+   ptrace_faultinfo = 0;
if(errno == EIO)
printf("not found\n");
else {
@@ -382,8 +395,10 @@
}
}
else {
-   ptrace_faultinfo = 1;
-   printf("found\n");
+   if (!ptrace_faultinfo)
+   printf("found but disabled on command line\n");
+   else
+   printf("found\n");
}
 
init_registers(pid);
@@ -396,13 +411,13 @@
if (os_access("/proc/mm", OS_ACC_W_OK) < 0) {
proc_mm = 0;
printf("not found\n");
-   goto out;
-   }
-   else {
-   printf("found\n");
+   } else {
+   if (!proc_mm)
+   printf("found but disabled on command line\n");
+   else
+   printf("found\n");
}
 
-out:
check_skas3_ptrace_support();
return 1;
 }
Index: linux-2.6.12/arch/um/kernel/um_arch.c
===
--- linux-2.6.12.orig/arch/um/kernel/um_arch.c  2005-07-23 09:27:27.0 
-0400
+++ linux-2.6.12/arch/um/kernel/um_arch.c   2005-07-23 10:59:25.0 
-0400
@@ -38,6 +38,9 @@
 #include "choose-mode.h"
 #include "mode_kern.h"
 #include "mode.h"
+#ifdef UML_CONFIG_MODE_SKAS
+#include "skas.h"
+#endif
 
 #define DEFAULT_COMMAND_LINE "root=98:0"
 
@@ -318,6 +321,7 @@
unsigned long avail, diff;
unsigned long virtmem_size, max_physmem;
unsigned int i, add;
+   char * mode;
 
for (i = 1; i < argc; i++){
if((i == 1) && (argv[i][0] == ' ')) continue;
@@ -338,6 +342,21 @@
exit(1);
}
 #endif
+
+#ifndef CONFIG_MODE_SKAS
+   mode = "TT";
+#else
+   /* Show to the user the result of selection */
+   if (mode_tt)
+   mode = "TT";
+   else if (proc_mm && ptrace_faultinfo)
+   mode = "SKAS3";
+   else
+   mode = "SKAS0";
+#endif
+
+   printf("UML running in %s mode\n", mode);
+
uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
 _task_size, _size);
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] UML - Add skas0 command-line option

2005-07-26 Thread Jeff Dike
From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]

This adds the skas0 parameter to force skas0 operation on SKAS3 host and
shows which operating mode has been selected.

Not intrusive, much more trivial than Bodo's patch, to merge for 2.6.13.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]

Index: linux-2.6.12/arch/um/kernel/process.c
===
--- linux-2.6.12.orig/arch/um/kernel/process.c  2005-07-23 09:27:27.0 
-0400
+++ linux-2.6.12/arch/um/kernel/process.c   2005-07-23 10:56:54.0 
-0400
@@ -212,12 +212,26 @@
 
 static int force_sysemu_disabled = 0;
 
+int ptrace_faultinfo = 1;
+int proc_mm = 1;
+
+static int __init skas0_cmd_param(char *str, int* add)
+{
+   ptrace_faultinfo = proc_mm = 0;
+   return 0;
+}
+
 static int __init nosysemu_cmd_param(char *str, int* add)
 {
force_sysemu_disabled = 1;
return 0;
 }
 
+__uml_setup(skas0, skas0_cmd_param,
+   skas0\n
+   Disables SKAS3 usage, so that SKAS0 is used, unless you \n
+   specify mode=tt.\n\n);
+
 __uml_setup(nosysemu, nosysemu_cmd_param,
nosysemu\n
Turns off syscall emulation patch for ptrace (SYSEMU) 
on.\n
@@ -359,12 +373,10 @@
kill(target, SIGIO);
 }
 
-int ptrace_faultinfo = 0;
-int proc_mm = 1;
-
 extern void *__syscall_stub_start, __syscall_stub_end;
 
 #ifdef UML_CONFIG_MODE_SKAS
+
 static inline void check_skas3_ptrace_support(void)
 {
struct ptrace_faultinfo fi;
@@ -375,6 +387,7 @@
 
n = ptrace(PTRACE_FAULTINFO, pid, 0, fi);
if (n  0) {
+   ptrace_faultinfo = 0;
if(errno == EIO)
printf(not found\n);
else {
@@ -382,8 +395,10 @@
}
}
else {
-   ptrace_faultinfo = 1;
-   printf(found\n);
+   if (!ptrace_faultinfo)
+   printf(found but disabled on command line\n);
+   else
+   printf(found\n);
}
 
init_registers(pid);
@@ -396,13 +411,13 @@
if (os_access(/proc/mm, OS_ACC_W_OK)  0) {
proc_mm = 0;
printf(not found\n);
-   goto out;
-   }
-   else {
-   printf(found\n);
+   } else {
+   if (!proc_mm)
+   printf(found but disabled on command line\n);
+   else
+   printf(found\n);
}
 
-out:
check_skas3_ptrace_support();
return 1;
 }
Index: linux-2.6.12/arch/um/kernel/um_arch.c
===
--- linux-2.6.12.orig/arch/um/kernel/um_arch.c  2005-07-23 09:27:27.0 
-0400
+++ linux-2.6.12/arch/um/kernel/um_arch.c   2005-07-23 10:59:25.0 
-0400
@@ -38,6 +38,9 @@
 #include choose-mode.h
 #include mode_kern.h
 #include mode.h
+#ifdef UML_CONFIG_MODE_SKAS
+#include skas.h
+#endif
 
 #define DEFAULT_COMMAND_LINE root=98:0
 
@@ -318,6 +321,7 @@
unsigned long avail, diff;
unsigned long virtmem_size, max_physmem;
unsigned int i, add;
+   char * mode;
 
for (i = 1; i  argc; i++){
if((i == 1)  (argv[i][0] == ' ')) continue;
@@ -338,6 +342,21 @@
exit(1);
}
 #endif
+
+#ifndef CONFIG_MODE_SKAS
+   mode = TT;
+#else
+   /* Show to the user the result of selection */
+   if (mode_tt)
+   mode = TT;
+   else if (proc_mm  ptrace_faultinfo)
+   mode = SKAS3;
+   else
+   mode = SKAS0;
+#endif
+
+   printf(UML running in %s mode\n, mode);
+
uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
 host_task_size, task_size);
 

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/