Re: [PATCH 0/5] UM: Fine-tuning for some function implementations

2017-01-19 Thread Jeff Dike
The kmalloc(sizeof(struct foo), ...) => kmalloc(sizeof(*foo), ...)
ones are OK.

The rest is cargo-cult programming.

Jeff
-- 
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)


Re: [PATCH 0/5] UM: Fine-tuning for some function implementations

2017-01-19 Thread Jeff Dike
The kmalloc(sizeof(struct foo), ...) => kmalloc(sizeof(*foo), ...)
ones are OK.

The rest is cargo-cult programming.

Jeff
-- 
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)


Re: [PATCH 1/5] um: port: Move an assignment for the variable "fd" in port_wait()

2017-01-18 Thread Jeff Dike
On Wed, Jan 18, 2017 at 10:56:17PM +0100, SF Markus Elfring wrote:
> diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
> index 40ca5cc275e9..b2bbda21c5f3 100644
> --- a/arch/um/drivers/port_kern.c
> +++ b/arch/um/drivers/port_kern.c
> @@ -230,10 +230,10 @@ int port_wait(void *data)
>  
>   atomic_inc(>wait_count);
>   while (1) {
> - fd = -ERESTARTSYS;
> - if (wait_for_completion_interruptible(>done))
> + if (wait_for_completion_interruptible(>done)) {
> + fd = -ERESTARTSYS;
>   goto out;
> -
> + }
>   spin_lock(>lock);
>  
>   conn = list_entry(port->connections.next, struct connection,
> -- 
> 2.11.0
>

The current code is pretty standard kernel coding style.  The inline
fd = -ERESTARTSYS;
is likely free, or close to it, and I believe that having anything
besides a goto inside the if could make it significantly more
expensive.

Jeff

-- 
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)


Re: [PATCH 1/5] um: port: Move an assignment for the variable "fd" in port_wait()

2017-01-18 Thread Jeff Dike
On Wed, Jan 18, 2017 at 10:56:17PM +0100, SF Markus Elfring wrote:
> diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
> index 40ca5cc275e9..b2bbda21c5f3 100644
> --- a/arch/um/drivers/port_kern.c
> +++ b/arch/um/drivers/port_kern.c
> @@ -230,10 +230,10 @@ int port_wait(void *data)
>  
>   atomic_inc(>wait_count);
>   while (1) {
> - fd = -ERESTARTSYS;
> - if (wait_for_completion_interruptible(>done))
> + if (wait_for_completion_interruptible(>done)) {
> + fd = -ERESTARTSYS;
>   goto out;
> -
> + }
>   spin_lock(>lock);
>  
>   conn = list_entry(port->connections.next, struct connection,
> -- 
> 2.11.0
>

The current code is pretty standard kernel coding style.  The inline
fd = -ERESTARTSYS;
is likely free, or close to it, and I believe that having anything
besides a goto inside the if could make it significantly more
expensive.

Jeff

-- 
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)


Re: [PATCH 2/5] um: port: Delete three error messages for a failed memory allocation

2017-01-18 Thread Jeff Dike
> --- a/arch/um/drivers/port_kern.c
> +++ b/arch/um/drivers/port_kern.c
> @@ -87,11 +87,8 @@ static int port_accept(struct port_list *port)
>   }
>  
>   conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
> - if (conn == NULL) {
> - printk(KERN_ERR "port_accept : failed to allocate "
> -"connection\n");
> + if (!conn)
>   goto out_close;
> - }
>   *conn = ((struct connection)
>   { .list = LIST_HEAD_INIT(conn->list),
> .fd   = fd,

I don't see how this eliminates a possible error.  It should behave
exactly the same.  To me, this is an expressiveness issue.

!x is something you use with something that is conceptually a Boolean.

x == NULL is a question about a pointer, which is the case here.

Jeff
-- 
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)


Re: [PATCH 2/5] um: port: Delete three error messages for a failed memory allocation

2017-01-18 Thread Jeff Dike
> --- a/arch/um/drivers/port_kern.c
> +++ b/arch/um/drivers/port_kern.c
> @@ -87,11 +87,8 @@ static int port_accept(struct port_list *port)
>   }
>  
>   conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
> - if (conn == NULL) {
> - printk(KERN_ERR "port_accept : failed to allocate "
> -"connection\n");
> + if (!conn)
>   goto out_close;
> - }
>   *conn = ((struct connection)
>   { .list = LIST_HEAD_INIT(conn->list),
> .fd   = fd,

I don't see how this eliminates a possible error.  It should behave
exactly the same.  To me, this is an expressiveness issue.

!x is something you use with something that is conceptually a Boolean.

x == NULL is a question about a pointer, which is the case here.

Jeff
-- 
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)


Re: Should a x86 gdb work under an x86_64 kernel?

2008-02-25 Thread Jeff Dike
On Mon, Feb 25, 2008 at 09:49:43AM -0500, Theodore Ts'o wrote:
>   I've noticed that if I try to use a 32-bit x86 gdb to debug a
> 32-bit program under a 64-bit x86_64 kernel, gdb (version 6.6-debian,
> from Ubuntu Gutsy) immediately core dumps as soon as I run the test
> program under the debugger.  Is this normal/expected/known bug?

Probably - UML broke too.

Roland found the bug and posted a patch fairly quickly -
http://marc.info/?l=linux-kernel=120365510230307=raw

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: Should a x86 gdb work under an x86_64 kernel?

2008-02-25 Thread Jeff Dike
On Mon, Feb 25, 2008 at 09:49:43AM -0500, Theodore Ts'o wrote:
   I've noticed that if I try to use a 32-bit x86 gdb to debug a
 32-bit program under a 64-bit x86_64 kernel, gdb (version 6.6-debian,
 from Ubuntu Gutsy) immediately core dumps as soon as I run the test
 program under the debugger.  Is this normal/expected/known bug?

Probably - UML broke too.

Roland found the bug and posted a patch fairly quickly -
http://marc.info/?l=linux-kernelm=120365510230307q=raw

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: [bug] uml doesn't boot under 2.6.25-rc1 host (was Re: 2.6.24-mm1 bugs)

2008-02-21 Thread Jeff Dike
On Thu, Feb 21, 2008 at 06:20:23PM +0100, Miklos Szeredi wrote:
> Bisected it down to
> 
> good e7b5e11eaaa8ef93a34e68016de51152d0d62911
> bad  bde6f5f59c2b2b48a7a849c129d5b48838fe77ee
> 
> I strongly suspect it's one of the ptrace cleanup patches.  Roland,
> could you please have a look?

I agree.  There's an awful lot of ptrace stuff in that range, and some
of it apparently broke 32-bit compatibility.

Thanks for chasing it down.

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: [bug] uml doesn't boot under 2.6.25-rc1 host (was Re: 2.6.24-mm1 bugs)

2008-02-21 Thread Jeff Dike
On Thu, Feb 21, 2008 at 06:20:23PM +0100, Miklos Szeredi wrote:
 Bisected it down to
 
 good e7b5e11eaaa8ef93a34e68016de51152d0d62911
 bad  bde6f5f59c2b2b48a7a849c129d5b48838fe77ee
 
 I strongly suspect it's one of the ptrace cleanup patches.  Roland,
 could you please have a look?

I agree.  There's an awful lot of ptrace stuff in that range, and some
of it apparently broke 32-bit compatibility.

Thanks for chasing it down.

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 09/16] um: use get_personality()

2008-02-20 Thread Jeff Dike
On Wed, Feb 20, 2008 at 07:19:13PM +0800, WANG Cong wrote:
> Signed-off-by: WANG Cong <[EMAIL PROTECTED]>

Looks good - you should add some sort of changelog though.

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 09/16] um: use get_personality()

2008-02-20 Thread Jeff Dike
On Wed, Feb 20, 2008 at 07:19:13PM +0800, WANG Cong wrote:
 Signed-off-by: WANG Cong [EMAIL PROTECTED]

Looks good - you should add some sort of changelog though.

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: 2.6.24-mm1 bugs

2008-02-15 Thread Jeff Dike
On Fri, Feb 15, 2008 at 08:52:04PM +0100, Miklos Szeredi wrote:
> > What does it do?
> 
> See below.

> [0.42] Checking host MADV_REMOVE support...<3>MADV_REMOVE failed, err 
> = -38

Where'd MADV_REMOVE go?  I have it on 2.6.24.

> [0.42] Failed to get registers from stub, errno = 3
> [0.42] wait_stub_done : failed to wait for SIGTRAP, pid = 30073, n = 
> 30073, errno = 0, status = 0x0

Is utrace in there, by any chance?  When I see crazy stuff like this,
I think utrace.

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: 2.6.24-mm1 bugs

2008-02-15 Thread Jeff Dike
On Fri, Feb 15, 2008 at 12:43:45PM +0100, Miklos Szeredi wrote:
>  - UML doesn't boot: guest is 2.6.24-mm1 also, haven't tried any
>other.  Same guest boots fine on 2.6.24 host.

What does it do?

Any chance you can bisect it?

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/


[RFC PATCH] Address spaces as independent objects

2008-02-15 Thread Jeff Dike
Below is a patch which allows address spaces to be created,
manipulated, and destroyed independently of processes.

The additions are
two system calls, new_mm and switch_mm
/proc//mm
PTRACE_SWITCH_MM

new_mm() returns a file descriptor referencing a new address space
which is a copy of the current one.

switch_mm(fd, save_regs, new_regs, ip, sp) switches the current
process to the address space referenced by fd.  If save_regs is
non-NULL, then the current registers are saved there.  It must be a
userspace pointer that's valid in the current address space.  If
new_regs is non-NULL, the registers are restored from there.  It must
be a userspace pointer valid in the new address space.  If new_regs is
NULL, then ip and sp will be used to initialize the instruction
pointer and stack pointer, respectively.

Opening /proc//mm gives you a descriptor referencing the address
space of the given process.  If you are switching temporarily to
another address space and want to come back to the current one, then
you need to open /proc/self/mm and use that descriptor to return.

PTRACE_SWITCH_MM takes a file descriptor in data and makes the child
process switch to the address space referenced by it.

If you're familiar with UML, you'll recognize this stuff as what's in
the host SKAS3 patch, except with a different interface.

The purpose behind this is to allow UML to run more efficiently.  With
this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build
performance in the 82% - 83% range compared to native on i386.

Internal interface changes - I made some previously static functions
global:
dup_mm - address space duplication
getreg, putreg, getreg32, putreg32 - save and restore process
register state

The guts of this are in mm/mmfs.c, which implements a little
filesystem sitting behind /proc//mm and new_mm().

Architecture support is there for 32 and 64-bit x86 and 32 bit compat
on 64-bit.

I want this to go into mainline, so I'd like to see it take a spin in
-mm during 2.6.24 and then go into 2.6.25 if there no major problems
with it.

TODO -
The architecture support needs work
Register saving and restoring should include the FP registers
Need to add /proc//task/mm

In order to play with this, you'll need either this patch, which is
a rolled-up patch containing both host and guest support:

http://marc.info/?l=user-mode-linux-devel=120223043225099=raw

or this broken-out series, of which the patch below is number 7:
http://marc.info/?l=user-mode-linux-devel=120223042625081=raw
http://marc.info/?l=user-mode-linux-devel=120223044925151=raw
http://marc.info/?l=user-mode-linux-devel=120223040825042=raw
http://marc.info/?l=user-mode-linux-devel=120223001024082=raw
http://marc.info/?l=user-mode-linux-devel=120223003824164=raw
http://marc.info/?l=user-mode-linux-devel=120223038325000=raw
http://marc.info/?l=user-mode-linux-devel=120223005224218=raw
http://marc.info/?l=user-mode-linux-devel=120223003124139=raw
http://marc.info/?l=user-mode-linux-devel=120223045825168=raw
http://marc.info/?l=user-mode-linux-devel=120223046325197=raw
http://marc.info/?l=user-mode-linux-devel=120223005624238=raw

These are against 2.6.24.  Build both host and guest from this tree.

Jeff

-- 
Work email - jdike at linux dot intel dot com

commit 8ebb7e2d1636f0fca44caaab936e9bfe21ae515b
Author: Jeff Dike <[EMAIL PROTECTED]>
Date:   Mon Feb 4 15:38:02 2008 -0500

Host get_mm and switch_mm

This is the new_mm, switch_mm, and /proc//mm implementation for
32- and 64-bit x86 and UML, plus 32-bit support on 64-bit x86.

diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h
index cd2327d..6b55c52 100644
--- a/arch/um/include/skas_ptrace.h
+++ b/arch/um/include/skas_ptrace.h
@@ -7,7 +7,9 @@
 #define __SKAS_PTRACE_H
 
 #define PTRACE_FAULTINFO 52
-#define PTRACE_SWITCH_MM 55
+#ifndef OLD_PTRACE_SWITCH_MM
+#define OLD_PTRACE_SWITCH_MM 55
+#endif
 
 #include "sysdep/skas_ptrace.h"
 
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 47b57b4..25721bf 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, 
long addr, long data)
}
 #endif
 #ifdef CONFIG_PROC_MM
-   case PTRACE_SWITCH_MM: {
+   case OLD_PTRACE_SWITCH_MM: {
struct mm_struct *old = child->mm;
struct mm_struct *new = proc_mm_get_mm(data);
 
@@ -292,3 +292,14 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit)
current->exit_code = 0;
}
 }
+
+int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs __user *from)
+{
+   memcpy(to, >regs, sizeof(from->regs));
+   return 0;
+}
+
+int pt_regs_to_ptrace(struct user_regs __user *to, struct pt_r

Re: [uml-devel] [Patch] arch/um/kernel/um_arch.c: some small improvements

2008-02-15 Thread Jeff Dike
On Fri, Feb 15, 2008 at 10:07:42PM +0800, WANG Cong wrote:
> 
> Make some small improvements for arch/um/kernel/um_arch.c.
> 
> Signed-off-by: WANG Cong <[EMAIL PROTECTED]>
> Cc: Jeff Dike <[EMAIL PROTECTED]>

ACK

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: [uml-devel] [Patch] arch/um/kernel/um_arch.c: some small improvements

2008-02-15 Thread Jeff Dike
On Fri, Feb 15, 2008 at 10:07:42PM +0800, WANG Cong wrote:
 
 Make some small improvements for arch/um/kernel/um_arch.c.
 
 Signed-off-by: WANG Cong [EMAIL PROTECTED]
 Cc: Jeff Dike [EMAIL PROTECTED]

ACK

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: 2.6.24-mm1 bugs

2008-02-15 Thread Jeff Dike
On Fri, Feb 15, 2008 at 12:43:45PM +0100, Miklos Szeredi wrote:
  - UML doesn't boot: guest is 2.6.24-mm1 also, haven't tried any
other.  Same guest boots fine on 2.6.24 host.

What does it do?

Any chance you can bisect it?

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: 2.6.24-mm1 bugs

2008-02-15 Thread Jeff Dike
On Fri, Feb 15, 2008 at 08:52:04PM +0100, Miklos Szeredi wrote:
  What does it do?
 
 See below.

 [0.42] Checking host MADV_REMOVE support...3MADV_REMOVE failed, err 
 = -38

Where'd MADV_REMOVE go?  I have it on 2.6.24.

 [0.42] Failed to get registers from stub, errno = 3
 [0.42] wait_stub_done : failed to wait for SIGTRAP, pid = 30073, n = 
 30073, errno = 0, status = 0x0

Is utrace in there, by any chance?  When I see crazy stuff like this,
I think utrace.

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/


[RFC PATCH] Address spaces as independent objects

2008-02-15 Thread Jeff Dike
Below is a patch which allows address spaces to be created,
manipulated, and destroyed independently of processes.

The additions are
two system calls, new_mm and switch_mm
/proc/pid/mm
PTRACE_SWITCH_MM

new_mm() returns a file descriptor referencing a new address space
which is a copy of the current one.

switch_mm(fd, save_regs, new_regs, ip, sp) switches the current
process to the address space referenced by fd.  If save_regs is
non-NULL, then the current registers are saved there.  It must be a
userspace pointer that's valid in the current address space.  If
new_regs is non-NULL, the registers are restored from there.  It must
be a userspace pointer valid in the new address space.  If new_regs is
NULL, then ip and sp will be used to initialize the instruction
pointer and stack pointer, respectively.

Opening /proc/pid/mm gives you a descriptor referencing the address
space of the given process.  If you are switching temporarily to
another address space and want to come back to the current one, then
you need to open /proc/self/mm and use that descriptor to return.

PTRACE_SWITCH_MM takes a file descriptor in data and makes the child
process switch to the address space referenced by it.

If you're familiar with UML, you'll recognize this stuff as what's in
the host SKAS3 patch, except with a different interface.

The purpose behind this is to allow UML to run more efficiently.  With
this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build
performance in the 82% - 83% range compared to native on i386.

Internal interface changes - I made some previously static functions
global:
dup_mm - address space duplication
getreg, putreg, getreg32, putreg32 - save and restore process
register state

The guts of this are in mm/mmfs.c, which implements a little
filesystem sitting behind /proc/pid/mm and new_mm().

Architecture support is there for 32 and 64-bit x86 and 32 bit compat
on 64-bit.

I want this to go into mainline, so I'd like to see it take a spin in
-mm during 2.6.24 and then go into 2.6.25 if there no major problems
with it.

TODO -
The architecture support needs work
Register saving and restoring should include the FP registers
Need to add /proc/pid/task/mm

In order to play with this, you'll need either this patch, which is
a rolled-up patch containing both host and guest support:

http://marc.info/?l=user-mode-linux-develm=120223043225099q=raw

or this broken-out series, of which the patch below is number 7:
http://marc.info/?l=user-mode-linux-develm=120223042625081q=raw
http://marc.info/?l=user-mode-linux-develm=120223044925151q=raw
http://marc.info/?l=user-mode-linux-develm=120223040825042q=raw
http://marc.info/?l=user-mode-linux-develm=120223001024082q=raw
http://marc.info/?l=user-mode-linux-develm=120223003824164q=raw
http://marc.info/?l=user-mode-linux-develm=120223038325000q=raw
http://marc.info/?l=user-mode-linux-develm=120223005224218q=raw
http://marc.info/?l=user-mode-linux-develm=120223003124139q=raw
http://marc.info/?l=user-mode-linux-develm=120223045825168q=raw
http://marc.info/?l=user-mode-linux-develm=120223046325197q=raw
http://marc.info/?l=user-mode-linux-develm=120223005624238q=raw

These are against 2.6.24.  Build both host and guest from this tree.

Jeff

-- 
Work email - jdike at linux dot intel dot com

commit 8ebb7e2d1636f0fca44caaab936e9bfe21ae515b
Author: Jeff Dike [EMAIL PROTECTED]
Date:   Mon Feb 4 15:38:02 2008 -0500

Host get_mm and switch_mm

This is the new_mm, switch_mm, and /proc/pid/mm implementation for
32- and 64-bit x86 and UML, plus 32-bit support on 64-bit x86.

diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h
index cd2327d..6b55c52 100644
--- a/arch/um/include/skas_ptrace.h
+++ b/arch/um/include/skas_ptrace.h
@@ -7,7 +7,9 @@
 #define __SKAS_PTRACE_H
 
 #define PTRACE_FAULTINFO 52
-#define PTRACE_SWITCH_MM 55
+#ifndef OLD_PTRACE_SWITCH_MM
+#define OLD_PTRACE_SWITCH_MM 55
+#endif
 
 #include sysdep/skas_ptrace.h
 
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 47b57b4..25721bf 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, 
long addr, long data)
}
 #endif
 #ifdef CONFIG_PROC_MM
-   case PTRACE_SWITCH_MM: {
+   case OLD_PTRACE_SWITCH_MM: {
struct mm_struct *old = child-mm;
struct mm_struct *new = proc_mm_get_mm(data);
 
@@ -292,3 +292,14 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit)
current-exit_code = 0;
}
 }
+
+int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs __user *from)
+{
+   memcpy(to, from-regs, sizeof(from-regs));
+   return 0;
+}
+
+int pt_regs_to_ptrace(struct user_regs __user *to, struct

Re: 2.6.24.2 won't compile UML

2008-02-14 Thread Jeff Dike
On Thu, Feb 14, 2008 at 12:13:09PM +0100, Ph. Marek wrote:
>   make -C linux-2.6.24.2/ O=output_path/build ARCH=um bzImage

>   make[2]: *** No rule to make target `bzImage'.  Stop.

This seems pretty clear, no?

bzImage is a x86-ism.  Just leave it off, and you'll get linux and vmlinux.

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: 2.6.24.2 won't compile UML

2008-02-14 Thread Jeff Dike
On Thu, Feb 14, 2008 at 12:13:09PM +0100, Ph. Marek wrote:
   make -C linux-2.6.24.2/ O=output_path/build ARCH=um bzImage

   make[2]: *** No rule to make target `bzImage'.  Stop.

This seems pretty clear, no?

bzImage is a x86-ism.  Just leave it off, and you'll get linux and vmlinux.

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] asm-*/futex.h should include linux/uaccess.h

2008-02-13 Thread Jeff Dike
[ non-urgent - 2.6.26 material ]

Lots of asm-*/futex.h call pagefault_enable and pagefault_disable,
which are declared in linux/uaccess.h, without including
linux/uaccess.h.

They all include asm/uaccess.h, so this patch replaces asm/uaccess.h
with linux/uaccess.h.

Compile-tested on sparc64, x86, ia64, mips, and powerpc.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 include/asm-generic/futex.h |2 +-
 include/asm-ia64/futex.h|2 +-
 include/asm-mips/futex.h|2 +-
 include/asm-parisc/futex.h  |2 +-
 include/asm-powerpc/futex.h |2 +-
 include/asm-sh/futex.h  |2 +-
 include/asm-sparc64/futex.h |2 +-
 include/asm-x86/futex.h |2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

Index: linux-2.6.22/include/asm-generic/futex.h
===
--- linux-2.6.22.orig/include/asm-generic/futex.h   2008-02-12 
12:47:49.0 -0500
+++ linux-2.6.22/include/asm-generic/futex.h2008-02-12 12:47:52.0 
-0500
@@ -4,8 +4,8 @@
 #ifdef __KERNEL__
 
 #include 
