[PATCH 0/4] UML - Code cleanups for 2.6.21

2007-03-28 Thread Jeff Dike
These are tidying patches from Blaisorblade - 2.6.21 material.

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 1/4] UML - hostfs variable renaming

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

* rename name to host_root_path
* rename data to req_root.

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

 fs/hostfs/hostfs_kern.c |   26 +-
 1 files changed, 13 insertions(+), 13 deletions(-)

Index: linux-2.6.21-mm/fs/hostfs/hostfs_kern.c
===
--- linux-2.6.21-mm.orig/fs/hostfs/hostfs_kern.c2007-03-27 
12:29:28.0 -0400
+++ linux-2.6.21-mm/fs/hostfs/hostfs_kern.c 2007-03-27 12:34:10.0 
-0400
@@ -938,7 +938,7 @@ static const struct address_space_operat
 static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
 {
struct inode *root_inode;
-   char *name, *data = d;
+   char *host_root_path, *req_root = d;
int err;
 
sb-s_blocksize = 1024;
@@ -947,16 +947,16 @@ static int hostfs_fill_sb_common(struct 
sb-s_op = hostfs_sbops;
 
/* NULL is printed as NULL by sprintf: avoid that. */
-   if (data == NULL)
-   data = ;
+   if (req_root == NULL)
+   req_root = ;
 
err = -ENOMEM;
-   name = kmalloc(strlen(root_ino) + 1
-   + strlen(data) + 1, GFP_KERNEL);
-   if(name == NULL)
+   host_root_path = kmalloc(strlen(root_ino) + 1
++ strlen(req_root) + 1, GFP_KERNEL);
+   if(host_root_path == NULL)
goto out;
 
-   sprintf(name, %s/%s, root_ino, data);
+   sprintf(host_root_path, %s/%s, root_ino, req_root);
 
root_inode = iget(sb, 0);
if(root_inode == NULL)
@@ -966,10 +966,10 @@ static int hostfs_fill_sb_common(struct 
if(err)
goto out_put;
 
-   HOSTFS_I(root_inode)-host_filename = name;
-   /* Avoid that in the error path, iput(root_inode) frees again name 
through
-* hostfs_destroy_inode! */
-   name = NULL;
+   HOSTFS_I(root_inode)-host_filename = host_root_path;
+   /* Avoid that in the error path, iput(root_inode) frees again
+* host_root_path through hostfs_destroy_inode! */
+   host_root_path = NULL;
 
err = -ENOMEM;
sb-s_root = d_alloc_root(root_inode);
@@ -989,7 +989,7 @@ static int hostfs_fill_sb_common(struct 
  out_put:
 iput(root_inode);
  out_free:
-   kfree(name);
+   kfree(host_root_path);
  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 3/4] UML - Eliminate temporary buffer in eth_configure

2007-03-28 Thread Jeff Dike
From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
  
Avoid using the temporary buffer introduced by previous patch to hold the
device name.

Btw, avoid leaking device on an error path. Other error paths may need cleanup.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/net_kern.c |   25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/net_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/net_kern.c 2007-03-28 
09:06:37.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/net_kern.c  2007-03-28 10:14:52.0 
-0400
@@ -348,17 +348,24 @@ static void eth_configure(int n, void *i
struct net_device *dev;
struct uml_net_private *lp;
int save, err, size;
-   char name[sizeof(dev-name)];
 
size = transport-private_size + sizeof(struct uml_net_private) +
sizeof(((struct uml_net_private *) 0)-user);
 
device = kzalloc(sizeof(*device), GFP_KERNEL);
if (device == NULL) {
-   printk(KERN_ERR eth_configure failed to allocate uml_net\n);
+   printk(KERN_ERR eth_configure failed to allocate struct 
+  uml_net\n);
return;
}
 
+   dev = alloc_etherdev(size);
+   if (dev == NULL) {
+   printk(KERN_ERR eth_configure: failed to allocate struct 
+  net_device for eth%d\n, n);
+   goto out_free_device;
+   }
+
INIT_LIST_HEAD(device-list);
device-index = n;
 
@@ -366,9 +373,9 @@ static void eth_configure(int n, void *i
 * netdevice, that is OK, register_netdev{,ice}() will notice this
 * and fail.
 */
-   snprintf(name, sizeof(name), eth%d, n);
+   snprintf(dev-name, sizeof(dev-name), eth%d, n);
 
-   setup_etheraddr(mac, device-mac, name);
+   setup_etheraddr(mac, device-mac, dev-name);
 
printk(KERN_INFO Netdevice %d , n);
printk((%02x:%02x:%02x:%02x:%02x:%02x) ,
@@ -376,11 +383,6 @@ static void eth_configure(int n, void *i
   device-mac[2], device-mac[3],
   device-mac[4], device-mac[5]);
printk(: );
-   dev = alloc_etherdev(size);
-   if (dev == NULL) {
-   printk(KERN_ERR eth_configure: failed to allocate device\n);
-   goto out_free_device;
-   }
 
lp = dev-priv;
/* This points to the transport private data. It's still clear, but we
@@ -399,7 +401,6 @@ static void eth_configure(int n, void *i
goto out_free_netdev;
SET_NETDEV_DEV(dev,device-pdev.dev);
 
-   strcpy(dev-name, name);
device-dev = dev;
 
/*
@@ -466,13 +467,13 @@ static void eth_configure(int n, void *i
return;
 
 out_undo_user_init:
-   if (transport-user-init != NULL)
+   if (transport-user-remove != NULL)
(*transport-user-remove)(lp-user);
 out_unregister:
platform_device_unregister(device-pdev);
 out_free_netdev:
free_netdev(dev);
-out_free_device: ;
+out_free_device:
kfree(device);
 }
 
-
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 0/6] UML - small fixes for 2.6.22

2007-03-27 Thread Jeff Dike
On Tue, Mar 27, 2007 at 02:27:45PM -0400, Jeff Dike wrote:
> These are all 2.6.22 material.

err, I meant 2.6.21...

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 - fix I/O hang when multiple devices are in use

2007-03-27 Thread Jeff Dike
[ This patch needs to get into 2.6.21, as it fixes a serious bug
introduced soon after 2.6.20 ]

Commit 62f96cb01e8de7a5daee472e540f726db2801499 introduced per-devices
queues and locks, which was fine as far as it went, but left in place
a global which controlled access to submitting requests to the host.
This should have been made per-device as well, since it causes I/O
hangs when multiple block devices are in use.

This patch fixes that by replacing the global with an activity flag in
the device structure in order to tell whether the queue is currently
being run.

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

Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-03-27 
20:27:16.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c  2007-03-27 20:28:29.0 
-0400
@@ -108,10 +108,6 @@ static inline void ubd_set_bit(__u64 bit
 
 static DEFINE_MUTEX(ubd_lock);
 
-/* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
- * probably it doesn't make sense even for that. */
-static int do_ubd;
-
 static int ubd_open(struct inode * inode, struct file * filp);
 static int ubd_release(struct inode * inode, struct file * file);
 static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -168,6 +164,7 @@ struct ubd {
struct platform_device pdev;
struct request_queue *queue;
spinlock_t lock;
+   int active;
 };
 
 #define DEFAULT_COW { \
@@ -189,6 +186,7 @@ struct ubd {
.shared =   0, \
 .cow = DEFAULT_COW, \
.lock = SPIN_LOCK_UNLOCKED, \
+   .active =   0, \
 }
 
 /* Protected by ubd_lock */
@@ -506,7 +504,6 @@ static void ubd_handler(void)
struct ubd *dev;
int n;
 
-   do_ubd = 0;
n = os_read_file(thread_fd, , sizeof(req));
if(n != sizeof(req)){
printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
@@ -516,6 +513,7 @@ static void ubd_handler(void)
 
rq = req.req;
dev = rq->rq_disk->private_data;
+   dev->active = 0;
 
ubd_finish(rq, req.error);
reactivate_fd(thread_fd, UBD_IRQ);
@@ -1081,11 +1079,12 @@ static void do_ubd_request(request_queue
}
}
else {
-   if(do_ubd || (req = elv_next_request(q)) == NULL)
+   struct ubd *dev = q->queuedata;
+   if(dev->active || (req = elv_next_request(q)) == NULL)
return;
err = prepare_request(req, _req);
if(!err){
-   do_ubd = 1;
+   dev->active = 1;
n = os_write_file(thread_fd, (char *) _req,
 sizeof(io_req));
if(n != sizeof(io_req))
-
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/6] i386 - fix cmpxchg warning

2007-03-27 Thread Jeff Dike
I started getting warnings from atomic.h about cmpxchg not having a
prototype.  It's declared in system.h, so including that fixes the UML
build warnings and has no noticable ill effects on the i386 build.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 include/asm-i386/atomic.h |1 +
 1 file changed, 1 insertion(+)

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

Index: linux-2.6.21-mm/include/asm-i386/atomic.h
===
--- linux-2.6.21-mm.orig/include/asm-i386/atomic.h  2007-03-27 
12:25:16.0 -0400
+++ linux-2.6.21-mm/include/asm-i386/atomic.h   2007-03-27 12:26:38.0 
-0400
@@ -3,6 +3,7 @@
 
 #include 
 #include 
+#include 
 
 /*
  * Atomic operations that C can't guarantee us.  Useful for
-
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/6] UML - small fixes for 2.6.22

2007-03-27 Thread Jeff Dike
These are all 2.6.22 material.  Patch 1 fixes what appears to be a
i386 compilation bug, so we'll want Andi's ack on that, probably.

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 6/6] UML - Fix LVM crash

2007-03-27 Thread Jeff Dike
From: Jason Lunz <[EMAIL PROTECTED]>

Permit lvm to create logical volumes without crashing UML.

When device-mapper's DM_DEV_CREATE_CMD ioctl is called to create a new
device, dev_create()->dm_create()->alloc_dev()->
blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY) is called.

blk_queue_bounce_limit(BLK_BOUNCE_ANY) calls init_emergency_isa_pool()
if blk_max_pfn < blk_max_low_pfn. This is the case on UML, but
init_emergency_isa_pool() hits BUG_ON(!isa_page_pool) because there
doesn't seem to be a dma zone on UML for mempool_create() to allocate
from.

Most architectures seem to have max_low_pfn == max_pfn, but UML doesn't
because of the uml_reserved chunk it keeps for itself. From what I can
see, max_pfn and max_low_pfn don't get much use after the
bootmem-allocator stops being used anyway, except that they initialize
the block layer's blk_max_low_pfn/blk_max_pfn.

This ensures init_emergency_isa_pool() doesn't crash uml in this
situation by setting max_low_pfn == max_pfn in mem_init().

Signed-off-by: Jason Lunz <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
---
 arch/um/kernel/mem.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/mem.c   2007-03-27 12:25:10.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/mem.c2007-03-27 12:58:36.0 
-0400
@@ -64,8 +64,6 @@ static void setup_highmem(unsigned long 
 
 void mem_init(void)
 {
-   max_low_pfn = (high_physmem - uml_physmem) >> PAGE_SHIFT;
-
/* clear the zero-page */
memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
@@ -80,6 +78,7 @@ void mem_init(void)
 
/* this will put all low memory onto the freelists */
totalram_pages = free_all_bootmem();
+   max_low_pfn = totalram_pages;
 #ifdef CONFIG_HIGHMEM
totalhigh_pages = highmem >> PAGE_SHIFT;
totalram_pages += totalhigh_pages;
-
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/6] UML - Fix pte bit collision

2007-03-27 Thread Jeff Dike
From: Miklos Szeredi <[EMAIL PROTECTED]>

_PAGE_PROTNONE conflicts with the lowest bit of pgoff.  This causes
all sorts of weirdness when nonlinear mappings are used.

Took me a good half day to track this down.

Signed-off-by: Miklos Szeredi <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 include/asm-um/pgtable-2level.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6.21-mm/include/asm-um/pgtable-2level.h
===
--- linux-2.6.21-mm.orig/include/asm-um/pgtable-2level.h2007-03-27 
12:34:31.0 -0400
+++ linux-2.6.21-mm/include/asm-um/pgtable-2level.h 2007-03-27 
12:52:12.0 -0400
@@ -45,12 +45,12 @@ static inline void pgd_mkuptodate(pgd_t 
((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
 
 /*
- * Bits 0 through 3 are taken
+ * Bits 0 through 4 are taken
  */
-#define PTE_FILE_MAX_BITS  28
+#define PTE_FILE_MAX_BITS  27
 
-#define pte_to_pgoff(pte) (pte_val(pte) >> 4)
+#define pte_to_pgoff(pte) (pte_val(pte) >> 5)
 
-#define pgoff_to_pte(off) ((pte_t) { ((off) << 4) + _PAGE_FILE })
+#define pgoff_to_pte(off) ((pte_t) { ((off) << 5) + _PAGE_FILE })
 
 #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 2/6] UML - fix compilation problems

2007-03-27 Thread Jeff Dike
Fix a few miscellaneous compilation problems -
an assignment with mismatched types in ldt.c
a missing include in mconsole.h which needs a definition of uml_pt_regs
when auditing is configured there are some mismatched types in ptrace.c
I missed removing an include of user_util.h in hostfs   

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/mconsole.h |2 ++
 arch/um/kernel/ptrace.c|   14 +++---
 arch/um/sys-i386/ldt.c |3 ++-
 fs/hostfs/hostfs_kern.c|1 -
 4 files changed, 11 insertions(+), 9 deletions(-)

Index: linux-2.6.21-mm/arch/um/sys-i386/ldt.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-i386/ldt.c 2007-03-27 12:25:16.0 
-0400
+++ linux-2.6.21-mm/arch/um/sys-i386/ldt.c  2007-03-27 12:28:26.0 
-0400
@@ -394,7 +394,8 @@ static short * host_ldt_entries = NULL;
 static void ldt_get_host_info(void)
 {
long ret;
-   struct ldt_entry * ldt, *tmp;
+   struct ldt_entry * ldt;
+   short *tmp;
int i, size, k, order;
 
spin_lock(_ldt_lock);
Index: linux-2.6.21-mm/arch/um/include/mconsole.h
===
--- linux-2.6.21-mm.orig/arch/um/include/mconsole.h 2007-03-27 
12:25:10.0 -0400
+++ linux-2.6.21-mm/arch/um/include/mconsole.h  2007-03-27 12:29:28.0 
-0400
@@ -12,6 +12,8 @@
 #define u32 uint32_t
 #endif
 
+#include "sysdep/ptrace.h"
+
 #define MCONSOLE_MAGIC (0xcafebabe)
 #define MCONSOLE_MAX_DATA (512)
 #define MCONSOLE_VERSION 2
Index: linux-2.6.21-mm/arch/um/kernel/ptrace.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/ptrace.c2007-03-27 
12:25:18.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/ptrace.c 2007-03-27 12:34:43.0 
-0400
@@ -53,8 +53,8 @@ void do_syscall_trace(struct pt_regs *re
secure_computing(PT_REGS_SYSCALL_NR(regs));
 
if (unlikely(current->audit_context) && entryexit)
-   audit_syscall_exit(AUDITSC_RESULT(UPT_SYSCALL_RET(regs)),
-  UPT_SYSCALL_RET(regs));
+   audit_syscall_exit(AUDITSC_RESULT(UPT_SYSCALL_RET(>regs)),
+  UPT_SYSCALL_RET(>regs));
 
if (test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall(regs, entryexit);
@@ -66,9 +66,9 @@ void do_syscall_trace(struct pt_regs *re
 
if (unlikely(current->audit_context) && !entryexit)
audit_syscall_entry(HOST_AUDIT_ARCH,
-   UPT_SYSCALL_NR(regs),
-   UPT_SYSCALL_ARG1(regs),
-   UPT_SYSCALL_ARG2(regs),
-   UPT_SYSCALL_ARG3(regs),
-   UPT_SYSCALL_ARG4(regs));
+   UPT_SYSCALL_NR(>regs),
+   UPT_SYSCALL_ARG1(>regs),
+   UPT_SYSCALL_ARG2(>regs),
+   UPT_SYSCALL_ARG3(>regs),
+   UPT_SYSCALL_ARG4(>regs));
 }
Index: linux-2.6.21-mm/fs/hostfs/hostfs_kern.c
===
--- linux-2.6.21-mm.orig/fs/hostfs/hostfs_kern.c2007-03-27 
12:25:11.0 -0400
+++ linux-2.6.21-mm/fs/hostfs/hostfs_kern.c 2007-03-27 12:34:31.0 
-0400
@@ -20,7 +20,6 @@
 #include "hostfs.h"
 #include "kern_util.h"
 #include "kern.h"
-#include "user_util.h"
 #include "init.h"
 
 struct hostfs_inode_info {
-
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/6] UML - Fix device unplug crash

2007-03-27 Thread Jeff Dike
Fix a NULL dereference when unplugging a device.  The default value of
err_msg wants to be "" in case the driver doesn't modify it.

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

Index: linux-2.6.21-mm/arch/um/drivers/mconsole_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/mconsole_kern.c2007-03-27 
11:35:47.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/mconsole_kern.c 2007-03-27 
11:46:28.0 -0400
@@ -614,6 +614,9 @@ void mconsole_remove(struct mc_request *
err_msg = NULL;
err = (*dev->remove)(n, _msg);
switch(err){
+   case 0:
+   err_msg = "";
+   break;
case -ENODEV:
if(err_msg == NULL)
err_msg = "Device doesn't exist";
-
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/6] UML - irq locking fixes

2007-03-27 Thread Jeff Dike
As the comment immediately preceding this points out, this list is
changed in irq context, so it needs to be protected with
spin_lock_irqsave in process context when it is processed.

Sometimes, gcc should just compile the comments and forget the code.

The IRQ side of this was better, in the sense that it blocked and
unblocked interrupts, but it still should have saved and restored
them.

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

Index: linux-2.6.21-mm/arch/um/drivers/chan_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_kern.c2007-03-27 
12:25:09.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_kern.c 2007-03-27 12:56:21.0 
-0400
@@ -235,11 +235,11 @@ void free_irqs(void)
struct chan *chan;
LIST_HEAD(list);
struct list_head *ele;
+   unsigned long flags;
 
-   spin_lock_irq(_to_free_lock);
+   spin_lock_irqsave(_to_free_lock, flags);
list_splice_init(_to_free, );
-   INIT_LIST_HEAD(_to_free);
-   spin_unlock_irq(_to_free_lock);
+   spin_unlock_irqrestore(_to_free_lock, flags);
 
list_for_each(ele, ){
chan = list_entry(ele, struct chan, free_list);
@@ -254,13 +254,15 @@ void free_irqs(void)
 
 static void close_one_chan(struct chan *chan, int delay_free_irq)
 {
+   unsigned long flags;
+
if(!chan->opened)
return;
 
if(delay_free_irq){
-   spin_lock_irq(_to_free_lock);
+   spin_lock_irqsave(_to_free_lock, flags);
list_add(>free_list, _to_free);
-   spin_unlock_irq(_to_free_lock);
+   spin_unlock_irqrestore(_to_free_lock, flags);
}
else {
if(chan->input)
-
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/6] UML - fix compilation problems

2007-03-27 Thread Jeff Dike
Fix a few miscellaneous compilation problems -
an assignment with mismatched types in ldt.c
a missing include in mconsole.h which needs a definition of uml_pt_regs
when auditing is configured there are some mismatched types in ptrace.c
I missed removing an include of user_util.h in hostfs   

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/mconsole.h |2 ++
 arch/um/kernel/ptrace.c|   14 +++---
 arch/um/sys-i386/ldt.c |3 ++-
 fs/hostfs/hostfs_kern.c|1 -
 4 files changed, 11 insertions(+), 9 deletions(-)

Index: linux-2.6.21-mm/arch/um/sys-i386/ldt.c
===
--- linux-2.6.21-mm.orig/arch/um/sys-i386/ldt.c 2007-03-27 12:25:16.0 
-0400
+++ linux-2.6.21-mm/arch/um/sys-i386/ldt.c  2007-03-27 12:28:26.0 
-0400
@@ -394,7 +394,8 @@ static short * host_ldt_entries = NULL;
 static void ldt_get_host_info(void)
 {
long ret;
-   struct ldt_entry * ldt, *tmp;
+   struct ldt_entry * ldt;
+   short *tmp;
int i, size, k, order;
 
spin_lock(host_ldt_lock);
Index: linux-2.6.21-mm/arch/um/include/mconsole.h
===
--- linux-2.6.21-mm.orig/arch/um/include/mconsole.h 2007-03-27 
12:25:10.0 -0400
+++ linux-2.6.21-mm/arch/um/include/mconsole.h  2007-03-27 12:29:28.0 
-0400
@@ -12,6 +12,8 @@
 #define u32 uint32_t
 #endif
 
+#include sysdep/ptrace.h
+
 #define MCONSOLE_MAGIC (0xcafebabe)
 #define MCONSOLE_MAX_DATA (512)
 #define MCONSOLE_VERSION 2
Index: linux-2.6.21-mm/arch/um/kernel/ptrace.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/ptrace.c2007-03-27 
12:25:18.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/ptrace.c 2007-03-27 12:34:43.0 
-0400
@@ -53,8 +53,8 @@ void do_syscall_trace(struct pt_regs *re
secure_computing(PT_REGS_SYSCALL_NR(regs));
 
if (unlikely(current-audit_context)  entryexit)
-   audit_syscall_exit(AUDITSC_RESULT(UPT_SYSCALL_RET(regs)),
-  UPT_SYSCALL_RET(regs));
+   audit_syscall_exit(AUDITSC_RESULT(UPT_SYSCALL_RET(regs-regs)),
+  UPT_SYSCALL_RET(regs-regs));
 
if (test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall(regs, entryexit);
@@ -66,9 +66,9 @@ void do_syscall_trace(struct pt_regs *re
 
if (unlikely(current-audit_context)  !entryexit)
audit_syscall_entry(HOST_AUDIT_ARCH,
-   UPT_SYSCALL_NR(regs),
-   UPT_SYSCALL_ARG1(regs),
-   UPT_SYSCALL_ARG2(regs),
-   UPT_SYSCALL_ARG3(regs),
-   UPT_SYSCALL_ARG4(regs));
+   UPT_SYSCALL_NR(regs-regs),
+   UPT_SYSCALL_ARG1(regs-regs),
+   UPT_SYSCALL_ARG2(regs-regs),
+   UPT_SYSCALL_ARG3(regs-regs),
+   UPT_SYSCALL_ARG4(regs-regs));
 }
Index: linux-2.6.21-mm/fs/hostfs/hostfs_kern.c
===
--- linux-2.6.21-mm.orig/fs/hostfs/hostfs_kern.c2007-03-27 
12:25:11.0 -0400
+++ linux-2.6.21-mm/fs/hostfs/hostfs_kern.c 2007-03-27 12:34:31.0 
-0400
@@ -20,7 +20,6 @@
 #include hostfs.h
 #include kern_util.h
 #include kern.h
-#include user_util.h
 #include init.h
 
 struct hostfs_inode_info {
-
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/6] UML - Fix device unplug crash

2007-03-27 Thread Jeff Dike
Fix a NULL dereference when unplugging a device.  The default value of
err_msg wants to be  in case the driver doesn't modify it.

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

Index: linux-2.6.21-mm/arch/um/drivers/mconsole_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/mconsole_kern.c2007-03-27 
11:35:47.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/mconsole_kern.c 2007-03-27 
11:46:28.0 -0400
@@ -614,6 +614,9 @@ void mconsole_remove(struct mc_request *
err_msg = NULL;
err = (*dev-remove)(n, err_msg);
switch(err){
+   case 0:
+   err_msg = ;
+   break;
case -ENODEV:
if(err_msg == NULL)
err_msg = Device doesn't exist;
-
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/6] UML - irq locking fixes

2007-03-27 Thread Jeff Dike
As the comment immediately preceding this points out, this list is
changed in irq context, so it needs to be protected with
spin_lock_irqsave in process context when it is processed.

Sometimes, gcc should just compile the comments and forget the code.

The IRQ side of this was better, in the sense that it blocked and
unblocked interrupts, but it still should have saved and restored
them.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/chan_kern.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/chan_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_kern.c2007-03-27 
12:25:09.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_kern.c 2007-03-27 12:56:21.0 
-0400
@@ -235,11 +235,11 @@ void free_irqs(void)
struct chan *chan;
LIST_HEAD(list);
struct list_head *ele;
+   unsigned long flags;
 
-   spin_lock_irq(irqs_to_free_lock);
+   spin_lock_irqsave(irqs_to_free_lock, flags);
list_splice_init(irqs_to_free, list);
-   INIT_LIST_HEAD(irqs_to_free);
-   spin_unlock_irq(irqs_to_free_lock);
+   spin_unlock_irqrestore(irqs_to_free_lock, flags);
 
list_for_each(ele, list){
chan = list_entry(ele, struct chan, free_list);
@@ -254,13 +254,15 @@ void free_irqs(void)
 
 static void close_one_chan(struct chan *chan, int delay_free_irq)
 {
+   unsigned long flags;
+
if(!chan-opened)
return;
 
if(delay_free_irq){
-   spin_lock_irq(irqs_to_free_lock);
+   spin_lock_irqsave(irqs_to_free_lock, flags);
list_add(chan-free_list, irqs_to_free);
-   spin_unlock_irq(irqs_to_free_lock);
+   spin_unlock_irqrestore(irqs_to_free_lock, flags);
}
else {
if(chan-input)
-
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/6] UML - small fixes for 2.6.22

2007-03-27 Thread Jeff Dike
These are all 2.6.22 material.  Patch 1 fixes what appears to be a
i386 compilation bug, so we'll want Andi's ack on that, probably.

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 6/6] UML - Fix LVM crash

2007-03-27 Thread Jeff Dike
From: Jason Lunz [EMAIL PROTECTED]

Permit lvm to create logical volumes without crashing UML.

When device-mapper's DM_DEV_CREATE_CMD ioctl is called to create a new
device, dev_create()-dm_create()-alloc_dev()-
blk_queue_bounce_limit(md-queue, BLK_BOUNCE_ANY) is called.

blk_queue_bounce_limit(BLK_BOUNCE_ANY) calls init_emergency_isa_pool()
if blk_max_pfn  blk_max_low_pfn. This is the case on UML, but
init_emergency_isa_pool() hits BUG_ON(!isa_page_pool) because there
doesn't seem to be a dma zone on UML for mempool_create() to allocate
from.

Most architectures seem to have max_low_pfn == max_pfn, but UML doesn't
because of the uml_reserved chunk it keeps for itself. From what I can
see, max_pfn and max_low_pfn don't get much use after the
bootmem-allocator stops being used anyway, except that they initialize
the block layer's blk_max_low_pfn/blk_max_pfn.

This ensures init_emergency_isa_pool() doesn't crash uml in this
situation by setting max_low_pfn == max_pfn in mem_init().

Signed-off-by: Jason Lunz [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
---
 arch/um/kernel/mem.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/mem.c   2007-03-27 12:25:10.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/mem.c2007-03-27 12:58:36.0 
-0400
@@ -64,8 +64,6 @@ static void setup_highmem(unsigned long 
 
 void mem_init(void)
 {
-   max_low_pfn = (high_physmem - uml_physmem)  PAGE_SHIFT;
-
/* clear the zero-page */
memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
@@ -80,6 +78,7 @@ void mem_init(void)
 
/* this will put all low memory onto the freelists */
totalram_pages = free_all_bootmem();
+   max_low_pfn = totalram_pages;
 #ifdef CONFIG_HIGHMEM
totalhigh_pages = highmem  PAGE_SHIFT;
totalram_pages += totalhigh_pages;
-
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/6] UML - Fix pte bit collision

2007-03-27 Thread Jeff Dike
From: Miklos Szeredi [EMAIL PROTECTED]

_PAGE_PROTNONE conflicts with the lowest bit of pgoff.  This causes
all sorts of weirdness when nonlinear mappings are used.

Took me a good half day to track this down.

Signed-off-by: Miklos Szeredi [EMAIL PROTECTED]
Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 include/asm-um/pgtable-2level.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6.21-mm/include/asm-um/pgtable-2level.h
===
--- linux-2.6.21-mm.orig/include/asm-um/pgtable-2level.h2007-03-27 
12:34:31.0 -0400
+++ linux-2.6.21-mm/include/asm-um/pgtable-2level.h 2007-03-27 
12:52:12.0 -0400
@@ -45,12 +45,12 @@ static inline void pgd_mkuptodate(pgd_t 
((unsigned long) __va(pmd_val(pmd)  PAGE_MASK))
 
 /*
- * Bits 0 through 3 are taken
+ * Bits 0 through 4 are taken
  */
-#define PTE_FILE_MAX_BITS  28
+#define PTE_FILE_MAX_BITS  27
 
-#define pte_to_pgoff(pte) (pte_val(pte)  4)
+#define pte_to_pgoff(pte) (pte_val(pte)  5)
 
-#define pgoff_to_pte(off) ((pte_t) { ((off)  4) + _PAGE_FILE })
+#define pgoff_to_pte(off) ((pte_t) { ((off)  5) + _PAGE_FILE })
 
 #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 1/6] i386 - fix cmpxchg warning

2007-03-27 Thread Jeff Dike
I started getting warnings from atomic.h about cmpxchg not having a
prototype.  It's declared in system.h, so including that fixes the UML
build warnings and has no noticable ill effects on the i386 build.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 include/asm-i386/atomic.h |1 +
 1 file changed, 1 insertion(+)

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

Index: linux-2.6.21-mm/include/asm-i386/atomic.h
===
--- linux-2.6.21-mm.orig/include/asm-i386/atomic.h  2007-03-27 
12:25:16.0 -0400
+++ linux-2.6.21-mm/include/asm-i386/atomic.h   2007-03-27 12:26:38.0 
-0400
@@ -3,6 +3,7 @@
 
 #include linux/compiler.h
 #include asm/processor.h
+#include asm/system.h
 
 /*
  * Atomic operations that C can't guarantee us.  Useful for
-
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 - fix I/O hang when multiple devices are in use

2007-03-27 Thread Jeff Dike
[ This patch needs to get into 2.6.21, as it fixes a serious bug
introduced soon after 2.6.20 ]

Commit 62f96cb01e8de7a5daee472e540f726db2801499 introduced per-devices
queues and locks, which was fine as far as it went, but left in place
a global which controlled access to submitting requests to the host.
This should have been made per-device as well, since it causes I/O
hangs when multiple block devices are in use.

This patch fixes that by replacing the global with an activity flag in
the device structure in order to tell whether the queue is currently
being run.

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

Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-03-27 
20:27:16.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c  2007-03-27 20:28:29.0 
-0400
@@ -108,10 +108,6 @@ static inline void ubd_set_bit(__u64 bit
 
 static DEFINE_MUTEX(ubd_lock);
 
-/* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
- * probably it doesn't make sense even for that. */
-static int do_ubd;
-
 static int ubd_open(struct inode * inode, struct file * filp);
 static int ubd_release(struct inode * inode, struct file * file);
 static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -168,6 +164,7 @@ struct ubd {
struct platform_device pdev;
struct request_queue *queue;
spinlock_t lock;
+   int active;
 };
 
 #define DEFAULT_COW { \
@@ -189,6 +186,7 @@ struct ubd {
.shared =   0, \
 .cow = DEFAULT_COW, \
.lock = SPIN_LOCK_UNLOCKED, \
+   .active =   0, \
 }
 
 /* Protected by ubd_lock */
@@ -506,7 +504,6 @@ static void ubd_handler(void)
struct ubd *dev;
int n;
 
-   do_ubd = 0;
n = os_read_file(thread_fd, req, sizeof(req));
if(n != sizeof(req)){
printk(KERN_ERR Pid %d - spurious interrupt in ubd_handler, 
@@ -516,6 +513,7 @@ static void ubd_handler(void)
 
rq = req.req;
dev = rq-rq_disk-private_data;
+   dev-active = 0;
 
ubd_finish(rq, req.error);
reactivate_fd(thread_fd, UBD_IRQ);
@@ -1081,11 +1079,12 @@ static void do_ubd_request(request_queue
}
}
else {
-   if(do_ubd || (req = elv_next_request(q)) == NULL)
+   struct ubd *dev = q-queuedata;
+   if(dev-active || (req = elv_next_request(q)) == NULL)
return;
err = prepare_request(req, io_req);
if(!err){
-   do_ubd = 1;
+   dev-active = 1;
n = os_write_file(thread_fd, (char *) io_req,
 sizeof(io_req));
if(n != sizeof(io_req))
-
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 0/6] UML - small fixes for 2.6.22

2007-03-27 Thread Jeff Dike
On Tue, Mar 27, 2007 at 02:27:45PM -0400, Jeff Dike wrote:
 These are all 2.6.22 material.

err, I meant 2.6.21...

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 - use correct register file size everywhere

2007-03-25 Thread Jeff Dike
This patch uses MAX_REG_NR consistently to refer to the register file
size.  FRAME_SIZE isn't sufficient because on x86_64, it is smaller
than the ptrace register file size.  MAX_REG_NR was introduced as a
consistent way to get the number of registers, but wasn't used
everywhere it should be.

When this causes a problem, it makes PTRACE_SETREGS fail on x86_64
because of a corrupted segment register value in the known-good
register file. The patch also adds a register dump at that point in
case there are any future problems here.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/sysdep-x86_64/ptrace.h  |4 
 arch/um/os-Linux/skas/mem.c |   10 +++---
 arch/um/os-Linux/skas/process.c |6 +++---
 arch/um/os-Linux/sys-i386/registers.c   |5 +++--
 arch/um/os-Linux/sys-x86_64/registers.c |4 ++--
 5 files changed, 15 insertions(+), 14 deletions(-)

Index: linux-2.6.21-mm/arch/um/include/sysdep-x86_64/ptrace.h
===
--- linux-2.6.21-mm.orig/arch/um/include/sysdep-x86_64/ptrace.h 2007-03-22 
11:18:04.0 -0400
+++ linux-2.6.21-mm/arch/um/include/sysdep-x86_64/ptrace.h  2007-03-23 
20:31:37.0 -0400
@@ -104,10 +104,6 @@ union uml_pt_regs {
 #endif
 #ifdef UML_CONFIG_MODE_SKAS
struct skas_regs {
-   /* x86_64 ptrace uses sizeof(user_regs_struct) as its register
-* file size, while i386 uses FRAME_SIZE.  Therefore, we need
-* to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
-*/
unsigned long regs[MAX_REG_NR];
unsigned long fp[HOST_FP_SIZE];
 struct faultinfo faultinfo;
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/mem.c2007-03-23 
15:05:31.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/mem.c 2007-03-25 10:33:30.0 
-0400
@@ -48,7 +48,7 @@ int multi_op_count = 0;
 static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
 {
unsigned long regs[MAX_REG_NR];
-   int n;
+   int n, i;
long ret, offset;
unsigned long * data;
unsigned long * syscall;
@@ -66,9 +66,13 @@ static inline long do_syscall_stub(struc
 (unsigned long) &__syscall_stub_start);
 
n = ptrace_setregs(pid, regs);
-   if(n < 0)
+   if(n < 0){
+   printk("Registers - \n");
+   for(i = 0; i < MAX_REG_NR; i++)
+   printk("\t%d\t0x%lx\n", i, regs[i]);
panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n",
- n);
+ -n);
+   }
 
wait_stub_done(pid, 0, "do_syscall_stub");
 
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/process.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/process.c2007-03-23 
15:05:31.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/process.c 2007-03-25 
10:33:30.0 -0400
@@ -67,7 +67,7 @@ void wait_stub_done(int pid, int sig, ch
 
if((n < 0) || !WIFSTOPPED(status) ||
   (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
-   unsigned long regs[HOST_FRAME_SIZE];
+   unsigned long regs[MAX_REG_NR];
 
if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
printk("Failed to get registers from stub, "
@@ -76,7 +76,7 @@ void wait_stub_done(int pid, int sig, ch
int i;
 
printk("Stub registers -\n");
-   for(i = 0; i < HOST_FRAME_SIZE; i++)
+   for(i = 0; i < ARRAY_SIZE(regs); i++)
printk("\t%d - %lx\n", i, regs[i]);
}
panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
@@ -328,7 +328,7 @@ void userspace(union uml_pt_regs *regs)
 int copy_context_skas0(unsigned long new_stack, int pid)
 {
int err;
-   unsigned long regs[HOST_FRAME_SIZE];
+   unsigned long regs[MAX_REG_NR];
unsigned long fp_regs[HOST_FP_SIZE];
unsigned long current_stack = current_stub_stack();
struct stub_data *data = (struct stub_data *) current_stack;
Index: linux-2.6.21-mm/arch/um/os-Linux/sys-i386/registers.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/sys-i386/registers.c  2007-03-23 
15:04:22.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/sys-i386/registers.c   2007-03-23 
20:31:37.0 -0400
@@ -15,7 +15,7 @@
 
 /* These are set once at boot time and not changed thereafter */
 
-static unsigned long exec_regs[HOST_FRAME_SIZE

[PATCH] UML - Fix static linking

2007-03-25 Thread Jeff Dike
[ This is both 2.6.21 and -stable material ]

During a static link, ld has started putting a .note section in the
.uml.setup.init section.  This has the result that the UML setups
begin with 32 bytes of garbage and UML crashes immediately on boot.

This patch creates a specific .note section for ld to drop this stuff
into.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 include/asm-um/common.lds.S |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.21-mm/include/asm-um/common.lds.S
===
--- linux-2.6.21-mm.orig/include/asm-um/common.lds.S2007-03-05 
13:03:47.0 -0500
+++ linux-2.6.21-mm/include/asm-um/common.lds.S 2007-03-23 23:03:53.0 
-0400
@@ -15,6 +15,7 @@
   PROVIDE (_unprotected_end = .);
 
   . = ALIGN(4096);
+  .note : { *(note.*) }
   __start___ex_table = .;
   __ex_table : { *(__ex_table) }
   __stop___ex_table = .;
-
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 - Fix static linking

2007-03-25 Thread Jeff Dike
[ This is both 2.6.21 and -stable material ]

During a static link, ld has started putting a .note section in the
.uml.setup.init section.  This has the result that the UML setups
begin with 32 bytes of garbage and UML crashes immediately on boot.

This patch creates a specific .note section for ld to drop this stuff
into.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 include/asm-um/common.lds.S |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.21-mm/include/asm-um/common.lds.S
===
--- linux-2.6.21-mm.orig/include/asm-um/common.lds.S2007-03-05 
13:03:47.0 -0500
+++ linux-2.6.21-mm/include/asm-um/common.lds.S 2007-03-23 23:03:53.0 
-0400
@@ -15,6 +15,7 @@
   PROVIDE (_unprotected_end = .);
 
   . = ALIGN(4096);
+  .note : { *(note.*) }
   __start___ex_table = .;
   __ex_table : { *(__ex_table) }
   __stop___ex_table = .;
-
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 - use correct register file size everywhere

2007-03-25 Thread Jeff Dike
This patch uses MAX_REG_NR consistently to refer to the register file
size.  FRAME_SIZE isn't sufficient because on x86_64, it is smaller
than the ptrace register file size.  MAX_REG_NR was introduced as a
consistent way to get the number of registers, but wasn't used
everywhere it should be.

When this causes a problem, it makes PTRACE_SETREGS fail on x86_64
because of a corrupted segment register value in the known-good
register file. The patch also adds a register dump at that point in
case there are any future problems here.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/sysdep-x86_64/ptrace.h  |4 
 arch/um/os-Linux/skas/mem.c |   10 +++---
 arch/um/os-Linux/skas/process.c |6 +++---
 arch/um/os-Linux/sys-i386/registers.c   |5 +++--
 arch/um/os-Linux/sys-x86_64/registers.c |4 ++--
 5 files changed, 15 insertions(+), 14 deletions(-)

Index: linux-2.6.21-mm/arch/um/include/sysdep-x86_64/ptrace.h
===
--- linux-2.6.21-mm.orig/arch/um/include/sysdep-x86_64/ptrace.h 2007-03-22 
11:18:04.0 -0400
+++ linux-2.6.21-mm/arch/um/include/sysdep-x86_64/ptrace.h  2007-03-23 
20:31:37.0 -0400
@@ -104,10 +104,6 @@ union uml_pt_regs {
 #endif
 #ifdef UML_CONFIG_MODE_SKAS
struct skas_regs {
-   /* x86_64 ptrace uses sizeof(user_regs_struct) as its register
-* file size, while i386 uses FRAME_SIZE.  Therefore, we need
-* to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
-*/
unsigned long regs[MAX_REG_NR];
unsigned long fp[HOST_FP_SIZE];
 struct faultinfo faultinfo;
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/mem.c2007-03-23 
15:05:31.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/mem.c 2007-03-25 10:33:30.0 
-0400
@@ -48,7 +48,7 @@ int multi_op_count = 0;
 static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
 {
unsigned long regs[MAX_REG_NR];
-   int n;
+   int n, i;
long ret, offset;
unsigned long * data;
unsigned long * syscall;
@@ -66,9 +66,13 @@ static inline long do_syscall_stub(struc
 (unsigned long) __syscall_stub_start);
 
n = ptrace_setregs(pid, regs);
-   if(n  0)
+   if(n  0){
+   printk(Registers - \n);
+   for(i = 0; i  MAX_REG_NR; i++)
+   printk(\t%d\t0x%lx\n, i, regs[i]);
panic(do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n,
- n);
+ -n);
+   }
 
wait_stub_done(pid, 0, do_syscall_stub);
 
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/process.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/process.c2007-03-23 
15:05:31.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/process.c 2007-03-25 
10:33:30.0 -0400
@@ -67,7 +67,7 @@ void wait_stub_done(int pid, int sig, ch
 
if((n  0) || !WIFSTOPPED(status) ||
   (WSTOPSIG(status) != SIGUSR1  WSTOPSIG(status) != SIGTRAP)){
-   unsigned long regs[HOST_FRAME_SIZE];
+   unsigned long regs[MAX_REG_NR];
 
if(ptrace(PTRACE_GETREGS, pid, 0, regs)  0)
printk(Failed to get registers from stub, 
@@ -76,7 +76,7 @@ void wait_stub_done(int pid, int sig, ch
int i;
 
printk(Stub registers -\n);
-   for(i = 0; i  HOST_FRAME_SIZE; i++)
+   for(i = 0; i  ARRAY_SIZE(regs); i++)
printk(\t%d - %lx\n, i, regs[i]);
}
panic(%s : failed to wait for SIGUSR1/SIGTRAP, 
@@ -328,7 +328,7 @@ void userspace(union uml_pt_regs *regs)
 int copy_context_skas0(unsigned long new_stack, int pid)
 {
int err;
-   unsigned long regs[HOST_FRAME_SIZE];
+   unsigned long regs[MAX_REG_NR];
unsigned long fp_regs[HOST_FP_SIZE];
unsigned long current_stack = current_stub_stack();
struct stub_data *data = (struct stub_data *) current_stack;
Index: linux-2.6.21-mm/arch/um/os-Linux/sys-i386/registers.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/sys-i386/registers.c  2007-03-23 
15:04:22.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/sys-i386/registers.c   2007-03-23 
20:31:37.0 -0400
@@ -15,7 +15,7 @@
 
 /* These are set once at boot time and not changed thereafter */
 
-static unsigned long exec_regs[HOST_FRAME_SIZE];
+static unsigned long exec_regs[MAX_REG_NR];
 static unsigned long exec_fp_regs[HOST_FP_SIZE];
 static unsigned long exec_fpx_regs[HOST_XFP_SIZE

[PATCH] UML - host VDSO fix

2007-03-23 Thread Jeff Dike
This fixes a problem seen by a number of people running UML on newer host
kernels.  init would hang with an infinite segfault loop.

It turns out that the host kernel was providing a AT_SYSINFO_EHDR of
0xe000, which faked UML into believing that the host VDSO page could be
reused.  However, AT_SYSINFO pointed into the middle of the address space, and
was unmapped as a result.  Because UML was providing AT_SYSINFO_EHDR and
AT_SYSINFO to its own processes, these would branch to nowhere when trying to
use the VDSO.

The fix is to also check the location of AT_SYSINFO when deciding whether to
use the host's VDSO.

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

Index: linux-2.6.17/arch/um/os-Linux/elf_aux.c
===
--- linux-2.6.17.orig/arch/um/os-Linux/elf_aux.c2007-02-23 
15:00:51.0 -0500
+++ linux-2.6.17/arch/um/os-Linux/elf_aux.c 2007-02-23 15:09:58.0 
-0500
@@ -39,6 +39,9 @@ __init void scan_elf_aux( char **envp)
switch ( auxv->a_type ) {
case AT_SYSINFO:
__kernel_vsyscall = auxv->a_un.a_val;
+   /* See if the page is under TASK_SIZE */
+   if (__kernel_vsyscall < (unsigned long) envp)
+   __kernel_vsyscall = 0;
break;
case AT_SYSINFO_EHDR:
vsyscall_ehdr = auxv->a_un.a_val;
-
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 - fix epoll

2007-03-23 Thread Jeff Dike
[ This is both 2.6.21 and -stable material ]

UML/x86_64 needs the same packing of struct epoll_event as x86_64.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 include/linux/eventpoll.h |7 +++
 1 file changed, 7 insertions(+)

Index: linux-2.6.21-mm/include/linux/eventpoll.h
===
--- linux-2.6.21-mm.orig/include/linux/eventpoll.h  2007-03-05 
13:01:17.0 -0500
+++ linux-2.6.21-mm/include/linux/eventpoll.h   2007-03-23 14:03:07.0 
-0400
@@ -31,12 +31,19 @@
 /* 
  * On x86-64 make the 64bit structure have the same alignment as the
  * 32bit structure. This makes 32bit emulation easier.
+ *
+ * UML/x86_64 needs the same packing as x86_64 - UML + UML_X86 +
+ * 64_BIT adds up to UML/x86_64.
  */
 #ifdef __x86_64__
 #define EPOLL_PACKED __attribute__((packed))
 #else
+#if defined(CONFIG_UML) && defined(CONFIG_UML_X86) && defined(CONFIG_64BIT)
+#define EPOLL_PACKED __attribute__((packed))
+#else
 #define EPOLL_PACKED
 #endif
+#endif
 
 struct epoll_event {
__u32 events;
-
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 4/7 ] UML - create as-layout.h

2007-03-23 Thread Jeff Dike
On Fri, Mar 23, 2007 at 07:47:50AM +0100, Blaisorblade wrote:
> Hey, I do like _these_ patches! A nice picture in that header could then be 
> added (in the very future ;-) ), but at least one knows there are so much of 
> them. And user_util.h is no more!

Heh :-)

user_util.h has disgusted me for a long time.  The best thing about it
is looking at the loong list of one-line deletions in that patch.

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 4/7 ] UML - create as-layout.h

2007-03-23 Thread Jeff Dike
On Fri, Mar 23, 2007 at 07:47:50AM +0100, Blaisorblade wrote:
 Hey, I do like _these_ patches! A nice picture in that header could then be 
 added (in the very future ;-) ), but at least one knows there are so much of 
 them. And user_util.h is no more!

Heh :-)

user_util.h has disgusted me for a long time.  The best thing about it
is looking at the loong list of one-line deletions in that patch.

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 - fix epoll

2007-03-23 Thread Jeff Dike
[ This is both 2.6.21 and -stable material ]

UML/x86_64 needs the same packing of struct epoll_event as x86_64.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 include/linux/eventpoll.h |7 +++
 1 file changed, 7 insertions(+)

Index: linux-2.6.21-mm/include/linux/eventpoll.h
===
--- linux-2.6.21-mm.orig/include/linux/eventpoll.h  2007-03-05 
13:01:17.0 -0500
+++ linux-2.6.21-mm/include/linux/eventpoll.h   2007-03-23 14:03:07.0 
-0400
@@ -31,12 +31,19 @@
 /* 
  * On x86-64 make the 64bit structure have the same alignment as the
  * 32bit structure. This makes 32bit emulation easier.
+ *
+ * UML/x86_64 needs the same packing as x86_64 - UML + UML_X86 +
+ * 64_BIT adds up to UML/x86_64.
  */
 #ifdef __x86_64__
 #define EPOLL_PACKED __attribute__((packed))
 #else
+#if defined(CONFIG_UML)  defined(CONFIG_UML_X86)  defined(CONFIG_64BIT)
+#define EPOLL_PACKED __attribute__((packed))
+#else
 #define EPOLL_PACKED
 #endif
+#endif
 
 struct epoll_event {
__u32 events;
-
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 - host VDSO fix

2007-03-23 Thread Jeff Dike
This fixes a problem seen by a number of people running UML on newer host
kernels.  init would hang with an infinite segfault loop.

It turns out that the host kernel was providing a AT_SYSINFO_EHDR of
0xe000, which faked UML into believing that the host VDSO page could be
reused.  However, AT_SYSINFO pointed into the middle of the address space, and
was unmapped as a result.  Because UML was providing AT_SYSINFO_EHDR and
AT_SYSINFO to its own processes, these would branch to nowhere when trying to
use the VDSO.

The fix is to also check the location of AT_SYSINFO when deciding whether to
use the host's VDSO.

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

Index: linux-2.6.17/arch/um/os-Linux/elf_aux.c
===
--- linux-2.6.17.orig/arch/um/os-Linux/elf_aux.c2007-02-23 
15:00:51.0 -0500
+++ linux-2.6.17/arch/um/os-Linux/elf_aux.c 2007-02-23 15:09:58.0 
-0500
@@ -39,6 +39,9 @@ __init void scan_elf_aux( char **envp)
switch ( auxv-a_type ) {
case AT_SYSINFO:
__kernel_vsyscall = auxv-a_un.a_val;
+   /* See if the page is under TASK_SIZE */
+   if (__kernel_vsyscall  (unsigned long) envp)
+   __kernel_vsyscall = 0;
break;
case AT_SYSINFO_EHDR:
vsyscall_ehdr = auxv-a_un.a_val;
-
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 0/7 ] UML - Header cleanup

2007-03-22 Thread Jeff Dike
On Thu, Mar 22, 2007 at 09:50:34AM -0800, Andrew Morton wrote:
> I have the ARRAY_SIZE change queued for 2.6.22.
> 
> It looks like the UML change needs to be folded into the same changeset to
> avoid build breaks?

Yes, that would be great.

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 7/7 ] UML - Add missing __init declarations

2007-03-22 Thread Jeff Dike
The build started finding calls from non-init to init functions.
These are just cases of init functions not being properly marked, so
this patch fixes that.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/kernel/mem.c|2 +-
 arch/um/os-Linux/main.c |2 +-
 arch/um/os-Linux/mem.c  |9 +
 arch/um/os-Linux/process.c  |5 +++--
 arch/um/os-Linux/start_up.c |4 ++--
 5 files changed, 12 insertions(+), 10 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/mem.c   2007-03-20 21:36:47.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/mem.c2007-03-20 21:37:11.0 
-0400
@@ -217,7 +217,7 @@ static void __init fixaddr_user_init( vo
 #endif
 }
 
-void paging_init(void)
+void __init paging_init(void)
 {
unsigned long zones_size[MAX_NR_ZONES], vaddr;
int i;
Index: linux-2.6.21-mm/arch/um/os-Linux/main.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/main.c2007-03-20 
21:36:47.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/main.c 2007-03-20 21:37:21.0 
-0400
@@ -120,7 +120,7 @@ extern int uml_exitcode;
 
 extern void scan_elf_aux( char **envp);
 
-int main(int argc, char **argv, char **envp)
+int __init main(int argc, char **argv, char **envp)
 {
char **new_argv;
int ret, i, err;
Index: linux-2.6.21-mm/arch/um/os-Linux/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/mem.c 2007-03-20 21:36:47.0 
-0400
+++ linux-2.6.21-mm/arch/um/os-Linux/mem.c  2007-03-20 21:37:34.0 
-0400
@@ -164,7 +164,8 @@ found:
  * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger).
  * So it isn't 'static' yet.
  */
-int make_tempfile(const char *template, char **out_tempname, int do_unlink)
+int __init make_tempfile(const char *template, char **out_tempname,
+int do_unlink)
 {
char *tempname;
int fd;
@@ -205,7 +206,7 @@ out:
  * This proc is used in start_up.c
  * So it isn't 'static'.
  */
-int create_tmp_file(unsigned long long len)
+int __init create_tmp_file(unsigned long long len)
 {
int fd, err;
char zero;
@@ -241,7 +242,7 @@ int create_tmp_file(unsigned long long l
return fd;
 }
 
-int create_mem_file(unsigned long long len)
+int __init create_mem_file(unsigned long long len)
 {
int err, fd;
 
@@ -256,7 +257,7 @@ int create_mem_file(unsigned long long l
 }
 
 
-void check_tmpexec(void)
+void __init check_tmpexec(void)
 {
void *addr;
int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE);
Index: linux-2.6.21-mm/arch/um/os-Linux/process.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/process.c 2007-03-20 
21:36:47.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/process.c  2007-03-20 21:37:43.0 
-0400
@@ -21,6 +21,7 @@
 #include "skas_ptrace.h"
 #include "kern_constants.h"
 #include "uml-config.h"
+#include "init.h"
 
 #define ARBITRARY_ADDR -1
 #define FAILURE_PID-1
@@ -192,7 +193,7 @@ int os_unmap_memory(void *addr, int len)
 #define MADV_REMOVE KERNEL_MADV_REMOVE
 #endif
 
-int os_drop_memory(void *addr, int length)
+int __init os_drop_memory(void *addr, int length)
 {
int err;
 
@@ -202,7 +203,7 @@ int os_drop_memory(void *addr, int lengt
return err;
 }
 
-int can_drop_memory(void)
+int __init can_drop_memory(void)
 {
void *addr;
int fd, ok = 0;
Index: linux-2.6.21-mm/arch/um/os-Linux/start_up.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/start_up.c2007-03-20 
21:36:47.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/start_up.c 2007-03-20 21:37:57.0 
-0400
@@ -329,7 +329,7 @@ static void __init check_ptrace(void)
 
 extern void check_tmpexec(void);
 
-static void check_coredump_limit(void)
+static void __init check_coredump_limit(void)
 {
struct rlimit lim;
int err = getrlimit(RLIMIT_CORE, );
@@ -350,7 +350,7 @@ static void check_coredump_limit(void)
else printf("%lu\n", lim.rlim_max);
 }
 
-void os_early_checks(void)
+void __init os_early_checks(void)
 {
/* Print out the core dump limits early */
check_coredump_limit();
-
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/7 ] UML - Move SIGIO testing to sigio.c

2007-03-22 Thread Jeff Dike
This patch narrows the sigio interface.  The boot-time SIGIO testing
used to be in start_up.c, which meant that pty_output_sigio and
pty_close_sigio needed to be global.  By moving that code here, those
can become static and the declarations moved from user_util.h.

os_check_bugs is also here because it only does the SIGIO checking.
If it does more, it'll probably move back to start_up.c.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/user_util.h |3 
 arch/um/os-Linux/sigio.c|  145 
 arch/um/os-Linux/start_up.c |  145 
 3 files changed, 145 insertions(+), 148 deletions(-)

Index: linux-2.6.21-mm/arch/um/os-Linux/start_up.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/start_up.c2007-03-21 
15:22:48.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/start_up.c 2007-03-21 15:24:33.0 
-0400
@@ -553,148 +553,3 @@ int __init parse_iomem(char *str, int *a
  out:
return 1;
 }
-
-
-/* Changed during early boot */
-int pty_output_sigio = 0;
-int pty_close_sigio = 0;
-
-/* Used as a flag during SIGIO testing early in boot */
-static volatile int got_sigio = 0;
-
-static void __init handler(int sig)
-{
-   got_sigio = 1;
-}
-
-struct openpty_arg {
-   int master;
-   int slave;
-   int err;
-};
-
-static void openpty_cb(void *arg)
-{
-   struct openpty_arg *info = arg;
-
-   info->err = 0;
-   if(openpty(>master, >slave, NULL, NULL, NULL))
-   info->err = -errno;
-}
-
-static int async_pty(int master, int slave)
-{
-   int flags;
-
-   flags = fcntl(master, F_GETFL);
-   if(flags < 0)
-   return -errno;
-
-   if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
-  (fcntl(master, F_SETOWN, os_getpid()) < 0))
-   return -errno;
-
-   if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
-   return -errno;
-
-   return(0);
-}
-
-static void __init check_one_sigio(void (*proc)(int, int))
-{
-   struct sigaction old, new;
-   struct openpty_arg pty = { .master = -1, .slave = -1 };
-   int master, slave, err;
-
-   initial_thread_cb(openpty_cb, );
-   if(pty.err){
-   printk("openpty failed, errno = %d\n", -pty.err);
-   return;
-   }
-
-   master = pty.master;
-   slave = pty.slave;
-
-   if((master == -1) || (slave == -1)){
-   printk("openpty failed to allocate a pty\n");
-   return;
-   }
-
-   /* Not now, but complain so we now where we failed. */
-   err = raw(master);
-   if (err < 0)
-   panic("check_sigio : __raw failed, errno = %d\n", -err);
-
-   err = async_pty(master, slave);
-   if(err < 0)
-   panic("tty_fds : sigio_async failed, err = %d\n", -err);
-
-   if(sigaction(SIGIO, NULL, ) < 0)
-   panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
-   new = old;
-   new.sa_handler = handler;
-   if(sigaction(SIGIO, , NULL) < 0)
-   panic("check_sigio : sigaction 2 failed, errno = %d\n", errno);
-
-   got_sigio = 0;
-   (*proc)(master, slave);
-
-   close(master);
-   close(slave);
-
-   if(sigaction(SIGIO, , NULL) < 0)
-   panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
-}
-
-static void tty_output(int master, int slave)
-{
-   int n;
-   char buf[512];
-
-   printk("Checking that host ptys support output SIGIO...");
-
-   memset(buf, 0, sizeof(buf));
-
-   while(os_write_file(master, buf, sizeof(buf)) > 0) ;
-   if(errno != EAGAIN)
-   panic("check_sigio : write failed, errno = %d\n", errno);
-   while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
-
-   if(got_sigio){
-   printk("Yes\n");
-   pty_output_sigio = 1;
-   }
-   else if(n == -EAGAIN) printk("No, enabling workaround\n");
-   else panic("check_sigio : read failed, err = %d\n", n);
-}
-
-static void tty_close(int master, int slave)
-{
-   printk("Checking that host ptys support SIGIO on close...");
-
-   close(slave);
-   if(got_sigio){
-   printk("Yes\n");
-   pty_close_sigio = 1;
-   }
-   else printk("No, enabling workaround\n");
-}
-
-void __init check_sigio(void)
-{
-   if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
-  (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
-   printk("No pseudo-terminals available - skipping pty SIGIO "
- 

[ PATCH 6/7 ] UML - Remove user_util.h

2007-03-22 Thread Jeff Dike
user_util.h isn't needed any more, so delete it and remove all
includes of it.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/chan_kern.c  |1 
 arch/um/drivers/chan_user.c  |1 
 arch/um/drivers/cow_sys.h|1 
 arch/um/drivers/daemon_user.c|1 
 arch/um/drivers/fd.c |1 
 arch/um/drivers/harddog_user.c   |1 
 arch/um/drivers/line.c   |1 
 arch/um/drivers/mcast_user.c |1 
 arch/um/drivers/mconsole_kern.c  |1 
 arch/um/drivers/mconsole_user.c  |1 
 arch/um/drivers/mmapper_kern.c   |1 
 arch/um/drivers/net_kern.c   |1 
 arch/um/drivers/net_user.c   |1 
 arch/um/drivers/port_user.c  |1 
 arch/um/drivers/pty.c|1 
 arch/um/drivers/slip_user.c  |1 
 arch/um/drivers/slirp_user.c |1 
 arch/um/drivers/ssl.c|1 
 arch/um/drivers/stdio_console.c  |1 
 arch/um/drivers/tty.c|1 
 arch/um/drivers/ubd_kern.c   |1 
 arch/um/drivers/ubd_user.c   |1 
 arch/um/drivers/xterm.c  |1 
 arch/um/include/user_util.h  |   32 ---
 arch/um/kernel/exec.c|1 
 arch/um/kernel/init_task.c   |1 
 arch/um/kernel/initrd.c  |1 
 arch/um/kernel/irq.c |1 
 arch/um/kernel/ksyms.c   |1 
 arch/um/kernel/mem.c |1 
 arch/um/kernel/physmem.c |1 
 arch/um/kernel/process.c |1 
 arch/um/kernel/reboot.c  |1 
 arch/um/kernel/signal.c  |1 
 arch/um/kernel/skas/process.c|1 
 arch/um/kernel/skas/tlb.c|1 
 arch/um/kernel/smp.c |1 
 arch/um/kernel/syscall.c |1 
 arch/um/kernel/sysrq.c   |1 
 arch/um/kernel/time.c|1 
 arch/um/kernel/tlb.c |1 
 arch/um/kernel/trap.c|1 
 arch/um/kernel/tt/exec_kern.c|1 
 arch/um/kernel/tt/exec_user.c|1 
 arch/um/kernel/tt/gdb.c  |1 
 arch/um/kernel/tt/mem.c  |1 
 arch/um/kernel/tt/mem_user.c |1 
 arch/um/kernel/tt/process_kern.c |1 
 arch/um/kernel/tt/ptproxy/proxy.c|1 
 arch/um/kernel/tt/ptproxy/ptrace.c   |1 
 arch/um/kernel/tt/ptproxy/sysdep.c   |1 
 arch/um/kernel/tt/ptproxy/wait.c |1 
 arch/um/kernel/tt/syscall_user.c |1 
 arch/um/kernel/tt/tlb.c  |1 
 arch/um/kernel/tt/tracer.c   |1 
 arch/um/kernel/tt/trap_user.c|1 
 arch/um/kernel/tt/uaccess_user.c |1 
 arch/um/kernel/um_arch.c |1 
 arch/um/os-Linux/drivers/ethertap_user.c |1 
 arch/um/os-Linux/drivers/tuntap_user.c   |1 
 arch/um/os-Linux/file.c  |1 
 arch/um/os-Linux/helper.c|1 
 arch/um/os-Linux/irq.c   |1 
 arch/um/os-Linux/main.c  |1 
 arch/um/os-Linux/mem.c   |1 
 arch/um/os-Linux/process.c   |1 
 arch/um/os-Linux/sigio.c |1 
 arch/um/os-Linux/signal.c|1 
 arch/um/os-Linux/skas/mem.c  |1 
 arch/um/os-Linux/skas/process.c  |1 
 arch/um/os-Linux/skas/trap.c |1 
 arch/um/os-Linux/start_up.c  |1 
 arch/um/os-Linux/sys-i386/tls.c  |1 
 arch/um/os-Linux/time.c  |1 
 arch/um/os-Linux/trap.c  |1 
 arch/um/os-Linux/tt.c|1 
 arch/um/os-Linux/util.c  |1 
 arch/um/sys-i386/bugs.c  |1 
 arch/um/sys-i386/ptrace_user.c   |1 
 arch/um/sys-ppc/sigcontext.c |1 
 80 files changed, 111 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/chan_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_kern.c2007-03-21 
15:22:43.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_kern.c 2007-03-21 17:30:34.0 
-0400
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include "chan_kern.h"
-#include "user_util.h"
 #include "kern.h"
 #include "irq_user.h"
 #include "sigio.h"
Index: linux-2.6.21-mm/arch/um/drivers/chan_user.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_user.c2007-03-21 
15:22:43.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_user.c 2007-03-21 17:30:34.0 

[ PATCH 5/7 ] UML - Move remaining useful contents of user_util.h

2007-03-22 Thread Jeff Dike
Rescue the useful contents of the soon-to-be-gone user-util.h.

pty.c now gets ptsname from stdlib.h like it should have always done.

CATCH_EINTR is now in os.h, although perhaps all usage should be under
os-Linux at some point.

get_pty is also in os.h.

This patch restores the old definition of ARRAY_SIZE in user.h.  This
file is included only in userspace files, so there will be no conflict
with the kernel's new ARRAY_SIZE.  The copy of the kernel's ARRAY_SIZE
and associated infrastructure is now gone.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/pty.c   |1 +
 arch/um/include/os.h|6 ++
 arch/um/include/user.h  |   19 ---
 arch/um/include/user_util.h |   18 --
 arch/um/os-Linux/sys-i386/tls.c |1 +
 5 files changed, 16 insertions(+), 29 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/pty.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/pty.c  2007-03-22 11:18:21.0 
-0400
+++ linux-2.6.21-mm/arch/um/drivers/pty.c   2007-03-22 11:21:01.0 
-0400
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: linux-2.6.21-mm/arch/um/include/os.h
===
--- linux-2.6.21-mm.orig/arch/um/include/os.h   2007-03-22 11:18:48.0 
-0400
+++ linux-2.6.21-mm/arch/um/include/os.h2007-03-22 11:21:01.0 
-0400
@@ -16,6 +16,8 @@
 #include "sysdep/tls.h"
 #include "sysdep/archsetjmp.h"
 
+#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
+
 #define OS_TYPE_FILE 1
 #define OS_TYPE_DIR 2
 #define OS_TYPE_SYMLINK 3
@@ -341,6 +343,10 @@ extern void maybe_sigio_broken(int fd, i
 extern void sig_handler_common_skas(int sig, void *sc_ptr);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
 
+/* sys-x86_64/prctl.c */
 extern int os_arch_prctl(int pid, int code, unsigned long *addr);
 
+/* tty.c */
+int get_pty(void);
+
 #endif
Index: linux-2.6.21-mm/arch/um/include/user.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user.h 2007-03-22 11:18:21.0 
-0400
+++ linux-2.6.21-mm/arch/um/include/user.h  2007-03-22 11:21:01.0 
-0400
@@ -6,6 +6,14 @@
 #ifndef __USER_H__
 #define __USER_H__
 
+/*
+ * The usual definition - copied here because the kernel provides its own,
+ * fancier, type-safe, definition.  Using that one would require
+ * copying too much infrastructure for my taste, so userspace files
+ * get less checking than kernel files.
+ */
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
 /* Both on kernelspace and userspace this will provide the size_t definition. 
It should, at
  * least. But on userspace it won't hurt surely. */
 #include 
@@ -21,14 +29,3 @@ extern size_t strlcpy(char *, const char
 extern size_t strlcat(char *, const char *, size_t);
 
 #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.21-mm/arch/um/include/user_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user_util.h2007-03-22 
11:18:21.0 -0400
+++ linux-2.6.21-mm/arch/um/include/user_util.h 2007-03-22 11:21:01.0 
-0400
@@ -8,31 +8,13 @@
 
 #include "sysdep/ptrace.h"
 
-/* Copied from kernel.h and compiler-gcc.h */
-
-/* Force a compilation error if condition is true, but also produce a
-   result (of value 0 and type size_t), so the expression can be used
-   e.g. in a structure initializer (or where-ever else comma expressions
-   aren't permitted). */
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
-
-/* [0] degrades to a pointer: a different type from an array */
-#define __must_be_array(a) \
-  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof([0])))
-
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
-
-#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
-
 extern int mode_tt;
 
 extern int grantpt(int __fd);
 extern int unlockpt(int __fd);
-extern char *ptsname(int __fd);
 
 extern void *add_signal_handler(int sig, void (*handler)(int));
 extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
-extern int get_pty(void);
 extern int switcheroo(int fd, int prot, void *from, void *to, int size);
 extern void do_exec(int old_pid, int new_pid);
 extern void tracer_panic(ch

[ PATCH 1/7 ] UML - Update UML definition of ARRAY_SIZE

2007-03-22 Thread Jeff Dike
This is the minimal change needed to keep UML building with the new
definition of ARRAY_SIZE.  It is defined in user_util.h so that
userspace files, which can't include kernel.h, can still use
ARRAY_SIZE.  However, since user_util.h is included everywhere,
including kernel files, the token sequence of the expansion has to
match.

This patch copies enough from the kernel headers to make that happen.

However, this is too gross to survive, and so is the entire header.
Future patches will make this header disappear, but this is a quick
and simple fix for the problem in case there is a noticable lag
between this patch and the more extensive patches which tidy this mess.

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

Index: linux-2.6.21-mm/arch/um/include/user_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user_util.h2007-03-21 
10:58:05.0 -0400
+++ linux-2.6.21-mm/arch/um/include/user_util.h 2007-03-21 11:05:44.0 
-0400
@@ -8,8 +8,19 @@
 
 #include "sysdep/ptrace.h"
 
-/* Copied from kernel.h */
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+/* Copied from kernel.h and compiler-gcc.h */
+
+/* Force a compilation error if condition is true, but also produce a
+   result (of value 0 and type size_t), so the expression can be used
+   e.g. in a structure initializer (or where-ever else comma expressions
+   aren't permitted). */
+#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
+
+/* [0] degrades to a pointer: a different type from an array */
+#define __must_be_array(a) \
+  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof([0])))
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 
 #define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
 
-
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/7 ] UML - Create arch.h

2007-03-22 Thread Jeff Dike
This patch moves the declarations of the architecture hooks from
user_util.h to a new header, arch.c, and adds the necessary includes
to files which need those declarations.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/arch.h  |   15 +++
 arch/um/include/user_util.h |4 
 arch/um/kernel/trap.c   |1 +
 arch/um/kernel/um_arch.c|1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

Index: linux-2.6.21-mm/arch/um/include/arch.h
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.21-mm/arch/um/include/arch.h  2007-03-21 17:29:15.0 
-0400
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __ARCH_H__
+#define __ARCH_H__
+
+#include "sysdep/ptrace.h"
+
+extern void arch_check_bugs(void);
+extern int arch_fixup(unsigned long address, void *sc_ptr);
+extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
+
+#endif
Index: linux-2.6.21-mm/arch/um/kernel/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/trap.c  2007-03-21 16:16:43.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/trap.c   2007-03-21 17:29:15.0 
-0400
@@ -20,6 +20,7 @@
 #include "sysdep/sigcontext.h"
 #include "user_util.h"
 #include "kern_util.h"
+#include "arch.h"
 #include "kern.h"
 #include "chan_kern.h"
 #include "mconsole_kern.h"
Index: linux-2.6.21-mm/arch/um/kernel/um_arch.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/um_arch.c   2007-03-21 
16:16:43.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/um_arch.c2007-03-21 17:29:15.0 
-0400
@@ -28,6 +28,7 @@
 #include "asm/current.h"
 #include "user_util.h"
 #include "kern_util.h"
+#include "arch.h"
 #include "kern.h"
 #include "mem_user.h"
 #include "mem.h"
Index: linux-2.6.21-mm/arch/um/include/user_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user_util.h2007-03-21 
16:17:50.0 -0400
+++ linux-2.6.21-mm/arch/um/include/user_util.h 2007-03-21 17:29:15.0 
-0400
@@ -65,10 +65,6 @@ extern int attach(int pid);
 extern void kill_child_dead(int pid);
 extern int cont(int pid);
 extern void check_sigio(void);
-extern void arch_check_bugs(void);
-extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
-extern int arch_fixup(unsigned long address, void *sc_ptr);
-extern void arch_init_thread(void);
 extern int raw(int fd);
 
 #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/7 ] UML - create as-layout.h

2007-03-22 Thread Jeff Dike
This patch moves all the the symbols defined in um_arch.c, which are
mostly boundaries between different parts of the UML kernel address
space, to a new header, as-layout.h.  There are also a few things here
which aren't really related to address space layout, but which don't
really have a better place to go.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/as-layout.h   |   35 +++
 arch/um/include/user_util.h   |   23 ---
 arch/um/kernel/exec.c |1 +
 arch/um/kernel/ksyms.c|1 +
 arch/um/kernel/mem.c  |1 +
 arch/um/kernel/physmem.c  |1 +
 arch/um/kernel/process.c  |1 +
 arch/um/kernel/skas/process.c |1 +
 arch/um/kernel/tlb.c  |1 +
 arch/um/kernel/trap.c |1 +
 arch/um/kernel/um_arch.c  |1 +
 arch/um/os-Linux/main.c   |1 +
 arch/um/os-Linux/skas/trap.c  |1 +
 13 files changed, 46 insertions(+), 23 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/exec.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/exec.c  2007-03-21 17:33:45.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/exec.c   2007-03-22 11:18:21.0 
-0400
@@ -12,6 +12,7 @@
 #include "asm/uaccess.h"
 #include "user_util.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "mem_user.h"
 #include "kern.h"
 #include "irq_user.h"
Index: linux-2.6.21-mm/arch/um/kernel/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/mem.c   2007-03-21 17:33:45.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/mem.c2007-03-22 11:18:21.0 
-0400
@@ -15,6 +15,7 @@
 #include "asm/pgalloc.h"
 #include "user_util.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "kern.h"
 #include "mem_user.h"
 #include "uml_uaccess.h"
Index: linux-2.6.21-mm/arch/um/kernel/process.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/process.c   2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/process.c2007-03-22 11:18:21.0 
-0400
@@ -34,6 +34,7 @@
 #include "asm/user.h"
 #include "user_util.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "kern.h"
 #include "signal_kern.h"
 #include "init.h"
Index: linux-2.6.21-mm/arch/um/kernel/skas/process.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/skas/process.c  2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/skas/process.c   2007-03-22 
11:18:21.0 -0400
@@ -13,6 +13,7 @@
 #include "asm/uaccess.h"
 #include "asm/atomic.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "skas.h"
 #include "os.h"
 #include "user_util.h"
Index: linux-2.6.21-mm/arch/um/os-Linux/main.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/main.c2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/main.c 2007-03-22 11:18:21.0 
-0400
@@ -15,6 +15,7 @@
 #include 
 #include "user_util.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "mem_user.h"
 #include "irq_user.h"
 #include "user.h"
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/trap.c   2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c2007-03-22 
11:18:21.0 -0400
@@ -7,6 +7,7 @@
 #include 
 #include "user_util.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "task.h"
 #include "sigcontext.h"
 #include "skas.h"
Index: linux-2.6.21-mm/arch/um/kernel/physmem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/physmem.c   2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/physmem.c2007-03-22 11:18:21.0 
-0400
@@ -13,6 +13,7 @@
 #include "asm/types.h"
 #include "asm/pgtable.h"
 #include "kern_util.h"
+#include "as-layout.h"
 #include "user_util.h"
 #include "mode_kern.h"
 #include "mem.h"
Index: linux-2.6.21-mm/arch/um/kernel/tlb.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/tlb.c   2007-03-21 17:33:45.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/tlb.c 

[ PATCH 0/7 ] UML - Header cleanup

2007-03-22 Thread Jeff Dike
These are post-2.6.21 material, except that if the new definition of
ARRAY_SIZE goes to Linus, patch 1 in this series should go as well.

These patches are a response to the new ARRAY_SIZE.  UML had a
duplicate definition for the use of the userspace side of things,
which can't directly use kernel.h.  This header was included
everywhere, and had a random collection of stuff in it.

This series first gets UML building again by replacing the old
ARRAY_SIZE definition with one that expands to the same token
sequence.  Then user_util.h is dismantled, primarily into two, more
coherent headers, and deleted.  ARRAY_SIZE is reintroduced, but in a
header which is only included in userspace files, and in its old form,
so this version is lacking the extra typechecking.

The final patch in the series is unrelated to the rest - it adds
__init declarations to some functions which were lacking them.

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/7 ] UML - Create arch.h

2007-03-22 Thread Jeff Dike
This patch moves the declarations of the architecture hooks from
user_util.h to a new header, arch.c, and adds the necessary includes
to files which need those declarations.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/arch.h  |   15 +++
 arch/um/include/user_util.h |4 
 arch/um/kernel/trap.c   |1 +
 arch/um/kernel/um_arch.c|1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

Index: linux-2.6.21-mm/arch/um/include/arch.h
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.21-mm/arch/um/include/arch.h  2007-03-21 17:29:15.0 
-0400
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel}.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __ARCH_H__
+#define __ARCH_H__
+
+#include sysdep/ptrace.h
+
+extern void arch_check_bugs(void);
+extern int arch_fixup(unsigned long address, void *sc_ptr);
+extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
+
+#endif
Index: linux-2.6.21-mm/arch/um/kernel/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/trap.c  2007-03-21 16:16:43.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/trap.c   2007-03-21 17:29:15.0 
-0400
@@ -20,6 +20,7 @@
 #include sysdep/sigcontext.h
 #include user_util.h
 #include kern_util.h
+#include arch.h
 #include kern.h
 #include chan_kern.h
 #include mconsole_kern.h
Index: linux-2.6.21-mm/arch/um/kernel/um_arch.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/um_arch.c   2007-03-21 
16:16:43.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/um_arch.c2007-03-21 17:29:15.0 
-0400
@@ -28,6 +28,7 @@
 #include asm/current.h
 #include user_util.h
 #include kern_util.h
+#include arch.h
 #include kern.h
 #include mem_user.h
 #include mem.h
Index: linux-2.6.21-mm/arch/um/include/user_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user_util.h2007-03-21 
16:17:50.0 -0400
+++ linux-2.6.21-mm/arch/um/include/user_util.h 2007-03-21 17:29:15.0 
-0400
@@ -65,10 +65,6 @@ extern int attach(int pid);
 extern void kill_child_dead(int pid);
 extern int cont(int pid);
 extern void check_sigio(void);
-extern void arch_check_bugs(void);
-extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
-extern int arch_fixup(unsigned long address, void *sc_ptr);
-extern void arch_init_thread(void);
 extern int raw(int fd);
 
 #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/7 ] UML - create as-layout.h

2007-03-22 Thread Jeff Dike
This patch moves all the the symbols defined in um_arch.c, which are
mostly boundaries between different parts of the UML kernel address
space, to a new header, as-layout.h.  There are also a few things here
which aren't really related to address space layout, but which don't
really have a better place to go.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/as-layout.h   |   35 +++
 arch/um/include/user_util.h   |   23 ---
 arch/um/kernel/exec.c |1 +
 arch/um/kernel/ksyms.c|1 +
 arch/um/kernel/mem.c  |1 +
 arch/um/kernel/physmem.c  |1 +
 arch/um/kernel/process.c  |1 +
 arch/um/kernel/skas/process.c |1 +
 arch/um/kernel/tlb.c  |1 +
 arch/um/kernel/trap.c |1 +
 arch/um/kernel/um_arch.c  |1 +
 arch/um/os-Linux/main.c   |1 +
 arch/um/os-Linux/skas/trap.c  |1 +
 13 files changed, 46 insertions(+), 23 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/exec.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/exec.c  2007-03-21 17:33:45.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/exec.c   2007-03-22 11:18:21.0 
-0400
@@ -12,6 +12,7 @@
 #include asm/uaccess.h
 #include user_util.h
 #include kern_util.h
+#include as-layout.h
 #include mem_user.h
 #include kern.h
 #include irq_user.h
Index: linux-2.6.21-mm/arch/um/kernel/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/mem.c   2007-03-21 17:33:45.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/mem.c2007-03-22 11:18:21.0 
-0400
@@ -15,6 +15,7 @@
 #include asm/pgalloc.h
 #include user_util.h
 #include kern_util.h
+#include as-layout.h
 #include kern.h
 #include mem_user.h
 #include uml_uaccess.h
Index: linux-2.6.21-mm/arch/um/kernel/process.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/process.c   2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/process.c2007-03-22 11:18:21.0 
-0400
@@ -34,6 +34,7 @@
 #include asm/user.h
 #include user_util.h
 #include kern_util.h
+#include as-layout.h
 #include kern.h
 #include signal_kern.h
 #include init.h
Index: linux-2.6.21-mm/arch/um/kernel/skas/process.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/skas/process.c  2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/skas/process.c   2007-03-22 
11:18:21.0 -0400
@@ -13,6 +13,7 @@
 #include asm/uaccess.h
 #include asm/atomic.h
 #include kern_util.h
+#include as-layout.h
 #include skas.h
 #include os.h
 #include user_util.h
Index: linux-2.6.21-mm/arch/um/os-Linux/main.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/main.c2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/main.c 2007-03-22 11:18:21.0 
-0400
@@ -15,6 +15,7 @@
 #include asm/page.h
 #include user_util.h
 #include kern_util.h
+#include as-layout.h
 #include mem_user.h
 #include irq_user.h
 #include user.h
Index: linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/skas/trap.c   2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/skas/trap.c2007-03-22 
11:18:21.0 -0400
@@ -7,6 +7,7 @@
 #include errno.h
 #include user_util.h
 #include kern_util.h
+#include as-layout.h
 #include task.h
 #include sigcontext.h
 #include skas.h
Index: linux-2.6.21-mm/arch/um/kernel/physmem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/physmem.c   2007-03-21 
17:33:45.0 -0400
+++ linux-2.6.21-mm/arch/um/kernel/physmem.c2007-03-22 11:18:21.0 
-0400
@@ -13,6 +13,7 @@
 #include asm/types.h
 #include asm/pgtable.h
 #include kern_util.h
+#include as-layout.h
 #include user_util.h
 #include mode_kern.h
 #include mem.h
Index: linux-2.6.21-mm/arch/um/kernel/tlb.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/tlb.c   2007-03-21 17:33:45.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/tlb.c2007-03-22 11:18:21.0 
-0400
@@ -9,6 +9,7 @@
 #include asm/tlbflush.h
 #include choose-mode.h
 #include mode_kern.h
+#include as-layout.h
 #include user_util.h
 #include tlb.h
 #include mem.h
Index: linux-2.6.21-mm/arch/um/kernel/trap.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/trap.c  2007-03-21 17:38:21.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/trap.c   2007-03-22 11:18:21.0 
-0400
@@ -20,6 +20,7 @@
 #include sysdep/sigcontext.h
 #include user_util.h

[ PATCH 0/7 ] UML - Header cleanup

2007-03-22 Thread Jeff Dike
These are post-2.6.21 material, except that if the new definition of
ARRAY_SIZE goes to Linus, patch 1 in this series should go as well.

These patches are a response to the new ARRAY_SIZE.  UML had a
duplicate definition for the use of the userspace side of things,
which can't directly use kernel.h.  This header was included
everywhere, and had a random collection of stuff in it.

This series first gets UML building again by replacing the old
ARRAY_SIZE definition with one that expands to the same token
sequence.  Then user_util.h is dismantled, primarily into two, more
coherent headers, and deleted.  ARRAY_SIZE is reintroduced, but in a
header which is only included in userspace files, and in its old form,
so this version is lacking the extra typechecking.

The final patch in the series is unrelated to the rest - it adds
__init declarations to some functions which were lacking them.

Jeff

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


[ PATCH 2/7 ] UML - Move SIGIO testing to sigio.c

2007-03-22 Thread Jeff Dike
This patch narrows the sigio interface.  The boot-time SIGIO testing
used to be in start_up.c, which meant that pty_output_sigio and
pty_close_sigio needed to be global.  By moving that code here, those
can become static and the declarations moved from user_util.h.

os_check_bugs is also here because it only does the SIGIO checking.
If it does more, it'll probably move back to start_up.c.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/user_util.h |3 
 arch/um/os-Linux/sigio.c|  145 
 arch/um/os-Linux/start_up.c |  145 
 3 files changed, 145 insertions(+), 148 deletions(-)

Index: linux-2.6.21-mm/arch/um/os-Linux/start_up.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/start_up.c2007-03-21 
15:22:48.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/start_up.c 2007-03-21 15:24:33.0 
-0400
@@ -553,148 +553,3 @@ int __init parse_iomem(char *str, int *a
  out:
return 1;
 }
-
-
-/* Changed during early boot */
-int pty_output_sigio = 0;
-int pty_close_sigio = 0;
-
-/* Used as a flag during SIGIO testing early in boot */
-static volatile int got_sigio = 0;
-
-static void __init handler(int sig)
-{
-   got_sigio = 1;
-}
-
-struct openpty_arg {
-   int master;
-   int slave;
-   int err;
-};
-
-static void openpty_cb(void *arg)
-{
-   struct openpty_arg *info = arg;
-
-   info-err = 0;
-   if(openpty(info-master, info-slave, NULL, NULL, NULL))
-   info-err = -errno;
-}
-
-static int async_pty(int master, int slave)
-{
-   int flags;
-
-   flags = fcntl(master, F_GETFL);
-   if(flags  0)
-   return -errno;
-
-   if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC)  0) ||
-  (fcntl(master, F_SETOWN, os_getpid())  0))
-   return -errno;
-
-   if((fcntl(slave, F_SETFL, flags | O_NONBLOCK)  0))
-   return -errno;
-
-   return(0);
-}
-
-static void __init check_one_sigio(void (*proc)(int, int))
-{
-   struct sigaction old, new;
-   struct openpty_arg pty = { .master = -1, .slave = -1 };
-   int master, slave, err;
-
-   initial_thread_cb(openpty_cb, pty);
-   if(pty.err){
-   printk(openpty failed, errno = %d\n, -pty.err);
-   return;
-   }
-
-   master = pty.master;
-   slave = pty.slave;
-
-   if((master == -1) || (slave == -1)){
-   printk(openpty failed to allocate a pty\n);
-   return;
-   }
-
-   /* Not now, but complain so we now where we failed. */
-   err = raw(master);
-   if (err  0)
-   panic(check_sigio : __raw failed, errno = %d\n, -err);
-
-   err = async_pty(master, slave);
-   if(err  0)
-   panic(tty_fds : sigio_async failed, err = %d\n, -err);
-
-   if(sigaction(SIGIO, NULL, old)  0)
-   panic(check_sigio : sigaction 1 failed, errno = %d\n, errno);
-   new = old;
-   new.sa_handler = handler;
-   if(sigaction(SIGIO, new, NULL)  0)
-   panic(check_sigio : sigaction 2 failed, errno = %d\n, errno);
-
-   got_sigio = 0;
-   (*proc)(master, slave);
-
-   close(master);
-   close(slave);
-
-   if(sigaction(SIGIO, old, NULL)  0)
-   panic(check_sigio : sigaction 3 failed, errno = %d\n, errno);
-}
-
-static void tty_output(int master, int slave)
-{
-   int n;
-   char buf[512];
-
-   printk(Checking that host ptys support output SIGIO...);
-
-   memset(buf, 0, sizeof(buf));
-
-   while(os_write_file(master, buf, sizeof(buf))  0) ;
-   if(errno != EAGAIN)
-   panic(check_sigio : write failed, errno = %d\n, errno);
-   while(((n = os_read_file(slave, buf, sizeof(buf)))  0)  !got_sigio) ;
-
-   if(got_sigio){
-   printk(Yes\n);
-   pty_output_sigio = 1;
-   }
-   else if(n == -EAGAIN) printk(No, enabling workaround\n);
-   else panic(check_sigio : read failed, err = %d\n, n);
-}
-
-static void tty_close(int master, int slave)
-{
-   printk(Checking that host ptys support SIGIO on close...);
-
-   close(slave);
-   if(got_sigio){
-   printk(Yes\n);
-   pty_close_sigio = 1;
-   }
-   else printk(No, enabling workaround\n);
-}
-
-void __init check_sigio(void)
-{
-   if((os_access(/dev/ptmx, OS_ACC_R_OK)  0) 
-  (os_access(/dev/ptyp0, OS_ACC_R_OK)  0)){
-   printk(No pseudo-terminals available - skipping pty SIGIO 
-  check\n);
-   return;
-   }
-   check_one_sigio(tty_output);
-   check_one_sigio(tty_close);
-}
-
-void os_check_bugs(void)
-{
-   check_ptrace();
-   check_sigio();
-}
-
Index: linux-2.6.21-mm/arch/um/os-Linux/sigio.c
===
--- linux

[ PATCH 6/7 ] UML - Remove user_util.h

2007-03-22 Thread Jeff Dike
user_util.h isn't needed any more, so delete it and remove all
includes of it.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/chan_kern.c  |1 
 arch/um/drivers/chan_user.c  |1 
 arch/um/drivers/cow_sys.h|1 
 arch/um/drivers/daemon_user.c|1 
 arch/um/drivers/fd.c |1 
 arch/um/drivers/harddog_user.c   |1 
 arch/um/drivers/line.c   |1 
 arch/um/drivers/mcast_user.c |1 
 arch/um/drivers/mconsole_kern.c  |1 
 arch/um/drivers/mconsole_user.c  |1 
 arch/um/drivers/mmapper_kern.c   |1 
 arch/um/drivers/net_kern.c   |1 
 arch/um/drivers/net_user.c   |1 
 arch/um/drivers/port_user.c  |1 
 arch/um/drivers/pty.c|1 
 arch/um/drivers/slip_user.c  |1 
 arch/um/drivers/slirp_user.c |1 
 arch/um/drivers/ssl.c|1 
 arch/um/drivers/stdio_console.c  |1 
 arch/um/drivers/tty.c|1 
 arch/um/drivers/ubd_kern.c   |1 
 arch/um/drivers/ubd_user.c   |1 
 arch/um/drivers/xterm.c  |1 
 arch/um/include/user_util.h  |   32 ---
 arch/um/kernel/exec.c|1 
 arch/um/kernel/init_task.c   |1 
 arch/um/kernel/initrd.c  |1 
 arch/um/kernel/irq.c |1 
 arch/um/kernel/ksyms.c   |1 
 arch/um/kernel/mem.c |1 
 arch/um/kernel/physmem.c |1 
 arch/um/kernel/process.c |1 
 arch/um/kernel/reboot.c  |1 
 arch/um/kernel/signal.c  |1 
 arch/um/kernel/skas/process.c|1 
 arch/um/kernel/skas/tlb.c|1 
 arch/um/kernel/smp.c |1 
 arch/um/kernel/syscall.c |1 
 arch/um/kernel/sysrq.c   |1 
 arch/um/kernel/time.c|1 
 arch/um/kernel/tlb.c |1 
 arch/um/kernel/trap.c|1 
 arch/um/kernel/tt/exec_kern.c|1 
 arch/um/kernel/tt/exec_user.c|1 
 arch/um/kernel/tt/gdb.c  |1 
 arch/um/kernel/tt/mem.c  |1 
 arch/um/kernel/tt/mem_user.c |1 
 arch/um/kernel/tt/process_kern.c |1 
 arch/um/kernel/tt/ptproxy/proxy.c|1 
 arch/um/kernel/tt/ptproxy/ptrace.c   |1 
 arch/um/kernel/tt/ptproxy/sysdep.c   |1 
 arch/um/kernel/tt/ptproxy/wait.c |1 
 arch/um/kernel/tt/syscall_user.c |1 
 arch/um/kernel/tt/tlb.c  |1 
 arch/um/kernel/tt/tracer.c   |1 
 arch/um/kernel/tt/trap_user.c|1 
 arch/um/kernel/tt/uaccess_user.c |1 
 arch/um/kernel/um_arch.c |1 
 arch/um/os-Linux/drivers/ethertap_user.c |1 
 arch/um/os-Linux/drivers/tuntap_user.c   |1 
 arch/um/os-Linux/file.c  |1 
 arch/um/os-Linux/helper.c|1 
 arch/um/os-Linux/irq.c   |1 
 arch/um/os-Linux/main.c  |1 
 arch/um/os-Linux/mem.c   |1 
 arch/um/os-Linux/process.c   |1 
 arch/um/os-Linux/sigio.c |1 
 arch/um/os-Linux/signal.c|1 
 arch/um/os-Linux/skas/mem.c  |1 
 arch/um/os-Linux/skas/process.c  |1 
 arch/um/os-Linux/skas/trap.c |1 
 arch/um/os-Linux/start_up.c  |1 
 arch/um/os-Linux/sys-i386/tls.c  |1 
 arch/um/os-Linux/time.c  |1 
 arch/um/os-Linux/trap.c  |1 
 arch/um/os-Linux/tt.c|1 
 arch/um/os-Linux/util.c  |1 
 arch/um/sys-i386/bugs.c  |1 
 arch/um/sys-i386/ptrace_user.c   |1 
 arch/um/sys-ppc/sigcontext.c |1 
 80 files changed, 111 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/chan_kern.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_kern.c2007-03-21 
15:22:43.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_kern.c 2007-03-21 17:30:34.0 
-0400
@@ -12,7 +12,6 @@
 #include linux/tty_flip.h
 #include asm/irq.h
 #include chan_kern.h
-#include user_util.h
 #include kern.h
 #include irq_user.h
 #include sigio.h
Index: linux-2.6.21-mm/arch/um/drivers/chan_user.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/chan_user.c2007-03-21 
15:22:43.0 -0400
+++ linux-2.6.21-mm/arch/um/drivers/chan_user.c 2007-03-21 17:30:34.0 
-0400
@@ -14,7 +14,6 @@
 #include sys/ioctl.h

[ PATCH 5/7 ] UML - Move remaining useful contents of user_util.h

2007-03-22 Thread Jeff Dike
Rescue the useful contents of the soon-to-be-gone user-util.h.

pty.c now gets ptsname from stdlib.h like it should have always done.

CATCH_EINTR is now in os.h, although perhaps all usage should be under
os-Linux at some point.

get_pty is also in os.h.

This patch restores the old definition of ARRAY_SIZE in user.h.  This
file is included only in userspace files, so there will be no conflict
with the kernel's new ARRAY_SIZE.  The copy of the kernel's ARRAY_SIZE
and associated infrastructure is now gone.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/pty.c   |1 +
 arch/um/include/os.h|6 ++
 arch/um/include/user.h  |   19 ---
 arch/um/include/user_util.h |   18 --
 arch/um/os-Linux/sys-i386/tls.c |1 +
 5 files changed, 16 insertions(+), 29 deletions(-)

Index: linux-2.6.21-mm/arch/um/drivers/pty.c
===
--- linux-2.6.21-mm.orig/arch/um/drivers/pty.c  2007-03-22 11:18:21.0 
-0400
+++ linux-2.6.21-mm/arch/um/drivers/pty.c   2007-03-22 11:21:01.0 
-0400
@@ -4,6 +4,7 @@
  */
 
 #include stdio.h
+#include stdlib.h
 #include unistd.h
 #include string.h
 #include errno.h
Index: linux-2.6.21-mm/arch/um/include/os.h
===
--- linux-2.6.21-mm.orig/arch/um/include/os.h   2007-03-22 11:18:48.0 
-0400
+++ linux-2.6.21-mm/arch/um/include/os.h2007-03-22 11:21:01.0 
-0400
@@ -16,6 +16,8 @@
 #include sysdep/tls.h
 #include sysdep/archsetjmp.h
 
+#define CATCH_EINTR(expr) while ((errno = 0, ((expr)  0))  (errno == EINTR))
+
 #define OS_TYPE_FILE 1
 #define OS_TYPE_DIR 2
 #define OS_TYPE_SYMLINK 3
@@ -341,6 +343,10 @@ extern void maybe_sigio_broken(int fd, i
 extern void sig_handler_common_skas(int sig, void *sc_ptr);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
 
+/* sys-x86_64/prctl.c */
 extern int os_arch_prctl(int pid, int code, unsigned long *addr);
 
+/* tty.c */
+int get_pty(void);
+
 #endif
Index: linux-2.6.21-mm/arch/um/include/user.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user.h 2007-03-22 11:18:21.0 
-0400
+++ linux-2.6.21-mm/arch/um/include/user.h  2007-03-22 11:21:01.0 
-0400
@@ -6,6 +6,14 @@
 #ifndef __USER_H__
 #define __USER_H__
 
+/*
+ * The usual definition - copied here because the kernel provides its own,
+ * fancier, type-safe, definition.  Using that one would require
+ * copying too much infrastructure for my taste, so userspace files
+ * get less checking than kernel files.
+ */
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
 /* Both on kernelspace and userspace this will provide the size_t definition. 
It should, at
  * least. But on userspace it won't hurt surely. */
 #include linux/types.h
@@ -21,14 +29,3 @@ extern size_t strlcpy(char *, const char
 extern size_t strlcat(char *, const char *, size_t);
 
 #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.21-mm/arch/um/include/user_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user_util.h2007-03-22 
11:18:21.0 -0400
+++ linux-2.6.21-mm/arch/um/include/user_util.h 2007-03-22 11:21:01.0 
-0400
@@ -8,31 +8,13 @@
 
 #include sysdep/ptrace.h
 
-/* Copied from kernel.h and compiler-gcc.h */
-
-/* Force a compilation error if condition is true, but also produce a
-   result (of value 0 and type size_t), so the expression can be used
-   e.g. in a structure initializer (or where-ever else comma expressions
-   aren't permitted). */
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
-
-/* a[0] degrades to a pointer: a different type from an array */
-#define __must_be_array(a) \
-  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(a[0])))
-
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
-
-#define CATCH_EINTR(expr) while ((errno = 0, ((expr)  0))  (errno == EINTR))
-
 extern int mode_tt;
 
 extern int grantpt(int __fd);
 extern int unlockpt(int __fd);
-extern char *ptsname(int __fd);
 
 extern void *add_signal_handler(int sig, void (*handler)(int));
 extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
-extern int get_pty(void);
 extern int switcheroo(int fd, int prot, void *from, void *to, int size);
 extern void do_exec(int old_pid, int new_pid);
 extern void tracer_panic(char *msg, ...)
Index: linux-2.6.21-mm/arch/um/os-Linux/sys-i386/tls.c

[ PATCH 1/7 ] UML - Update UML definition of ARRAY_SIZE

2007-03-22 Thread Jeff Dike
This is the minimal change needed to keep UML building with the new
definition of ARRAY_SIZE.  It is defined in user_util.h so that
userspace files, which can't include kernel.h, can still use
ARRAY_SIZE.  However, since user_util.h is included everywhere,
including kernel files, the token sequence of the expansion has to
match.

This patch copies enough from the kernel headers to make that happen.

However, this is too gross to survive, and so is the entire header.
Future patches will make this header disappear, but this is a quick
and simple fix for the problem in case there is a noticable lag
between this patch and the more extensive patches which tidy this mess.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/user_util.h |   15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

Index: linux-2.6.21-mm/arch/um/include/user_util.h
===
--- linux-2.6.21-mm.orig/arch/um/include/user_util.h2007-03-21 
10:58:05.0 -0400
+++ linux-2.6.21-mm/arch/um/include/user_util.h 2007-03-21 11:05:44.0 
-0400
@@ -8,8 +8,19 @@
 
 #include sysdep/ptrace.h
 
-/* Copied from kernel.h */
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+/* Copied from kernel.h and compiler-gcc.h */
+
+/* Force a compilation error if condition is true, but also produce a
+   result (of value 0 and type size_t), so the expression can be used
+   e.g. in a structure initializer (or where-ever else comma expressions
+   aren't permitted). */
+#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
+
+/* a[0] degrades to a pointer: a different type from an array */
+#define __must_be_array(a) \
+  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(a[0])))
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 
 #define CATCH_EINTR(expr) while ((errno = 0, ((expr)  0))  (errno == EINTR))
 
-
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 7/7 ] UML - Add missing __init declarations

2007-03-22 Thread Jeff Dike
The build started finding calls from non-init to init functions.
These are just cases of init functions not being properly marked, so
this patch fixes that.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/kernel/mem.c|2 +-
 arch/um/os-Linux/main.c |2 +-
 arch/um/os-Linux/mem.c  |9 +
 arch/um/os-Linux/process.c  |5 +++--
 arch/um/os-Linux/start_up.c |4 ++--
 5 files changed, 12 insertions(+), 10 deletions(-)

Index: linux-2.6.21-mm/arch/um/kernel/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/kernel/mem.c   2007-03-20 21:36:47.0 
-0400
+++ linux-2.6.21-mm/arch/um/kernel/mem.c2007-03-20 21:37:11.0 
-0400
@@ -217,7 +217,7 @@ static void __init fixaddr_user_init( vo
 #endif
 }
 
-void paging_init(void)
+void __init paging_init(void)
 {
unsigned long zones_size[MAX_NR_ZONES], vaddr;
int i;
Index: linux-2.6.21-mm/arch/um/os-Linux/main.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/main.c2007-03-20 
21:36:47.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/main.c 2007-03-20 21:37:21.0 
-0400
@@ -120,7 +120,7 @@ extern int uml_exitcode;
 
 extern void scan_elf_aux( char **envp);
 
-int main(int argc, char **argv, char **envp)
+int __init main(int argc, char **argv, char **envp)
 {
char **new_argv;
int ret, i, err;
Index: linux-2.6.21-mm/arch/um/os-Linux/mem.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/mem.c 2007-03-20 21:36:47.0 
-0400
+++ linux-2.6.21-mm/arch/um/os-Linux/mem.c  2007-03-20 21:37:34.0 
-0400
@@ -164,7 +164,8 @@ found:
  * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger).
  * So it isn't 'static' yet.
  */
-int make_tempfile(const char *template, char **out_tempname, int do_unlink)
+int __init make_tempfile(const char *template, char **out_tempname,
+int do_unlink)
 {
char *tempname;
int fd;
@@ -205,7 +206,7 @@ out:
  * This proc is used in start_up.c
  * So it isn't 'static'.
  */
-int create_tmp_file(unsigned long long len)
+int __init create_tmp_file(unsigned long long len)
 {
int fd, err;
char zero;
@@ -241,7 +242,7 @@ int create_tmp_file(unsigned long long l
return fd;
 }
 
-int create_mem_file(unsigned long long len)
+int __init create_mem_file(unsigned long long len)
 {
int err, fd;
 
@@ -256,7 +257,7 @@ int create_mem_file(unsigned long long l
 }
 
 
-void check_tmpexec(void)
+void __init check_tmpexec(void)
 {
void *addr;
int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE);
Index: linux-2.6.21-mm/arch/um/os-Linux/process.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/process.c 2007-03-20 
21:36:47.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/process.c  2007-03-20 21:37:43.0 
-0400
@@ -21,6 +21,7 @@
 #include skas_ptrace.h
 #include kern_constants.h
 #include uml-config.h
+#include init.h
 
 #define ARBITRARY_ADDR -1
 #define FAILURE_PID-1
@@ -192,7 +193,7 @@ int os_unmap_memory(void *addr, int len)
 #define MADV_REMOVE KERNEL_MADV_REMOVE
 #endif
 
-int os_drop_memory(void *addr, int length)
+int __init os_drop_memory(void *addr, int length)
 {
int err;
 
@@ -202,7 +203,7 @@ int os_drop_memory(void *addr, int lengt
return err;
 }
 
-int can_drop_memory(void)
+int __init can_drop_memory(void)
 {
void *addr;
int fd, ok = 0;
Index: linux-2.6.21-mm/arch/um/os-Linux/start_up.c
===
--- linux-2.6.21-mm.orig/arch/um/os-Linux/start_up.c2007-03-20 
21:36:47.0 -0400
+++ linux-2.6.21-mm/arch/um/os-Linux/start_up.c 2007-03-20 21:37:57.0 
-0400
@@ -329,7 +329,7 @@ static void __init check_ptrace(void)
 
 extern void check_tmpexec(void);
 
-static void check_coredump_limit(void)
+static void __init check_coredump_limit(void)
 {
struct rlimit lim;
int err = getrlimit(RLIMIT_CORE, lim);
@@ -350,7 +350,7 @@ static void check_coredump_limit(void)
else printf(%lu\n, lim.rlim_max);
 }
 
-void os_early_checks(void)
+void __init os_early_checks(void)
 {
/* Print out the core dump limits early */
check_coredump_limit();
-
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 0/7 ] UML - Header cleanup

2007-03-22 Thread Jeff Dike
On Thu, Mar 22, 2007 at 09:50:34AM -0800, Andrew Morton wrote:
 I have the ARRAY_SIZE change queued for 2.6.22.
 
 It looks like the UML change needs to be folded into the same changeset to
 avoid build breaks?

Yes, that would be great.

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: [stable] [PATCH] UML - arch_prctl should set thread fs

2007-03-19 Thread Jeff Dike
On Fri, Mar 16, 2007 at 04:00:31PM -0700, Greg KH wrote:
> That's because it doesn't apply at all to the current 2.6.20.3 kernel
> tree.  Can you rediff it for that one so that we can apply it properly?

My apologies - that depended on a previous patch which I thought had
made it into -stable.  Below is a combination patch - I think larger
than normal for -stable, but a good part of it is non-code changes.

Jeff

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


x86_64 needs some TLS fixes.  What was missing was remembering the child
thread id during clone and stuffing it into the child during each context
switch.

The %fs value is stored separately in the thread structure since the host
controls what effect it has on the actual register file.  The host also needs
to store it in its own thread struct, so we need the value kept outside the
register file.

arch_prctl_skas was fixed to call PTRACE_ARCH_PRCTL appropriately.  There is
some saving and restoring of registers in the ARCH_SET_* cases so that the
correct set of registers are changed on the host and restored to the process
when it runs again.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/include/os.h |2 
 arch/um/os-Linux/sys-x86_64/Makefile |2 
 arch/um/os-Linux/sys-x86_64/prctl.c  |   12 +
 arch/um/sys-x86_64/syscalls.c|   76 ++-
 arch/um/sys-x86_64/tls.c |   11 +++--
 include/asm-um/processor-x86_64.h|6 +-
 include/asm-um/ptrace-x86_64.h   |6 --
 7 files changed, 86 insertions(+), 29 deletions(-)

Index: linux-2.6.20.3/arch/um/include/os.h
===
--- linux-2.6.20.3.orig/arch/um/include/os.h
+++ linux-2.6.20.3/arch/um/include/os.h
@@ -341,4 +341,6 @@ extern void maybe_sigio_broken(int fd, i
 extern void sig_handler_common_skas(int sig, void *sc_ptr);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
 
+extern int os_arch_prctl(int pid, int code, unsigned long *addr);
+
 #endif
Index: linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/Makefile
===
--- linux-2.6.20.3.orig/arch/um/os-Linux/sys-x86_64/Makefile
+++ linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/Makefile
@@ -3,7 +3,7 @@
 # Licensed under the GPL
 #
 
-obj-$(CONFIG_MODE_SKAS) = registers.o signal.o
+obj-$(CONFIG_MODE_SKAS) = registers.o prctl.o signal.o
 
 USER_OBJS := $(obj-y)
 
Index: linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/prctl.c
===
--- /dev/null
+++ linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/prctl.c
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel.com})
+ * Licensed under the GPL
+ */
+
+#include 
+#include 
+
+int os_arch_prctl(int pid, int code, unsigned long *addr)
+{
+   return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, code);
+}
Index: linux-2.6.20.3/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.20.3.orig/arch/um/sys-x86_64/syscalls.c
+++ linux-2.6.20.3/arch/um/sys-x86_64/syscalls.c
@@ -16,6 +16,7 @@
 #include "asm/prctl.h" /* XXX This should get the constants from libc */
 #include "choose-mode.h"
 #include "kern.h"
+#include "os.h"
 
 asmlinkage long sys_uname64(struct new_utsname __user * name)
 {
@@ -58,40 +59,70 @@ static long arch_prctl_tt(int code, unsi
 
 #ifdef CONFIG_MODE_SKAS
 
-/* XXX: Must also call arch_prctl in the host, beside saving the segment 
bases! */
-static long arch_prctl_skas(int code, unsigned long addr)
+static long arch_prctl_skas(int code, unsigned long __user *addr)
 {
-   long ret = 0;
+   unsigned long *ptr = addr, tmp;
+   long ret;
+   int pid = current->mm->context.skas.id.u.pid;
+
+   /*
+* With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to
+* be safe), we need to call arch_prctl on the host because
+* setting %fs may result in something else happening (like a
+* GDT being set instead).  So, we let the host fiddle the
+* registers and restore them afterwards.
+*
+* So, the saved registers are stored to the process (this
+* needed because a stub may have been the last thing to run),
+* arch_prctl is run on the host, then the registers are read
+* back.
+*/
+   switch(code){
+   case ARCH_SET_FS:
+   case ARCH_SET_GS:
+   restore_registers(pid, >thread.regs.regs);
+   break;
+   case ARCH_GET_FS:
+   case ARCH_GET_GS:
+   /*
+* With these two, we read to a local pointer and
+* put_user it to the userspace pointer that we were
+* given.  If addr isn't valid (because it hasn't been
+* faulted in or

Re: [stable] [PATCH] UML - arch_prctl should set thread fs

2007-03-19 Thread Jeff Dike
On Fri, Mar 16, 2007 at 04:00:31PM -0700, Greg KH wrote:
 That's because it doesn't apply at all to the current 2.6.20.3 kernel
 tree.  Can you rediff it for that one so that we can apply it properly?

My apologies - that depended on a previous patch which I thought had
made it into -stable.  Below is a combination patch - I think larger
than normal for -stable, but a good part of it is non-code changes.

Jeff

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


x86_64 needs some TLS fixes.  What was missing was remembering the child
thread id during clone and stuffing it into the child during each context
switch.

The %fs value is stored separately in the thread structure since the host
controls what effect it has on the actual register file.  The host also needs
to store it in its own thread struct, so we need the value kept outside the
register file.

arch_prctl_skas was fixed to call PTRACE_ARCH_PRCTL appropriately.  There is
some saving and restoring of registers in the ARCH_SET_* cases so that the
correct set of registers are changed on the host and restored to the process
when it runs again.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/include/os.h |2 
 arch/um/os-Linux/sys-x86_64/Makefile |2 
 arch/um/os-Linux/sys-x86_64/prctl.c  |   12 +
 arch/um/sys-x86_64/syscalls.c|   76 ++-
 arch/um/sys-x86_64/tls.c |   11 +++--
 include/asm-um/processor-x86_64.h|6 +-
 include/asm-um/ptrace-x86_64.h   |6 --
 7 files changed, 86 insertions(+), 29 deletions(-)

Index: linux-2.6.20.3/arch/um/include/os.h
===
--- linux-2.6.20.3.orig/arch/um/include/os.h
+++ linux-2.6.20.3/arch/um/include/os.h
@@ -341,4 +341,6 @@ extern void maybe_sigio_broken(int fd, i
 extern void sig_handler_common_skas(int sig, void *sc_ptr);
 extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
 
+extern int os_arch_prctl(int pid, int code, unsigned long *addr);
+
 #endif
Index: linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/Makefile
===
--- linux-2.6.20.3.orig/arch/um/os-Linux/sys-x86_64/Makefile
+++ linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/Makefile
@@ -3,7 +3,7 @@
 # Licensed under the GPL
 #
 
-obj-$(CONFIG_MODE_SKAS) = registers.o signal.o
+obj-$(CONFIG_MODE_SKAS) = registers.o prctl.o signal.o
 
 USER_OBJS := $(obj-y)
 
Index: linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/prctl.c
===
--- /dev/null
+++ linux-2.6.20.3/arch/um/os-Linux/sys-x86_64/prctl.c
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2007 Jeff Dike ([EMAIL PROTECTED],linux.intel.com})
+ * Licensed under the GPL
+ */
+
+#include sys/ptrace.h
+#include linux/ptrace.h
+
+int os_arch_prctl(int pid, int code, unsigned long *addr)
+{
+   return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, code);
+}
Index: linux-2.6.20.3/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.20.3.orig/arch/um/sys-x86_64/syscalls.c
+++ linux-2.6.20.3/arch/um/sys-x86_64/syscalls.c
@@ -16,6 +16,7 @@
 #include asm/prctl.h /* XXX This should get the constants from libc */
 #include choose-mode.h
 #include kern.h
+#include os.h
 
 asmlinkage long sys_uname64(struct new_utsname __user * name)
 {
@@ -58,40 +59,70 @@ static long arch_prctl_tt(int code, unsi
 
 #ifdef CONFIG_MODE_SKAS
 
-/* XXX: Must also call arch_prctl in the host, beside saving the segment 
bases! */
-static long arch_prctl_skas(int code, unsigned long addr)
+static long arch_prctl_skas(int code, unsigned long __user *addr)
 {
-   long ret = 0;
+   unsigned long *ptr = addr, tmp;
+   long ret;
+   int pid = current-mm-context.skas.id.u.pid;
+
+   /*
+* With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to
+* be safe), we need to call arch_prctl on the host because
+* setting %fs may result in something else happening (like a
+* GDT being set instead).  So, we let the host fiddle the
+* registers and restore them afterwards.
+*
+* So, the saved registers are stored to the process (this
+* needed because a stub may have been the last thing to run),
+* arch_prctl is run on the host, then the registers are read
+* back.
+*/
+   switch(code){
+   case ARCH_SET_FS:
+   case ARCH_SET_GS:
+   restore_registers(pid, current-thread.regs.regs);
+   break;
+   case ARCH_GET_FS:
+   case ARCH_GET_GS:
+   /*
+* With these two, we read to a local pointer and
+* put_user it to the userspace pointer that we were
+* given.  If addr isn't valid (because it hasn't been
+* faulted in or is just bogus), we want put_user

Re: [patch 4/6] mm: merge populate and nopage into fault (fixes nonlinear)

2007-03-18 Thread Jeff Dike
On Sun, Mar 18, 2007 at 03:50:10AM +0100, Nick Piggin wrote:
> Yes, that should be the case. So would this mean that nonlinear protections
> don't work on regular files? I guess that's OK if Oracle and UML both use
> tmpfs/shm?

It's OK for UML.

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 4/6] mm: merge populate and nopage into fault (fixes nonlinear)

2007-03-18 Thread Jeff Dike
On Sun, Mar 18, 2007 at 03:50:10AM +0100, Nick Piggin wrote:
 Yes, that should be the case. So would this mean that nonlinear protections
 don't work on regular files? I guess that's OK if Oracle and UML both use
 tmpfs/shm?

It's OK for UML.

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] UML utrace support, step 1

2007-03-16 Thread Jeff Dike
On Wed, Mar 07, 2007 at 12:01:59AM -0800, Roland McGrath wrote:
> > Below is a tracehook patch for UML which goes right after
> > utrace-utrace-tracehook.patch.
> 
> It does not.  That patch has regset and ptrace stuff in it.  It indeed
> applies fine before or after utrace patches.  But it doesn't close to
> compile without utrace-regset.patch and utrace-core.patch applied,
> and even with utrace-ptrace-compat.patch it still doesn't compile for me
> with a lot of complaints about TIF_SINGLESTEP not being defined where
> it's used in asm/tracehook.h.

Did I send the right patch?  The one I meant to send (appended below),
indeed builds and runs without utrace-regset.patch and
utrace-core.patch applied.  It's utrace-1 in the following:

+ utrace-prep.patch
+ utrace-prep-2.patch
+ utrace-utrace-tracehook.patch
= utrace-1
  utrace-utrace-tracehook-ia64.patch
  utrace-utrace-tracehook-sparc64.patch
  utrace-utrace-tracehook-s390.patch
  utrace-utrace-regset.patch
  utrace-utrace-regset-ia64.patch
  utrace-utrace-regset-sparc64.patch
  utrace-utrace-regset-s390.patch
  utrace-utrace-core.patch
  utrace-utrace-ptrace-compat.patch
  utrace-utrace-ptrace-compat-ia64.patch
  utrace-utrace-ptrace-compat-sparc64.patch
  utrace-utrace-ptrace-compat-s390.patch
  revert-utrace-prep-2.patch
  utrace-vs-reduce-size-of-task_struct-on-64-bit-machines.patch

Jeff

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



This is the tracehook part of the UML utrace work, enough to get UML
building with the utrace prep patches applied.

Checks of task->ptrace & PT_DTRACE were replaced with
test_thread_flag(TIF_SINGLESTEP, or removed, in the case of execve.

Most of arch/um/kernel/ptrace.c is gone, to be reinstated in future
utrace work.

Similarly, calls to syscall_trace and ptrace notifications in the
signal delivery code are gone. 

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/kernel/exec.c   |1 
 arch/um/kernel/process.c|6 
 arch/um/kernel/ptrace.c |  333 +---
 arch/um/kernel/signal.c |5 
 arch/um/kernel/skas/syscall.c   |4 
 arch/um/sys-i386/signal.c   |4 
 include/asm-um/ptrace-generic.h |3 
 include/asm-um/ptrace-i386.h|2 
 include/asm-um/ptrace-x86_64.h  |2 
 include/asm-um/tracehook.h  |   64 +++
 10 files changed, 117 insertions(+), 307 deletions(-)

Index: linux-2.6.21-rc2/arch/um/kernel/exec.c
===
--- linux-2.6.21-rc2.orig/arch/um/kernel/exec.c 2007-03-05 13:24:49.0 
-0500
+++ linux-2.6.21-rc2/arch/um/kernel/exec.c  2007-03-05 13:24:57.0 
-0500
@@ -51,7 +51,6 @@ static long execve1(char *file, char __u
 error = do_execve(file, argv, env, >thread.regs);
 if (error == 0){
task_lock(current);
-current->ptrace &= ~PT_DTRACE;
 #ifdef SUBARCH_EXECVE1
SUBARCH_EXECVE1(>thread.regs.regs);
 #endif
Index: linux-2.6.21-rc2/arch/um/kernel/process.c
===
--- linux-2.6.21-rc2.orig/arch/um/kernel/process.c  2007-03-05 
13:24:49.0 -0500
+++ linux-2.6.21-rc2/arch/um/kernel/process.c   2007-03-05 13:24:57.0 
-0500
@@ -458,11 +458,11 @@ int singlestepping(void * t)
 {
struct task_struct *task = t ? t : current;
 
-   if ( ! (task->ptrace & PT_DTRACE) )
-   return(0);
+   if (!test_thread_flag(TIF_SINGLESTEP))
+   return 0;
 
if (task->thread.singlestep_syscall)
-   return(1);
+   return 1;
 
return 2;
 }
Index: linux-2.6.21-rc2/arch/um/kernel/ptrace.c
===
--- linux-2.6.21-rc2.orig/arch/um/kernel/ptrace.c   2007-03-05 
13:24:49.0 -0500
+++ linux-2.6.21-rc2/arch/um/kernel/ptrace.c2007-03-05 13:47:30.0 
-0500
@@ -3,261 +3,26 @@
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "linux/errno.h"
-#include "linux/smp_lock.h"
-#include "linux/security.h"
-#include "linux/ptrace.h"
-#include "linux/audit.h"
-#ifdef CONFIG_PROC_MM
-#include "linux/proc_mm.h"
-#endif
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
-#include "skas_ptrace.h"
-#include "sysdep/ptrace.h"
-#include "os.h"
-
-static inline void set_singlestepping(struct task_struct *child, int on)
-{
-if (on)
-child->ptrace |= PT_DTRACE;
-else
-child->ptrace &= ~PT_DTR

[PATCH] UML - arch_prctl should set thread fs

2007-03-16 Thread Jeff Dike
[ This missed getting into -stable the first time I sent it ]

In my previous x86_64 thread fix, I forgot to initialize
thread.arch.fs in arch_prctl.  A process calling arch_prctl to set %fs
would lose it on the next context switch.

It also turns out that you can switch to a process which is in the
process of exiting and which has lost its mm.  In this case, it's
worse than useless to try to call arch_prctl on the host process. 

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/sys-x86_64/syscalls.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6.17/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.17.orig/arch/um/sys-x86_64/syscalls.c 2007-03-07 
12:18:38.0 -0500
+++ linux-2.6.17/arch/um/sys-x86_64/syscalls.c  2007-03-16 12:04:40.0 
-0400
@@ -103,6 +103,9 @@ long arch_prctl_skas(struct task_struct 
 
 switch(code){
case ARCH_SET_FS:
+   current->thread.arch.fs = (unsigned long) ptr;
+   save_registers(pid, >thread.regs.regs);
+   break;
case ARCH_SET_GS:
 save_registers(pid, >thread.regs.regs);
break;
@@ -140,9 +143,8 @@ long sys_clone(unsigned long clone_flags
 
 void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
 {
-if(to->thread.arch.fs == 0)
+if((to->thread.arch.fs == 0) || (to->mm == NULL))
 return;
 
 arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
 }
-
-
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] USER-MODE LINUX: Delete unused header file.

2007-03-16 Thread Jeff Dike
On Sat, Mar 10, 2007 at 04:27:30PM -0500, Robert P. J. Day wrote:
> 
>   Delete the apparently unused header file
> arch/um/kernel/tt/include/mode_kern-tt.h.
> 
> Signed-off-by: Robert P. J. Day <[EMAIL PROTECTED]>

ACK

>   this one i'm not so sure about as there is a header file named
> "mode_kern_tt.h", and those names are uncomfortably similar.

There was a renaming because I was annoyed by the mix of '-' amd '_'
in the name, but somehow I missed deleting the old file.

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] USER-MODE LINUX: Delete unused header file.

2007-03-16 Thread Jeff Dike
On Sat, Mar 10, 2007 at 04:27:30PM -0500, Robert P. J. Day wrote:
 
   Delete the apparently unused header file
 arch/um/kernel/tt/include/mode_kern-tt.h.
 
 Signed-off-by: Robert P. J. Day [EMAIL PROTECTED]

ACK

   this one i'm not so sure about as there is a header file named
 mode_kern_tt.h, and those names are uncomfortably similar.

There was a renaming because I was annoyed by the mix of '-' amd '_'
in the name, but somehow I missed deleting the old file.

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] UML utrace support, step 1

2007-03-16 Thread Jeff Dike
On Wed, Mar 07, 2007 at 12:01:59AM -0800, Roland McGrath wrote:
  Below is a tracehook patch for UML which goes right after
  utrace-utrace-tracehook.patch.
 
 It does not.  That patch has regset and ptrace stuff in it.  It indeed
 applies fine before or after utrace patches.  But it doesn't close to
 compile without utrace-regset.patch and utrace-core.patch applied,
 and even with utrace-ptrace-compat.patch it still doesn't compile for me
 with a lot of complaints about TIF_SINGLESTEP not being defined where
 it's used in asm/tracehook.h.

Did I send the right patch?  The one I meant to send (appended below),
indeed builds and runs without utrace-regset.patch and
utrace-core.patch applied.  It's utrace-1 in the following:

+ utrace-prep.patch
+ utrace-prep-2.patch
+ utrace-utrace-tracehook.patch
= utrace-1
  utrace-utrace-tracehook-ia64.patch
  utrace-utrace-tracehook-sparc64.patch
  utrace-utrace-tracehook-s390.patch
  utrace-utrace-regset.patch
  utrace-utrace-regset-ia64.patch
  utrace-utrace-regset-sparc64.patch
  utrace-utrace-regset-s390.patch
  utrace-utrace-core.patch
  utrace-utrace-ptrace-compat.patch
  utrace-utrace-ptrace-compat-ia64.patch
  utrace-utrace-ptrace-compat-sparc64.patch
  utrace-utrace-ptrace-compat-s390.patch
  revert-utrace-prep-2.patch
  utrace-vs-reduce-size-of-task_struct-on-64-bit-machines.patch

Jeff

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



This is the tracehook part of the UML utrace work, enough to get UML
building with the utrace prep patches applied.

Checks of task-ptrace  PT_DTRACE were replaced with
test_thread_flag(TIF_SINGLESTEP, or removed, in the case of execve.

Most of arch/um/kernel/ptrace.c is gone, to be reinstated in future
utrace work.

Similarly, calls to syscall_trace and ptrace notifications in the
signal delivery code are gone. 

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/kernel/exec.c   |1 
 arch/um/kernel/process.c|6 
 arch/um/kernel/ptrace.c |  333 +---
 arch/um/kernel/signal.c |5 
 arch/um/kernel/skas/syscall.c   |4 
 arch/um/sys-i386/signal.c   |4 
 include/asm-um/ptrace-generic.h |3 
 include/asm-um/ptrace-i386.h|2 
 include/asm-um/ptrace-x86_64.h  |2 
 include/asm-um/tracehook.h  |   64 +++
 10 files changed, 117 insertions(+), 307 deletions(-)

Index: linux-2.6.21-rc2/arch/um/kernel/exec.c
===
--- linux-2.6.21-rc2.orig/arch/um/kernel/exec.c 2007-03-05 13:24:49.0 
-0500
+++ linux-2.6.21-rc2/arch/um/kernel/exec.c  2007-03-05 13:24:57.0 
-0500
@@ -51,7 +51,6 @@ static long execve1(char *file, char __u
 error = do_execve(file, argv, env, current-thread.regs);
 if (error == 0){
task_lock(current);
-current-ptrace = ~PT_DTRACE;
 #ifdef SUBARCH_EXECVE1
SUBARCH_EXECVE1(current-thread.regs.regs);
 #endif
Index: linux-2.6.21-rc2/arch/um/kernel/process.c
===
--- linux-2.6.21-rc2.orig/arch/um/kernel/process.c  2007-03-05 
13:24:49.0 -0500
+++ linux-2.6.21-rc2/arch/um/kernel/process.c   2007-03-05 13:24:57.0 
-0500
@@ -458,11 +458,11 @@ int singlestepping(void * t)
 {
struct task_struct *task = t ? t : current;
 
-   if ( ! (task-ptrace  PT_DTRACE) )
-   return(0);
+   if (!test_thread_flag(TIF_SINGLESTEP))
+   return 0;
 
if (task-thread.singlestep_syscall)
-   return(1);
+   return 1;
 
return 2;
 }
Index: linux-2.6.21-rc2/arch/um/kernel/ptrace.c
===
--- linux-2.6.21-rc2.orig/arch/um/kernel/ptrace.c   2007-03-05 
13:24:49.0 -0500
+++ linux-2.6.21-rc2/arch/um/kernel/ptrace.c2007-03-05 13:47:30.0 
-0500
@@ -3,261 +3,26 @@
  * Licensed under the GPL
  */
 
-#include linux/sched.h
-#include linux/mm.h
-#include linux/errno.h
-#include linux/smp_lock.h
-#include linux/security.h
-#include linux/ptrace.h
-#include linux/audit.h
-#ifdef CONFIG_PROC_MM
-#include linux/proc_mm.h
-#endif
-#include asm/ptrace.h
-#include asm/uaccess.h
-#include kern_util.h
-#include skas_ptrace.h
-#include sysdep/ptrace.h
-#include os.h
-
-static inline void set_singlestepping(struct task_struct *child, int on)
-{
-if (on)
-child-ptrace |= PT_DTRACE;
-else
-child-ptrace = ~PT_DTRACE;
-child-thread.singlestep_syscall = 0;
-
-#ifdef SUBARCH_SET_SINGLESTEPPING
-SUBARCH_SET_SINGLESTEPPING(child, on);
-#endif
-}
+#include linux/audit.h
+#include linux/elf.h
+#include linux/module.h
+#include linux/ptrace.h
+#include

[PATCH] UML - arch_prctl should set thread fs

2007-03-16 Thread Jeff Dike
[ This missed getting into -stable the first time I sent it ]

In my previous x86_64 thread fix, I forgot to initialize
thread.arch.fs in arch_prctl.  A process calling arch_prctl to set %fs
would lose it on the next context switch.

It also turns out that you can switch to a process which is in the
process of exiting and which has lost its mm.  In this case, it's
worse than useless to try to call arch_prctl on the host process. 

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/sys-x86_64/syscalls.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6.17/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.17.orig/arch/um/sys-x86_64/syscalls.c 2007-03-07 
12:18:38.0 -0500
+++ linux-2.6.17/arch/um/sys-x86_64/syscalls.c  2007-03-16 12:04:40.0 
-0400
@@ -103,6 +103,9 @@ long arch_prctl_skas(struct task_struct 
 
 switch(code){
case ARCH_SET_FS:
+   current-thread.arch.fs = (unsigned long) ptr;
+   save_registers(pid, current-thread.regs.regs);
+   break;
case ARCH_SET_GS:
 save_registers(pid, current-thread.regs.regs);
break;
@@ -140,9 +143,8 @@ long sys_clone(unsigned long clone_flags
 
 void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
 {
-if(to-thread.arch.fs == 0)
+if((to-thread.arch.fs == 0) || (to-mm == NULL))
 return;
 
 arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to-thread.arch.fs);
 }
-
-
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 - arch_prctl should set thread fs

2007-03-07 Thread Jeff Dike
[ Andrew, this is definite 2.6.21 material ]

In my previous x86_64 thread fix, I forgot to initialize
thread.arch.fs in arch_prctl.  A process calling arch_prctl to set %fs
would lose it on the next context switch.

It also turns out that you can switch to a process which is in the
process of exiting and which has lost its mm.  In this case, it's
worse than useless to try to call arch_prctl on the host process.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/sys-x86_64/syscalls.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6.18-mm/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.18-mm.orig/arch/um/sys-x86_64/syscalls.c  2007-03-07 
12:05:02.0 -0500
+++ linux-2.6.18-mm/arch/um/sys-x86_64/syscalls.c   2007-03-07 
14:01:16.0 -0500
@@ -103,6 +103,9 @@ long arch_prctl_skas(struct task_struct 
 
 switch(code){
case ARCH_SET_FS:
+   current->thread.arch.fs = (unsigned long) ptr;
+   save_registers(pid, >thread.regs.regs);
+   break;
case ARCH_SET_GS:
 save_registers(pid, >thread.regs.regs);
break;
@@ -140,9 +143,8 @@ long sys_clone(unsigned long clone_flags
 
 void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
 {
-if(to->thread.arch.fs == 0)
+if((to->thread.arch.fs == 0) || (to->mm == NULL))
 return;
 
 arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
 }
-
-
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 4/5] UML - driver formatting fixes

2007-03-07 Thread Jeff Dike
On Tue, Mar 06, 2007 at 08:07:16PM +0100, Blaisorblade wrote:
> The second line should better say -err instead of err.

Right, patch below.

Jeff

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


My last formatting patch got the sign of an error wrong in a printk.

Thanks to Blaisorblade for the close look.

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

Index: test/arch/um/drivers/chan_user.c
===
--- test.orig/arch/um/drivers/chan_user.c   2007-03-06 12:10:12.0 
-0500
+++ test/arch/um/drivers/chan_user.c2007-03-07 11:14:12.0 -0500
@@ -158,7 +158,7 @@ static int winch_tramp(int fd, struct tt
 */
err = run_helper_thread(winch_thread, , CLONE_FILES, , 0);
if(err < 0){
-   printk("fork of winch_thread failed - errno = %d\n", err);
+   printk("fork of winch_thread failed - errno = %d\n", -err);
goto out_close;
}
 
-
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 4/6] mm: merge populate and nopage into fault (fixes nonlinear)

2007-03-07 Thread Jeff Dike
On Wed, Mar 07, 2007 at 02:52:12PM +0100, Peter Zijlstra wrote:
> > Well I don't think UML uses nonlinear yet anyway, does it? Can they
> > make do with restricting nonlinear to mlocked vmas, I wonder? Probably
> > not.
> 
> I think it does, but lets ask, Jeff?

Nope, UML needs to be able to change permissions as well as locations.

Would be nice, though, there are apparently nice UML speedups with 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: [patch 4/6] mm: merge populate and nopage into fault (fixes nonlinear)

2007-03-07 Thread Jeff Dike
On Wed, Mar 07, 2007 at 02:52:12PM +0100, Peter Zijlstra wrote:
  Well I don't think UML uses nonlinear yet anyway, does it? Can they
  make do with restricting nonlinear to mlocked vmas, I wonder? Probably
  not.
 
 I think it does, but lets ask, Jeff?

Nope, UML needs to be able to change permissions as well as locations.

Would be nice, though, there are apparently nice UML speedups with 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/


[PATCH] UML - arch_prctl should set thread fs

2007-03-07 Thread Jeff Dike
[ Andrew, this is definite 2.6.21 material ]

In my previous x86_64 thread fix, I forgot to initialize
thread.arch.fs in arch_prctl.  A process calling arch_prctl to set %fs
would lose it on the next context switch.

It also turns out that you can switch to a process which is in the
process of exiting and which has lost its mm.  In this case, it's
worse than useless to try to call arch_prctl on the host process.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/sys-x86_64/syscalls.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6.18-mm/arch/um/sys-x86_64/syscalls.c
===
--- linux-2.6.18-mm.orig/arch/um/sys-x86_64/syscalls.c  2007-03-07 
12:05:02.0 -0500
+++ linux-2.6.18-mm/arch/um/sys-x86_64/syscalls.c   2007-03-07 
14:01:16.0 -0500
@@ -103,6 +103,9 @@ long arch_prctl_skas(struct task_struct 
 
 switch(code){
case ARCH_SET_FS:
+   current-thread.arch.fs = (unsigned long) ptr;
+   save_registers(pid, current-thread.regs.regs);
+   break;
case ARCH_SET_GS:
 save_registers(pid, current-thread.regs.regs);
break;
@@ -140,9 +143,8 @@ long sys_clone(unsigned long clone_flags
 
 void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
 {
-if(to-thread.arch.fs == 0)
+if((to-thread.arch.fs == 0) || (to-mm == NULL))
 return;
 
 arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to-thread.arch.fs);
 }
-
-
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 4/5] UML - driver formatting fixes

2007-03-07 Thread Jeff Dike
On Tue, Mar 06, 2007 at 08:07:16PM +0100, Blaisorblade wrote:
 The second line should better say -err instead of err.

Right, patch below.

Jeff

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


My last formatting patch got the sign of an error wrong in a printk.

Thanks to Blaisorblade for the close look.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/chan_user.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: test/arch/um/drivers/chan_user.c
===
--- test.orig/arch/um/drivers/chan_user.c   2007-03-06 12:10:12.0 
-0500
+++ test/arch/um/drivers/chan_user.c2007-03-07 11:14:12.0 -0500
@@ -158,7 +158,7 @@ static int winch_tramp(int fd, struct tt
 */
err = run_helper_thread(winch_thread, data, CLONE_FILES, stack, 0);
if(err  0){
-   printk(fork of winch_thread failed - errno = %d\n, err);
+   printk(fork of winch_thread failed - errno = %d\n, -err);
goto out_close;
}
 
-
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 - driver formatting fixes

2007-03-06 Thread Jeff Dike
Fix a bunch of formatting violations in the drivers:
return(n) -> return n
whitespace fixes
emacs formatting comment removal
breaking if(foo) return(n) into two lines

There are also a couple of errno use bugs:
using errno in a printk when the failure put errno into a local variable
saving errno after a printk, which can change it

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/chan_user.c  |2 -
 arch/um/drivers/daemon_user.c|   25 +--
 arch/um/drivers/mcast_user.c |   12 -
 arch/um/drivers/pcap_user.c  |   33 -
 arch/um/drivers/ubd_user.c   |   15 +--
 arch/um/os-Linux/drivers/ethertap_user.c |   36 ++-
 arch/um/os-Linux/drivers/tuntap_user.c   |   40 ---
 7 files changed, 57 insertions(+), 106 deletions(-)

Index: test/arch/um/drivers/daemon_user.c
===
--- test.orig/arch/um/drivers/daemon_user.c 2007-03-06 12:09:47.0 
-0500
+++ test/arch/um/drivers/daemon_user.c  2007-03-06 12:10:12.0 -0500
@@ -39,11 +39,11 @@ static struct sockaddr_un *new_addr(void
sun = um_kmalloc(sizeof(struct sockaddr_un));
if(sun == NULL){
printk("new_addr: allocation of sockaddr_un failed\n");
-   return(NULL);
+   return NULL;
}
sun->sun_family = AF_UNIX;
memcpy(sun->sun_path, name, len);
-   return(sun);
+   return sun;
 }
 
 static int connect_to_switch(struct daemon_data *pri)
@@ -112,7 +112,7 @@ static int connect_to_switch(struct daem
}
 
pri->data_addr = sun;
-   return(fd);
+   return fd;
 
  out_free:
kfree(sun);
@@ -120,7 +120,7 @@ static int connect_to_switch(struct daem
os_close_file(fd);
  out:
os_close_file(pri->control);
-   return(err);
+   return err;
 }
 
 static void daemon_user_init(void *data, void *dev)
@@ -152,7 +152,7 @@ static void daemon_user_init(void *data,
 static int daemon_open(void *data)
 {
struct daemon_data *pri = data;
-   return(pri->fd);
+   return pri->fd;
 }
 
 static void daemon_remove(void *data)
@@ -176,12 +176,12 @@ int daemon_user_write(int fd, void *buf,
 {
struct sockaddr_un *data_addr = pri->data_addr;
 
-   return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
+   return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
 }
 
 static int daemon_set_mtu(int mtu, void *data)
 {
-   return(mtu);
+   return mtu;
 }
 
 const struct net_user_info daemon_user_info = {
@@ -194,14 +194,3 @@ const struct net_user_info daemon_user_i
.delete_address = NULL,
.max_packet = MAX_PACKET - ETH_HEADER_OTHER
 };
-
-/*
- * 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: test/arch/um/drivers/mcast_user.c
===
--- test.orig/arch/um/drivers/mcast_user.c  2007-03-06 12:09:45.0 
-0500
+++ test/arch/um/drivers/mcast_user.c   2007-03-06 12:09:57.0 -0500
@@ -34,12 +34,12 @@ static struct sockaddr_in *new_addr(char
sin = um_kmalloc(sizeof(struct sockaddr_in));
if(sin == NULL){
printk("new_addr: allocation of sockaddr_in failed\n");
-   return(NULL);
+   return NULL;
}
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = in_aton(addr);
sin->sin_port = htons(port);
-   return(sin);
+   return sin;
 }
 
 static void mcast_user_init(void *data, void *dev)
@@ -107,8 +107,8 @@ static int mcast_open(void *data)
err = -errno;
printk("mcast_open : data bind failed, errno = %d\n", errno);
goto out_close;
-   }   
-   
+   }
+
/* subscribe to the multicast group */
mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr;
mreq.imr_interface.s_addr = 0;
@@ -153,12 +153,12 @@ int mcast_user_write(int fd, void *buf, 
 {
struct sockaddr_in *data_addr = pri->mcast_addr;
 
-   return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
+   return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
 }
 
 static int mcast_set_mtu(int mtu, void *data)
 {
-   return(mtu);
+   return mtu;
 }
 
 const struct net_user_info mcast_user_info = {
Index: test/arch/um/drivers/pcap_user.c

[PATCH 3/5] UML - handle block device hotplug errors

2007-03-06 Thread Jeff Dike
If a disk fails to open, i.e. its host file doesn't exist, it won't
be removable because the hot-unplug code checks the existence of its
gendisk.  This won't exist because it is only allocated for
successfully opened disks.  Thus, a typo on the command line can
result in a unusable and unfixable disk.

This is fixed by freeing the gendisk if it's there, but not letting
that affect the removal.

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

Index: test/arch/um/drivers/ubd_kern.c
===
--- test.orig/arch/um/drivers/ubd_kern.c2007-03-05 13:14:50.0 
-0500
+++ test/arch/um/drivers/ubd_kern.c 2007-03-05 13:40:13.0 -0500
@@ -790,14 +790,12 @@ static int ubd_id(char **str, int *start
 
 static int ubd_remove(int n, char **error_out)
 {
+   struct gendisk *disk;
struct ubd *ubd_dev;
int err = -ENODEV;
 
mutex_lock(_lock);
 
-   if(ubd_gendisk[n] == NULL)
-   goto out;
-
ubd_dev = _devs[n];
 
if(ubd_dev->file == NULL)
@@ -808,9 +806,12 @@ static int ubd_remove(int n, char **erro
if(ubd_dev->count > 0)
goto out;
 
-   del_gendisk(ubd_gendisk[n]);
-   put_disk(ubd_gendisk[n]);
-   ubd_gendisk[n] = NULL;
+   disk = ubd_gendisk[n];
+   ubd_gendisk[n] = NULL;
+   if(disk != NULL){
+   del_gendisk(disk);
+   put_disk(disk);
+   }
 
if(fake_gendisk[n] != NULL){
del_gendisk(fake_gendisk[n]);

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


[PATCH 0/5] UML - hotplug fixes and cleanup

2007-03-06 Thread Jeff Dike
These patches can wait till after 2.6.21.

Three of them are tidying patches of various sorts.  The other two fix
network interface and block device hotplug bugs.

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/


[PATCH 2/5] UML - print coredump limits

2007-03-06 Thread Jeff Dike
Print out core dump limits at boot time.  This is to allow core dumps
to be collected if something goes very wrong and to tell if a core
dump isn't going to happen because of a resource limit.

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

Index: test/arch/um/os-Linux/start_up.c
===
--- test.orig/arch/um/os-Linux/start_up.c   2007-03-06 10:21:43.0 
-0500
+++ test/arch/um/os-Linux/start_up.c2007-03-06 10:43:02.0 -0500
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -329,8 +330,32 @@ static void __init check_ptrace(void)
 
 extern void check_tmpexec(void);
 
+static void check_coredump_limit(void)
+{
+   struct rlimit lim;
+   int err = getrlimit(RLIMIT_CORE, );
+
+   if(err){
+   perror("Getting core dump limit");
+   return;
+   }
+
+   printf("Core dump limits :\n\tsoft - ");
+   if(lim.rlim_cur == RLIM_INFINITY)
+   printf("NONE\n");
+   else printf("%lu\n", lim.rlim_cur);
+
+   printf("\thard - ");
+   if(lim.rlim_max == RLIM_INFINITY)
+   printf("NONE\n");
+   else printf("%lu\n", lim.rlim_max);
+}
+
 void os_early_checks(void)
 {
+   /* Print out the core dump limits early */
+   check_coredump_limit();
+
check_ptrace();
 
/* Need to check this early because mmapping happens before the

-
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/5] UML - Mark tt-mode code for future removal

2007-03-06 Thread Jeff Dike
Mark some tt-mode-only code as such.

Also cleaned up some formatting.

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

Index: linux-2.6.18-mm/arch/um/sys-i386/ptrace_user.c
===
--- linux-2.6.18-mm.orig/arch/um/sys-i386/ptrace_user.c 2007-03-02 
21:18:13.0 -0500
+++ linux-2.6.18-mm/arch/um/sys-i386/ptrace_user.c  2007-03-02 
21:23:19.0 -0500
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2002 Jeff Dike ([EMAIL PROTECTED])
  * Licensed under the GPL
  */
@@ -45,7 +45,8 @@ int ptrace_setfpregs(long pid, unsigned 
return 0;
 }
 
-/* All the below stuff is of interest for TT mode only */
+#ifdef UML_CONFIG_MODE_TT
+
 static void write_debugregs(int pid, unsigned long *regs)
 {
struct user *dummy;
@@ -128,13 +129,4 @@ void update_debugregs(int seq)
 }
 #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:
- */
+#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 5/5] UML - network interface hotplug error handling

2007-03-06 Thread Jeff Dike
This fixes a number of problems associated with network interface hotplug.

The userspace initialization function can fail in some cases, but the
failure was never passed back to eth_configure, which proceeded with
the configuration.  This results in a zombie device that is present,
but can't work.  This is fixed by allowing the initialization routines
to return an error, which is checked, and the configuration aborted on
failure.

eth_configure failed to check for many failures. Even when it did
check, it didn't undo whatever initializations has already happened,
so a present, but partially initialized and non-working device could
result.  It now checks everything that can fail, and bails out,
undoing whatever had been done.

The return value of eth_configure was always ignored, so it is now
just void.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/drivers/daemon_user.c|5 +
 arch/um/drivers/mcast_user.c |3 -
 arch/um/drivers/net_kern.c   |   81 +--
 arch/um/drivers/pcap_user.c  |5 +
 arch/um/drivers/slip_user.c  |3 -
 arch/um/drivers/slirp_user.c |3 -
 arch/um/include/net_user.h   |2 
 arch/um/os-Linux/drivers/ethertap_user.c |3 -
 arch/um/os-Linux/drivers/tuntap_user.c   |3 -
 9 files changed, 64 insertions(+), 44 deletions(-)

Index: test/arch/um/drivers/daemon_user.c
===
--- test.orig/arch/um/drivers/daemon_user.c 2007-03-06 12:10:12.0 
-0500
+++ test/arch/um/drivers/daemon_user.c  2007-03-06 12:14:45.0 -0500
@@ -123,7 +123,7 @@ static int connect_to_switch(struct daem
return err;
 }
 
-static void daemon_user_init(void *data, void *dev)
+static int daemon_user_init(void *data, void *dev)
 {
struct daemon_data *pri = data;
struct timeval tv;
@@ -146,7 +146,10 @@ static void daemon_user_init(void *data,
if(pri->fd < 0){
kfree(pri->local_addr);
pri->local_addr = NULL;
+   return pri->fd;
}
+
+   return 0;
 }
 
 static int daemon_open(void *data)
Index: test/arch/um/drivers/mcast_user.c
===
--- test.orig/arch/um/drivers/mcast_user.c  2007-03-06 12:09:57.0 
-0500
+++ test/arch/um/drivers/mcast_user.c   2007-03-06 12:14:45.0 -0500
@@ -42,12 +42,13 @@ static struct sockaddr_in *new_addr(char
return sin;
 }
 
-static void mcast_user_init(void *data, void *dev)
+static int mcast_user_init(void *data, void *dev)
 {
struct mcast_data *pri = data;
 
pri->mcast_addr = new_addr(pri->addr, pri->port);
pri->dev = dev;
+   return 0;
 }
 
 static void mcast_remove(void *data)
Index: test/arch/um/drivers/net_kern.c
===
--- test.orig/arch/um/drivers/net_kern.c2007-03-06 12:03:02.0 
-0500
+++ test/arch/um/drivers/net_kern.c 2007-03-06 12:14:45.0 -0500
@@ -325,8 +325,8 @@ static struct platform_driver uml_net_dr
 };
 static int driver_registered;
 
-static int eth_configure(int n, void *init, char *mac,
-struct transport *transport)
+static void eth_configure(int n, void *init, char *mac,
+ struct transport *transport)
 {
struct uml_net *device;
struct net_device *dev;
@@ -339,16 +339,12 @@ static int eth_configure(int n, void *in
device = kzalloc(sizeof(*device), GFP_KERNEL);
if (device == NULL) {
printk(KERN_ERR "eth_configure failed to allocate uml_net\n");
-   return(1);
+   return;
}
 
INIT_LIST_HEAD(>list);
device->index = n;
 
-   spin_lock(_lock);
-   list_add(>list, );
-   spin_unlock(_lock);
-
setup_etheraddr(mac, device->mac);
 
printk(KERN_INFO "Netdevice %d ", n);
@@ -360,7 +356,7 @@ static int eth_configure(int n, void *in
dev = alloc_etherdev(size);
if (dev == NULL) {
printk(KERN_ERR "eth_configure: failed to allocate device\n");
-   return 1;
+   goto out_free_device;
}
 
lp = dev->priv;
@@ -376,7 +372,8 @@ static int eth_configure(int n, void *in
}
device->pdev.id = n;
device->pdev.name = DRIVER_NAME;
-   platform_device_register(>pdev);
+   if(platform_device_register(>pdev))
+   goto out_free_netdev;
SET_NETDEV_DEV(dev,>pdev.dev);
 
/* If this name ends up conflicting with an existing registered
@@ -386,31 +383,12 @@ static int eth_configure(int n, void *in
snprintf(dev->name, sizeof(dev->name), "eth%d", n);
device->dev = dev;
 

[PATCH 0/5] UML - hotplug fixes and cleanup

2007-03-06 Thread Jeff Dike
These patches can wait till after 2.6.21.

Three of them are tidying patches of various sorts.  The other two fix
network interface and block device hotplug bugs.

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/


[PATCH 2/5] UML - print coredump limits

2007-03-06 Thread Jeff Dike
Print out core dump limits at boot time.  This is to allow core dumps
to be collected if something goes very wrong and to tell if a core
dump isn't going to happen because of a resource limit.

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

Index: test/arch/um/os-Linux/start_up.c
===
--- test.orig/arch/um/os-Linux/start_up.c   2007-03-06 10:21:43.0 
-0500
+++ test/arch/um/os-Linux/start_up.c2007-03-06 10:43:02.0 -0500
@@ -17,6 +17,7 @@
 #include sys/time.h
 #include sys/wait.h
 #include sys/mman.h
+#include sys/resource.h
 #include asm/unistd.h
 #include asm/page.h
 #include sys/types.h
@@ -329,8 +330,32 @@ static void __init check_ptrace(void)
 
 extern void check_tmpexec(void);
 
+static void check_coredump_limit(void)
+{
+   struct rlimit lim;
+   int err = getrlimit(RLIMIT_CORE, lim);
+
+   if(err){
+   perror(Getting core dump limit);
+   return;
+   }
+
+   printf(Core dump limits :\n\tsoft - );
+   if(lim.rlim_cur == RLIM_INFINITY)
+   printf(NONE\n);
+   else printf(%lu\n, lim.rlim_cur);
+
+   printf(\thard - );
+   if(lim.rlim_max == RLIM_INFINITY)
+   printf(NONE\n);
+   else printf(%lu\n, lim.rlim_max);
+}
+
 void os_early_checks(void)
 {
+   /* Print out the core dump limits early */
+   check_coredump_limit();
+
check_ptrace();
 
/* Need to check this early because mmapping happens before the

-
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/5] UML - Mark tt-mode code for future removal

2007-03-06 Thread Jeff Dike
Mark some tt-mode-only code as such.

Also cleaned up some formatting.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/sys-i386/ptrace_user.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

Index: linux-2.6.18-mm/arch/um/sys-i386/ptrace_user.c
===
--- linux-2.6.18-mm.orig/arch/um/sys-i386/ptrace_user.c 2007-03-02 
21:18:13.0 -0500
+++ linux-2.6.18-mm/arch/um/sys-i386/ptrace_user.c  2007-03-02 
21:23:19.0 -0500
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2002 Jeff Dike ([EMAIL PROTECTED])
  * Licensed under the GPL
  */
@@ -45,7 +45,8 @@ int ptrace_setfpregs(long pid, unsigned 
return 0;
 }
 
-/* All the below stuff is of interest for TT mode only */
+#ifdef UML_CONFIG_MODE_TT
+
 static void write_debugregs(int pid, unsigned long *regs)
 {
struct user *dummy;
@@ -128,13 +129,4 @@ void update_debugregs(int seq)
 }
 #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:
- */
+#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 5/5] UML - network interface hotplug error handling

2007-03-06 Thread Jeff Dike
This fixes a number of problems associated with network interface hotplug.

The userspace initialization function can fail in some cases, but the
failure was never passed back to eth_configure, which proceeded with
the configuration.  This results in a zombie device that is present,
but can't work.  This is fixed by allowing the initialization routines
to return an error, which is checked, and the configuration aborted on
failure.

eth_configure failed to check for many failures. Even when it did
check, it didn't undo whatever initializations has already happened,
so a present, but partially initialized and non-working device could
result.  It now checks everything that can fail, and bails out,
undoing whatever had been done.

The return value of eth_configure was always ignored, so it is now
just void.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/daemon_user.c|5 +
 arch/um/drivers/mcast_user.c |3 -
 arch/um/drivers/net_kern.c   |   81 +--
 arch/um/drivers/pcap_user.c  |5 +
 arch/um/drivers/slip_user.c  |3 -
 arch/um/drivers/slirp_user.c |3 -
 arch/um/include/net_user.h   |2 
 arch/um/os-Linux/drivers/ethertap_user.c |3 -
 arch/um/os-Linux/drivers/tuntap_user.c   |3 -
 9 files changed, 64 insertions(+), 44 deletions(-)

Index: test/arch/um/drivers/daemon_user.c
===
--- test.orig/arch/um/drivers/daemon_user.c 2007-03-06 12:10:12.0 
-0500
+++ test/arch/um/drivers/daemon_user.c  2007-03-06 12:14:45.0 -0500
@@ -123,7 +123,7 @@ static int connect_to_switch(struct daem
return err;
 }
 
-static void daemon_user_init(void *data, void *dev)
+static int daemon_user_init(void *data, void *dev)
 {
struct daemon_data *pri = data;
struct timeval tv;
@@ -146,7 +146,10 @@ static void daemon_user_init(void *data,
if(pri-fd  0){
kfree(pri-local_addr);
pri-local_addr = NULL;
+   return pri-fd;
}
+
+   return 0;
 }
 
 static int daemon_open(void *data)
Index: test/arch/um/drivers/mcast_user.c
===
--- test.orig/arch/um/drivers/mcast_user.c  2007-03-06 12:09:57.0 
-0500
+++ test/arch/um/drivers/mcast_user.c   2007-03-06 12:14:45.0 -0500
@@ -42,12 +42,13 @@ static struct sockaddr_in *new_addr(char
return sin;
 }
 
-static void mcast_user_init(void *data, void *dev)
+static int mcast_user_init(void *data, void *dev)
 {
struct mcast_data *pri = data;
 
pri-mcast_addr = new_addr(pri-addr, pri-port);
pri-dev = dev;
+   return 0;
 }
 
 static void mcast_remove(void *data)
Index: test/arch/um/drivers/net_kern.c
===
--- test.orig/arch/um/drivers/net_kern.c2007-03-06 12:03:02.0 
-0500
+++ test/arch/um/drivers/net_kern.c 2007-03-06 12:14:45.0 -0500
@@ -325,8 +325,8 @@ static struct platform_driver uml_net_dr
 };
 static int driver_registered;
 
-static int eth_configure(int n, void *init, char *mac,
-struct transport *transport)
+static void eth_configure(int n, void *init, char *mac,
+ struct transport *transport)
 {
struct uml_net *device;
struct net_device *dev;
@@ -339,16 +339,12 @@ static int eth_configure(int n, void *in
device = kzalloc(sizeof(*device), GFP_KERNEL);
if (device == NULL) {
printk(KERN_ERR eth_configure failed to allocate uml_net\n);
-   return(1);
+   return;
}
 
INIT_LIST_HEAD(device-list);
device-index = n;
 
-   spin_lock(devices_lock);
-   list_add(device-list, devices);
-   spin_unlock(devices_lock);
-
setup_etheraddr(mac, device-mac);
 
printk(KERN_INFO Netdevice %d , n);
@@ -360,7 +356,7 @@ static int eth_configure(int n, void *in
dev = alloc_etherdev(size);
if (dev == NULL) {
printk(KERN_ERR eth_configure: failed to allocate device\n);
-   return 1;
+   goto out_free_device;
}
 
lp = dev-priv;
@@ -376,7 +372,8 @@ static int eth_configure(int n, void *in
}
device-pdev.id = n;
device-pdev.name = DRIVER_NAME;
-   platform_device_register(device-pdev);
+   if(platform_device_register(device-pdev))
+   goto out_free_netdev;
SET_NETDEV_DEV(dev,device-pdev.dev);
 
/* If this name ends up conflicting with an existing registered
@@ -386,31 +383,12 @@ static int eth_configure(int n, void *in
snprintf(dev-name, sizeof(dev-name), eth%d, n);
device-dev = dev;
 
+   /*
+* These just fill in a data structure, so there's no failure
+* to be worried

[PATCH 3/5] UML - handle block device hotplug errors

2007-03-06 Thread Jeff Dike
If a disk fails to open, i.e. its host file doesn't exist, it won't
be removable because the hot-unplug code checks the existence of its
gendisk.  This won't exist because it is only allocated for
successfully opened disks.  Thus, a typo on the command line can
result in a unusable and unfixable disk.

This is fixed by freeing the gendisk if it's there, but not letting
that affect the removal.

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

Index: test/arch/um/drivers/ubd_kern.c
===
--- test.orig/arch/um/drivers/ubd_kern.c2007-03-05 13:14:50.0 
-0500
+++ test/arch/um/drivers/ubd_kern.c 2007-03-05 13:40:13.0 -0500
@@ -790,14 +790,12 @@ static int ubd_id(char **str, int *start
 
 static int ubd_remove(int n, char **error_out)
 {
+   struct gendisk *disk;
struct ubd *ubd_dev;
int err = -ENODEV;
 
mutex_lock(ubd_lock);
 
-   if(ubd_gendisk[n] == NULL)
-   goto out;
-
ubd_dev = ubd_devs[n];
 
if(ubd_dev-file == NULL)
@@ -808,9 +806,12 @@ static int ubd_remove(int n, char **erro
if(ubd_dev-count  0)
goto out;
 
-   del_gendisk(ubd_gendisk[n]);
-   put_disk(ubd_gendisk[n]);
-   ubd_gendisk[n] = NULL;
+   disk = ubd_gendisk[n];
+   ubd_gendisk[n] = NULL;
+   if(disk != NULL){
+   del_gendisk(disk);
+   put_disk(disk);
+   }
 
if(fake_gendisk[n] != NULL){
del_gendisk(fake_gendisk[n]);

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


[PATCH 4/5] UML - driver formatting fixes

2007-03-06 Thread Jeff Dike
Fix a bunch of formatting violations in the drivers:
return(n) - return n
whitespace fixes
emacs formatting comment removal
breaking if(foo) return(n) into two lines

There are also a couple of errno use bugs:
using errno in a printk when the failure put errno into a local variable
saving errno after a printk, which can change it

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/drivers/chan_user.c  |2 -
 arch/um/drivers/daemon_user.c|   25 +--
 arch/um/drivers/mcast_user.c |   12 -
 arch/um/drivers/pcap_user.c  |   33 -
 arch/um/drivers/ubd_user.c   |   15 +--
 arch/um/os-Linux/drivers/ethertap_user.c |   36 ++-
 arch/um/os-Linux/drivers/tuntap_user.c   |   40 ---
 7 files changed, 57 insertions(+), 106 deletions(-)

Index: test/arch/um/drivers/daemon_user.c
===
--- test.orig/arch/um/drivers/daemon_user.c 2007-03-06 12:09:47.0 
-0500
+++ test/arch/um/drivers/daemon_user.c  2007-03-06 12:10:12.0 -0500
@@ -39,11 +39,11 @@ static struct sockaddr_un *new_addr(void
sun = um_kmalloc(sizeof(struct sockaddr_un));
if(sun == NULL){
printk(new_addr: allocation of sockaddr_un failed\n);
-   return(NULL);
+   return NULL;
}
sun-sun_family = AF_UNIX;
memcpy(sun-sun_path, name, len);
-   return(sun);
+   return sun;
 }
 
 static int connect_to_switch(struct daemon_data *pri)
@@ -112,7 +112,7 @@ static int connect_to_switch(struct daem
}
 
pri-data_addr = sun;
-   return(fd);
+   return fd;
 
  out_free:
kfree(sun);
@@ -120,7 +120,7 @@ static int connect_to_switch(struct daem
os_close_file(fd);
  out:
os_close_file(pri-control);
-   return(err);
+   return err;
 }
 
 static void daemon_user_init(void *data, void *dev)
@@ -152,7 +152,7 @@ static void daemon_user_init(void *data,
 static int daemon_open(void *data)
 {
struct daemon_data *pri = data;
-   return(pri-fd);
+   return pri-fd;
 }
 
 static void daemon_remove(void *data)
@@ -176,12 +176,12 @@ int daemon_user_write(int fd, void *buf,
 {
struct sockaddr_un *data_addr = pri-data_addr;
 
-   return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
+   return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
 }
 
 static int daemon_set_mtu(int mtu, void *data)
 {
-   return(mtu);
+   return mtu;
 }
 
 const struct net_user_info daemon_user_info = {
@@ -194,14 +194,3 @@ const struct net_user_info daemon_user_i
.delete_address = NULL,
.max_packet = MAX_PACKET - ETH_HEADER_OTHER
 };
-
-/*
- * 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: test/arch/um/drivers/mcast_user.c
===
--- test.orig/arch/um/drivers/mcast_user.c  2007-03-06 12:09:45.0 
-0500
+++ test/arch/um/drivers/mcast_user.c   2007-03-06 12:09:57.0 -0500
@@ -34,12 +34,12 @@ static struct sockaddr_in *new_addr(char
sin = um_kmalloc(sizeof(struct sockaddr_in));
if(sin == NULL){
printk(new_addr: allocation of sockaddr_in failed\n);
-   return(NULL);
+   return NULL;
}
sin-sin_family = AF_INET;
sin-sin_addr.s_addr = in_aton(addr);
sin-sin_port = htons(port);
-   return(sin);
+   return sin;
 }
 
 static void mcast_user_init(void *data, void *dev)
@@ -107,8 +107,8 @@ static int mcast_open(void *data)
err = -errno;
printk(mcast_open : data bind failed, errno = %d\n, errno);
goto out_close;
-   }   
-   
+   }
+
/* subscribe to the multicast group */
mreq.imr_multiaddr.s_addr = sin-sin_addr.s_addr;
mreq.imr_interface.s_addr = 0;
@@ -153,12 +153,12 @@ int mcast_user_write(int fd, void *buf, 
 {
struct sockaddr_in *data_addr = pri-mcast_addr;
 
-   return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
+   return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
 }
 
 static int mcast_set_mtu(int mtu, void *data)
 {
-   return(mtu);
+   return mtu;
 }
 
 const struct net_user_info mcast_user_info = {
Index: test/arch/um/drivers/pcap_user.c
===
--- test.orig/arch/um/drivers/pcap_user.c   2007-03

Re: BUG: problems compiling UML

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 12:40:32PM +0100, mrkiko wrote:
> Problem:
> make all ARCH=um fails always on linking: it seems that a -llibname is 
> missing.  If this report is too stupid, sorry!

It's not too stupid - it's too short on details.

Show us the relevant portion of the build output.

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 04/11] uml - hostfs: avoid possible escapes from hostfs=.

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 11:59:13PM +0100, Blaisorblade wrote:
> I gave a look, and it's nice. Except that maybe "escapes_jail" would be a 
> clearer name (there's confusion about the subject of "escaping").

Feel free to change the name.

> Also, what about concurrent UML threads caring about current directory? I
> know that without SMP/preemption we can't have this problem, but
> when I see this I count a future bug unless this is checked (I think I
> reason mathematically about correctness, even if not formally).

Good point, yes this does need fixing for SMP.

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 4/4] UML - Comment the initialization of a global

2007-03-05 Thread Jeff Dike
Comment the fact that sig_info is initialized early in boot, and thus doesn't
need any locking.

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

Index: linux-2.6.18-mm/arch/um/os-Linux/trap.c
===
--- linux-2.6.18-mm.orig/arch/um/os-Linux/trap.c2006-12-30 
04:20:14.0 +1100
+++ linux-2.6.18-mm/arch/um/os-Linux/trap.c 2007-01-16 10:38:21.0 
+1100
@@ -16,6 +16,7 @@ void usr2_handler(int sig, union uml_pt_
CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
 }
 
+/* Initialized from linux_main() */
 void (*sig_info[NSIG])(int, union uml_pt_regs *);
 
 void os_fill_handlinfo(struct kern_handlers h)

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


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

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

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

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

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


[PATCH 3/4] UML - Add a debugging message

2007-03-05 Thread Jeff Dike
Add a debugging message in the case that mapping a stub fails.

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

Index: test/arch/um/os-Linux/skas/process.c
===
--- test.orig/arch/um/os-Linux/skas/process.c   2007-03-05 15:08:18.0 
-0500
+++ test/arch/um/os-Linux/skas/process.c2007-03-05 16:14:56.0 
-0500
@@ -419,9 +419,12 @@ void map_stub_pages(int fd, unsigned lon
  .offset  = code_offset
} } });
n = os_write_file(fd, , sizeof(mmop));
-   if(n != sizeof(mmop))
+   if(n != sizeof(mmop)){
+   printk("mmap args - addr = 0x%lx, fd = %d, offset = %llx\n",
+  code, code_fd, (unsigned long long) code_offset);
panic("map_stub_pages : /proc/mm map for code failed, "
  "err = %d\n", -n);
+   }
 
if ( stack ) {
__u64 map_offset;

-
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] linux/audit.h needs linux/types.h

2007-03-05 Thread Jeff Dike
Include linux/types.h here because we need a definition of __u32.  This file
appears not be exported verbatim by libc, so I think this doesn't have any
userspace consequences.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 include/linux/audit.h |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.18-mm/include/linux/audit.h
===
--- linux-2.6.18-mm.orig/include/linux/audit.h  2007-02-20 16:16:03.0 
-0500
+++ linux-2.6.18-mm/include/linux/audit.h   2007-02-20 16:16:25.0 
-0500
@@ -24,6 +24,7 @@
 #ifndef _LINUX_AUDIT_H_
 #define _LINUX_AUDIT_H_
 
+#include 
 #include 
 
 /* The netlink messages for the audit system is divided into blocks:

-
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] Small UML and audit.h cleanups

2007-03-05 Thread Jeff Dike
These are for 2.6.21.  Three are UML cleanups, and one is adding an include
to linux/audit.h.

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 00/11] Uml simple fixes

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 09:42:29PM +0100, Paolo 'Blaisorblade' Giarrusso wrote:
> Some tested UML fixes - should be applied for 2.6.21.

ACK on all of these except for 1, which won't apply to current -mm,
and 4, which might need some more work.

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 04/11] uml - hostfs: avoid possible escapes from hostfs=.

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 09:49:02PM +0100, Paolo 'Blaisorblade' Giarrusso wrote:
> From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
> 
> Avoid accepting things like -o .., -o dir/../../dir2, -o dir/../.. .
> This may be considered useless, but YMMV. I consider that this has a limited
> security value, exactly like disabling module support (in many case it is
> useful).

Two comments on this one:

> + return  strstr(path, "/../") != NULL ||
> + strcmp(path, "..") == 0 ||
> + strncmp(path, "../", strlen("../")) == 0 ||
> + str_ends_with(path, "/..");

Minor style point - I'd be happier with more parens:

+   return  (strstr(path, "/../") != NULL) ||
+   (strcmp(path, "..") == 0) ||
+   (strncmp(path, "../", strlen("../")) == 0) ||
+   str_ends_with(path, "/..");

C gets operator precedence wrong in one or two cases, so I just put parens
any place it might matter.

Second, there is code in externfs which does the same thing without
parsing paths which you might consider instead.  It sees whether the
requested directory is outside the jail by cd-ing to it and then
repeatedly cd .. until it either reaches / or the jail root.

A copy is below for your reading pleasure.

Jeff

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


/* This does a careful check of whether it's being asked to mount something
 * that's outside the hostfs jail.  It does so by cd-ing to the requested
 * directory and "cd .." until it either reaches / or the jail directory.
 * If it reaches /, then we were outside the jail and we return -EPERM.
 * I do things this way rather than trying to examine the passed-in root
 * to avoid having to parse the string for instances of ".." and the like.
 * Examining the string also doesn't help with symlinks that point outside
 * the jail.  Plus, if there's no parsing, there's no parser to try to exploit.
 */
static int escaping_jail(char *root)
{
struct uml_stat jail_inode;
struct uml_stat last_dir, cur_dir;
int save_pwd, err, escaping = -EPERM;
const char *path[] = { jail_dir, root, NULL };
char tmp[HOSTFS_BUFSIZE], *file;

err = os_stat_file(jail_dir, _inode);
if(err)
goto out;

save_pwd = os_open_file(".", of_read(OPENFLAGS()), 0);
if(save_pwd < 0)
goto out;

file = get_path(path, tmp, sizeof(tmp));
if(file == NULL)
goto out_close;

err = os_change_dir(file);
if(err)
goto out_free;

err = os_stat_file(".", _dir);
if(err)
goto out_back;

do {
if(SAME_INO(cur_dir, jail_inode)){
escaping = 0;
break;
}

err = os_change_dir("..");
if(err)
goto out_back;

last_dir = cur_dir;

err = os_stat_file(".", _dir);
if(err)
goto out_back;

} while(!SAME_INO(last_dir, cur_dir));

err = os_fchange_dir(save_pwd);
if(err)
goto out_close;

free_path(file, tmp);
os_close_file(save_pwd);

return escaping;

out_back:
os_fchange_dir(save_pwd);
out_free:
free_path(file, tmp);
out_close:
os_close_file(save_pwd);
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/


Re: [PATCH 01/11] uml: code convention cleanup of a file

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 09:48:59PM +0100, Paolo 'Blaisorblade' Giarrusso wrote:
> From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
> 
> Fix coding conventions violations is arch/um/os-Linux/helper.c.

The code which you're changing here is gone in current -mm.

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: nonlinear vma problem in uml

2007-03-05 Thread Jeff Dike
On Sat, Mar 03, 2007 at 12:06:20AM +0100, Miklos Szeredi wrote:
> _PAGE_PROTNONE conflicts with the lowest bit of pgoff.  This causes
> all sorts of weirdness when nonlinear mappings are used.
> 
> Took me a good half day to track this down.

Thanks, I'll send this in.

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] UML utrace support, step 1

2007-03-05 Thread Jeff Dike
On Thu, Feb 22, 2007 at 07:19:03PM -0800, Roland McGrath wrote:
> Your replacement patch still has utrace_regset stuff in it, so it doesn't
> compile without the later patches in the series.  Try applying only
> utrace-tracehook.patch from the series, then get it to build and make your
> utrace-tracehook-um.patch.

Below is a tracehook patch for UML which goes right after
utrace-utrace-tracehook.patch.

Jeff

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


This is the tracehook part of the UML utrace work, enough to get UML
building with the utrace prep patches applied.

Checks of task->ptrace & PT_DTRACE were replaced with
test_thread_flag(TIF_SINGLESTEP, or removed, in the case of execve.

Most of arch/um/kernel/ptrace.c is gone, to be reinstated in future
utrace work.

Similarly, calls to syscall_trace and ptrace notifications in the
signal delivery code are gone.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/kernel/exec.c   |1 
 arch/um/kernel/process.c|6 
 arch/um/kernel/ptrace.c |  333 +---
 arch/um/kernel/signal.c |5 
 arch/um/kernel/skas/syscall.c   |4 
 arch/um/sys-i386/signal.c   |4 
 include/asm-um/ptrace-generic.h |3 
 include/asm-um/ptrace-i386.h|2 
 include/asm-um/ptrace-x86_64.h  |2 
 include/asm-um/tracehook.h  |   64 +++
 10 files changed, 117 insertions(+), 307 deletions(-)


Index: linux-2.6.18-mm/arch/um/kernel/exec.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/exec.c  2007-03-03 16:23:47.0 
-0500
+++ linux-2.6.18-mm/arch/um/kernel/exec.c   2007-03-03 16:26:42.0 
-0500
@@ -51,7 +51,6 @@ static long execve1(char *file, char __u
 error = do_execve(file, argv, env, >thread.regs);
 if (error == 0){
task_lock(current);
-current->ptrace &= ~PT_DTRACE;
 #ifdef SUBARCH_EXECVE1
SUBARCH_EXECVE1(>thread.regs.regs);
 #endif
Index: linux-2.6.18-mm/arch/um/kernel/process.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/process.c   2007-03-03 
16:20:36.0 -0500
+++ linux-2.6.18-mm/arch/um/kernel/process.c2007-03-03 16:26:42.0 
-0500
@@ -458,11 +458,11 @@ int singlestepping(void * t)
 {
struct task_struct *task = t ? t : current;
 
-   if ( ! (task->ptrace & PT_DTRACE) )
-   return(0);
+   if (!test_thread_flag(TIF_SINGLESTEP))
+   return 0;
 
if (task->thread.singlestep_syscall)
-   return(1);
+   return 1;
 
return 2;
 }
Index: linux-2.6.18-mm/arch/um/kernel/ptrace.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/ptrace.c2007-03-03 
16:23:47.0 -0500
+++ linux-2.6.18-mm/arch/um/kernel/ptrace.c 2007-03-03 16:26:42.0 
-0500
@@ -3,261 +3,29 @@
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "linux/errno.h"
-#include "linux/smp_lock.h"
-#include "linux/security.h"
-#include "linux/ptrace.h"
-#include "linux/audit.h"
-#ifdef CONFIG_PROC_MM
-#include "linux/proc_mm.h"
-#endif
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
-#include "skas_ptrace.h"
-#include "sysdep/ptrace.h"
-#include "os.h"
-
-static inline void set_singlestepping(struct task_struct *child, int on)
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const struct utrace_regset_view utrace_um_native = {
+   .name   = SUBARCH,
+   .e_machine  = ELF_ARCH,
+   .regsets= NULL,
+   .n  = 0,
+};
+EXPORT_SYMBOL_GPL(utrace_um_native);
+
+int arch_ptrace(long *req, struct task_struct *child,
+   struct utrace_attached_engine *engine,
+   unsigned long addr, unsigned long data, long *val)
 {
-if (on)
-child->ptrace |= PT_DTRACE;
-else
-child->ptrace &= ~PT_DTRACE;
-child->thread.singlestep_syscall = 0;
-
-#ifdef SUBARCH_SET_SINGLESTEPPING
-SUBARCH_SET_SINGLESTEPPING(child, on);
-#endif
+   return -ENOSYS;
 }
 
-/*
- * Called by kernel/ptrace.c when detaching..
- */
-void ptrace_disable(struct task_struct *child)
-{ 
-set_singlestepping(child,0);
-}
-
-extern int peek_user(struct task_struct * child, long addr, long data);
-extern int poke_user(struct task_struct * child, long addr, long data);
-
-long arch_ptrace(struct task_struct *child, long request, long addr, long data)
-{
-   int i, ret;
-   unsigned long __user *p = (void __user *)(unsigned long)data;
-
-   

Re: nonlinear vma problem in uml

2007-03-05 Thread Jeff Dike
On Sat, Mar 03, 2007 at 12:06:20AM +0100, Miklos Szeredi wrote:
 _PAGE_PROTNONE conflicts with the lowest bit of pgoff.  This causes
 all sorts of weirdness when nonlinear mappings are used.
 
 Took me a good half day to track this down.

Thanks, I'll send this in.

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: problems compiling UML

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 12:40:32PM +0100, mrkiko wrote:
 Problem:
 make all ARCH=um fails always on linking: it seems that a -llibname is 
 missing.  If this report is too stupid, sorry!

It's not too stupid - it's too short on details.

Show us the relevant portion of the build output.

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] UML utrace support, step 1

2007-03-05 Thread Jeff Dike
On Thu, Feb 22, 2007 at 07:19:03PM -0800, Roland McGrath wrote:
 Your replacement patch still has utrace_regset stuff in it, so it doesn't
 compile without the later patches in the series.  Try applying only
 utrace-tracehook.patch from the series, then get it to build and make your
 utrace-tracehook-um.patch.

Below is a tracehook patch for UML which goes right after
utrace-utrace-tracehook.patch.

Jeff

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


This is the tracehook part of the UML utrace work, enough to get UML
building with the utrace prep patches applied.

Checks of task-ptrace  PT_DTRACE were replaced with
test_thread_flag(TIF_SINGLESTEP, or removed, in the case of execve.

Most of arch/um/kernel/ptrace.c is gone, to be reinstated in future
utrace work.

Similarly, calls to syscall_trace and ptrace notifications in the
signal delivery code are gone.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/kernel/exec.c   |1 
 arch/um/kernel/process.c|6 
 arch/um/kernel/ptrace.c |  333 +---
 arch/um/kernel/signal.c |5 
 arch/um/kernel/skas/syscall.c   |4 
 arch/um/sys-i386/signal.c   |4 
 include/asm-um/ptrace-generic.h |3 
 include/asm-um/ptrace-i386.h|2 
 include/asm-um/ptrace-x86_64.h  |2 
 include/asm-um/tracehook.h  |   64 +++
 10 files changed, 117 insertions(+), 307 deletions(-)


Index: linux-2.6.18-mm/arch/um/kernel/exec.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/exec.c  2007-03-03 16:23:47.0 
-0500
+++ linux-2.6.18-mm/arch/um/kernel/exec.c   2007-03-03 16:26:42.0 
-0500
@@ -51,7 +51,6 @@ static long execve1(char *file, char __u
 error = do_execve(file, argv, env, current-thread.regs);
 if (error == 0){
task_lock(current);
-current-ptrace = ~PT_DTRACE;
 #ifdef SUBARCH_EXECVE1
SUBARCH_EXECVE1(current-thread.regs.regs);
 #endif
Index: linux-2.6.18-mm/arch/um/kernel/process.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/process.c   2007-03-03 
16:20:36.0 -0500
+++ linux-2.6.18-mm/arch/um/kernel/process.c2007-03-03 16:26:42.0 
-0500
@@ -458,11 +458,11 @@ int singlestepping(void * t)
 {
struct task_struct *task = t ? t : current;
 
-   if ( ! (task-ptrace  PT_DTRACE) )
-   return(0);
+   if (!test_thread_flag(TIF_SINGLESTEP))
+   return 0;
 
if (task-thread.singlestep_syscall)
-   return(1);
+   return 1;
 
return 2;
 }
Index: linux-2.6.18-mm/arch/um/kernel/ptrace.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/ptrace.c2007-03-03 
16:23:47.0 -0500
+++ linux-2.6.18-mm/arch/um/kernel/ptrace.c 2007-03-03 16:26:42.0 
-0500
@@ -3,261 +3,29 @@
  * Licensed under the GPL
  */
 
-#include linux/sched.h
-#include linux/mm.h
-#include linux/errno.h
-#include linux/smp_lock.h
-#include linux/security.h
-#include linux/ptrace.h
-#include linux/audit.h
-#ifdef CONFIG_PROC_MM
-#include linux/proc_mm.h
-#endif
-#include asm/ptrace.h
-#include asm/uaccess.h
-#include kern_util.h
-#include skas_ptrace.h
-#include sysdep/ptrace.h
-#include os.h
-
-static inline void set_singlestepping(struct task_struct *child, int on)
+#include linux/audit.h
+#include linux/elf.h
+#include linux/module.h
+#include linux/ptrace.h
+#include linux/tracehook.h
+
+const struct utrace_regset_view utrace_um_native = {
+   .name   = SUBARCH,
+   .e_machine  = ELF_ARCH,
+   .regsets= NULL,
+   .n  = 0,
+};
+EXPORT_SYMBOL_GPL(utrace_um_native);
+
+int arch_ptrace(long *req, struct task_struct *child,
+   struct utrace_attached_engine *engine,
+   unsigned long addr, unsigned long data, long *val)
 {
-if (on)
-child-ptrace |= PT_DTRACE;
-else
-child-ptrace = ~PT_DTRACE;
-child-thread.singlestep_syscall = 0;
-
-#ifdef SUBARCH_SET_SINGLESTEPPING
-SUBARCH_SET_SINGLESTEPPING(child, on);
-#endif
+   return -ENOSYS;
 }
 
-/*
- * Called by kernel/ptrace.c when detaching..
- */
-void ptrace_disable(struct task_struct *child)
-{ 
-set_singlestepping(child,0);
-}
-
-extern int peek_user(struct task_struct * child, long addr, long data);
-extern int poke_user(struct task_struct * child, long addr, long data);
-
-long arch_ptrace(struct task_struct *child, long request, long addr, long data)
-{
-   int i, ret;
-   unsigned long __user *p = (void __user *)(unsigned long)data;
-
-   switch (request) {
-   /* when I and D space are separate, these will need to be 
fixed. */
-   case PTRACE_PEEKTEXT: /* read word at location addr

Re: [PATCH 01/11] uml: code convention cleanup of a file

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 09:48:59PM +0100, Paolo 'Blaisorblade' Giarrusso wrote:
 From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
 
 Fix coding conventions violations is arch/um/os-Linux/helper.c.

The code which you're changing here is gone in current -mm.

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 04/11] uml - hostfs: avoid possible escapes from hostfs=.

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 09:49:02PM +0100, Paolo 'Blaisorblade' Giarrusso wrote:
 From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED]
 
 Avoid accepting things like -o .., -o dir/../../dir2, -o dir/../.. .
 This may be considered useless, but YMMV. I consider that this has a limited
 security value, exactly like disabling module support (in many case it is
 useful).

Two comments on this one:

 + return  strstr(path, /../) != NULL ||
 + strcmp(path, ..) == 0 ||
 + strncmp(path, ../, strlen(../)) == 0 ||
 + str_ends_with(path, /..);

Minor style point - I'd be happier with more parens:

+   return  (strstr(path, /../) != NULL) ||
+   (strcmp(path, ..) == 0) ||
+   (strncmp(path, ../, strlen(../)) == 0) ||
+   str_ends_with(path, /..);

C gets operator precedence wrong in one or two cases, so I just put parens
any place it might matter.

Second, there is code in externfs which does the same thing without
parsing paths which you might consider instead.  It sees whether the
requested directory is outside the jail by cd-ing to it and then
repeatedly cd .. until it either reaches / or the jail root.

A copy is below for your reading pleasure.

Jeff

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


/* This does a careful check of whether it's being asked to mount something
 * that's outside the hostfs jail.  It does so by cd-ing to the requested
 * directory and cd .. until it either reaches / or the jail directory.
 * If it reaches /, then we were outside the jail and we return -EPERM.
 * I do things this way rather than trying to examine the passed-in root
 * to avoid having to parse the string for instances of .. and the like.
 * Examining the string also doesn't help with symlinks that point outside
 * the jail.  Plus, if there's no parsing, there's no parser to try to exploit.
 */
static int escaping_jail(char *root)
{
struct uml_stat jail_inode;
struct uml_stat last_dir, cur_dir;
int save_pwd, err, escaping = -EPERM;
const char *path[] = { jail_dir, root, NULL };
char tmp[HOSTFS_BUFSIZE], *file;

err = os_stat_file(jail_dir, jail_inode);
if(err)
goto out;

save_pwd = os_open_file(., of_read(OPENFLAGS()), 0);
if(save_pwd  0)
goto out;

file = get_path(path, tmp, sizeof(tmp));
if(file == NULL)
goto out_close;

err = os_change_dir(file);
if(err)
goto out_free;

err = os_stat_file(., cur_dir);
if(err)
goto out_back;

do {
if(SAME_INO(cur_dir, jail_inode)){
escaping = 0;
break;
}

err = os_change_dir(..);
if(err)
goto out_back;

last_dir = cur_dir;

err = os_stat_file(., cur_dir);
if(err)
goto out_back;

} while(!SAME_INO(last_dir, cur_dir));

err = os_fchange_dir(save_pwd);
if(err)
goto out_close;

free_path(file, tmp);
os_close_file(save_pwd);

return escaping;

out_back:
os_fchange_dir(save_pwd);
out_free:
free_path(file, tmp);
out_close:
os_close_file(save_pwd);
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/


Re: [PATCH 00/11] Uml simple fixes

2007-03-05 Thread Jeff Dike
On Mon, Mar 05, 2007 at 09:42:29PM +0100, Paolo 'Blaisorblade' Giarrusso wrote:
 Some tested UML fixes - should be applied for 2.6.21.

ACK on all of these except for 1, which won't apply to current -mm,
and 4, which might need some more work.

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 0/4] Small UML and audit.h cleanups

2007-03-05 Thread Jeff Dike
These are for 2.6.21.  Three are UML cleanups, and one is adding an include
to linux/audit.h.

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/


[PATCH 1/4] linux/audit.h needs linux/types.h

2007-03-05 Thread Jeff Dike
Include linux/types.h here because we need a definition of __u32.  This file
appears not be exported verbatim by libc, so I think this doesn't have any
userspace consequences.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 include/linux/audit.h |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.18-mm/include/linux/audit.h
===
--- linux-2.6.18-mm.orig/include/linux/audit.h  2007-02-20 16:16:03.0 
-0500
+++ linux-2.6.18-mm/include/linux/audit.h   2007-02-20 16:16:25.0 
-0500
@@ -24,6 +24,7 @@
 #ifndef _LINUX_AUDIT_H_
 #define _LINUX_AUDIT_H_
 
+#include linux/types.h
 #include linux/elf-em.h
 
 /* The netlink messages for the audit system is divided into blocks:

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


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

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

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

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

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


[PATCH 3/4] UML - Add a debugging message

2007-03-05 Thread Jeff Dike
Add a debugging message in the case that mapping a stub fails.

Signed-off-by: Jeff Dike [EMAIL PROTECTED]
--
 arch/um/os-Linux/skas/process.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: test/arch/um/os-Linux/skas/process.c
===
--- test.orig/arch/um/os-Linux/skas/process.c   2007-03-05 15:08:18.0 
-0500
+++ test/arch/um/os-Linux/skas/process.c2007-03-05 16:14:56.0 
-0500
@@ -419,9 +419,12 @@ void map_stub_pages(int fd, unsigned lon
  .offset  = code_offset
} } });
n = os_write_file(fd, mmop, sizeof(mmop));
-   if(n != sizeof(mmop))
+   if(n != sizeof(mmop)){
+   printk(mmap args - addr = 0x%lx, fd = %d, offset = %llx\n,
+  code, code_fd, (unsigned long long) code_offset);
panic(map_stub_pages : /proc/mm map for code failed, 
  err = %d\n, -n);
+   }
 
if ( stack ) {
__u64 map_offset;

-
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 - Comment the initialization of a global

2007-03-05 Thread Jeff Dike
Comment the fact that sig_info is initialized early in boot, and thus doesn't
need any locking.

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

Index: linux-2.6.18-mm/arch/um/os-Linux/trap.c
===
--- linux-2.6.18-mm.orig/arch/um/os-Linux/trap.c2006-12-30 
04:20:14.0 +1100
+++ linux-2.6.18-mm/arch/um/os-Linux/trap.c 2007-01-16 10:38:21.0 
+1100
@@ -16,6 +16,7 @@ void usr2_handler(int sig, union uml_pt_
CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
 }
 
+/* Initialized from linux_main() */
 void (*sig_info[NSIG])(int, union uml_pt_regs *);
 
 void os_fill_handlinfo(struct kern_handlers 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/


<    7   8   9   10   11   12   13   14   15   16   >