+#include 
 #include 
-#include 
 
 static inline int
 futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
Index: linux-2.6.22/include/asm-ia64/futex.h
===
--- linux-2.6.22.orig/include/asm-ia64/futex.h  2007-07-08 19:32:17.0 
-0400
+++ linux-2.6.22/include/asm-ia64/futex.h   2008-02-12 12:49:31.0 
-0500
@@ -2,9 +2,9 @@
 #define _ASM_FUTEX_H
 
 #include 
+#include 
 #include 
 #include 
-#include 
 
 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
 do {   \
Index: linux-2.6.22/include/asm-mips/futex.h
===
--- linux-2.6.22.orig/include/asm-mips/futex.h  2007-12-05 10:29:35.0 
-0500
+++ linux-2.6.22/include/asm-mips/futex.h   2008-02-12 12:49:49.0 
-0500
@@ -11,9 +11,9 @@
 #ifdef __KERNEL__
 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
Index: linux-2.6.22/include/asm-parisc/futex.h
===
--- linux-2.6.22.orig/include/asm-parisc/futex.h2007-07-08 
19:32:17.0 -0400
+++ linux-2.6.22/include/asm-parisc/futex.h 2008-02-12 12:50:03.0 
-0500
@@ -4,8 +4,8 @@
 #ifdef __KERNEL__
 
 #include 
+#include 
 #include 
-#include 
 
 static inline int
 futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
Index: linux-2.6.22/include/asm-powerpc/futex.h
===
--- linux-2.6.22.orig/include/asm-powerpc/futex.h   2007-07-08 
19:32:17.0 -0400
+++ linux-2.6.22/include/asm-powerpc/futex.h2008-02-12 12:50:22.0 
-0500
@@ -4,9 +4,9 @@
 #ifdef __KERNEL__
 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
Index: linux-2.6.22/include/asm-sh/futex.h
===
--- linux-2.6.22.orig/include/asm-sh/futex.h2007-10-12 12:07:06.0 
-0400
+++ linux-2.6.22/include/asm-sh/futex.h 2008-02-12 12:51:17.0 -0500
@@ -4,8 +4,8 @@
 #ifdef __KERNEL__
 
 #include 
+#include 
 #include 
-#include 
 
 /* XXX: UP variants, fix for SH-4A and SMP.. */
 #include 
Index: linux-2.6.22/include/asm-sparc64/futex.h
===
--- linux-2.6.22.orig/include/asm-sparc64/futex.h   2007-11-14 
10:33:41.0 -0500
+++ linux-2.6.22/include/asm-sparc64/futex.h2008-02-12 12:51:35.0 
-0500
@@ -2,9 +2,9 @@
 #define _SPARC64_FUTEX_H
 
 #include 
+#include 
 #include 
 #include 
-#include 
 
 #define __futex_cas_op(insn, ret, oldval, uaddr, oparg)\
__asm__ __volatile__(   \
Index: linux-2.6.22/include/asm-x86/futex.h
===
--- linux-2.6.22.orig/include/asm-x86/futex.h   2008-02-05 12:25:21.0 
-0500
+++ linux-2.6.22/include/asm-x86/futex.h2008-02-12 12:51:51.0 
-0500
@@ -4,12 +4,12 @@
 #ifdef __KERNEL__
 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg)\
   __asm__ __volatile(  \
--
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 3/4] UML - Fix helper_wait calls in watchdog

2008-02-12 Thread Jeff Dike
From: Johann Felix Soden <[EMAIL PROTECTED]>

In 1aa351a308d2c3ddb92b6cc45083fc54271d0010 the arguments of helper_wait() were
changed. The adaptation of harddog_user.c was forgotten, so this errors occur:

/arch/um/drivers/harddog_user.c: In function 'start_watchdog':
/arch/um/drivers/harddog_user.c:82: error: too many arguments to function 
'helper_wait'
/arch/um/drivers/harddog_user.c:89: error: too many arguments to function 
'helper_wait'

Signed-off-by: Johann Felix Soden <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/harddog_user.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.22/arch/um/drivers/harddog_user.c
===
--- linux-2.6.22.orig/arch/um/drivers/harddog_user.c2008-01-17 
12:50:20.0 -0500
+++ linux-2.6.22/arch/um/drivers/harddog_user.c 2008-02-11 18:46:05.0 
-0500
@@ -79,14 +79,14 @@ int start_watchdog(int *in_fd_ret, int *
n = read(in_fds[0], , sizeof(c));
if (n == 0) {
printk("harddog_open - EOF on watchdog pipe\n");
-   helper_wait(pid, 1, NULL);
+   helper_wait(pid);
err = -EIO;
goto out_close_out;
}
else if (n < 0) {
printk("harddog_open - read of watchdog pipe failed, "
   "err = %d\n", errno);
-   helper_wait(pid, 1, NULL);
+   helper_wait(pid);
err = n;
goto out_close_out;
}
--
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 1/4] UML - Fix initrd printk

2008-02-12 Thread Jeff Dike
From: Johann Felix Soden <[EMAIL PROTECTED]>

If the initrd file has zero-length, the error message should contain
the filepath.

Cc: WANG Cong <[EMAIL PROTECTED]>
Signed-off-by: Johann Felix Soden <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/kernel/initrd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Index: linux-2.6-git/arch/um/kernel/initrd.c
===
--- linux-2.6-git.orig/arch/um/kernel/initrd.c  2008-02-12 12:44:44.0 
-0500
+++ linux-2.6-git/arch/um/kernel/initrd.c   2008-02-12 13:19:11.0 
-0500
@@ -32,7 +32,7 @@ static int __init read_initrd(void)
 * ask for no memory.
 */
if (size == 0) {
-   printk(KERN_ERR "\"%\" is a zero-size initrd\n");
+   printk(KERN_ERR "\"%s\" is a zero-size initrd\n", initrd);
return 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 4/4] UML - Fix FP register corruption

2008-02-12 Thread Jeff Dike
Commit ee3d9bd4de1ed93d2a7ee41c331ed30a1c7b8acd, while greatly
simplifying the kernel SIGSEGV handler that runs in the process
address space, introduced a bug which corrupts FP state in the
process.

Previously, the SIGSEGV handler called the sigreturn system call by
hand - it couldn't return through the restorer provided to it because
that could try to call the libc restorer which likely wouldn't exist
in the process address space.  So, it blocked off some signals,
including SIGUSR1, on entry to the SIGSEGV handler, queued a SIGUSR1
to itself, and invoked sigreturn.  The SIGUSR1 was delivered, and was
visible to the UML kernel after sigreturn finished.

The commit eliminated the signal masking and the call to sigreturn.
The handler simply hits itself with a SIGTRAP to let the UML kernel
know that it is finished.  UML then restores the process registers,
which effectively longjmps the process out of the signal handler,
skipping sigreturn's restoring of register state and the signal mask.

The bug is that the host apparently sets used_fp to 0 when it saves
the process FP state in the sigcontext on the process signal stack.
Thus, when the process is longjmped out of the handler, its FP state
is corrupt because it wasn't saved on the context switch to the UML
kernel.

This manifested itself as sleep hanging.  For some reason, sleep uses
floating point in order to calculate the sleep interval.  When a page
fault corrupts its FP state, it is faked into essentially sleeping
forever.

This patch saves the FP state before entering the SIGSEGV handler and
restores it afterwards.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/registers.h |2 ++
 arch/um/include/sysdep-i386/ptrace_user.h   |3 +++
 arch/um/include/sysdep-x86_64/ptrace_user.h |3 +++
 arch/um/os-Linux/skas/process.c |   15 +++
 arch/um/os-Linux/sys-i386/registers.c   |   16 
 arch/um/os-Linux/sys-x86_64/registers.c |   10 ++
 6 files changed, 49 insertions(+)

Index: linux-2.6-git/arch/um/include/sysdep-i386/ptrace_user.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-i386/ptrace_user.h
2008-02-12 13:18:59.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-i386/ptrace_user.h 2008-02-12 
13:35:12.0 -0500
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include "user_constants.h"
 
 #define PT_OFFSET(r) ((r) * sizeof(long))
 
@@ -40,6 +41,8 @@
 #define PT_SP_OFFSET PT_OFFSET(UESP)
 #define PT_SP(regs) ((regs)[UESP])
 
+#define FP_SIZE ((HOST_XFP_SIZE > HOST_FP_SIZE) ? HOST_XFP_SIZE : HOST_FP_SIZE)
+
 #ifndef FRAME_SIZE
 #define FRAME_SIZE (17)
 #endif
Index: linux-2.6-git/arch/um/include/sysdep-x86_64/ptrace_user.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/ptrace_user.h  
2008-02-12 13:18:59.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/ptrace_user.h   2008-02-12 
13:35:12.0 -0500
@@ -12,6 +12,7 @@
 #include 
 #include 
 #undef __FRAME_OFFSETS
+#include "user_constants.h"
 
 #define PT_INDEX(off) ((off) / sizeof(unsigned long))
 
@@ -69,6 +70,8 @@
 #define REGS_IP_INDEX PT_INDEX(RIP)
 #define REGS_SP_INDEX PT_INDEX(RSP)
 
+#define FP_SIZE (HOST_FP_SIZE)
+
 #endif
 
 /*
Index: linux-2.6-git/arch/um/os-Linux/skas/process.c
===
--- linux-2.6-git.orig/arch/um/os-Linux/skas/process.c  2008-02-12 
13:18:59.0 -0500
+++ linux-2.6-git/arch/um/os-Linux/skas/process.c   2008-02-12 
13:37:02.0 -0500
@@ -115,6 +115,14 @@ void get_skas_faultinfo(int pid, struct 
   sizeof(struct ptrace_faultinfo));
}
else {
+   unsigned long fpregs[FP_SIZE];
+
+   err = get_fp_registers(pid, fpregs);
+   if (err < 0) {
+   printk(UM_KERN_ERR "save_fp_registers returned %d\n",
+  err);
+   fatal_sigsegv();
+   }
err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV);
if (err) {
printk(UM_KERN_ERR "Failed to continue stub, pid = %d, "
@@ -128,6 +136,13 @@ void get_skas_faultinfo(int pid, struct 
 * the stub stack page. We just have to copy it.
 */
memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
+
+   err = put_fp_registers(pid, fpregs);
+   if (err < 0) {
+   printk(UM_KERN_ERR "put_fp_registers returned %d\n",
+  err);
+   fatal_sigsegv();
+   }
}
 }
 
Index: linux-2.6-git/arch/um/include/registers.h
===
--- l

[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 0/4] UML - Four for 2.6.25

2008-02-12 Thread Jeff Dike
These should go to Linus - there are three build fixes and a serious bug fix.

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 3/4] UML - Fix helper_wait calls in watchdog

2008-02-12 Thread Jeff Dike
From: Johann Felix Soden [EMAIL PROTECTED]

In 1aa351a308d2c3ddb92b6cc45083fc54271d0010 the arguments of helper_wait() were
changed. The adaptation of harddog_user.c was forgotten, so this errors occur:

/arch/um/drivers/harddog_user.c: In function 'start_watchdog':
/arch/um/drivers/harddog_user.c:82: error: too many arguments to function 
'helper_wait'
/arch/um/drivers/harddog_user.c:89: error: too many arguments to function 
'helper_wait'

Signed-off-by: Johann Felix Soden [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/drivers/harddog_user.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.22/arch/um/drivers/harddog_user.c
===
--- linux-2.6.22.orig/arch/um/drivers/harddog_user.c2008-01-17 
12:50:20.0 -0500
+++ linux-2.6.22/arch/um/drivers/harddog_user.c 2008-02-11 18:46:05.0 
-0500
@@ -79,14 +79,14 @@ int start_watchdog(int *in_fd_ret, int *
n = read(in_fds[0], c, sizeof(c));
if (n == 0) {
printk(harddog_open - EOF on watchdog pipe\n);
-   helper_wait(pid, 1, NULL);
+   helper_wait(pid);
err = -EIO;
goto out_close_out;
}
else if (n  0) {
printk(harddog_open - read of watchdog pipe failed, 
   err = %d\n, errno);
-   helper_wait(pid, 1, NULL);
+   helper_wait(pid);
err = n;
goto out_close_out;
}
--
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 1/4] UML - Fix initrd printk

2008-02-12 Thread Jeff Dike
From: Johann Felix Soden [EMAIL PROTECTED]

If the initrd file has zero-length, the error message should contain
the filepath.

Cc: WANG Cong [EMAIL PROTECTED]
Signed-off-by: Johann Felix Soden [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/kernel/initrd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Index: linux-2.6-git/arch/um/kernel/initrd.c
===
--- linux-2.6-git.orig/arch/um/kernel/initrd.c  2008-02-12 12:44:44.0 
-0500
+++ linux-2.6-git/arch/um/kernel/initrd.c   2008-02-12 13:19:11.0 
-0500
@@ -32,7 +32,7 @@ static int __init read_initrd(void)
 * ask for no memory.
 */
if (size == 0) {
-   printk(KERN_ERR \%\ is a zero-size initrd\n);
+   printk(KERN_ERR \%s\ is a zero-size initrd\n, initrd);
return 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 0/4] UML - Four for 2.6.25

2008-02-12 Thread Jeff Dike
These should go to Linus - there are three build fixes and a serious bug fix.

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] slob: fix linking for user mode linux

2008-02-11 Thread Jeff Dike
On Mon, Feb 11, 2008 at 02:44:21PM -0800, Christoph Lameter wrote:
> UML defined its own external __kmalloc and things. Isnt there some other 
> way to fix it? I guess including slab.h is not possible here?

This is definitely dubious code on my part and I wouldn't support
Pekka's patch unless you're going to uninline __kmalloc for some
other reason.

The reason for this is that part of UML is userspace code, and thus
can't use kernel headers.  However, they do need some kernel
interfaces in some form.  That form has traditionally been little
wrappers in the kernel side of UML which just call the kernel
interface.

In this case, there used to be um_kmalloc, which just called kmalloc.
I've been trying to get rid of these stupid little helpers for a
while, and this is what I ended up with for kmalloc.

It would be an annoyance to reintroduce um_kmalloc, but that might be
the best thing to do here.

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] slob: fix linking for user mode linux

2008-02-11 Thread Jeff Dike
On Mon, Feb 11, 2008 at 02:44:21PM -0800, Christoph Lameter wrote:
 UML defined its own external __kmalloc and things. Isnt there some other 
 way to fix it? I guess including slab.h is not possible here?

This is definitely dubious code on my part and I wouldn't support
Pekka's patch unless you're going to uninline __kmalloc for some
other reason.

The reason for this is that part of UML is userspace code, and thus
can't use kernel headers.  However, they do need some kernel
interfaces in some form.  That form has traditionally been little
wrappers in the kernel side of UML which just call the kernel
interface.

In this case, there used to be um_kmalloc, which just called kmalloc.
I've been trying to get rid of these stupid little helpers for a
while, and this is what I ended up with for kmalloc.

It would be an annoyance to reintroduce um_kmalloc, but that might be
the best thing to do here.

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] UML - update defconfig

2008-02-07 Thread Jeff Dike
[ This is 2.6.25 fodder ]

Update defconfig.

Cc: Christoph Hellwig <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/defconfig |  280 --
 1 file changed, 187 insertions(+), 93 deletions(-)

Index: linux-2.6-git/arch/um/defconfig
===
--- linux-2.6-git.orig/arch/um/defconfig2008-02-07 11:46:12.0 
-0500
+++ linux-2.6-git/arch/um/defconfig 2008-02-07 11:49:03.0 -0500
@@ -1,13 +1,22 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.17-rc3
-# Fri Apr 28 09:31:20 2006
+# Linux kernel version: 2.6.24
+# Thu Feb  7 11:48:55 2008
 #
+CONFIG_DEFCONFIG_LIST="arch/$ARCH/defconfig"
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_UML=y
 CONFIG_MMU=y
+CONFIG_NO_IOMEM=y
+# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set
+CONFIG_LOCKDEP_SUPPORT=y
+# CONFIG_STACKTRACE_SUPPORT is not set
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
 CONFIG_IRQ_RELEASE_METHOD=y
+CONFIG_HZ=100
 
 #
 # UML-specific options
@@ -40,11 +49,13 @@ CONFIG_M686=y
 # CONFIG_MCYRIXIII is not set
 # CONFIG_MVIAC3_2 is not set
 # CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+# CONFIG_GENERIC_CPU is not set
 # CONFIG_X86_GENERIC is not set
 CONFIG_X86_CMPXCHG=y
-CONFIG_X86_XADD=y
 CONFIG_X86_L1_CACHE_SHIFT=5
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_X86_XADD=y
 CONFIG_X86_PPRO_FENCE=y
 CONFIG_X86_WP_WORKS_OK=y
 CONFIG_X86_INVLPG=y
@@ -53,7 +64,12 @@ CONFIG_X86_POPAD_OK=y
 CONFIG_X86_GOOD_APIC=y
 CONFIG_X86_USE_PPRO_CHECKSUM=y
 CONFIG_X86_TSC=y
+CONFIG_X86_CMOV=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=4
+CONFIG_X86_DEBUGCTLMSR=y
 CONFIG_UML_X86=y
+CONFIG_X86_32=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 # CONFIG_64BIT is not set
 CONFIG_SEMAPHORE_SLEEPERS=y
 # CONFIG_3_LEVEL_PGTABLES is not set
@@ -67,13 +83,18 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
 CONFIG_TICK_ONESHOT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
 CONFIG_LD_SCRIPT_DYN=y
-CONFIG_NET=y
 CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
 CONFIG_BINFMT_MISC=m
 CONFIG_HOSTFS=y
 # CONFIG_HPPFS is not set
@@ -83,31 +104,38 @@ CONFIG_MAGIC_SYSRQ=y
 CONFIG_KERNEL_STACK_ORDER=0
 
 #
-# Code maturity level options
+# General setup
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_BROKEN_ON_SMP=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
+CONFIG_INIT_ENV_ARG_LIMIT=128
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
 # CONFIG_AUDIT is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_CGROUPS is not set
+CONFIG_FAIR_GROUP_SCHED=y
+CONFIG_FAIR_USER_SCHED=y
+# CONFIG_FAIR_CGROUP_SCHED is not set
+CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
-CONFIG_INITRAMFS_SOURCE=""
-CONFIG_UID16=y
+# CONFIG_BLK_DEV_INITRD is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
 # CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_ALL is not set
 CONFIG_KALLSYMS_EXTRA_PASS=y
@@ -117,29 +145,36 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+# CONFIG_HAVE_OPROFILE is not set
+# CONFIG_HAVE_KPROBES is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
-# CONFIG_SLOB is not set
-
-#
-# Loadable module support
-#
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
-
-#
-# Block layer
-#
+CONFIG_BLOCK=y
 # CONFIG_LBD is not set
 # CONFIG_BLK_DEV_IO_TRACE is not set
 # CONFIG_LSF is not set
+# CONFIG_BLK_DEV_BSG is not set
 
 #
 # IO Schedulers
@@ -153,19 +188,16 @@ CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="anticipatory"
-
-#
-# Block devices
-#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_PREEMPT_RCU is not set
+CONFIG_BLK_DEV=y
 CONFIG_BLK_DEV_UBD=y
 # CONFIG_BLK_DEV_UBD_SYNC is not set
 CONFIG_BLK_DEV_COW_COMMON=y
-# CONFIG_MMAPPER is not set
 CONFIG_BL

[PATCH] UML - update defconfig

2008-02-07 Thread Jeff Dike
[ This is 2.6.25 fodder ]

Update defconfig.

Cc: Christoph Hellwig [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/defconfig |  280 --
 1 file changed, 187 insertions(+), 93 deletions(-)

Index: linux-2.6-git/arch/um/defconfig
===
--- linux-2.6-git.orig/arch/um/defconfig2008-02-07 11:46:12.0 
-0500
+++ linux-2.6-git/arch/um/defconfig 2008-02-07 11:49:03.0 -0500
@@ -1,13 +1,22 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.17-rc3
-# Fri Apr 28 09:31:20 2006
+# Linux kernel version: 2.6.24
+# Thu Feb  7 11:48:55 2008
 #
+CONFIG_DEFCONFIG_LIST=arch/$ARCH/defconfig
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_UML=y
 CONFIG_MMU=y
+CONFIG_NO_IOMEM=y
+# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set
+CONFIG_LOCKDEP_SUPPORT=y
+# CONFIG_STACKTRACE_SUPPORT is not set
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
 CONFIG_IRQ_RELEASE_METHOD=y
+CONFIG_HZ=100
 
 #
 # UML-specific options
@@ -40,11 +49,13 @@ CONFIG_M686=y
 # CONFIG_MCYRIXIII is not set
 # CONFIG_MVIAC3_2 is not set
 # CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+# CONFIG_GENERIC_CPU is not set
 # CONFIG_X86_GENERIC is not set
 CONFIG_X86_CMPXCHG=y
-CONFIG_X86_XADD=y
 CONFIG_X86_L1_CACHE_SHIFT=5
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_X86_XADD=y
 CONFIG_X86_PPRO_FENCE=y
 CONFIG_X86_WP_WORKS_OK=y
 CONFIG_X86_INVLPG=y
@@ -53,7 +64,12 @@ CONFIG_X86_POPAD_OK=y
 CONFIG_X86_GOOD_APIC=y
 CONFIG_X86_USE_PPRO_CHECKSUM=y
 CONFIG_X86_TSC=y
+CONFIG_X86_CMOV=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=4
+CONFIG_X86_DEBUGCTLMSR=y
 CONFIG_UML_X86=y
+CONFIG_X86_32=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
 # CONFIG_64BIT is not set
 CONFIG_SEMAPHORE_SLEEPERS=y
 # CONFIG_3_LEVEL_PGTABLES is not set
@@ -67,13 +83,18 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
 CONFIG_TICK_ONESHOT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
 CONFIG_LD_SCRIPT_DYN=y
-CONFIG_NET=y
 CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
 CONFIG_BINFMT_MISC=m
 CONFIG_HOSTFS=y
 # CONFIG_HPPFS is not set
@@ -83,31 +104,38 @@ CONFIG_MAGIC_SYSRQ=y
 CONFIG_KERNEL_STACK_ORDER=0
 
 #
-# Code maturity level options
+# General setup
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_BROKEN_ON_SMP=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
+CONFIG_INIT_ENV_ARG_LIMIT=128
 CONFIG_LOCALVERSION=
 CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
 # CONFIG_AUDIT is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_CGROUPS is not set
+CONFIG_FAIR_GROUP_SCHED=y
+CONFIG_FAIR_USER_SCHED=y
+# CONFIG_FAIR_CGROUP_SCHED is not set
+CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
-CONFIG_INITRAMFS_SOURCE=
-CONFIG_UID16=y
+# CONFIG_BLK_DEV_INITRD is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
 # CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_ALL is not set
 CONFIG_KALLSYMS_EXTRA_PASS=y
@@ -117,29 +145,36 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+# CONFIG_HAVE_OPROFILE is not set
+# CONFIG_HAVE_KPROBES is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
-# CONFIG_SLOB is not set
-
-#
-# Loadable module support
-#
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 CONFIG_KMOD=y
-
-#
-# Block layer
-#
+CONFIG_BLOCK=y
 # CONFIG_LBD is not set
 # CONFIG_BLK_DEV_IO_TRACE is not set
 # CONFIG_LSF is not set
+# CONFIG_BLK_DEV_BSG is not set
 
 #
 # IO Schedulers
@@ -153,19 +188,16 @@ CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED=anticipatory
-
-#
-# Block devices
-#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_PREEMPT_RCU is not set
+CONFIG_BLK_DEV=y
 CONFIG_BLK_DEV_UBD=y
 # CONFIG_BLK_DEV_UBD_SYNC is not set
 CONFIG_BLK_DEV_COW_COMMON=y
-# CONFIG_MMAPPER is not set
 CONFIG_BLK_DEV_LOOP=m
 # CONFIG_BLK_DEV_CRYPTOLOOP is not set

[PATCH 3/5] UML - Improved error handling while locating temp dir

2008-02-06 Thread Jeff Dike
From: Jim Meyering <[EMAIL PROTECTED]>

* arch/um/os-Linux/mem.c (make_tempfile): Don't deref NULL upon failed malloc.

* arch/um/os-Linux/mem.c (make_tempfile): Handle NULL tempdir.
Don't let a long tempdir (e.g., via TMPDIR) provoke heap corruption.

[ jdike - formatting cleanups, deleted obsolete comment ]

Signed-off-by: Jim Meyering <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/os-Linux/mem.c |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

Index: linux-2.6-git/arch/um/os-Linux/mem.c
===
--- linux-2.6-git.orig/arch/um/os-Linux/mem.c   2008-02-05 13:20:46.0 
-0500
+++ linux-2.6-git/arch/um/os-Linux/mem.c2008-02-05 16:37:37.0 
-0500
@@ -162,11 +162,6 @@ found:
goto out;
 }
 
-/*
- * This proc still used in tt-mode
- * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger).
- * So it isn't 'static' yet.
- */
 static int __init make_tempfile(const char *template, char **out_tempname,
int do_unlink)
 {
@@ -175,10 +170,13 @@ static int __init make_tempfile(const ch
 
which_tmpdir();
tempname = malloc(MAXPATHLEN);
-   if (!tempname)
-   goto out;
+   if (tempname == NULL)
+   return -1;
 
find_tempdir();
+   if ((tempdir == NULL) || (strlen(tempdir) >= MAXPATHLEN))
+   return -1;
+
if (template[0] != '/')
strcpy(tempname, tempdir);
else
@@ -196,9 +194,8 @@ static int __init make_tempfile(const ch
}
if (out_tempname) {
*out_tempname = tempname;
-   } else {
+   } else
free(tempname);
-   }
return fd;
 out:
free(tempname);
--
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/5] UML - Style fixes in arch/um/os-Linux

2008-02-06 Thread Jeff Dike
Style changes under arch/um/os-Linux:
include trimming
CodingStyle fixes
some printks needed severity indicators 

make_tempfile turns out not to be used outside of mem.c, so it is now
static.  Its declaration in tempfile.h is no longer needed, and
tempfile.h itself is no longer needed.

create_tmp_file was also made static.

checkpatch moans about an EXPORT_SYMBOL in user_syms.c which is part
of a macro definition - this is copying a bit of kernel infrastructure
into the libc side of UML because the kernel headers can't be included
there.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/tempfile.h   |   11 ---
 arch/um/os-Linux/aio.c   |2 
 arch/um/os-Linux/drivers/ethertap_kern.c |8 +-
 arch/um/os-Linux/drivers/tuntap_kern.c   |6 -
 arch/um/os-Linux/include/file.h  |   13 ---
 arch/um/os-Linux/mem.c   |  101 +++
 arch/um/os-Linux/process.c   |2 
 arch/um/os-Linux/signal.c|2 
 arch/um/os-Linux/skas/process.c  |6 -
 arch/um/os-Linux/sys-i386/registers.c|4 -
 arch/um/os-Linux/sys-x86_64/registers.c  |   21 +++---
 arch/um/os-Linux/uaccess.c   |4 -
 arch/um/os-Linux/user_syms.c |4 -
 arch/um/os-Linux/util.c  |   43 -
 14 files changed, 98 insertions(+), 129 deletions(-)

Index: linux-2.6.22/arch/um/os-Linux/user_syms.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/user_syms.c  2007-12-14 
11:21:17.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/user_syms.c   2007-12-14 11:23:36.0 
-0500
@@ -34,8 +34,8 @@ EXPORT_SYMBOL(printf);
  * good; so the versions of these symbols will always match
  */
 #define EXPORT_SYMBOL_PROTO(sym)   \
-   int sym(void);  \
-   EXPORT_SYMBOL(sym);
+   int sym(void);  \
+   EXPORT_SYMBOL(sym);
 
 extern void readdir64(void) __attribute__((weak));
 EXPORT_SYMBOL(readdir64);
Index: linux-2.6.22/arch/um/include/tempfile.h
===
--- linux-2.6.22.orig/arch/um/include/tempfile.h2007-12-14 
11:21:17.0 -0500
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,11 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike ([EMAIL PROTECTED])
- * Licensed under the GPL
- */
-
-#ifndef __TEMPFILE_H__
-#define __TEMPFILE_H__
-
-extern int make_tempfile(const char *template, char **tempname, int do_unlink);
-
-#endif
Index: linux-2.6.22/arch/um/os-Linux/aio.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/aio.c2007-12-14 11:21:17.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/aio.c 2007-12-14 11:28:05.0 -0500
@@ -142,7 +142,7 @@ static int do_not_aio(struct aio_thread_
if (actual != req->offset)
return -errno;
 
-   switch(req->type) {
+   switch (req->type) {
case AIO_READ:
n = read(req->io_fd, req->buf, req->len);
break;
Index: linux-2.6.22/arch/um/os-Linux/include/file.h
===
--- linux-2.6.22.orig/arch/um/os-Linux/include/file.h   2007-12-14 
11:21:17.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/include/file.h2007-12-14 
11:23:36.0 -0500
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike ([EMAIL PROTECTED])
+ * Copyright (C) 2002 - 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,14 +9,3 @@
 #define DEV_NULL "/dev/null"
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
Index: linux-2.6.22/arch/um/os-Linux/mem.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/mem.c2007-12-14 11:21:17.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/mem.c 2007-12-14 11:35:12.0 -0500
@@ -1,22 +1,21 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
+ * Licensed under the GPL
+ */
+
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include "user.h"
-#include "mem_user.h"
+#include 
 #include "init.h"
-#include "os.h"
-#include "tempfile.h"
 #include "kern_constants.h"
-
-#include 
+#include "os.h"
+#include "user.h"
 
 /* Modified by whic

[PATCH 1/5] UML - Runtime host VMSPLIT detection

2008-02-06 Thread Jeff Dike
Calculate TASK_SIZE at run-time by figuring out the host's VMSPLIT -
this is needed on i386 if UML is to run on hosts with varying VMSPLITs
without recompilation.

TASK_SIZE is now defined in terms of a variable, task_size.  This gets
rid of an include of pgtable.h from processor.h, which can cause
include loops.

On i386, task_size is calculated early in boot by probing the address
space in a binary search to figure out where the boundary between
usable and non-usable memory is.  This tries to make sure that a page
that is considered to be in userspace is, or can be made, read-write.
I'm concerned about a system-global VDSO page in kernel memory being
hit and considered to be a userspace page.

On x86_64, task_size is just the old value of CONFIG_TOP_ADDR.

A bunch of config variable are gone now.  CONFIG_TOP_ADDR is directly
replaced by TASK_SIZE.  NEST_LEVEL is gone since the relocation of
the stubs makes it irrelevant.  All the HOST_VMSPLIT stuff is gone.
All references to these in arch/um/Makefile are also gone.

I noticed and fixed a missing extern in os.h when adding
os_get_task_size.

Note: This has been revised to fix the 32-bit UML on 64-bit host bug
that Miklos ran into.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/Kconfig |   11 --
 arch/um/Kconfig.i386|   37 -
 arch/um/Kconfig.x86_64  |4 -
 arch/um/Makefile|   11 --
 arch/um/defconfig   |3 
 arch/um/include/as-layout.h |2 
 arch/um/include/os.h|5 +
 arch/um/kernel/exec.c   |2 
 arch/um/kernel/um_arch.c|   16 +++-
 arch/um/os-Linux/sys-i386/Makefile  |2 
 arch/um/os-Linux/sys-i386/task_size.c   |  120 
 arch/um/os-Linux/sys-x86_64/Makefile|2 
 arch/um/os-Linux/sys-x86_64/task_size.c |5 +
 include/asm-um/fixmap.h |3 
 include/asm-um/processor-generic.h  |5 -
 15 files changed, 153 insertions(+), 75 deletions(-)

Index: linux-2.6-git/arch/um/kernel/um_arch.c
===
--- linux-2.6-git.orig/arch/um/kernel/um_arch.c 2008-02-06 11:19:07.0 
-0500
+++ linux-2.6-git/arch/um/kernel/um_arch.c  2008-02-06 11:31:53.0 
-0500
@@ -241,6 +241,11 @@ static struct notifier_block panic_exit_
 };
 
 /* Set during early boot */
+unsigned long task_size;
+EXPORT_SYMBOL(task_size);
+
+unsigned long host_task_size;
+
 unsigned long brk_start;
 unsigned long end_iomem;
 EXPORT_SYMBOL(end_iomem);
@@ -267,6 +272,13 @@ int __init linux_main(int argc, char **a
if (have_root == 0)
add_arg(DEFAULT_COMMAND_LINE);
 
+   host_task_size = os_get_task_size();
+   /*
+* TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
+* out
+*/
+   task_size = host_task_size & PGDIR_MASK;
+
/* OS sanity checks that need to happen before the kernel runs */
os_early_checks();
 
@@ -303,7 +315,7 @@ int __init linux_main(int argc, char **a
 
highmem = 0;
iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
-   max_physmem = CONFIG_TOP_ADDR - uml_physmem - iomem_size - MIN_VMALLOC;
+   max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
 
/*
 * Zones have to begin on a 1 << MAX_ORDER page boundary,
@@ -335,7 +347,7 @@ int __init linux_main(int argc, char **a
}
 
virtmem_size = physmem_size;
-   avail = CONFIG_TOP_ADDR - start_vm;
+   avail = TASK_SIZE - start_vm;
if (physmem_size > avail)
virtmem_size = avail;
end_vm = start_vm + virtmem_size;
Index: linux-2.6-git/include/asm-um/processor-generic.h
===
--- linux-2.6-git.orig/include/asm-um/processor-generic.h   2008-02-06 
11:19:09.0 -0500
+++ linux-2.6-git/include/asm-um/processor-generic.h2008-02-06 
11:31:53.0 -0500
@@ -11,7 +11,6 @@ struct pt_regs;
 struct task_struct;
 
 #include "asm/ptrace.h"
-#include "asm/pgtable.h"
 #include "registers.h"
 #include "sysdep/archsetjmp.h"
 
@@ -92,7 +91,9 @@ static inline void mm_copy_segments(stru
 /*
  * User space process size: 3GB (default).
  */
-#define TASK_SIZE (CONFIG_TOP_ADDR & PGDIR_MASK)
+extern unsigned long task_size;
+
+#define TASK_SIZE (task_size)
 
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
Index: linux-2.6-git/arch/um/include/os.h
===
--- linux-2.6-git.orig/arch/um/include/os.h 2008-02-06 11:19:07.0 
-0500
+++ linux-2.6-git/arch/um/include/os.h  2008-02-06 11:31:53.0 -0500
@@ -295,6 +295,9 @@ extern void maybe_sigio_broken(int fd, i
 extern int

[PATCH 0/5] UML - Five for 2.6.25

2008-02-06 Thread Jeff Dike
This batch should go into the 2.6.25 merge window.

There are a couple of patches which had been sitting in -mm waiting
for this merge window, but got lost somehow:
runtime host vmsplit detection - Miklos spotted a bug, since
fixed, with a 32-bit UML on a 64-bit host
style fixes in arch/um/os-Linux - there's a false-positive
checkpatch complaint with this one

The rest are bug fixes.

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 5/5] UML - Fix mm_context memory leak

2008-02-06 Thread Jeff Dike
[ Spotted by Miklos ]

Fix a memory leak in init_new_context.  The struct page ** buffer
allocated for install_special_mapping was never recorded, and thus
leaked when the mm_struct was freed.  Fix it by saving the pointer in
mm_context_t and freeing it in arch_exit_mmap.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Cc: Miklos Szeredi <[EMAIL PROTECTED]>
---
 arch/um/include/um_mmu.h  |1 +
 arch/um/kernel/skas/mmu.c |5 +
 2 files changed, 6 insertions(+)

Index: linux-2.6-git/arch/um/include/um_mmu.h
===
--- linux-2.6-git.orig/arch/um/include/um_mmu.h 2008-02-06 12:15:05.0 
-0500
+++ linux-2.6-git/arch/um/include/um_mmu.h  2008-02-06 12:24:08.0 
-0500
@@ -13,6 +13,7 @@
 typedef struct mm_context {
struct mm_id id;
struct uml_ldt ldt;
+   struct page **stub_pages;
 } mm_context_t;
 
 extern void __switch_mm(struct mm_id * mm_idp);
Index: linux-2.6-git/arch/um/kernel/skas/mmu.c
===
--- linux-2.6-git.orig/arch/um/kernel/skas/mmu.c2008-02-06 
12:15:05.0 -0500
+++ linux-2.6-git/arch/um/kernel/skas/mmu.c 2008-02-06 12:24:31.0 
-0500
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct 
goto out_free;
}
 
+   to_mm->stub_pages = NULL;
+
return 0;
 
  out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *old
 
pages[0] = virt_to_page(&__syscall_stub_start);
pages[1] = virt_to_page(mm->context.id.stack);
+   mm->context.stub_pages = pages;
 
/* dup_mmap already holds mmap_sem */
err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm
 {
pte_t *pte;
 
+   if (mm->context.stub_pages != NULL)
+   kfree(mm->context.stub_pages);
pte = virt_to_pte(mm, STUB_CODE);
if (pte != NULL)
pte_clear(mm, STUB_CODE, pte);
--
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 4/5] UML - x86_64 should copy %fs during fork

2008-02-06 Thread Jeff Dike
%fs needs to be copied from parent to child during fork.

Tidied up some whitespace while I was here.

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

Index: linux-2.6-git/include/asm-um/processor-x86_64.h
===
--- linux-2.6-git.orig/include/asm-um/processor-x86_64.h2008-02-06 
11:17:20.0 -0500
+++ linux-2.6-git/include/asm-um/processor-x86_64.h 2008-02-06 
12:17:21.0 -0500
@@ -26,7 +26,7 @@ static inline void rep_nop(void)
 #define cpu_relax()   rep_nop()
 
 #define INIT_ARCH_THREAD { .debugregs  = { [ 0 ... 7 ] = 0 }, \
-   .debugregs_seq  = 0,   \
+  .debugregs_seq   = 0, \
   .fs  = 0, \
   .faultinfo   = { 0, 0, 0 } }
 
@@ -37,6 +37,7 @@ static inline void arch_flush_thread(str
 static inline void arch_copy_thread(struct arch_thread *from,
 struct arch_thread *to)
 {
+   to->fs = from->fs;
 }
 
 #include "asm/arch/user.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 4/5] UML - x86_64 should copy %fs during fork

2008-02-06 Thread Jeff Dike
%fs needs to be copied from parent to child during fork.

Tidied up some whitespace while I was here.

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

Index: linux-2.6-git/include/asm-um/processor-x86_64.h
===
--- linux-2.6-git.orig/include/asm-um/processor-x86_64.h2008-02-06 
11:17:20.0 -0500
+++ linux-2.6-git/include/asm-um/processor-x86_64.h 2008-02-06 
12:17:21.0 -0500
@@ -26,7 +26,7 @@ static inline void rep_nop(void)
 #define cpu_relax()   rep_nop()
 
 #define INIT_ARCH_THREAD { .debugregs  = { [ 0 ... 7 ] = 0 }, \
-   .debugregs_seq  = 0,   \
+  .debugregs_seq   = 0, \
   .fs  = 0, \
   .faultinfo   = { 0, 0, 0 } }
 
@@ -37,6 +37,7 @@ static inline void arch_flush_thread(str
 static inline void arch_copy_thread(struct arch_thread *from,
 struct arch_thread *to)
 {
+   to-fs = from-fs;
 }
 
 #include asm/arch/user.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 0/5] UML - Five for 2.6.25

2008-02-06 Thread Jeff Dike
This batch should go into the 2.6.25 merge window.

There are a couple of patches which had been sitting in -mm waiting
for this merge window, but got lost somehow:
runtime host vmsplit detection - Miklos spotted a bug, since
fixed, with a 32-bit UML on a 64-bit host
style fixes in arch/um/os-Linux - there's a false-positive
checkpatch complaint with this one

The rest are bug fixes.

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 5/5] UML - Fix mm_context memory leak

2008-02-06 Thread Jeff Dike
[ Spotted by Miklos ]

Fix a memory leak in init_new_context.  The struct page ** buffer
allocated for install_special_mapping was never recorded, and thus
leaked when the mm_struct was freed.  Fix it by saving the pointer in
mm_context_t and freeing it in arch_exit_mmap.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
Cc: Miklos Szeredi [EMAIL PROTECTED]
---
 arch/um/include/um_mmu.h  |1 +
 arch/um/kernel/skas/mmu.c |5 +
 2 files changed, 6 insertions(+)

Index: linux-2.6-git/arch/um/include/um_mmu.h
===
--- linux-2.6-git.orig/arch/um/include/um_mmu.h 2008-02-06 12:15:05.0 
-0500
+++ linux-2.6-git/arch/um/include/um_mmu.h  2008-02-06 12:24:08.0 
-0500
@@ -13,6 +13,7 @@
 typedef struct mm_context {
struct mm_id id;
struct uml_ldt ldt;
+   struct page **stub_pages;
 } mm_context_t;
 
 extern void __switch_mm(struct mm_id * mm_idp);
Index: linux-2.6-git/arch/um/kernel/skas/mmu.c
===
--- linux-2.6-git.orig/arch/um/kernel/skas/mmu.c2008-02-06 
12:15:05.0 -0500
+++ linux-2.6-git/arch/um/kernel/skas/mmu.c 2008-02-06 12:24:31.0 
-0500
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct 
goto out_free;
}
 
+   to_mm-stub_pages = NULL;
+
return 0;
 
  out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *old
 
pages[0] = virt_to_page(__syscall_stub_start);
pages[1] = virt_to_page(mm-context.id.stack);
+   mm-context.stub_pages = pages;
 
/* dup_mmap already holds mmap_sem */
err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm
 {
pte_t *pte;
 
+   if (mm-context.stub_pages != NULL)
+   kfree(mm-context.stub_pages);
pte = virt_to_pte(mm, STUB_CODE);
if (pte != NULL)
pte_clear(mm, STUB_CODE, pte);
--
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/5] UML - Style fixes in arch/um/os-Linux

2008-02-06 Thread Jeff Dike
Style changes under arch/um/os-Linux:
include trimming
CodingStyle fixes
some printks needed severity indicators 

make_tempfile turns out not to be used outside of mem.c, so it is now
static.  Its declaration in tempfile.h is no longer needed, and
tempfile.h itself is no longer needed.

create_tmp_file was also made static.

checkpatch moans about an EXPORT_SYMBOL in user_syms.c which is part
of a macro definition - this is copying a bit of kernel infrastructure
into the libc side of UML because the kernel headers can't be included
there.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/include/tempfile.h   |   11 ---
 arch/um/os-Linux/aio.c   |2 
 arch/um/os-Linux/drivers/ethertap_kern.c |8 +-
 arch/um/os-Linux/drivers/tuntap_kern.c   |6 -
 arch/um/os-Linux/include/file.h  |   13 ---
 arch/um/os-Linux/mem.c   |  101 +++
 arch/um/os-Linux/process.c   |2 
 arch/um/os-Linux/signal.c|2 
 arch/um/os-Linux/skas/process.c  |6 -
 arch/um/os-Linux/sys-i386/registers.c|4 -
 arch/um/os-Linux/sys-x86_64/registers.c  |   21 +++---
 arch/um/os-Linux/uaccess.c   |4 -
 arch/um/os-Linux/user_syms.c |4 -
 arch/um/os-Linux/util.c  |   43 -
 14 files changed, 98 insertions(+), 129 deletions(-)

Index: linux-2.6.22/arch/um/os-Linux/user_syms.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/user_syms.c  2007-12-14 
11:21:17.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/user_syms.c   2007-12-14 11:23:36.0 
-0500
@@ -34,8 +34,8 @@ EXPORT_SYMBOL(printf);
  * good; so the versions of these symbols will always match
  */
 #define EXPORT_SYMBOL_PROTO(sym)   \
-   int sym(void);  \
-   EXPORT_SYMBOL(sym);
+   int sym(void);  \
+   EXPORT_SYMBOL(sym);
 
 extern void readdir64(void) __attribute__((weak));
 EXPORT_SYMBOL(readdir64);
Index: linux-2.6.22/arch/um/include/tempfile.h
===
--- linux-2.6.22.orig/arch/um/include/tempfile.h2007-12-14 
11:21:17.0 -0500
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,11 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike ([EMAIL PROTECTED])
- * Licensed under the GPL
- */
-
-#ifndef __TEMPFILE_H__
-#define __TEMPFILE_H__
-
-extern int make_tempfile(const char *template, char **tempname, int do_unlink);
-
-#endif
Index: linux-2.6.22/arch/um/os-Linux/aio.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/aio.c2007-12-14 11:21:17.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/aio.c 2007-12-14 11:28:05.0 -0500
@@ -142,7 +142,7 @@ static int do_not_aio(struct aio_thread_
if (actual != req-offset)
return -errno;
 
-   switch(req-type) {
+   switch (req-type) {
case AIO_READ:
n = read(req-io_fd, req-buf, req-len);
break;
Index: linux-2.6.22/arch/um/os-Linux/include/file.h
===
--- linux-2.6.22.orig/arch/um/os-Linux/include/file.h   2007-12-14 
11:21:17.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/include/file.h2007-12-14 
11:23:36.0 -0500
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike ([EMAIL PROTECTED])
+ * Copyright (C) 2002 - 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,14 +9,3 @@
 #define DEV_NULL /dev/null
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---
- * Local variables:
- * c-file-style: linux
- * End:
- */
Index: linux-2.6.22/arch/um/os-Linux/mem.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/mem.c2007-12-14 11:21:17.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/mem.c 2007-12-14 11:35:12.0 -0500
@@ -1,22 +1,21 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
+ * Licensed under the GPL
+ */
+
 #include stdio.h
-#include stdlib.h
 #include stddef.h
-#include stdarg.h
+#include stdlib.h
 #include unistd.h
 #include errno.h
-#include string.h
 #include fcntl.h
-#include sys/types.h
+#include string.h
 #include sys/mman.h
-#include sys/statfs.h
-#include user.h
-#include mem_user.h
+#include sys/param.h
 #include init.h
-#include os.h
-#include tempfile.h
 #include kern_constants.h
-
-#include sys/param.h
+#include os.h
+#include user.h
 
 /* Modified by which_tmpdir, which is called

[PATCH 1/5] UML - Runtime host VMSPLIT detection

2008-02-06 Thread Jeff Dike
Calculate TASK_SIZE at run-time by figuring out the host's VMSPLIT -
this is needed on i386 if UML is to run on hosts with varying VMSPLITs
without recompilation.

TASK_SIZE is now defined in terms of a variable, task_size.  This gets
rid of an include of pgtable.h from processor.h, which can cause
include loops.

On i386, task_size is calculated early in boot by probing the address
space in a binary search to figure out where the boundary between
usable and non-usable memory is.  This tries to make sure that a page
that is considered to be in userspace is, or can be made, read-write.
I'm concerned about a system-global VDSO page in kernel memory being
hit and considered to be a userspace page.

On x86_64, task_size is just the old value of CONFIG_TOP_ADDR.

A bunch of config variable are gone now.  CONFIG_TOP_ADDR is directly
replaced by TASK_SIZE.  NEST_LEVEL is gone since the relocation of
the stubs makes it irrelevant.  All the HOST_VMSPLIT stuff is gone.
All references to these in arch/um/Makefile are also gone.

I noticed and fixed a missing extern in os.h when adding
os_get_task_size.

Note: This has been revised to fix the 32-bit UML on 64-bit host bug
that Miklos ran into.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/Kconfig |   11 --
 arch/um/Kconfig.i386|   37 -
 arch/um/Kconfig.x86_64  |4 -
 arch/um/Makefile|   11 --
 arch/um/defconfig   |3 
 arch/um/include/as-layout.h |2 
 arch/um/include/os.h|5 +
 arch/um/kernel/exec.c   |2 
 arch/um/kernel/um_arch.c|   16 +++-
 arch/um/os-Linux/sys-i386/Makefile  |2 
 arch/um/os-Linux/sys-i386/task_size.c   |  120 
 arch/um/os-Linux/sys-x86_64/Makefile|2 
 arch/um/os-Linux/sys-x86_64/task_size.c |5 +
 include/asm-um/fixmap.h |3 
 include/asm-um/processor-generic.h  |5 -
 15 files changed, 153 insertions(+), 75 deletions(-)

Index: linux-2.6-git/arch/um/kernel/um_arch.c
===
--- linux-2.6-git.orig/arch/um/kernel/um_arch.c 2008-02-06 11:19:07.0 
-0500
+++ linux-2.6-git/arch/um/kernel/um_arch.c  2008-02-06 11:31:53.0 
-0500
@@ -241,6 +241,11 @@ static struct notifier_block panic_exit_
 };
 
 /* Set during early boot */
+unsigned long task_size;
+EXPORT_SYMBOL(task_size);
+
+unsigned long host_task_size;
+
 unsigned long brk_start;
 unsigned long end_iomem;
 EXPORT_SYMBOL(end_iomem);
@@ -267,6 +272,13 @@ int __init linux_main(int argc, char **a
if (have_root == 0)
add_arg(DEFAULT_COMMAND_LINE);
 
+   host_task_size = os_get_task_size();
+   /*
+* TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
+* out
+*/
+   task_size = host_task_size  PGDIR_MASK;
+
/* OS sanity checks that need to happen before the kernel runs */
os_early_checks();
 
@@ -303,7 +315,7 @@ int __init linux_main(int argc, char **a
 
highmem = 0;
iomem_size = (iomem_size + PAGE_SIZE - 1)  PAGE_MASK;
-   max_physmem = CONFIG_TOP_ADDR - uml_physmem - iomem_size - MIN_VMALLOC;
+   max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
 
/*
 * Zones have to begin on a 1  MAX_ORDER page boundary,
@@ -335,7 +347,7 @@ int __init linux_main(int argc, char **a
}
 
virtmem_size = physmem_size;
-   avail = CONFIG_TOP_ADDR - start_vm;
+   avail = TASK_SIZE - start_vm;
if (physmem_size  avail)
virtmem_size = avail;
end_vm = start_vm + virtmem_size;
Index: linux-2.6-git/include/asm-um/processor-generic.h
===
--- linux-2.6-git.orig/include/asm-um/processor-generic.h   2008-02-06 
11:19:09.0 -0500
+++ linux-2.6-git/include/asm-um/processor-generic.h2008-02-06 
11:31:53.0 -0500
@@ -11,7 +11,6 @@ struct pt_regs;
 struct task_struct;
 
 #include asm/ptrace.h
-#include asm/pgtable.h
 #include registers.h
 #include sysdep/archsetjmp.h
 
@@ -92,7 +91,9 @@ static inline void mm_copy_segments(stru
 /*
  * User space process size: 3GB (default).
  */
-#define TASK_SIZE (CONFIG_TOP_ADDR  PGDIR_MASK)
+extern unsigned long task_size;
+
+#define TASK_SIZE (task_size)
 
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
Index: linux-2.6-git/arch/um/include/os.h
===
--- linux-2.6-git.orig/arch/um/include/os.h 2008-02-06 11:19:07.0 
-0500
+++ linux-2.6-git/arch/um/include/os.h  2008-02-06 11:31:53.0 -0500
@@ -295,6 +295,9 @@ extern void maybe_sigio_broken(int fd, i
 extern int os_arch_prctl(int pid, int code, unsigned long *addr);
 
 /* tty.c */
-int get_pty

[PATCH 3/5] UML - Improved error handling while locating temp dir

2008-02-06 Thread Jeff Dike
From: Jim Meyering [EMAIL PROTECTED]

* arch/um/os-Linux/mem.c (make_tempfile): Don't deref NULL upon failed malloc.

* arch/um/os-Linux/mem.c (make_tempfile): Handle NULL tempdir.
Don't let a long tempdir (e.g., via TMPDIR) provoke heap corruption.

[ jdike - formatting cleanups, deleted obsolete comment ]

Signed-off-by: Jim Meyering [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/os-Linux/mem.c |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

Index: linux-2.6-git/arch/um/os-Linux/mem.c
===
--- linux-2.6-git.orig/arch/um/os-Linux/mem.c   2008-02-05 13:20:46.0 
-0500
+++ linux-2.6-git/arch/um/os-Linux/mem.c2008-02-05 16:37:37.0 
-0500
@@ -162,11 +162,6 @@ found:
goto out;
 }
 
-/*
- * This proc still used in tt-mode
- * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger).
- * So it isn't 'static' yet.
- */
 static int __init make_tempfile(const char *template, char **out_tempname,
int do_unlink)
 {
@@ -175,10 +170,13 @@ static int __init make_tempfile(const ch
 
which_tmpdir();
tempname = malloc(MAXPATHLEN);
-   if (!tempname)
-   goto out;
+   if (tempname == NULL)
+   return -1;
 
find_tempdir();
+   if ((tempdir == NULL) || (strlen(tempdir) = MAXPATHLEN))
+   return -1;
+
if (template[0] != '/')
strcpy(tempname, tempdir);
else
@@ -196,9 +194,8 @@ static int __init make_tempfile(const ch
}
if (out_tempname) {
*out_tempname = tempname;
-   } else {
+   } else
free(tempname);
-   }
return fd;
 out:
free(tempname);
--
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] uml: handle unusual results from find_tempdir.

2008-02-05 Thread Jeff Dike
On Tue, Feb 05, 2008 at 05:25:06PM +0100, Jim Meyering wrote:
> 
> An alternative: make find_tempdir set tempdir to default_tempdir
> upon malloc failure.
> 
> * arch/um/os-Linux/mem.c (make_tempfile): Handle NULL tempdir.
> Don't let a long tempdir (e.g., via TMPDIR) provoke heap corruption.
> 
> Signed-off-by: Jim Meyering <[EMAIL PROTECTED]>

Thanks, I'll forward this on.

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: [-mm Patch] arch/um/kernel/initrd.c: fix a missed conversion specifier

2008-02-05 Thread Jeff Dike
On Wed, Feb 06, 2008 at 12:25:57AM +0800, WANG Cong wrote:
> 
> Fix a missed conversion specifier of a printk in
> arch/um/kernel/initrd.c.
> 
> Signed-off-by: WANG Cong <[EMAIL PROTECTED]>
> Cc: Jeff Dike <[EMAIL PROTECTED]>

ACK - 2.6.25 material.  Sigh.

Jeff
--
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: [-mm Patch] arch/um/kernel/initrd.c: fix a missed conversion specifier

2008-02-05 Thread Jeff Dike
On Wed, Feb 06, 2008 at 12:25:57AM +0800, WANG Cong wrote:
 
 Fix a missed conversion specifier of a printk in
 arch/um/kernel/initrd.c.
 
 Signed-off-by: WANG Cong [EMAIL PROTECTED]
 Cc: Jeff Dike [EMAIL PROTECTED]

ACK - 2.6.25 material.  Sigh.

Jeff
--
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] uml: handle unusual results from find_tempdir.

2008-02-05 Thread Jeff Dike
On Tue, Feb 05, 2008 at 05:25:06PM +0100, Jim Meyering wrote:
 
 An alternative: make find_tempdir set tempdir to default_tempdir
 upon malloc failure.
 
 * arch/um/os-Linux/mem.c (make_tempfile): Handle NULL tempdir.
 Don't let a long tempdir (e.g., via TMPDIR) provoke heap corruption.
 
 Signed-off-by: Jim Meyering [EMAIL PROTECTED]

Thanks, I'll forward this on.

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: [git Patch] UML: a build error fix

2008-02-01 Thread Jeff Dike
On Thu, Jan 31, 2008 at 11:17:41PM +0800, WANG Cong wrote:
> This patch fixed this error:
> 
> arch/um/kernel/skas/syscall.c: In function 'handle_syscall':
> arch/um/kernel/skas/syscall.c:33: error: 'NR_syscalls' undeclared (first use 
> in this function)

That works, but I think doing things the way that i386 does them is cleaner.

Andrew, can you stick the patch below into -mm and push it to Linus?

Jeff

-- 
Work email - jdike at linux dot intel dot com



Redo the calculation of NR_syscalls since that disappeared from i386
and use a similar mechanism on x86_64.

We now figure out the size of the system call table in arch code and
stick that in syscall_table_size.  arch/um/kernel/skas/syscall.c
defines NR_syscalls in terms of that since its the only thing that
needs to know how many system calls there are.

The old mechananism that was used on x86_64 is gone.

arch/um/include/sysdep-i386/syscalls.h got some formatting since I was
looking at it.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Cc: WANG Cong <[EMAIL PROTECTED]>
---
 arch/um/include/sysdep-i386/syscalls.h |5 +++--
 arch/um/include/sysdep-x86_64/kernel-offsets.h |9 -
 arch/um/include/sysdep-x86_64/syscalls.h   |2 --
 arch/um/kernel/skas/syscall.c  |3 +++
 arch/um/sys-i386/sys_call_table.S  |5 +
 arch/um/sys-x86_64/syscall_table.c |   17 ++---
 6 files changed, 25 insertions(+), 16 deletions(-)

Index: linux-2.6-git/arch/um/include/sysdep-x86_64/syscalls.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/syscalls.h 2008-02-01 
11:24:32.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/syscalls.h  2008-02-01 
11:47:51.0 -0500
@@ -30,6 +30,4 @@ extern long old_mmap(unsigned long addr,
 extern syscall_handler_t sys_modify_ldt;
 extern syscall_handler_t sys_arch_prctl;
 
-#define NR_syscalls (UM_NR_syscall_max + 1)
-
 #endif
Index: linux-2.6-git/arch/um/kernel/skas/syscall.c
===
--- linux-2.6-git.orig/arch/um/kernel/skas/syscall.c2008-02-01 
11:24:32.0 -0500
+++ linux-2.6-git/arch/um/kernel/skas/syscall.c 2008-02-01 11:48:02.0 
-0500
@@ -9,6 +9,9 @@
 #include "sysdep/ptrace.h"
 #include "sysdep/syscalls.h"
 
+extern int syscall_table_size;
+#define NR_syscalls (syscall_table_size / sizeof(void *))
+
 void handle_syscall(struct uml_pt_regs *r)
 {
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
Index: linux-2.6-git/arch/um/sys-i386/sys_call_table.S
===
--- linux-2.6-git.orig/arch/um/sys-i386/sys_call_table.S2008-02-01 
11:24:32.0 -0500
+++ linux-2.6-git/arch/um/sys-i386/sys_call_table.S 2008-02-01 
12:08:17.0 -0500
@@ -9,4 +9,9 @@
 
 #define old_mmap old_mmap_i386
 
+.section .rodata,"a"
+
 #include "../../x86/kernel/syscall_table_32.S"
+
+ENTRY(syscall_table_size)
+.long .-sys_call_table
Index: linux-2.6-git/arch/um/include/sysdep-i386/syscalls.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-i386/syscalls.h   2007-11-28 
13:01:17.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-i386/syscalls.h2008-02-01 
11:48:02.00000 -0500
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000 Jeff Dike ([EMAIL PROTECTED])
+ * Copyright (C) 2000 - 2008 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -18,7 +18,8 @@ extern syscall_handler_t old_mmap_i386;
 extern syscall_handler_t *sys_call_table[];
 
 #define EXECUTE_SYSCALL(syscall, regs) \
-   ((long (*)(struct syscall_args)) 
(*sys_call_table[syscall]))(SYSCALL_ARGS(>regs))
+   ((long (*)(struct syscall_args)) \
+(*sys_call_table[syscall]))(SYSCALL_ARGS(>regs))
 
 extern long sys_mmap2(unsigned long addr, unsigned long len,
  unsigned long prot, unsigned long flags,
Index: linux-2.6-git/arch/um/include/sysdep-x86_64/kernel-offsets.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/kernel-offsets.h   
2007-12-03 23:56:34.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/kernel-offsets.h
2008-02-01 11:48:01.0 -0500
@@ -17,16 +17,7 @@
 #define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem));
 
-#define __NO_STUBS 1
-#undef __SYSCALL
-#undef _ASM_X86_64_UNISTD_H_
-#define __SYSCALL(nr, sym) [nr] = 1,
-static char syscalls[] = {
-#include 
-};
-
 void foo(void)
 {
 #include 
-DEFINE(UM_NR_syscall_max, sizeof(syscalls) - 1);
 }
Index: linux-2.6-git/arch/um/sys-x86_64/syscall_table.c
===
--- linu

Re: [Patch] arch/um/include/init.h: Fix missing macro definitions

2008-02-01 Thread Jeff Dike
On Thu, Jan 31, 2008 at 11:06:34PM +0800, WANG Cong wrote:
> This patch fixed the following build error in current -git tree.
> 
> arch/um/kernel/config.c:10: error: expected declaration specifiers or '...' 
> before '.' token
> ...

This is close to uml-arch-um-include-inith-needs-a-definition-of-__used.patch
that's currently in -mm.

Andrew, could you replace
uml-arch-um-include-inith-needs-a-definition-of-__used.patch with the
version below and push it to Linus?

Jeff

-- 
Work email - jdike at linux dot intel dot com


init.h started breaking now for some reason.  It turns out that there wasn't a
definition of __used.  Fixed this by copying the relevant stuff from
compiler.h in the userspace case, and including compiler.h in the kernel case.

>From WANG Cong <[EMAIL PROTECTED]> - added definition of __section

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Cc: WANG Cong <[EMAIL PROTECTED]>
---
 arch/um/include/init.h |   25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

Index: linux-2.6-git/arch/um/include/init.h
===
--- linux-2.6-git.orig/arch/um/include/init.h   2008-02-01 10:41:14.0 
-0500
+++ linux-2.6-git/arch/um/include/init.h2008-02-01 10:52:34.0 
-0500
@@ -40,6 +40,20 @@
 typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
+#ifndef __KERNEL__
+#ifndef __section
+# define __section(S) __attribute__ ((__section__(#S)))
+#endif
+
+#if __GNUC_MINOR__ >= 3
+# define __used__attribute__((__used__))
+#else
+# define __used__attribute__((__unused__))
+#endif
+
+#else
+#include 
+#endif
 /* These are for everybody (although not all archs will actually
discard it in modules) */
 #define __init __section(.init.text)
@@ -127,14 +141,3 @@ extern struct uml_param __uml_setup_star
 #endif
 
 #endif /* _LINUX_UML_INIT_H */
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
--
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] arch/um/include/init.h: Fix missing macro definitions

2008-02-01 Thread Jeff Dike
On Thu, Jan 31, 2008 at 11:06:34PM +0800, WANG Cong wrote:
 This patch fixed the following build error in current -git tree.
 
 arch/um/kernel/config.c:10: error: expected declaration specifiers or '...' 
 before '.' token
 ...

This is close to uml-arch-um-include-inith-needs-a-definition-of-__used.patch
that's currently in -mm.

Andrew, could you replace
uml-arch-um-include-inith-needs-a-definition-of-__used.patch with the
version below and push it to Linus?

Jeff

-- 
Work email - jdike at linux dot intel dot com


init.h started breaking now for some reason.  It turns out that there wasn't a
definition of __used.  Fixed this by copying the relevant stuff from
compiler.h in the userspace case, and including compiler.h in the kernel case.

From WANG Cong [EMAIL PROTECTED] - added definition of __section

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
Cc: WANG Cong [EMAIL PROTECTED]
---
 arch/um/include/init.h |   25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

Index: linux-2.6-git/arch/um/include/init.h
===
--- linux-2.6-git.orig/arch/um/include/init.h   2008-02-01 10:41:14.0 
-0500
+++ linux-2.6-git/arch/um/include/init.h2008-02-01 10:52:34.0 
-0500
@@ -40,6 +40,20 @@
 typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
+#ifndef __KERNEL__
+#ifndef __section
+# define __section(S) __attribute__ ((__section__(#S)))
+#endif
+
+#if __GNUC_MINOR__ = 3
+# define __used__attribute__((__used__))
+#else
+# define __used__attribute__((__unused__))
+#endif
+
+#else
+#include linux/compiler.h
+#endif
 /* These are for everybody (although not all archs will actually
discard it in modules) */
 #define __init __section(.init.text)
@@ -127,14 +141,3 @@ extern struct uml_param __uml_setup_star
 #endif
 
 #endif /* _LINUX_UML_INIT_H */
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---
- * Local variables:
- * c-file-style: linux
- * End:
- */
--
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: [git Patch] UML: a build error fix

2008-02-01 Thread Jeff Dike
On Thu, Jan 31, 2008 at 11:17:41PM +0800, WANG Cong wrote:
 This patch fixed this error:
 
 arch/um/kernel/skas/syscall.c: In function 'handle_syscall':
 arch/um/kernel/skas/syscall.c:33: error: 'NR_syscalls' undeclared (first use 
 in this function)

That works, but I think doing things the way that i386 does them is cleaner.

Andrew, can you stick the patch below into -mm and push it to Linus?

Jeff

-- 
Work email - jdike at linux dot intel dot com



Redo the calculation of NR_syscalls since that disappeared from i386
and use a similar mechanism on x86_64.

We now figure out the size of the system call table in arch code and
stick that in syscall_table_size.  arch/um/kernel/skas/syscall.c
defines NR_syscalls in terms of that since its the only thing that
needs to know how many system calls there are.

The old mechananism that was used on x86_64 is gone.

arch/um/include/sysdep-i386/syscalls.h got some formatting since I was
looking at it.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
Cc: WANG Cong [EMAIL PROTECTED]
---
 arch/um/include/sysdep-i386/syscalls.h |5 +++--
 arch/um/include/sysdep-x86_64/kernel-offsets.h |9 -
 arch/um/include/sysdep-x86_64/syscalls.h   |2 --
 arch/um/kernel/skas/syscall.c  |3 +++
 arch/um/sys-i386/sys_call_table.S  |5 +
 arch/um/sys-x86_64/syscall_table.c |   17 ++---
 6 files changed, 25 insertions(+), 16 deletions(-)

Index: linux-2.6-git/arch/um/include/sysdep-x86_64/syscalls.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/syscalls.h 2008-02-01 
11:24:32.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/syscalls.h  2008-02-01 
11:47:51.0 -0500
@@ -30,6 +30,4 @@ extern long old_mmap(unsigned long addr,
 extern syscall_handler_t sys_modify_ldt;
 extern syscall_handler_t sys_arch_prctl;
 
-#define NR_syscalls (UM_NR_syscall_max + 1)
-
 #endif
Index: linux-2.6-git/arch/um/kernel/skas/syscall.c
===
--- linux-2.6-git.orig/arch/um/kernel/skas/syscall.c2008-02-01 
11:24:32.0 -0500
+++ linux-2.6-git/arch/um/kernel/skas/syscall.c 2008-02-01 11:48:02.0 
-0500
@@ -9,6 +9,9 @@
 #include sysdep/ptrace.h
 #include sysdep/syscalls.h
 
+extern int syscall_table_size;
+#define NR_syscalls (syscall_table_size / sizeof(void *))
+
 void handle_syscall(struct uml_pt_regs *r)
 {
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
Index: linux-2.6-git/arch/um/sys-i386/sys_call_table.S
===
--- linux-2.6-git.orig/arch/um/sys-i386/sys_call_table.S2008-02-01 
11:24:32.0 -0500
+++ linux-2.6-git/arch/um/sys-i386/sys_call_table.S 2008-02-01 
12:08:17.0 -0500
@@ -9,4 +9,9 @@
 
 #define old_mmap old_mmap_i386
 
+.section .rodata,a
+
 #include ../../x86/kernel/syscall_table_32.S
+
+ENTRY(syscall_table_size)
+.long .-sys_call_table
Index: linux-2.6-git/arch/um/include/sysdep-i386/syscalls.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-i386/syscalls.h   2007-11-28 
13:01:17.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-i386/syscalls.h2008-02-01 
11:48:02.0 -0500
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000 Jeff Dike ([EMAIL PROTECTED])
+ * Copyright (C) 2000 - 2008 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -18,7 +18,8 @@ extern syscall_handler_t old_mmap_i386;
 extern syscall_handler_t *sys_call_table[];
 
 #define EXECUTE_SYSCALL(syscall, regs) \
-   ((long (*)(struct syscall_args)) 
(*sys_call_table[syscall]))(SYSCALL_ARGS(regs-regs))
+   ((long (*)(struct syscall_args)) \
+(*sys_call_table[syscall]))(SYSCALL_ARGS(regs-regs))
 
 extern long sys_mmap2(unsigned long addr, unsigned long len,
  unsigned long prot, unsigned long flags,
Index: linux-2.6-git/arch/um/include/sysdep-x86_64/kernel-offsets.h
===
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/kernel-offsets.h   
2007-12-03 23:56:34.0 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/kernel-offsets.h
2008-02-01 11:48:01.0 -0500
@@ -17,16 +17,7 @@
 #define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem));
 
-#define __NO_STUBS 1
-#undef __SYSCALL
-#undef _ASM_X86_64_UNISTD_H_
-#define __SYSCALL(nr, sym) [nr] = 1,
-static char syscalls[] = {
-#include asm/arch/unistd.h
-};
-
 void foo(void)
 {
 #include common-offsets.h
-DEFINE(UM_NR_syscall_max, sizeof(syscalls) - 1);
 }
Index: linux-2.6-git/arch/um/sys-x86_64/syscall_table.c
===
--- linux-2.6-git.orig/arch/um/sys-x86_64/syscall_table.c

[RFC PATCH] Address spaces as independent objects

2008-01-29 Thread Jeff Dike
Below is a patch which allows address spaces to be created,
manipulated, and destroyed independently of processes.

The additions are
two system calls, new_mm and switch_mm
/proc//mm
PTRACE_SWITCH_MM

new_mm() returns a file descriptor referencing a new address space
which is a copy of the current one.

switch_mm(fd, flags, new_regs, save_regs) switches the current process
to the address space referenced by fd.  flags describes how the
registers should be initialized once in the other address space.
MM_ALL_REGS initializes all of the registers from new_regs.  MM_SP_IP
initialize only the instruction pointer and stack pointer from
new_regs.  If save is non-NULL, then the current registers are saved
there.  It must be a userspace pointer that's valid in the new address
space.

Opening /proc//mm gives you a descriptor referencing the address
space of the given process.  If you are switching temporarily to
another address space and want to come back to the current one, then
you need to open /proc/self/mm and use that descriptor to return.

PTRACE_SWITCH_MM takes a file descriptor in data and makes the child
process switch to the address space referenced by it.

If you're familiar with UML, you'll recognize this stuff as what's in
the host SKAS3 patch, except with a different interface.

The purpose behind this is to allow UML to run more efficiently.  With
this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build
performance in the 82% - 83% range compared to native on i386.

Internal interface changes - I made some previously static functions
global:
dup_mm - address space duplication
getreg, putreg, getreg32, putreg32 - save and restore process
register state

The guts of this are in mm/mmfs.c, which implements a little
filesystem sitting behind /proc//mm and new_mm().

Architecture support is there for 32 and 64-bit x86 and 32 bit compat
on 64-bit.

I want this to go into mainline, so I'd like to see it take a spin in
-mm during 2.6.24 and then go into 2.6.25 if there no major problems
with it.

TODO -
The architecture support needs work
Register saving and restoring should include the FP registers
Registers should be saved in the current address space
Need to add /proc//task/mm

In order to play with this, you'll need either this patch, which is
a rolled-up patch containing both host and guest support:

http://marc.info/?l=user-mode-linux-devel=120155633500396=raw

or this broken-out series, of which the patch below is number 7:
http://marc.info/?l=user-mode-linux-devel=120155631600315=raw
http://marc.info/?l=user-mode-linux-devel=120155631700323=raw
http://marc.info/?l=user-mode-linux-devel=120155634000413=raw
http://marc.info/?l=user-mode-linux-devel=120155631900336=raw
http://marc.info/?l=user-mode-linux-devel=120155634200425=raw
http://marc.info/?l=user-mode-linux-devel=120155632800373=raw
http://marc.info/?l=user-mode-linux-devel=120155635600462=raw
http://marc.info/?l=user-mode-linux-devel=120155633100382=raw
http://marc.info/?l=user-mode-linux-devel=120155634600430=raw
http://marc.info/?l=user-mode-linux-devel=120155636000474=raw

These are against 2.6.24.  Build both host and guest from this tree.

Jeff

-- 
Work email - jdike at linux dot intel dot com

diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h
index cd2327d..6b55c52 100644
--- a/arch/um/include/skas_ptrace.h
+++ b/arch/um/include/skas_ptrace.h
@@ -7,7 +7,9 @@
 #define __SKAS_PTRACE_H
 
 #define PTRACE_FAULTINFO 52
-#define PTRACE_SWITCH_MM 55
+#ifndef OLD_PTRACE_SWITCH_MM
+#define OLD_PTRACE_SWITCH_MM 55
+#endif
 
 #include "sysdep/skas_ptrace.h"
 
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 47b57b4..913037e 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, 
long addr, long data)
}
 #endif
 #ifdef CONFIG_PROC_MM
-   case PTRACE_SWITCH_MM: {
+   case OLD_PTRACE_SWITCH_MM: {
struct mm_struct *old = child->mm;
struct mm_struct *new = proc_mm_get_mm(data);
 
@@ -292,3 +292,19 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit)
current->exit_code = 0;
}
 }
+
+int copyin_user_regs(struct user_regs *to, unsigned long __user *from)
+{
+   return copy_from_user(>regs, from, sizeof(to->regs));
+}
+
+int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs *from)
+{
+   memcpy(to, >regs, sizeof(from->regs));
+   return 0;
+}
+
+int pt_regs_to_ptrace(unsigned long __user *to, struct pt_regs *from)
+{
+   return copy_to_user(to, >regs.gp, sizeof(from->regs.gp));
+}
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 82a0780..522d0f1 100644
--- a/arch/um/os-Linux/skas/process.c

[RFC PATCH] Address spaces as independent objects

2008-01-29 Thread Jeff Dike
Below is a patch which allows address spaces to be created,
manipulated, and destroyed independently of processes.

The additions are
two system calls, new_mm and switch_mm
/proc/pid/mm
PTRACE_SWITCH_MM

new_mm() returns a file descriptor referencing a new address space
which is a copy of the current one.

switch_mm(fd, flags, new_regs, save_regs) switches the current process
to the address space referenced by fd.  flags describes how the
registers should be initialized once in the other address space.
MM_ALL_REGS initializes all of the registers from new_regs.  MM_SP_IP
initialize only the instruction pointer and stack pointer from
new_regs.  If save is non-NULL, then the current registers are saved
there.  It must be a userspace pointer that's valid in the new address
space.

Opening /proc/pid/mm gives you a descriptor referencing the address
space of the given process.  If you are switching temporarily to
another address space and want to come back to the current one, then
you need to open /proc/self/mm and use that descriptor to return.

PTRACE_SWITCH_MM takes a file descriptor in data and makes the child
process switch to the address space referenced by it.

If you're familiar with UML, you'll recognize this stuff as what's in
the host SKAS3 patch, except with a different interface.

The purpose behind this is to allow UML to run more efficiently.  With
this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build
performance in the 82% - 83% range compared to native on i386.

Internal interface changes - I made some previously static functions
global:
dup_mm - address space duplication
getreg, putreg, getreg32, putreg32 - save and restore process
register state

The guts of this are in mm/mmfs.c, which implements a little
filesystem sitting behind /proc/pid/mm and new_mm().

Architecture support is there for 32 and 64-bit x86 and 32 bit compat
on 64-bit.

I want this to go into mainline, so I'd like to see it take a spin in
-mm during 2.6.24 and then go into 2.6.25 if there no major problems
with it.

TODO -
The architecture support needs work
Register saving and restoring should include the FP registers
Registers should be saved in the current address space
Need to add /proc/pid/task/mm

In order to play with this, you'll need either this patch, which is
a rolled-up patch containing both host and guest support:

http://marc.info/?l=user-mode-linux-develm=120155633500396q=raw

or this broken-out series, of which the patch below is number 7:
http://marc.info/?l=user-mode-linux-develm=120155631600315q=raw
http://marc.info/?l=user-mode-linux-develm=120155631700323q=raw
http://marc.info/?l=user-mode-linux-develm=120155634000413q=raw
http://marc.info/?l=user-mode-linux-develm=120155631900336q=raw
http://marc.info/?l=user-mode-linux-develm=120155634200425q=raw
http://marc.info/?l=user-mode-linux-develm=120155632800373q=raw
http://marc.info/?l=user-mode-linux-develm=120155635600462q=raw
http://marc.info/?l=user-mode-linux-develm=120155633100382q=raw
http://marc.info/?l=user-mode-linux-develm=120155634600430q=raw
http://marc.info/?l=user-mode-linux-develm=120155636000474q=raw

These are against 2.6.24.  Build both host and guest from this tree.

Jeff

-- 
Work email - jdike at linux dot intel dot com

diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h
index cd2327d..6b55c52 100644
--- a/arch/um/include/skas_ptrace.h
+++ b/arch/um/include/skas_ptrace.h
@@ -7,7 +7,9 @@
 #define __SKAS_PTRACE_H
 
 #define PTRACE_FAULTINFO 52
-#define PTRACE_SWITCH_MM 55
+#ifndef OLD_PTRACE_SWITCH_MM
+#define OLD_PTRACE_SWITCH_MM 55
+#endif
 
 #include sysdep/skas_ptrace.h
 
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 47b57b4..913037e 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, 
long addr, long data)
}
 #endif
 #ifdef CONFIG_PROC_MM
-   case PTRACE_SWITCH_MM: {
+   case OLD_PTRACE_SWITCH_MM: {
struct mm_struct *old = child-mm;
struct mm_struct *new = proc_mm_get_mm(data);
 
@@ -292,3 +292,19 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit)
current-exit_code = 0;
}
 }
+
+int copyin_user_regs(struct user_regs *to, unsigned long __user *from)
+{
+   return copy_from_user(to-regs, from, sizeof(to-regs));
+}
+
+int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs *from)
+{
+   memcpy(to, from-regs, sizeof(from-regs));
+   return 0;
+}
+
+int pt_regs_to_ptrace(unsigned long __user *to, struct pt_regs *from)
+{
+   return copy_to_user(to, from-regs.gp, sizeof(from-regs.gp));
+}
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 82a0780..522d0f1 100644
--- 

Re: [PATCH] random - add async I/O support

2008-01-21 Thread Jeff Dike
On Mon, Jan 21, 2008 at 12:43:25PM -0600, Matt Mackall wrote:
> This conflicts just about everywhere with my latest code, but I'll fix
> that up.

Great, thanks.

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] random - add async I/O support

2008-01-21 Thread Jeff Dike
Add async notification support to /dev/random.

A little test case is below.  Without this patch, you get:

$ ./async-random 
Drained the pool
Found more randomness

With it, you get:

$ ./async-random 
Drained the pool
SIGIO
Found more randomness

#include 
#include 
#include 
#include 
#include 

static void handler(int sig)
{
printf("SIGIO\n");
}

int main(int argc, char **argv)
{
int fd, n, err, flags;

if(signal(SIGIO, handler) < 0){
perror("setting SIGIO handler");
exit(1);
}

fd = open("/dev/random", O_RDONLY);
if(fd < 0){
perror("open");
exit(1);
}

flags = fcntl(fd, F_GETFL);
if (flags < 0){
perror("getting flags");
exit(1);
}

flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0){
perror("setting flags");
exit(1);
}

while((err = read(fd, , sizeof(n))) > 0) ;

if(err == 0){
printf("random returned 0\n");
exit(1);
}
else if(errno != EAGAIN){
perror("read");
exit(1);
}

flags |= O_ASYNC;
if (fcntl(fd, F_SETFL, flags) < 0){
perror("setting flags");
exit(1);
}

if (fcntl(fd, F_SETOWN, getpid()) < 0) {
perror("Setting SIGIO");
exit(1);
}

printf("Drained the pool\n");
read(fd, , sizeof(n));
printf("Found more randomness\n");

return(0);
}

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 drivers/char/random.c |   43 +--
 1 file changed, 33 insertions(+), 10 deletions(-)

Index: linux-2.6.22/drivers/char/random.c
===
--- linux-2.6.22.orig/drivers/char/random.c 2008-01-17 12:51:07.0 
-0500
+++ linux-2.6.22/drivers/char/random.c  2008-01-21 13:02:02.0 -0500
@@ -371,6 +371,8 @@ static struct poolinfo {
 static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
 static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
 
+static struct fasync_struct *fasync;
+
 #if 0
 static int debug = 0;
 module_param(debug, bool, 0644);
@@ -751,8 +753,10 @@ static size_t account(struct entropy_sto
else
r->entropy_count = reserved;
 
-   if (r->entropy_count < random_write_wakeup_thresh)
+   if (r->entropy_count < random_write_wakeup_thresh) {
wake_up_interruptible(_write_wait);
+   kill_fasync(, SIGIO, POLL_OUT);
+   }
}
 
DEBUG_ENT("debiting %d entropy credits from %s%s\n",
@@ -1090,8 +1094,11 @@ random_ioctl(struct inode * inode, struc
 * Wake up waiting processes if we have enough
 * entropy.
 */
-   if (input_pool.entropy_count >= random_read_wakeup_thresh)
+   if (input_pool.entropy_count >= random_read_wakeup_thresh) {
wake_up_interruptible(_read_wait);
+   kill_fasync(, SIGIO, POLL_IN);
+   }
+
return 0;
case RNDADDENTROPY:
if (!capable(CAP_SYS_ADMIN))
@@ -,8 +1118,10 @@ random_ioctl(struct inode * inode, struc
 * Wake up waiting processes if we have enough
 * entropy.
 */
-   if (input_pool.entropy_count >= random_read_wakeup_thresh)
+   if (input_pool.entropy_count >= random_read_wakeup_thresh) {
wake_up_interruptible(_read_wait);
+   kill_fasync(, SIGIO, POLL_IN);
+   }
return 0;
case RNDZAPENTCNT:
case RNDCLEARPOOL:
@@ -1128,17 +1137,31 @@ random_ioctl(struct inode * inode, struc
}
 }
 
+static int random_fasync(int fd, struct file *filp, int on)
+{
+   return fasync_helper(fd, filp, on, );
+}
+
+static int random_release(struct inode *inode, struct file *filp)
+{
+   return fasync_helper(-1, filp, 0, );
+}
+
 const struct file_operations random_fops = {
-   .read  = random_read,
-   .write = random_write,
-   .poll  = random_poll,
-   .ioctl = random_ioctl,
+   .read= random_read,
+   .write   = random_write,
+   .poll= random_poll,
+   .ioctl   = random_ioctl,
+   .fasync  = random_fasync,
+   .release = random_release,
 };
 
 const struct file_operations urandom_fops = {
-   .read  = urandom_read,
-   .write = random_write,
-   .ioct

[PATCH] random - add async I/O support

2008-01-21 Thread Jeff Dike
Add async notification support to /dev/random.

A little test case is below.  Without this patch, you get:

$ ./async-random 
Drained the pool
Found more randomness

With it, you get:

$ ./async-random 
Drained the pool
SIGIO
Found more randomness

#include stdio.h
#include stdlib.h
#include signal.h
#include errno.h
#include fcntl.h

static void handler(int sig)
{
printf(SIGIO\n);
}

int main(int argc, char **argv)
{
int fd, n, err, flags;

if(signal(SIGIO, handler)  0){
perror(setting SIGIO handler);
exit(1);
}

fd = open(/dev/random, O_RDONLY);
if(fd  0){
perror(open);
exit(1);
}

flags = fcntl(fd, F_GETFL);
if (flags  0){
perror(getting flags);
exit(1);
}

flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags)  0){
perror(setting flags);
exit(1);
}

while((err = read(fd, n, sizeof(n)))  0) ;

if(err == 0){
printf(random returned 0\n);
exit(1);
}
else if(errno != EAGAIN){
perror(read);
exit(1);
}

flags |= O_ASYNC;
if (fcntl(fd, F_SETFL, flags)  0){
perror(setting flags);
exit(1);
}

if (fcntl(fd, F_SETOWN, getpid())  0) {
perror(Setting SIGIO);
exit(1);
}

printf(Drained the pool\n);
read(fd, n, sizeof(n));
printf(Found more randomness\n);

return(0);
}

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 drivers/char/random.c |   43 +--
 1 file changed, 33 insertions(+), 10 deletions(-)

Index: linux-2.6.22/drivers/char/random.c
===
--- linux-2.6.22.orig/drivers/char/random.c 2008-01-17 12:51:07.0 
-0500
+++ linux-2.6.22/drivers/char/random.c  2008-01-21 13:02:02.0 -0500
@@ -371,6 +371,8 @@ static struct poolinfo {
 static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
 static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
 
+static struct fasync_struct *fasync;
+
 #if 0
 static int debug = 0;
 module_param(debug, bool, 0644);
@@ -751,8 +753,10 @@ static size_t account(struct entropy_sto
else
r-entropy_count = reserved;
 
-   if (r-entropy_count  random_write_wakeup_thresh)
+   if (r-entropy_count  random_write_wakeup_thresh) {
wake_up_interruptible(random_write_wait);
+   kill_fasync(fasync, SIGIO, POLL_OUT);
+   }
}
 
DEBUG_ENT(debiting %d entropy credits from %s%s\n,
@@ -1090,8 +1094,11 @@ random_ioctl(struct inode * inode, struc
 * Wake up waiting processes if we have enough
 * entropy.
 */
-   if (input_pool.entropy_count = random_read_wakeup_thresh)
+   if (input_pool.entropy_count = random_read_wakeup_thresh) {
wake_up_interruptible(random_read_wait);
+   kill_fasync(fasync, SIGIO, POLL_IN);
+   }
+
return 0;
case RNDADDENTROPY:
if (!capable(CAP_SYS_ADMIN))
@@ -,8 +1118,10 @@ random_ioctl(struct inode * inode, struc
 * Wake up waiting processes if we have enough
 * entropy.
 */
-   if (input_pool.entropy_count = random_read_wakeup_thresh)
+   if (input_pool.entropy_count = random_read_wakeup_thresh) {
wake_up_interruptible(random_read_wait);
+   kill_fasync(fasync, SIGIO, POLL_IN);
+   }
return 0;
case RNDZAPENTCNT:
case RNDCLEARPOOL:
@@ -1128,17 +1137,31 @@ random_ioctl(struct inode * inode, struc
}
 }
 
+static int random_fasync(int fd, struct file *filp, int on)
+{
+   return fasync_helper(fd, filp, on, fasync);
+}
+
+static int random_release(struct inode *inode, struct file *filp)
+{
+   return fasync_helper(-1, filp, 0, fasync);
+}
+
 const struct file_operations random_fops = {
-   .read  = random_read,
-   .write = random_write,
-   .poll  = random_poll,
-   .ioctl = random_ioctl,
+   .read= random_read,
+   .write   = random_write,
+   .poll= random_poll,
+   .ioctl   = random_ioctl,
+   .fasync  = random_fasync,
+   .release = random_release,
 };
 
 const struct file_operations urandom_fops = {
-   .read  = urandom_read,
-   .write = random_write,
-   .ioctl = random_ioctl,
+   .read= urandom_read,
+   .write   = random_write,
+   .ioctl   = random_ioctl,
+   .fasync  = random_fasync,
+   .release = random_release

Re: [PATCH] random - add async I/O support

2008-01-21 Thread Jeff Dike
On Mon, Jan 21, 2008 at 12:43:25PM -0600, Matt Mackall wrote:
 This conflicts just about everywhere with my latest code, but I'll fix
 that up.

Great, thanks.

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: UML is leaking memory in arch_dup_mmap

2008-01-18 Thread Jeff Dike
On Fri, Jan 18, 2008 at 03:42:54PM +0100, Miklos Szeredi wrote:
> uml:~#  grep arch_dup_mmap /proc/slab_allocators
> size-32: 10861 arch_dup_mmap+0x9f/0x130

Whoops - try the patch below.

Jeff

-- 
Work email - jdike at linux dot intel dot com

Index: linux-2.6.22/arch/um/include/um_mmu.h
===
--- linux-2.6.22.orig/arch/um/include/um_mmu.h  2008-01-17 13:44:49.0 
-0500
+++ linux-2.6.22/arch/um/include/um_mmu.h   2008-01-18 12:53:10.0 
-0500
@@ -17,6 +17,7 @@ typedef struct mm_context {
unsigned long last_pmd;
 #endif
struct uml_ldt ldt;
+   struct page **stub_pages;
 } mm_context_t;
 
 extern void __switch_mm(struct mm_id * mm_idp);
Index: linux-2.6.22/arch/um/kernel/skas/mmu.c
===
--- linux-2.6.22.orig/arch/um/kernel/skas/mmu.c 2008-01-18 13:02:52.0 
-0500
+++ linux-2.6.22/arch/um/kernel/skas/mmu.c  2008-01-18 13:04:42.0 
-0500
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct 
goto out_free;
}
 
+   to_mm->stub_pages = NULL;
+
return 0;
 
  out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *old
 
pages[0] = virt_to_page(&__syscall_stub_start);
pages[1] = virt_to_page(mm->context.id.stack);
+   mm->context.stub_pages = pages;
 
/* dup_mmap already holds mmap_sem */
err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm
 {
pte_t *pte;
 
+   if(mm->context.stub_pages != NULL)
+   kfree(mm->context.stub_pages);
pte = virt_to_pte(mm, STUB_CODE);
if (pte != NULL)
pte_clear(mm, STUB_CODE, pte);
--
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 is leaking memory in arch_dup_mmap

2008-01-18 Thread Jeff Dike
On Fri, Jan 18, 2008 at 03:42:54PM +0100, Miklos Szeredi wrote:
 uml:~#  grep arch_dup_mmap /proc/slab_allocators
 size-32: 10861 arch_dup_mmap+0x9f/0x130

Whoops - try the patch below.

Jeff

-- 
Work email - jdike at linux dot intel dot com

Index: linux-2.6.22/arch/um/include/um_mmu.h
===
--- linux-2.6.22.orig/arch/um/include/um_mmu.h  2008-01-17 13:44:49.0 
-0500
+++ linux-2.6.22/arch/um/include/um_mmu.h   2008-01-18 12:53:10.0 
-0500
@@ -17,6 +17,7 @@ typedef struct mm_context {
unsigned long last_pmd;
 #endif
struct uml_ldt ldt;
+   struct page **stub_pages;
 } mm_context_t;
 
 extern void __switch_mm(struct mm_id * mm_idp);
Index: linux-2.6.22/arch/um/kernel/skas/mmu.c
===
--- linux-2.6.22.orig/arch/um/kernel/skas/mmu.c 2008-01-18 13:02:52.0 
-0500
+++ linux-2.6.22/arch/um/kernel/skas/mmu.c  2008-01-18 13:04:42.0 
-0500
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct 
goto out_free;
}
 
+   to_mm-stub_pages = NULL;
+
return 0;
 
  out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *old
 
pages[0] = virt_to_page(__syscall_stub_start);
pages[1] = virt_to_page(mm-context.id.stack);
+   mm-context.stub_pages = pages;
 
/* dup_mmap already holds mmap_sem */
err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm
 {
pte_t *pte;
 
+   if(mm-context.stub_pages != NULL)
+   kfree(mm-context.stub_pages);
pte = virt_to_pte(mm, STUB_CODE);
if (pte != NULL)
pte_clear(mm, STUB_CODE, pte);
--
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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 03:17:38PM -0800, Pallipadi, Venkatesh wrote:
> >#define X X
> >
> >is a no-op, yes?
> >
> 
> Later there is code in generic.h which is doing
> #ifndef ioremap_wc
> #define ioremap_wc ioremap_nocache
> #endif

Ah, that makes a bit more sense.

It'd be nice if there was less of a WTF factor there, though.

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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 01:41:50PM -0800, Venki Pallipadi wrote:
> > And while we're on the subject, what's the deal with these, in
> > include/asm-x86/io.h?
> > 
> > #define ioremap_wc ioremap_wc
> > #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
> > 
> 
> If archs want to override the defaults for these two functions, they define
> the above and then include asm-generic/iomap.h.

That wasn't really the question.

#define X X

is a no-op, yes?

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 19/20] UML - port mutex conversion

2008-01-17 Thread Jeff Dike
From: Daniel Walker <[EMAIL PROTECTED]>

The port_sem is already used as a mutex since it's using DECLARE_MUTEX(),
but the underlying construct is still a semaphore .. This patch switches
it over to a struct mutex.

Signed-off-by: Daniel Walker <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/port_kern.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-2.6.22/arch/um/drivers/port_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/port_kern.c   2008-01-17 
13:44:46.0 -0500
+++ linux-2.6.22/arch/um/drivers/port_kern.c2008-01-17 13:47:39.0 
-0500
@@ -6,6 +6,7 @@
 #include "linux/completion.h"
 #include "linux/interrupt.h"
 #include "linux/list.h"
+#include "linux/mutex.h"
 #include "asm/atomic.h"
 #include "init.h"
 #include "irq_kern.h"
@@ -120,7 +121,7 @@ static int port_accept(struct port_list 
return 0;
 }
 
-static DECLARE_MUTEX(ports_sem);
+static DEFINE_MUTEX(ports_mutex);
 static LIST_HEAD(ports);
 
 static void port_work_proc(struct work_struct *unused)
@@ -161,7 +162,7 @@ void *port_data(int port_num)
struct port_dev *dev = NULL;
int fd;
 
-   down(_sem);
+   mutex_lock(_mutex);
list_for_each(ele, ) {
port = list_entry(ele, struct port_list, list);
if (port->port == port_num)
@@ -216,7 +217,7 @@ void *port_data(int port_num)
  out_free:
kfree(port);
  out:
-   up(_sem);
+   mutex_unlock(_mutex);
return dev;
 }
 
--
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 13/20] UML - Spelling fix

2008-01-17 Thread Jeff Dike
From: Joe Perches <[EMAIL PROTECTED]>

Spelling fix

Signed-off-by: Joe Perches <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/sys-x86_64/signal.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6-git/arch/um/sys-x86_64/signal.c
===
--- linux-2.6-git.orig/arch/um/sys-x86_64/signal.c  2008-01-02 
11:25:13.0 -0500
+++ linux-2.6-git/arch/um/sys-x86_64/signal.c   2008-01-02 12:01:05.0 
-0500
@@ -112,7 +112,7 @@ static int copy_sc_to_user(struct sigcon
err |= PUTREG(regs, RSI, to, rsi);
err |= PUTREG(regs, RBP, to, rbp);
/*
-* Must use orignal RSP, which is passed in, rather than what's in
+* Must use original RSP, which is passed in, rather than what's in
 * the pt_regs, because that's already been updated to point at the
 * signal frame.
 */
--
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 1/20] UML - Runtime detection of host VMSPLIT on i386

2008-01-17 Thread Jeff Dike
Calculate TASK_SIZE at run-time by figuring out the host's VMSPLIT -
this is needed on i386 if UML is to run on hosts with varying VMSPLITs
without recompilation.

TASK_SIZE is now defined in terms of a variable, task_size.  This gets
rid of an include of pgtable.h from processor.h, which can cause
include loops.

On i386, task_size is calculated early in boot by probing the address
space in a binary search to figure out where the boundary between
usable and non-usable memory is.  This tries to make sure that a page
that is considered to be in userspace is, or can be made, read-write.
I'm concerned about a system-global VDSO page in kernel memory being
hit and considered to be a userspace page.

On x86_64, task_size is just the old value of CONFIG_TOP_ADDR.

A bunch of config variable are gone now.  CONFIG_TOP_ADDR is directly
replaced by TASK_SIZE.  NEST_LEVEL is gone since the relocation of
the stubs makes it irrelevant.  All the HOST_VMSPLIT stuff is gone.
All references to these in arch/um/Makefile are also gone.

I noticed and fixed a missing extern in os.h when adding
os_get_task_size.

Note: This has been revised to fix the 32-bit UML on 64-bit host bug
that Miklos ran into.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/Kconfig |   11 --
 arch/um/Kconfig.i386|   37 -
 arch/um/Kconfig.x86_64  |4 -
 arch/um/Makefile|   11 --
 arch/um/defconfig   |3 
 arch/um/include/as-layout.h |2 
 arch/um/include/os.h|5 +
 arch/um/kernel/exec.c   |2 
 arch/um/kernel/um_arch.c|   16 +++-
 arch/um/os-Linux/sys-i386/Makefile  |2 
 arch/um/os-Linux/sys-i386/task_size.c   |  120 
 arch/um/os-Linux/sys-x86_64/Makefile|2 
 arch/um/os-Linux/sys-x86_64/task_size.c |5 +
 include/asm-um/fixmap.h |3 
 include/asm-um/processor-generic.h  |5 -
 15 files changed, 153 insertions(+), 75 deletions(-)

Index: linux-2.6-git/arch/um/kernel/um_arch.c
===
--- linux-2.6-git.orig/arch/um/kernel/um_arch.c 2008-01-17 14:32:56.0 
-0500
+++ linux-2.6-git/arch/um/kernel/um_arch.c  2008-01-17 14:34:15.0 
-0500
@@ -224,6 +224,11 @@ static void __init uml_postsetup(void)
 }
 
 /* Set during early boot */
+unsigned long task_size;
+EXPORT_SYMBOL(task_size);
+
+unsigned long host_task_size;
+
 unsigned long brk_start;
 unsigned long end_iomem;
 EXPORT_SYMBOL(end_iomem);
@@ -250,6 +255,13 @@ int __init linux_main(int argc, char **a
if (have_root == 0)
add_arg(DEFAULT_COMMAND_LINE);
 
+   host_task_size = os_get_task_size();
+   /*
+* TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
+* out
+*/
+   task_size = host_task_size & PGDIR_MASK;
+
/* OS sanity checks that need to happen before the kernel runs */
os_early_checks();
 
@@ -286,7 +298,7 @@ int __init linux_main(int argc, char **a
 
highmem = 0;
iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
-   max_physmem = CONFIG_TOP_ADDR - uml_physmem - iomem_size - MIN_VMALLOC;
+   max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
 
/*
 * Zones have to begin on a 1 << MAX_ORDER page boundary,
@@ -318,7 +330,7 @@ int __init linux_main(int argc, char **a
}
 
virtmem_size = physmem_size;
-   avail = CONFIG_TOP_ADDR - start_vm;
+   avail = TASK_SIZE - start_vm;
if (physmem_size > avail)
virtmem_size = avail;
end_vm = start_vm + virtmem_size;
Index: linux-2.6-git/include/asm-um/processor-generic.h
===
--- linux-2.6-git.orig/include/asm-um/processor-generic.h   2008-01-17 
14:32:56.0 -0500
+++ linux-2.6-git/include/asm-um/processor-generic.h2008-01-17 
14:34:15.0 -0500
@@ -11,7 +11,6 @@ struct pt_regs;
 struct task_struct;
 
 #include "asm/ptrace.h"
-#include "asm/pgtable.h"
 #include "registers.h"
 #include "sysdep/archsetjmp.h"
 
@@ -94,7 +93,9 @@ static inline void mm_copy_segments(stru
 /*
  * User space process size: 3GB (default).
  */
-#define TASK_SIZE (CONFIG_TOP_ADDR & PGDIR_MASK)
+extern unsigned long task_size;
+
+#define TASK_SIZE (task_size)
 
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
Index: linux-2.6-git/arch/um/include/os.h
===
--- linux-2.6-git.orig/arch/um/include/os.h 2008-01-17 14:32:56.0 
-0500
+++ linux-2.6-git/arch/um/include/os.h  2008-01-17 14:34:15.0 -0500
@@ -302,6 +302,9 @@ extern void sig_handler_common_skas(int 
 extern int

[PATCH 15/20] UML - Fix infinite mconsole loop

2008-01-17 Thread Jeff Dike
From: Karol Swietlicki <[EMAIL PROTECTED]>

This patch takes care of a problem with the stopping code.

The function inside the while condition returns 0 to signify a problem.
A problem could be for example a bad command or a bad version of the
mconsole client.
A bad command would terminate the stopping loop and resume the kernel.
This is a problem.

A better solution is to make the loop infinite and don't leave it
until we are explicitly told to.

Signed-off-by: Karol Swietlicki <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/mconsole_kern.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6.22/arch/um/drivers/mconsole_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/mconsole_kern.c   2007-12-12 
13:44:20.0 -0500
+++ linux-2.6.22/arch/um/drivers/mconsole_kern.c2007-12-12 
15:53:08.0 -0500
@@ -305,7 +305,9 @@ void mconsole_stop(struct mc_request *re
deactivate_fd(req->originating_fd, MCONSOLE_IRQ);
os_set_fd_block(req->originating_fd, 1);
mconsole_reply(req, "stopped", 0, 0);
-   while (mconsole_get_request(req->originating_fd, req)) {
+   for (;;) {
+   if (!mconsole_get_request(req->originating_fd, req))
+   continue;
if (req->cmd->handler == mconsole_go)
break;
if (req->cmd->handler == mconsole_stop) {
--
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 10/20] UML - Move register initialization

2008-01-17 Thread Jeff Dike
Calling init_registers inside the skas3 checking causes mysterious
crashes if it doesn't happen because the skas3 checking is bypassed.
This patch moves it to os_early_checks.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/os-Linux/start_up.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6.22/arch/um/os-Linux/start_up.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/start_up.c   2007-12-19 
13:15:22.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/start_up.c2007-12-19 13:16:08.0 
-0500
@@ -342,6 +342,8 @@ static void __init check_coredump_limit(
 
 void __init os_early_checks(void)
 {
+   int pid;
+
/* Print out the core dump limits early */
check_coredump_limit();
 
@@ -351,6 +353,11 @@ void __init os_early_checks(void)
 * kernel is running.
 */
check_tmpexec();
+
+   pid = start_ptraced_child();
+   if (init_registers(pid))
+   fatal("Failed to initialize default registers");
+   stop_ptraced_child(pid, 1, 1);
 }
 
 static int __init noprocmm_cmd_param(char *str, int* add)
@@ -412,9 +419,6 @@ static inline void check_skas3_ptrace_fa
non_fatal("found\n");
}
 
-   if (init_registers(pid))
-   fatal("Failed to initialize default registers");
-
stop_ptraced_child(pid, 1, 1);
 }
 
--
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/20] UML - Style fixes in arch/um/os-LInux

2008-01-17 Thread Jeff Dike
Style changes under arch/um/os-Linux:
include trimming
CodingStyle fixes
some printks needed severity indicators 

make_tempfile turns out not to be used outside of mem.c, so it is now
static.  Its declaration in tempfile.h is no longer needed, and
tempfile.h itself is no longer needed.

create_tmp_file was also made static.

checkpatch moans about an EXPORT_SYMBOL in user_syms.c which is part
of a macro definition - this is copying a bit of kernel infrastructure
into the libc side of UML because the kernel headers can't be included
there.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/tempfile.h   |   11 ---
 arch/um/os-Linux/aio.c   |2 
 arch/um/os-Linux/drivers/ethertap_kern.c |8 +-
 arch/um/os-Linux/drivers/tuntap_kern.c   |6 -
 arch/um/os-Linux/include/file.h  |   13 ---
 arch/um/os-Linux/mem.c   |  101 +++
 arch/um/os-Linux/process.c   |2 
 arch/um/os-Linux/signal.c|2 
 arch/um/os-Linux/skas/process.c  |6 -
 arch/um/os-Linux/sys-i386/registers.c|4 -
 arch/um/os-Linux/sys-x86_64/registers.c  |   21 +++---
 arch/um/os-Linux/uaccess.c   |4 -
 arch/um/os-Linux/user_syms.c |4 -
 arch/um/os-Linux/util.c  |   43 -
 14 files changed, 98 insertions(+), 129 deletions(-)

Index: linux-2.6.22/arch/um/os-Linux/user_syms.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/user_syms.c  2007-12-14 
11:21:17.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/user_syms.c   2007-12-14 11:23:36.0 
-0500
@@ -34,8 +34,8 @@ EXPORT_SYMBOL(printf);
  * good; so the versions of these symbols will always match
  */
 #define EXPORT_SYMBOL_PROTO(sym)   \
-   int sym(void);  \
-   EXPORT_SYMBOL(sym);
+   int sym(void);  \
+   EXPORT_SYMBOL(sym);
 
 extern void readdir64(void) __attribute__((weak));
 EXPORT_SYMBOL(readdir64);
Index: linux-2.6.22/arch/um/include/tempfile.h
===
--- linux-2.6.22.orig/arch/um/include/tempfile.h2007-12-14 
11:21:17.0 -0500
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,11 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike ([EMAIL PROTECTED])
- * Licensed under the GPL
- */
-
-#ifndef __TEMPFILE_H__
-#define __TEMPFILE_H__
-
-extern int make_tempfile(const char *template, char **tempname, int do_unlink);
-
-#endif
Index: linux-2.6.22/arch/um/os-Linux/aio.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/aio.c2007-12-14 11:21:17.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/aio.c 2007-12-14 11:28:05.0 -0500
@@ -142,7 +142,7 @@ static int do_not_aio(struct aio_thread_
if (actual != req->offset)
return -errno;
 
-   switch(req->type) {
+   switch (req->type) {
case AIO_READ:
n = read(req->io_fd, req->buf, req->len);
break;
Index: linux-2.6.22/arch/um/os-Linux/include/file.h
===
--- linux-2.6.22.orig/arch/um/os-Linux/include/file.h   2007-12-14 
11:21:17.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/include/file.h2007-12-14 
11:23:36.0 -0500
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike ([EMAIL PROTECTED])
+ * Copyright (C) 2002 - 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,14 +9,3 @@
 #define DEV_NULL "/dev/null"
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
Index: linux-2.6.22/arch/um/os-Linux/mem.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/mem.c2007-12-14 11:21:17.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/mem.c 2007-12-14 11:35:12.0 -0500
@@ -1,22 +1,21 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
+ * Licensed under the GPL
+ */
+
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include "user.h"
-#include "mem_user.h"
+#include 
 #include "init.h"
-#include "os.h"
-#include "tempfile.h"
 #include "kern_constants.h"
-
-#include 
+#include "os.h"
+#include "user.h"
 
 /* Modified by whic

[PATCH 7/20] UML - Add back CONFIG_HZ

2008-01-17 Thread Jeff Dike
avoid-overflows-in-kernel-timec.patch makes CONFIG_HZ necessary for a
successful build.  UML lacks a definition, so this patch adds one.  It
also changes the hard-wired definition of HZ to CONFIG_HZ.

Note: this patch is a good idea even in the absence of hpa's time
fixes.

Cc: "H. Peter Anvin" <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/Kconfig|4 
 include/asm-um/param.h |2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

Index: linux-2.6.22/arch/um/Kconfig
===
--- linux-2.6.22.orig/arch/um/Kconfig   2008-01-01 17:32:04.0 -0500
+++ linux-2.6.22/arch/um/Kconfig2008-01-02 11:16:44.0 -0500
@@ -68,6 +68,10 @@ config IRQ_RELEASE_METHOD
bool
default y
 
+config HZ
+   int
+   default 100
+
 menu "UML-specific options"
 
 config STATIC_LINK
Index: linux-2.6.22/include/asm-um/param.h
===
--- linux-2.6.22.orig/include/asm-um/param.h2007-07-08 19:32:17.0 
-0400
+++ linux-2.6.22/include/asm-um/param.h 2008-01-02 11:18:44.0 -0500
@@ -10,7 +10,7 @@
 #define MAXHOSTNAMELEN  64  /* max length of hostname */
 
 #ifdef __KERNEL__
-#define HZ 100
+#define HZ CONFIG_HZ
 #define USER_HZ100/* .. some user interfaces are in "ticks" */
 #define CLOCKS_PER_SEC (USER_HZ)  /* frequency at which times() counts */
 #endif
--
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 4/20] UML - Implement O_APPEND

2008-01-17 Thread Jeff Dike
The .a flags in openflags never had an implementation.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/os-Linux/file.c |2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6.22/arch/um/os-Linux/file.c
===
--- linux-2.6.22.orig/arch/um/os-Linux/file.c   2007-12-13 13:50:52.0 
-0500
+++ linux-2.6.22/arch/um/os-Linux/file.c2007-12-13 15:23:13.0 
-0500
@@ -191,6 +191,8 @@ int os_open_file(const char *file, struc
f |= O_TRUNC;
if (flags.e)
f |= O_EXCL;
+   if (flags.a)
+   f |= O_APPEND;
 
fd = open64(file, f, mode);
if (fd < 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 5/20] UML - Remove fakehd

2008-01-17 Thread Jeff Dike
The fakehd switch lost its implementation at some point.  Since no one is
screaming for it, we might as well remove it.

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

Index: linux-2.6.22/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/ubd_kern.c2007-12-14 
11:28:06.0 -0500
+++ linux-2.6.22/arch/um/drivers/ubd_kern.c 2007-12-14 12:33:26.0 
-0500
@@ -460,20 +460,6 @@ __uml_help(udb_setup,
 "in the boot output.\n\n"
 );
 
-static int fakehd_set = 0;
-static int fakehd(char *str)
-{
-   printk(KERN_INFO "fakehd : Changing ubd name to \"hd\".\n");
-   fakehd_set = 1;
-   return 1;
-}
-
-__setup("fakehd", fakehd);
-__uml_help(fakehd,
-"fakehd\n"
-"Change the ubd device name to \"hd\".\n\n"
-);
-
 static void do_ubd_request(struct request_queue * q);
 
 /* Only changed by ubd_init, which is an initcall. */
@@ -730,8 +716,10 @@ static int ubd_add(int n, char **error_o
ubd_disk_register(fake_major, ubd_dev->size, n,
  _gendisk[n]);
 
-   /* perhaps this should also be under the "if (fake_major)" above */
-   /* using the fake_disk->disk_name and also the fakehd_set name */
+   /*
+* Perhaps this should also be under the "if (fake_major)" above
+* using the fake_disk->disk_name
+*/
if (fake_ide)
make_ide_entries(ubd_gendisk[n]->disk_name);
 
--
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 6/20] UML - DEBUG_SHIRQ fixes

2008-01-17 Thread Jeff Dike
A couple more DEBUG_SHIRQ fixes.

The previous mconsole blocking fix exposed the lack of O_NONBLOCK on
the mconsole socket.

Also, winch_interrupt started crashing because it is called at irq
free time and it tries to dereference tty->driver_data, which has
already been set to NULL.

I added some error cleanup in mconsole_init while I was there.

Cc: "Karol Swietlicki" <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/line.c  |8 +---
 arch/um/drivers/mconsole_kern.c |8 +++-
 2 files changed, 12 insertions(+), 4 deletions(-)

Index: linux-2.6.22/arch/um/drivers/line.c
===
--- linux-2.6.22.orig/arch/um/drivers/line.c2007-12-14 11:28:06.0 
-0500
+++ linux-2.6.22/arch/um/drivers/line.c 2007-12-14 12:47:43.0 -0500
@@ -774,9 +774,11 @@ static irqreturn_t winch_interrupt(int i
tty = winch->tty;
if (tty != NULL) {
line = tty->driver_data;
-   chan_window_size(>chan_list, >winsize.ws_row,
->winsize.ws_col);
-   kill_pgrp(tty->pgrp, SIGWINCH, 1);
+   if (line != NULL) {
+   chan_window_size(>chan_list, >winsize.ws_row,
+>winsize.ws_col);
+   kill_pgrp(tty->pgrp, SIGWINCH, 1);
+   }
}
  out:
if (winch->fd != -1)
Index: linux-2.6.22/arch/um/drivers/mconsole_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/mconsole_kern.c   2007-12-14 
11:28:06.0 -0500
+++ linux-2.6.22/arch/um/drivers/mconsole_kern.c2007-12-14 
12:53:49.0 -0500
@@ -792,6 +792,8 @@ static int __init mconsole_init(void)
printk(KERN_ERR "Failed to initialize management console\n");
return 1;
}
+   if (os_set_fd_block(sock, 0))
+   goto out;
 
register_reboot_notifier(_notifier);
 
@@ -800,7 +802,7 @@ static int __init mconsole_init(void)
 "mconsole", (void *)sock);
if (err) {
printk(KERN_ERR "Failed to get IRQ for management console\n");
-   return 1;
+   goto out;
}
 
if (notify_socket != NULL) {
@@ -816,6 +818,10 @@ static int __init mconsole_init(void)
printk(KERN_INFO "mconsole (version %d) initialized on %s\n",
   MCONSOLE_VERSION, mconsole_socket_name);
return 0;
+
+ out:
+   os_close_file(sock);
+   return 1;
 }
 
 __initcall(mconsole_init);
--
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 8/20] UML - Style fixes in arch/um/sys-x86_64

2008-01-17 Thread Jeff Dike
Style fixes in arch/um/sys-x86_64:
updated copyrights
CodingStyle fixes
added severities to printks which needed them

A bunch of functions in sys-*/ptrace_user.c turn out to be unused, so
they and their declarations are gone.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/ptrace_user.h  |   11 ++--
 arch/um/sys-i386/ptrace_user.c |   14 ---
 arch/um/sys-x86_64/bug.c   |3 +-
 arch/um/sys-x86_64/ptrace.c|   29 ---
 arch/um/sys-x86_64/ptrace_user.c   |   46 -
 arch/um/sys-x86_64/syscall_table.c |   31 
 arch/um/sys-x86_64/sysrq.c |   29 ---
 arch/um/sys-x86_64/um_module.c |8 --
 8 files changed, 65 insertions(+), 106 deletions(-)

Index: linux-2.6.22/arch/um/include/ptrace_user.h
===
--- linux-2.6.22.orig/arch/um/include/ptrace_user.h 2007-12-14 
11:28:07.0 -0500
+++ linux-2.6.22/arch/um/include/ptrace_user.h  2007-12-14 11:47:57.0 
-0500
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike ([EMAIL PROTECTED])
+ * Copyright (C) 2000 - 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -10,12 +10,6 @@
 
 extern int ptrace_getregs(long pid, unsigned long *regs_out);
 extern int ptrace_setregs(long pid, unsigned long *regs_in);
-extern int ptrace_getfpregs(long pid, unsigned long *regs_out);
-extern int ptrace_setfpregs(long pid, unsigned long *regs);
-extern void arch_enter_kernel(void *task, int pid);
-extern void arch_leave_kernel(void *task, int pid);
-extern void ptrace_pokeuser(unsigned long addr, unsigned long data);
-
 
 /* syscall emulation path in ptrace */
 
@@ -54,7 +48,8 @@ extern int sysemu_supported;
(((int[3][3] ) { \
{ PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \
{ PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \
-   { PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, 
PTRACE_SYSEMU_SINGLESTEP }}) \
+   { PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, \
+ PTRACE_SYSEMU_SINGLESTEP } }) \
[sysemu_mode][singlestep_mode])
 
 #endif
Index: linux-2.6.22/arch/um/sys-i386/ptrace_user.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/ptrace_user.c2007-12-14 
11:28:07.0 -0500
+++ linux-2.6.22/arch/um/sys-i386/ptrace_user.c 2007-12-14 11:38:28.0 
-0500
@@ -19,17 +19,3 @@ int ptrace_setregs(long pid, unsigned lo
return -errno;
return 0;
 }
-
-int ptrace_getfpregs(long pid, unsigned long *regs)
-{
-   if (ptrace(PTRACE_GETFPREGS, pid, 0, regs) < 0)
-   return -errno;
-   return 0;
-}
-
-int ptrace_setfpregs(long pid, unsigned long *regs)
-{
-   if (ptrace(PTRACE_SETFPREGS, pid, 0, regs) < 0)
-   return -errno;
-   return 0;
-}
Index: linux-2.6.22/arch/um/sys-x86_64/bug.c
===
--- linux-2.6.22.orig/arch/um/sys-x86_64/bug.c  2007-12-14 11:28:07.0 
-0500
+++ linux-2.6.22/arch/um/sys-x86_64/bug.c   2007-12-14 11:38:28.0 
-0500
@@ -5,7 +5,8 @@
 
 #include 
 
-/* Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
+/*
+ * Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
  * that's not relevant in skas mode.
  */
 
Index: linux-2.6.22/arch/um/sys-x86_64/ptrace.c
===
--- linux-2.6.22.orig/arch/um/sys-x86_64/ptrace.c   2007-12-14 
11:28:07.0 -0500
+++ linux-2.6.22/arch/um/sys-x86_64/ptrace.c2007-12-14 11:47:21.0 
-0500
@@ -5,13 +5,12 @@
  * Licensed under the GPL
  */
 
-#define __FRAME_OFFSETS
-#include 
+#include 
 #include 
 #include 
-#include 
+#define __FRAME_OFFSETS
+#include 
 #include 
-#include 
 
 /*
  * determines which flags the user has access to.
@@ -24,12 +23,14 @@ int putreg(struct task_struct *child, in
unsigned long tmp;
 
 #ifdef TIF_IA32
-   /* Some code in the 64bit emulation may not be 64bit clean.
-  Don't take any chances. */
+   /*
+* Some code in the 64bit emulation may not be 64bit clean.
+* Don't take any chances.
+*/
if (test_tsk_thread_flag(child, TIF_IA32))
value &= 0x;
 #endif
-   switch (regno){
+   switch (regno) {
case FS:
case GS:
case DS:
@@ -66,7 +67,7 @@ int poke_user(struct task_struct *child,
if (addr < MAX_REG_OFFSET)
return putreg(child, addr, data);
else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
-   (addr <= offsetof(struct user, u_debugreg[7]))){
+   (add

[PATCH 0/20] UML - Lots of patches for 2.6.25

2008-01-17 Thread Jeff Dike
This is a lot of cleanup.  There are style fixes, printk fixes,
spelling fixes, mutex conversions, and small bug fixes.

This is all obviously for 2.6.25.

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 17/20] UML - LDT mutex conversion

2008-01-17 Thread Jeff Dike
From: Daniel Walker <[EMAIL PROTECTED]>

The ldt.semaphore conforms to the new struct mutex requirments,
so I converted it to use the new API and changed the name.

Signed-off-by: Daniel Walker <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/sys-i386/ldt.c |   14 +++---
 include/asm-um/ldt.h   |4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6.22/arch/um/sys-i386/ldt.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/ldt.c2008-01-17 13:44:46.0 
-0500
+++ linux-2.6.22/arch/um/sys-i386/ldt.c 2008-01-17 13:45:32.0 -0500
@@ -147,7 +147,7 @@ static int read_ldt(void __user * ptr, u
if (ptrace_ldt)
return read_ldt_from_host(ptr, bytecount);
 
-   down(>semaphore);
+   mutex_lock(>lock);
if (ldt->entry_count <= LDT_DIRECT_ENTRIES) {
size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES;
if (size > bytecount)
@@ -171,7 +171,7 @@ static int read_ldt(void __user * ptr, u
ptr += size;
}
}
-   up(>semaphore);
+   mutex_unlock(>lock);
 
if (bytecount == 0 || err == -EFAULT)
goto out;
@@ -229,7 +229,7 @@ static int write_ldt(void __user * ptr, 
}
 
if (!ptrace_ldt)
-   down(>semaphore);
+   mutex_lock(>lock);
 
err = write_ldt_entry(mm_idp, func, _info, , 1);
if (err)
@@ -289,7 +289,7 @@ static int write_ldt(void __user * ptr, 
err = 0;
 
 out_unlock:
-   up(>semaphore);
+   mutex_unlock(>lock);
 out:
return err;
 }
@@ -396,7 +396,7 @@ long init_new_ldt(struct mm_context *new
 
 
if (!ptrace_ldt)
-   init_MUTEX(_mm->ldt.semaphore);
+   mutex_init(_mm->ldt.lock);
 
if (!from_mm) {
memset(, 0, sizeof(desc));
@@ -456,7 +456,7 @@ long init_new_ldt(struct mm_context *new
 * i.e., we have to use the stub for modify_ldt, which
 * can't handle the big read buffer of up to 64kB.
 */
-   down(_mm->ldt.semaphore);
+   mutex_lock(_mm->ldt.lock);
if (from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES)
memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries,
   sizeof(new_mm->ldt.u.entries));
@@ -475,7 +475,7 @@ long init_new_ldt(struct mm_context *new
}
}
new_mm->ldt.entry_count = from_mm->ldt.entry_count;
-   up(_mm->ldt.semaphore);
+   mutex_unlock(_mm->ldt.lock);
}
 
 out:
Index: linux-2.6.22/include/asm-um/ldt.h
===
--- linux-2.6.22.orig/include/asm-um/ldt.h  2007-11-14 10:33:41.0 
-0500
+++ linux-2.6.22/include/asm-um/ldt.h   2008-01-17 13:45:32.0 -0500
@@ -8,7 +8,7 @@
 #ifndef __ASM_LDT_H
 #define __ASM_LDT_H
 
-#include "asm/semaphore.h"
+#include 
 #include "asm/host_ldt.h"
 
 extern void ldt_host_info(void);
@@ -27,7 +27,7 @@ struct ldt_entry {
 
 typedef struct uml_ldt {
int entry_count;
-   struct semaphore semaphore;
+   struct mutex lock;
union {
struct ldt_entry * pages[LDT_PAGES_MAX];
struct ldt_entry entries[LDT_DIRECT_ENTRIES];
--
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 12/20] UML - Remove TOPDIR

2008-01-17 Thread Jeff Dike
From: WANG Cong <[EMAIL PROTECTED]>

TOPDIR is obsolete, use srctree instead.
This patch removes TOPDIR from all UML Makefiles.

Cc: Sam Ravnborg <[EMAIL PROTECTED]>
Signed-off-by: WANG Cong <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/Makefile |4 ++--
 arch/um/sys-ppc/Makefile |   22 +++---
 2 files changed, 13 insertions(+), 13 deletions(-)

Index: linux-2.6.22/arch/um/Makefile
===
--- linux-2.6.22.orig/arch/um/Makefile  2008-01-01 18:39:11.0 -0500
+++ linux-2.6.22/arch/um/Makefile   2008-01-02 09:59:21.0 -0500
@@ -149,7 +149,7 @@ ifneq ($(KBUILD_SRC),)
$(Q)mkdir -p $(objtree)/include/asm-um
$(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir 
$@))-$(SUBARCH)$(suffix $@) $@
 else
-   $(Q)cd $(TOPDIR)/$(dir $@) ; \
+   $(Q)cd $(srctree)/$(dir $@) ; \
ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
 endif
 
@@ -159,7 +159,7 @@ ifneq ($(KBUILD_SRC),)
$(Q)mkdir -p $(objtree)/include/asm-um
$(Q)ln -fsn $(srctree)/include/asm-$(HEADER_ARCH) include/asm-um/arch
 else
-   $(Q)cd $(TOPDIR)/include/asm-um && ln -fsn ../asm-$(HEADER_ARCH) arch
+   $(Q)cd $(srctree)/include/asm-um && ln -fsn ../asm-$(HEADER_ARCH) arch
 endif
 
 $(objtree)/$(ARCH_DIR)/include:
Index: linux-2.6.22/arch/um/sys-ppc/Makefile
===
--- linux-2.6.22.orig/arch/um/sys-ppc/Makefile  2007-11-14 10:33:29.0 
-0500
+++ linux-2.6.22/arch/um/sys-ppc/Makefile   2008-01-02 09:59:21.0 
-0500
@@ -6,7 +6,7 @@ OBJ = built-in.o
 OBJS = ptrace.o sigcontext.o semaphore.o checksum.o miscthings.o misc.o \
ptrace_user.o sysrq.o
 
-EXTRA_AFLAGS := -DCONFIG_PPC32 -I. -I$(TOPDIR)/arch/ppc/kernel
+EXTRA_AFLAGS := -DCONFIG_PPC32 -I. -I$(srctree)/arch/ppc/kernel
 
 all: $(OBJ)
 
@@ -22,25 +22,25 @@ sigcontext.o: sigcontext.c
 
 semaphore.c:
rm -f $@
-   ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
+   ln -s $(srctree)/arch/ppc/kernel/$@ $@
 
 checksum.S:
rm -f $@
-   ln -s $(TOPDIR)/arch/ppc/lib/$@ $@
+   ln -s $(srctree)/arch/ppc/lib/$@ $@
 
 mk_defs.c:
rm -f $@
-   ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
+   ln -s $(srctree)/arch/ppc/kernel/$@ $@
 
 ppc_defs.head:
rm -f $@
-   ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
+   ln -s $(srctree)/arch/ppc/kernel/$@ $@
 
 ppc_defs.h: mk_defs.c ppc_defs.head \
-   $(TOPDIR)/include/asm-ppc/mmu.h \
-   $(TOPDIR)/include/asm-ppc/processor.h \
-   $(TOPDIR)/include/asm-ppc/pgtable.h \
-   $(TOPDIR)/include/asm-ppc/ptrace.h
+   $(srctree)/include/asm-ppc/mmu.h \
+   $(srctree)/include/asm-ppc/processor.h \
+   $(srctree)/include/asm-ppc/pgtable.h \
+   $(srctree)/include/asm-ppc/ptrace.h
 #  $(CC) $(CFLAGS) -S mk_defs.c
cp ppc_defs.head ppc_defs.h
 # for bk, this way we can write to the file even if it's not checked out
@@ -56,13 +56,13 @@ ppc_defs.h: mk_defs.c ppc_defs.head \
 
 checksum.o: checksum.S
rm -f asm
-   ln -s $(TOPDIR)/include/asm-ppc asm
+   ln -s $(srctree)/include/asm-ppc asm
$(CC) $(EXTRA_AFLAGS) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c 
$< -o $*.o
rm -f asm
 
 misc.o: misc.S ppc_defs.h
rm -f asm
-   ln -s $(TOPDIR)/include/asm-ppc asm
+   ln -s $(srctree)/include/asm-ppc asm
$(CC) $(EXTRA_AFLAGS) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c 
$< -o $*.o
rm -f asm
 
--
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 18/20] UML - mconsole mutex conversion

2008-01-17 Thread Jeff Dike
From: Daniel Walker <[EMAIL PROTECTED]>

The plug_mem_mutex is already used as a mutex since it's using DECLARE_MUTEX(),
but the underlying construct is still a semaphore .. This patch switches
it over to a struct mutex.

Signed-off-by: Daniel Walker <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/mconsole_kern.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-2.6-git/arch/um/drivers/mconsole_kern.c
===
--- linux-2.6-git.orig/arch/um/drivers/mconsole_kern.c  2008-01-17 
14:35:43.0 -0500
+++ linux-2.6-git/arch/um/drivers/mconsole_kern.c   2008-01-17 
14:37:29.0 -0500
@@ -17,6 +17,7 @@
 #include "linux/syscalls.h"
 #include "linux/utsname.h"
 #include "linux/workqueue.h"
+#include "linux/mutex.h"
 #include "asm/uaccess.h"
 #include "init.h"
 #include "irq_kern.h"
@@ -360,7 +361,7 @@ struct unplugged_pages {
void *pages[UNPLUGGED_PER_PAGE];
 };
 
-static DECLARE_MUTEX(plug_mem_mutex);
+static DEFINE_MUTEX(plug_mem_mutex);
 static unsigned long long unplugged_pages_count = 0;
 static LIST_HEAD(unplugged_pages);
 static int unplug_index = UNPLUGGED_PER_PAGE;
@@ -396,7 +397,7 @@ static int mem_config(char *str, char **
 
diff /= PAGE_SIZE;
 
-   down(_mem_mutex);
+   mutex_lock(_mem_mutex);
for (i = 0; i < diff; i++) {
struct unplugged_pages *unplugged;
void *addr;
@@ -453,7 +454,7 @@ static int mem_config(char *str, char **
 
err = 0;
 out_unlock:
-   up(_mem_mutex);
+   mutex_unlock(_mem_mutex);
 out:
return err;
 }
--
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 14/20] UML - Remove map_cb

2008-01-17 Thread Jeff Dike
John Reiser noticed that a physical memory region was being mapped twice.

This patch fixes that, and it inlines the responsible function, as
that had only one caller.

Cc: John Reiser <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/kernel/mem.c |8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

Index: linux-2.6.22/arch/um/kernel/mem.c
===
--- linux-2.6.22.orig/arch/um/kernel/mem.c  2008-01-02 11:44:36.0 
-0500
+++ linux-2.6.22/arch/um/kernel/mem.c   2008-01-02 12:08:45.0 -0500
@@ -36,11 +36,6 @@ int kmalloc_ok = 0;
 /* Used during early boot */
 static unsigned long brk_end;
 
-static void map_cb(void *unused)
-{
-   map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
-}
-
 #ifdef CONFIG_HIGHMEM
 static void setup_highmem(unsigned long highmem_start,
  unsigned long highmem_len)
@@ -68,8 +63,7 @@ void __init mem_init(void)
 * to be turned on.
 */
brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
-   map_cb(NULL);
-   initial_thread_cb(map_cb, NULL);
+   map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
free_bootmem(__pa(brk_end), uml_reserved - brk_end);
uml_reserved = brk_end;
 
--
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 11/20] UML - Remove unused fields from mm_context

2008-01-17 Thread Jeff Dike
The 3-level page table fixes forgot to remove a couple now-unused
fields from struct mm_context.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/include/um_mmu.h |4 
 1 file changed, 4 deletions(-)

Index: linux-2.6.22/arch/um/include/um_mmu.h
===
--- linux-2.6.22.orig/arch/um/include/um_mmu.h  2007-12-19 13:17:20.0 
-0500
+++ linux-2.6.22/arch/um/include/um_mmu.h   2007-12-19 19:34:49.0 
-0500
@@ -12,10 +12,6 @@
 
 typedef struct mm_context {
struct mm_id id;
-   unsigned long last_page_table;
-#ifdef CONFIG_3_LEVEL_PGTABLES
-   unsigned long last_pmd;
-#endif
struct uml_ldt ldt;
 } mm_context_t;
 
--
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 20/20] UML - defconfig tweaks

2008-01-17 Thread Jeff Dike
Tweak the UML defconfig -
  we probably don't need 256 old-style ptys - this slows down udev
noticably
  enable hostfs
  disable slab debugging - another noticable performance hit

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

Index: linux-2.6.22/arch/um/defconfig
===
--- linux-2.6.22.orig/arch/um/defconfig 2008-01-17 14:39:06.0 -0500
+++ linux-2.6.22/arch/um/defconfig  2008-01-17 14:40:07.0 -0500
@@ -75,7 +75,7 @@ CONFIG_LD_SCRIPT_DYN=y
 CONFIG_NET=y
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=m
-# CONFIG_HOSTFS is not set
+CONFIG_HOSTFS=y
 # CONFIG_HPPFS is not set
 CONFIG_MCONSOLE=y
 CONFIG_MAGIC_SYSRQ=y
@@ -185,7 +185,7 @@ CONFIG_CON_CHAN="xterm"
 CONFIG_SSL_CHAN="pts"
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_LEGACY_PTY_COUNT=32
 # CONFIG_WATCHDOG is not set
 CONFIG_UML_SOUND=m
 CONFIG_SOUND=m
@@ -505,7 +505,7 @@ CONFIG_DEBUG_KERNEL=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
-CONFIG_DEBUG_SLAB=y
+# CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SLAB_LEAK is not set
 # CONFIG_DEBUG_MUTEXES is not set
 # CONFIG_DEBUG_SPINLOCK is not set
--
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 16/20] UML - Use of a public MAC is a warning, not an error

2008-01-17 Thread Jeff Dike
Downgrade one of the MAC validity checks.  If it's one that could be
possibly assigned to a physical NIC, then nothing will break.  So,
emit a warning in this case, but keep the requested MAC.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/net_kern.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

Index: linux-2.6-git/arch/um/drivers/net_kern.c
===
--- linux-2.6-git.orig/arch/um/drivers/net_kern.c   2008-01-02 
13:16:19.0 -0500
+++ linux-2.6-git/arch/um/drivers/net_kern.c2008-01-02 15:37:02.0 
-0500
@@ -318,7 +318,7 @@ static void setup_etheraddr(char *str, u
if (str == NULL)
goto random;
 
-   for (i = 0;i < 6; i++) {
+   for (i = 0; i < 6; i++) {
addr[i] = simple_strtoul(str, , 16);
if ((end == str) ||
   ((*end != ':') && (*end != ',') && (*end != '\0'))) {
@@ -343,14 +343,13 @@ static void setup_etheraddr(char *str, u
}
if (!is_local_ether_addr(addr)) {
printk(KERN_WARNING
-  "Warning: attempt to assign a globally valid ethernet "
+  "Warning: Assigning 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,\n");
+   printk(KERN_WARNING "You should set the 2nd rightmost bit in "
+  "the first byte of the MAC,\n");
printk(KERN_WARNING "i.e. %02x:%02x:%02x:%02x:%02x:%02x\n",
   addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4],
   addr[5]);
-   goto random;
}
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 9/20] UML - Add newlines to printks

2008-01-17 Thread Jeff Dike
Some printks were missing newlines.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/os-Linux/skas/process.c |8 
 1 file changed, 4 insertions(+), 4 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-12-19 
13:13:54.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/skas/process.c2007-12-19 
13:14:16.0 -0500
@@ -273,7 +273,7 @@ int start_userspace(unsigned long stub_s
if (stack == MAP_FAILED) {
err = -errno;
printk(UM_KERN_ERR "start_userspace : mmap failed, "
-  "errno = %d", errno);
+  "errno = %d\n", errno);
return err;
}
 
@@ -289,7 +289,7 @@ int start_userspace(unsigned long stub_s
if (pid < 0) {
err = -errno;
printk(UM_KERN_ERR "start_userspace : clone failed, "
-  "errno = %d", errno);
+  "errno = %d\n", errno);
return err;
}
 
@@ -298,7 +298,7 @@ int start_userspace(unsigned long stub_s
if (n < 0) {
err = -errno;
printk(UM_KERN_ERR "start_userspace : wait failed, "
-  "errno = %d", errno);
+  "errno = %d\n", errno);
goto out_kill;
}
} while (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM));
@@ -306,7 +306,7 @@ int start_userspace(unsigned long stub_s
if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) {
err = -EINVAL;
printk(UM_KERN_ERR "start_userspace : expected SIGSTOP, got "
-  "status = %d", status);
+  "status = %d\n", status);
goto out_kill;
}
 
--
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 3/20] UML - SMP locking commentary

2008-01-17 Thread Jeff Dike
Add some more commentary about various pieces of global data not
needing locking.

Also got rid of unmap_physmem since that is no longer used.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/drivers/net_kern.c |7 ++-
 arch/um/include/mem_user.h |1 -
 arch/um/kernel/mem.c   |   13 -
 arch/um/kernel/physmem.c   |6 +++---
 4 files changed, 17 insertions(+), 10 deletions(-)

Index: linux-2.6.22/arch/um/include/mem_user.h
===
--- linux-2.6.22.orig/arch/um/include/mem_user.h2007-12-14 
10:45:27.0 -0500
+++ linux-2.6.22/arch/um/include/mem_user.h 2007-12-14 11:19:06.0 
-0500
@@ -56,7 +56,6 @@ extern void setup_physmem(unsigned long 
  unsigned long len, unsigned long long highmem);
 extern void add_iomem(char *name, int fd, unsigned long size);
 extern unsigned long phys_offset(unsigned long phys);
-extern void unmap_physmem(void);
 extern void map_memory(unsigned long virt, unsigned long phys,
   unsigned long len, int r, int w, int x);
 
Index: linux-2.6.22/arch/um/kernel/mem.c
===
--- linux-2.6.22.orig/arch/um/kernel/mem.c  2007-12-14 10:45:27.0 
-0500
+++ linux-2.6.22/arch/um/kernel/mem.c   2007-12-14 11:20:01.0 -0500
@@ -22,17 +22,20 @@
 unsigned long *empty_zero_page = NULL;
 /* allocated in paging_init and unchanged thereafter */
 unsigned long *empty_bad_page = NULL;
+
+/*
+ * Initialized during boot, and readonly for initializing page tables
+ * afterwards
+ */
 pgd_t swapper_pg_dir[PTRS_PER_PGD];
+
+/* Initialized at boot time, and readonly after that */
 unsigned long long highmem;
 int kmalloc_ok = 0;
 
+/* Used during early boot */
 static unsigned long brk_end;
 
-void unmap_physmem(void)
-{
-   os_unmap_memory((void *) brk_end, uml_reserved - brk_end);
-}
-
 static void map_cb(void *unused)
 {
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
Index: linux-2.6.22/arch/um/kernel/physmem.c
===
--- linux-2.6.22.orig/arch/um/kernel/physmem.c  2007-12-14 10:45:27.0 
-0500
+++ linux-2.6.22/arch/um/kernel/physmem.c   2007-12-14 11:19:06.0 
-0500
@@ -164,10 +164,10 @@ __uml_setup("iomem=", parse_iomem,
  * setup_iomem, both of which run during early boot.  Afterwards, it's
  * unchanged.
  */
-struct iomem_region *iomem_regions = NULL;
+struct iomem_region *iomem_regions;
 
-/* Initialized in parse_iomem */
-int iomem_size = 0;
+/* Initialized in parse_iomem and unchanged thereafter */
+int iomem_size;
 
 unsigned long find_iomem(char *driver, unsigned long *len_out)
 {
Index: linux-2.6.22/arch/um/drivers/net_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/net_kern.c2007-12-14 
10:45:27.0 -0500
+++ linux-2.6.22/arch/um/drivers/net_kern.c 2007-12-14 11:19:06.0 
-0500
@@ -368,7 +368,6 @@ static struct platform_driver uml_net_dr
.name  = DRIVER_NAME,
},
 };
-static int driver_registered;
 
 static void net_device_release(struct device *dev)
 {
@@ -383,6 +382,12 @@ static void net_device_release(struct de
free_netdev(netdev);
 }
 
+/*
+ * Ensures that platform_driver_register is called only once by
+ * eth_configure.  Will be set in an initcall.
+ */
+static int driver_registered;
+
 static void eth_configure(int n, void *init, char *mac,
  struct transport *transport)
 {
--
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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 11:38:53AM -0800, Pallipadi, Venkatesh wrote:
> Apart from unxlate, there is also ioremap_wc which is defined in the
> same way.

And while we're on the subject, what's the deal with these, in
include/asm-x86/io.h?

#define ioremap_wc ioremap_wc
#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr

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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 07:11:13PM +0100, Mariusz Kozlowski wrote:
> I see this on sparc64 as well:
> 
>   CC  drivers/char/mem.o
> drivers/char/mem.c: In function 'read_mem':
> drivers/char/mem.c:136: error: implicit declaration of function 
> 'unxlate_dev_mem_ptr'
> make[2]: *** [drivers/char/mem.o] Error 1
> make[1]: *** [drivers/char] Error 2
> make: *** [drivers] Error 2
> 
> Does sparc64 need similar fix?

Probably - it seems that xlate_dev_mem_ptr can now introduce
side-effects which need to be undone with unxlate_dev_mem_ptr.

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: [-mm Patch] UML: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 09:21:08PM +0800, WANG Cong wrote:
> Building uml failed in current -mm tree. ;(
> 
> The below patch fixes this building error:
> ...
> include/asm/arch/system.h:8:22: error: asm/nops.h: No such file or directory
> ...
> 
> Cc: Jeff Dike <[EMAIL PROTECTED]>
> Signed-off-by: WANG Cong <[EMAIL PROTECTED]>

ACK

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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 09:56:41PM +0800, WANG Cong wrote:
> 
> This patch fixes this building error:
> ...
> drivers/char/mem.c: In function ‘read_mem’:
> drivers/char/mem.c:136: error: implicit declaration of function 
> ‘unxlate_dev_mem_ptr’
> ...
> 
> Cc: Jeff Dike <[EMAIL PROTECTED]>
> Signed-off-by: WANG Cong <[EMAIL PROTECTED]>

ACK

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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 07:11:13PM +0100, Mariusz Kozlowski wrote:
 I see this on sparc64 as well:
 
   CC  drivers/char/mem.o
 drivers/char/mem.c: In function 'read_mem':
 drivers/char/mem.c:136: error: implicit declaration of function 
 'unxlate_dev_mem_ptr'
 make[2]: *** [drivers/char/mem.o] Error 1
 make[1]: *** [drivers/char] Error 2
 make: *** [drivers] Error 2
 
 Does sparc64 need similar fix?

Probably - it seems that xlate_dev_mem_ptr can now introduce
side-effects which need to be undone with unxlate_dev_mem_ptr.

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: [-mm Patch] UML: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 09:21:08PM +0800, WANG Cong wrote:
 Building uml failed in current -mm tree. ;(
 
 The below patch fixes this building error:
 ...
 include/asm/arch/system.h:8:22: error: asm/nops.h: No such file or directory
 ...
 
 Cc: Jeff Dike [EMAIL PROTECTED]
 Signed-off-by: WANG Cong [EMAIL PROTECTED]

ACK

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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 09:56:41PM +0800, WANG Cong wrote:
 
 This patch fixes this building error:
 ...
 drivers/char/mem.c: In function ‘read_mem’:
 drivers/char/mem.c:136: error: implicit declaration of function 
 ‘unxlate_dev_mem_ptr’
 ...
 
 Cc: Jeff Dike [EMAIL PROTECTED]
 Signed-off-by: WANG Cong [EMAIL PROTECTED]

ACK

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 3/20] UML - SMP locking commentary

2008-01-17 Thread Jeff Dike
Add some more commentary about various pieces of global data not
needing locking.

Also got rid of unmap_physmem since that is no longer used.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/drivers/net_kern.c |7 ++-
 arch/um/include/mem_user.h |1 -
 arch/um/kernel/mem.c   |   13 -
 arch/um/kernel/physmem.c   |6 +++---
 4 files changed, 17 insertions(+), 10 deletions(-)

Index: linux-2.6.22/arch/um/include/mem_user.h
===
--- linux-2.6.22.orig/arch/um/include/mem_user.h2007-12-14 
10:45:27.0 -0500
+++ linux-2.6.22/arch/um/include/mem_user.h 2007-12-14 11:19:06.0 
-0500
@@ -56,7 +56,6 @@ extern void setup_physmem(unsigned long 
  unsigned long len, unsigned long long highmem);
 extern void add_iomem(char *name, int fd, unsigned long size);
 extern unsigned long phys_offset(unsigned long phys);
-extern void unmap_physmem(void);
 extern void map_memory(unsigned long virt, unsigned long phys,
   unsigned long len, int r, int w, int x);
 
Index: linux-2.6.22/arch/um/kernel/mem.c
===
--- linux-2.6.22.orig/arch/um/kernel/mem.c  2007-12-14 10:45:27.0 
-0500
+++ linux-2.6.22/arch/um/kernel/mem.c   2007-12-14 11:20:01.0 -0500
@@ -22,17 +22,20 @@
 unsigned long *empty_zero_page = NULL;
 /* allocated in paging_init and unchanged thereafter */
 unsigned long *empty_bad_page = NULL;
+
+/*
+ * Initialized during boot, and readonly for initializing page tables
+ * afterwards
+ */
 pgd_t swapper_pg_dir[PTRS_PER_PGD];
+
+/* Initialized at boot time, and readonly after that */
 unsigned long long highmem;
 int kmalloc_ok = 0;
 
+/* Used during early boot */
 static unsigned long brk_end;
 
-void unmap_physmem(void)
-{
-   os_unmap_memory((void *) brk_end, uml_reserved - brk_end);
-}
-
 static void map_cb(void *unused)
 {
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
Index: linux-2.6.22/arch/um/kernel/physmem.c
===
--- linux-2.6.22.orig/arch/um/kernel/physmem.c  2007-12-14 10:45:27.0 
-0500
+++ linux-2.6.22/arch/um/kernel/physmem.c   2007-12-14 11:19:06.0 
-0500
@@ -164,10 +164,10 @@ __uml_setup(iomem=, parse_iomem,
  * setup_iomem, both of which run during early boot.  Afterwards, it's
  * unchanged.
  */
-struct iomem_region *iomem_regions = NULL;
+struct iomem_region *iomem_regions;
 
-/* Initialized in parse_iomem */
-int iomem_size = 0;
+/* Initialized in parse_iomem and unchanged thereafter */
+int iomem_size;
 
 unsigned long find_iomem(char *driver, unsigned long *len_out)
 {
Index: linux-2.6.22/arch/um/drivers/net_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/net_kern.c2007-12-14 
10:45:27.0 -0500
+++ linux-2.6.22/arch/um/drivers/net_kern.c 2007-12-14 11:19:06.0 
-0500
@@ -368,7 +368,6 @@ static struct platform_driver uml_net_dr
.name  = DRIVER_NAME,
},
 };
-static int driver_registered;
 
 static void net_device_release(struct device *dev)
 {
@@ -383,6 +382,12 @@ static void net_device_release(struct de
free_netdev(netdev);
 }
 
+/*
+ * Ensures that platform_driver_register is called only once by
+ * eth_configure.  Will be set in an initcall.
+ */
+static int driver_registered;
+
 static void eth_configure(int n, void *init, char *mac,
  struct transport *transport)
 {
--
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: [-mm Patch] uml: fix a building error

2008-01-17 Thread Jeff Dike
On Thu, Jan 17, 2008 at 11:38:53AM -0800, Pallipadi, Venkatesh wrote:
 Apart from unxlate, there is also ioremap_wc which is defined in the
 same way.

And while we're on the subject, what's the deal with these, in
include/asm-x86/io.h?

#define ioremap_wc ioremap_wc
#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr

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 13/20] UML - Spelling fix

2008-01-17 Thread Jeff Dike
From: Joe Perches [EMAIL PROTECTED]

Spelling fix

Signed-off-by: Joe Perches [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/sys-x86_64/signal.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6-git/arch/um/sys-x86_64/signal.c
===
--- linux-2.6-git.orig/arch/um/sys-x86_64/signal.c  2008-01-02 
11:25:13.0 -0500
+++ linux-2.6-git/arch/um/sys-x86_64/signal.c   2008-01-02 12:01:05.0 
-0500
@@ -112,7 +112,7 @@ static int copy_sc_to_user(struct sigcon
err |= PUTREG(regs, RSI, to, rsi);
err |= PUTREG(regs, RBP, to, rbp);
/*
-* Must use orignal RSP, which is passed in, rather than what's in
+* Must use original RSP, which is passed in, rather than what's in
 * the pt_regs, because that's already been updated to point at the
 * signal frame.
 */
--
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 9/20] UML - Add newlines to printks

2008-01-17 Thread Jeff Dike
Some printks were missing newlines.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/os-Linux/skas/process.c |8 
 1 file changed, 4 insertions(+), 4 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-12-19 
13:13:54.0 -0500
+++ linux-2.6.22/arch/um/os-Linux/skas/process.c2007-12-19 
13:14:16.0 -0500
@@ -273,7 +273,7 @@ int start_userspace(unsigned long stub_s
if (stack == MAP_FAILED) {
err = -errno;
printk(UM_KERN_ERR start_userspace : mmap failed, 
-  errno = %d, errno);
+  errno = %d\n, errno);
return err;
}
 
@@ -289,7 +289,7 @@ int start_userspace(unsigned long stub_s
if (pid  0) {
err = -errno;
printk(UM_KERN_ERR start_userspace : clone failed, 
-  errno = %d, errno);
+  errno = %d\n, errno);
return err;
}
 
@@ -298,7 +298,7 @@ int start_userspace(unsigned long stub_s
if (n  0) {
err = -errno;
printk(UM_KERN_ERR start_userspace : wait failed, 
-  errno = %d, errno);
+  errno = %d\n, errno);
goto out_kill;
}
} while (WIFSTOPPED(status)  (WSTOPSIG(status) == SIGVTALRM));
@@ -306,7 +306,7 @@ int start_userspace(unsigned long stub_s
if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) {
err = -EINVAL;
printk(UM_KERN_ERR start_userspace : expected SIGSTOP, got 
-  status = %d, status);
+  status = %d\n, status);
goto out_kill;
}
 
--
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 11/20] UML - Remove unused fields from mm_context

2008-01-17 Thread Jeff Dike
The 3-level page table fixes forgot to remove a couple now-unused
fields from struct mm_context.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/include/um_mmu.h |4 
 1 file changed, 4 deletions(-)

Index: linux-2.6.22/arch/um/include/um_mmu.h
===
--- linux-2.6.22.orig/arch/um/include/um_mmu.h  2007-12-19 13:17:20.0 
-0500
+++ linux-2.6.22/arch/um/include/um_mmu.h   2007-12-19 19:34:49.0 
-0500
@@ -12,10 +12,6 @@
 
 typedef struct mm_context {
struct mm_id id;
-   unsigned long last_page_table;
-#ifdef CONFIG_3_LEVEL_PGTABLES
-   unsigned long last_pmd;
-#endif
struct uml_ldt ldt;
 } mm_context_t;
 
--
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 20/20] UML - defconfig tweaks

2008-01-17 Thread Jeff Dike
Tweak the UML defconfig -
  we probably don't need 256 old-style ptys - this slows down udev
noticably
  enable hostfs
  disable slab debugging - another noticable performance hit

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

Index: linux-2.6.22/arch/um/defconfig
===
--- linux-2.6.22.orig/arch/um/defconfig 2008-01-17 14:39:06.0 -0500
+++ linux-2.6.22/arch/um/defconfig  2008-01-17 14:40:07.0 -0500
@@ -75,7 +75,7 @@ CONFIG_LD_SCRIPT_DYN=y
 CONFIG_NET=y
 CONFIG_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=m
-# CONFIG_HOSTFS is not set
+CONFIG_HOSTFS=y
 # CONFIG_HPPFS is not set
 CONFIG_MCONSOLE=y
 CONFIG_MAGIC_SYSRQ=y
@@ -185,7 +185,7 @@ CONFIG_CON_CHAN=xterm
 CONFIG_SSL_CHAN=pts
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_LEGACY_PTY_COUNT=32
 # CONFIG_WATCHDOG is not set
 CONFIG_UML_SOUND=m
 CONFIG_SOUND=m
@@ -505,7 +505,7 @@ CONFIG_DEBUG_KERNEL=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
-CONFIG_DEBUG_SLAB=y
+# CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SLAB_LEAK is not set
 # CONFIG_DEBUG_MUTEXES is not set
 # CONFIG_DEBUG_SPINLOCK is not set
--
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 17/20] UML - LDT mutex conversion

2008-01-17 Thread Jeff Dike
From: Daniel Walker [EMAIL PROTECTED]

The ldt.semaphore conforms to the new struct mutex requirments,
so I converted it to use the new API and changed the name.

Signed-off-by: Daniel Walker [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/sys-i386/ldt.c |   14 +++---
 include/asm-um/ldt.h   |4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6.22/arch/um/sys-i386/ldt.c
===
--- linux-2.6.22.orig/arch/um/sys-i386/ldt.c2008-01-17 13:44:46.0 
-0500
+++ linux-2.6.22/arch/um/sys-i386/ldt.c 2008-01-17 13:45:32.0 -0500
@@ -147,7 +147,7 @@ static int read_ldt(void __user * ptr, u
if (ptrace_ldt)
return read_ldt_from_host(ptr, bytecount);
 
-   down(ldt-semaphore);
+   mutex_lock(ldt-lock);
if (ldt-entry_count = LDT_DIRECT_ENTRIES) {
size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES;
if (size  bytecount)
@@ -171,7 +171,7 @@ static int read_ldt(void __user * ptr, u
ptr += size;
}
}
-   up(ldt-semaphore);
+   mutex_unlock(ldt-lock);
 
if (bytecount == 0 || err == -EFAULT)
goto out;
@@ -229,7 +229,7 @@ static int write_ldt(void __user * ptr, 
}
 
if (!ptrace_ldt)
-   down(ldt-semaphore);
+   mutex_lock(ldt-lock);
 
err = write_ldt_entry(mm_idp, func, ldt_info, addr, 1);
if (err)
@@ -289,7 +289,7 @@ static int write_ldt(void __user * ptr, 
err = 0;
 
 out_unlock:
-   up(ldt-semaphore);
+   mutex_unlock(ldt-lock);
 out:
return err;
 }
@@ -396,7 +396,7 @@ long init_new_ldt(struct mm_context *new
 
 
if (!ptrace_ldt)
-   init_MUTEX(new_mm-ldt.semaphore);
+   mutex_init(new_mm-ldt.lock);
 
if (!from_mm) {
memset(desc, 0, sizeof(desc));
@@ -456,7 +456,7 @@ long init_new_ldt(struct mm_context *new
 * i.e., we have to use the stub for modify_ldt, which
 * can't handle the big read buffer of up to 64kB.
 */
-   down(from_mm-ldt.semaphore);
+   mutex_lock(from_mm-ldt.lock);
if (from_mm-ldt.entry_count = LDT_DIRECT_ENTRIES)
memcpy(new_mm-ldt.u.entries, from_mm-ldt.u.entries,
   sizeof(new_mm-ldt.u.entries));
@@ -475,7 +475,7 @@ long init_new_ldt(struct mm_context *new
}
}
new_mm-ldt.entry_count = from_mm-ldt.entry_count;
-   up(from_mm-ldt.semaphore);
+   mutex_unlock(from_mm-ldt.lock);
}
 
 out:
Index: linux-2.6.22/include/asm-um/ldt.h
===
--- linux-2.6.22.orig/include/asm-um/ldt.h  2007-11-14 10:33:41.0 
-0500
+++ linux-2.6.22/include/asm-um/ldt.h   2008-01-17 13:45:32.0 -0500
@@ -8,7 +8,7 @@
 #ifndef __ASM_LDT_H
 #define __ASM_LDT_H
 
-#include asm/semaphore.h
+#include linux/mutex.h
 #include asm/host_ldt.h
 
 extern void ldt_host_info(void);
@@ -27,7 +27,7 @@ struct ldt_entry {
 
 typedef struct uml_ldt {
int entry_count;
-   struct semaphore semaphore;
+   struct mutex lock;
union {
struct ldt_entry * pages[LDT_PAGES_MAX];
struct ldt_entry entries[LDT_DIRECT_ENTRIES];
--
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/


  1   2   3   4   5   6   7   8   9   10   >