[uml-devel] Re: Running uml on 2.6.16.x kernels

2006-04-25 Thread Jeff Dike
On Mon, Apr 24, 2006 at 10:37:51PM +0200, Blaisorblade wrote:
> I can't run a 64 bit UML on a 2.6.16.9 kernel. I get constantly this error 
> with various binaries, some of which I'm sure worked on 2.6.15 host (I'm 
> going to retest):
> 
> VFS: Mounted root (ext3 filesystem) readonly.
> Warning: unable to open an initial console.
> Kernel panic - not syncing: handle_trap - failed to wait at end of syscall, 
> errno = 0, status = 2943

The ptraced process is getting a segfault instead of a trap.  Smells like
ptrace...

> I went looking for ptrace commits in -stable (I didn't check yet between 
> 2.6.15 and 2.6.16) and found that in 2.6.16.6 this was added: 

Obviously, revert these and see if they make a difference.

Jeff


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] Re: [RFC] PATCH 3/4 - Time virtualization : PTRACE_SYSCALL_MASK

2006-04-25 Thread Jeff Dike
On Sat, Apr 22, 2006 at 09:06:10AM +0200, Heiko Carstens wrote:
> > The flags could be:
> > 
> > MASK_DEFAULT_TRACE (set the default to 1 for remaining bits)
> > MASK_DEFAULT_IGNORE (set the default to 0 for remaining bits)
> > MASK_STRICT_VERIFY (return -EINVAL for bits exceeding NR_syscalls and set 
> > differently than the default).

I'd prefer (given that there aren't any unused ptrace arguments) using
the operation for this - PTRACE_SYSCALL_MASK_TRACE,
PTRACE_SYSCALL_MASK_IGNORE.  We'd need better names than these
horribly over-long ones, though.

> You might as well introduce yet another ptrace call which returns the number
> of system calls and for this ptrace call force user space to pass a complete
> bitmap. Sounds easier to me.

I think that's just building in fragility whenever userspace doesn't
happen to match the kernel.  Both UML and strace will know what system
calls they are interested in.  Having the kernel 1- or 0-extend the
mask will automatically do the right thing.  If userspace is newer
than the kernel, and asks for special treatment for system calls that
don't exist, then it should get a -EINVAL.

Jeff


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] [RFC] PATCH 3/4 - Time virtualization : PTRACE_SYSCALL_MASK

2006-04-25 Thread Jeff Dike
On Fri, Apr 21, 2006 at 08:34:52PM +0200, Blaisorblade wrote:
> >  #define PTRACE_GET_THREAD_AREA25
> >  #define PTRACE_SET_THREAD_AREA26
> > +#define PTRACE_SYSCALL_MASK  27
> 
> I think there could be a reason we skipped that for SYSEMU - that's to see. 
> Also, if this capability will be implemented in other archs, we should use 
> the 0x4200-0x4300 range for it.

Yeah, we need to decide somewhat carefully which number to use.

> > +   for(i = NR_syscalls; i < len * 8; i++){
> > +   get_user(c, &mask[i / 8]);
> 
> This get_user() inside a loop is poor, it could slow down a valid call. It'd 
> be simpler to copy the mask from userspace in a local variable (with 400 
> syscalls that's 50 bytes, i.e. fully ok), and then perform the checks, if 
> wanted (I disagree with Heiko's message, this check is needed
> sometimes - see  my response to that).

Agree, except that we need to be careful about when userspace knows
about more system calls than the kernel.  We should copy-user as many
bits as the kernel knows about (or the process passes in, which ever
is less) and if the process knows about more system calls than the
kernel, the extra bits should be checked (maybe in a get_user(c, ...)
loop) to make sure that special treatment isn't being requested for
unknown syscalls.

> And only after that set all at once child->syscall_mask. You copy twice that 
> little quantity of data but that's not at all time-critical, and you're 
> forced to do that to avoid partial updates; btw you've saved getting twice 
> the content from userspace (slow when address spaces are distinct, like for 
> 4G/4G or SKAS implementation of copy_from_user).

Yup.

> Actually we would copy the whole struct in my API proposal (as I've
> described in the other message, we need to pass another param IMHO,
> so we'd pack them in a struct and pass its address).

You mean adding a fifth argument to ptrace?  I don't really like that
idea.  We could either make two new PTRACE_* operations (I don't like
the MASK_STRICT_VERIFY option since that seems unnecessary and
fragile) or make the data argument something like this
struct {
int flag;
void *mask;
}

which seems to be something like what you're suggesting.  You'll want
to stick the mask length in there as well, and leave the data argument
unused.

Except that passing pointers to pointers into system calls seems like
a bad idea - it makes ptrace look (more) like ioctl.  So, you'd want
something like
struct {
int flag;
char mask[(NR_syscalls + 7)/8];
}

then you'd want the length back in data so you know how much data the
process is giving you.  But then, you'll read the smaller of the
kernel's and process's version of the structure, and if the process
one is bigger, you need to read the extra bits to sanity-check them.
Given that you'll need this extra treatment, I think it's simpler to
just leave the addr argument as a pointer to the bits and add an extra
ptrace op.

Jeff


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] Re: [RFC] PATCH 3/4 - Time virtualization : PTRACE_SYSCALL_MASK

2006-04-25 Thread Jeff Dike
On Thu, Apr 20, 2006 at 04:17:28PM +0200, Bodo Stroesser wrote:
> Shouldn't 'len' better be the number of bits in the mask than the number of 
> chars?

Yup.

> OTOH, I think UML shouldn't send the entire mask, but relevant part only. 
> The missing end is filled with 0xff by host anyway. So it would be
> enough to send the mask up to the highest bit representing a
> syscall, that needs to be executed by host.  (currently, that is
> __NR_gettimeofday). If UML would do so, no more problem results from
> UML having a higher NR_syscall than the host (as long as the new
> syscalls are to be intercepted and executed by UML)

Yup, that was part of the intent of sending in the mask length.

> A greater problem might be a process in UML, that calls an invalid syscall 
> number. AFAICS syscall number (orig_eax) isn't checked before it is
> used in do_syscall_trace to address syscall_mask. This might result
> in a crash. 

Yeah, this needs fixing.

Heff


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] [PATCH] uml: problem with 2G/2G host address space

2006-04-25 Thread Jeff Dike
On Wed, Apr 19, 2006 at 11:52:00AM +0200, Blaisorblade wrote:
> Jeff, for now please merge a band-aid patch (and also add an option
> to support 1G/3G, while at it).

OK, do you have such a patch handy?  I know I saw one go by, but some
grepping didn't turn it up.

Jeff


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] [PATCH] uml: problem with 2G/2G host address space

2006-04-25 Thread Jeff Dike
On Tue, Apr 25, 2006 at 04:19:22PM -0400, Jeff Dike wrote:
> OK, do you have such a patch handy?  I know I saw one go by, but some
> grepping didn't turn it up.

Nevermind, I found it - it was the start of this thread.

Jeff


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


[uml-devel] [RFC][PATCH] Converting mconsole to SOCK_STREAM

2006-04-25 Thread Erik Walthinsen
We (Vcolo.com, formerly pdxcolo.net) have been running with a variation on 
the attached patch from day one.  I figure it's probably time to see if it 
should be included in the main distribution finally, especially since the 
API has now changed enough that moving it to 2.6.16 is going to get interesting.


The premise is simple: mconsole should be SOCK_STREAM.  In our case, this is 
used to detect the shutdown of the machine by simply polling for the control 
socket to close.  It's saved us from all kinds of potentially bizarre 
polling modes, so it's been well worth it.


The patch has worked fine so far, but I've never been satisfied with the way 
I kinda had to hack it into place without *fully* understanding the whole 
channel IRQ setup.  Since 2.6.16 changed how that works, I'm now at the 
point where I need more expert advise, hopefully along the way to putting 
this into the mainstream UML kernel.


Also attached is a version of uml_mconsole.c, forked who knows back when 
(~3yrs ago) so I'll have to dig out a file later to diff it against.  The 
only changes that should be in that file are switching to SOCK_STREAM and 
read()/write() instead of recv()/sendto().


Whether this is something that belongs in the main UML kernel or not, I 
would much appreciate it if someone has the time to help me to make sure the 
soft-IRQ handling is sane while moving it to the 2.6.16 codebase.


The patch is against 2.6.15.6 with uml-2.6.15-bs3-tls.patch.  There might be 
some minor line offset fuzz from some other local patches.


TIA,
   Omega
   aka Erik Walthinsen
   [EMAIL PROTECTED]
diff -urN linux-2.6.15.6-bs3-tls/arch/um/drivers/mconsole_kern.c 
linux-2.6.15.6-bs3-tls-stream/arch/um/drivers/mconsole_kern.c
--- linux-2.6.15.6-bs3-tls/arch/um/drivers/mconsole_kern.c  2006-04-25 
20:26:57.0 -0700
+++ linux-2.6.15.6-bs3-tls-stream/arch/um/drivers/mconsole_kern.c   
2006-04-25 20:51:21.0 -0700
@@ -72,16 +72,30 @@
 
 DECLARE_WORK(mconsole_work, mc_work_proc, NULL);
 
+static int mconsole_listen_sock = 0;
+static char *notify_socket = NULL;
+
 static irqreturn_t mconsole_interrupt(int irq, void *dev_id,
  struct pt_regs *regs)
 {
/* long to avoid size mismatch warnings from gcc */
long fd;
+   int err;
struct mconsole_entry *new;
struct mc_request req;
 
fd = (long) dev_id;
-   while (mconsole_get_request(fd, &req)){
+   while ((err = mconsole_get_request(fd, &req)) >= 0) {
+   /* if we got back and end-of-file, close off this client */
+   if (err == 0) {
+   free_irq_later(MCONSOLE_CLIENT_IRQ, (void *)fd);
+   close(fd);
+   return(IRQ_HANDLED);
+   }
+
+   /* if there is no valid command, don't chase it down */
+   if (! req.cmd) continue;
+
if(req.cmd->context == MCONSOLE_INTR)
(*req.cmd->handler)(&req);
else {
@@ -96,7 +110,37 @@
}
if(!list_empty(&mc_requests))
schedule_work(&mconsole_work);
-   reactivate_fd(fd, MCONSOLE_IRQ);
+   reactivate_fd(fd, MCONSOLE_CLIENT_IRQ);
+   return(IRQ_HANDLED);
+}
+
+void mconsole_accept_task_proc(void *unused)
+{
+   int fd;
+   unsigned long flags;
+
+   local_save_flags(flags);
+
+   while ((fd = os_accept_unix_stream_socket(mconsole_listen_sock)) >= 0) {
+   if (um_request_irq(MCONSOLE_CLIENT_IRQ, fd, IRQ_READ, 
mconsole_interrupt,
+  SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
+  "mconsole", (void *)fd)) {
+   printk(KERN_ERR "mconsole_accept_task_proc: failed to 
get IRQ for client %d\n",fd);
+   local_irq_restore(flags);
+   return;
+   }
+   }
+
+   reactivate_fd(mconsole_listen_sock, MCONSOLE_IRQ);
+
+   local_irq_restore(flags);
+}
+
+DECLARE_WORK(mconsole_accept_task, mconsole_accept_task_proc, NULL);
+
+static irqreturn_t mconsole_accept_interrupt(int irq, void *data, struct 
pt_regs *regs)
+{
+   schedule_work(&mconsole_accept_task);
return(IRQ_HANDLED);
 }
 
@@ -563,29 +607,34 @@
 /* Changed by mconsole_setup, which is __setup, and called before SMP is
  * active.
  */
-static char *notify_socket = NULL; 
+//static char *notify_socket = NULL; 
 
 int mconsole_init(void)
 {
/* long to avoid size mismatch warnings from gcc */
-   long sock;
+// long sock;
int err;
char file[256];
 
if(umid_file_name("mconsole", file, sizeof(file))) return(-1);
snprintf(mconsole_socket_name, sizeof(file), "%s", file);
 
-   sock = os_create_unix_socket(file, sizeof(file), 1);
-   if (sock < 0){
+// sock = os_create_unix_socket(file, sizeof(file), 1);
+// if (sock < 0){
+   mconsole_listen_sock = os_creat

[uml-devel] Just published - "User Mode Linux"; the definitive book on UML

2006-04-25 Thread William Stearns

Good evening, all,
Jeff's too modest to announce it, so I will. :-)  /me ducks

	Jeff spent a good portion of the last year putting together an 
excellent text on UML.  While those of us on these lists are certainly 
comfortable with basic operation, the book covers that and goes well 
beyond, into cow files, advanced filesystems and networking, mconsole, 
skas and patching, setting up clusters, and the future of UML.  I'd like 
to think I'm pretty familiar with UML, but have to admit there are tools 
and techniques he covers that were completely new to me.

It's _well_ worth the purchase.

ISBN: 0-13-186505-6

Here's Prentice Hall's page for it:
http://www.phptr.com/bookstore/product.asp?isbn=0131865056&rl=1

Amazon.com is already shipping it:
http://www.amazon.com/gp/product/0131865056/qid=1146027972/sr=1-1/ref=sr_1_1/104-1678044-3181532?s=books&v=glance&n=283155

Cheers,
- Bill

---
"Free UNIX accounts.  Telnet to 127.0.0.1.  Use your existing
user ID and password to login."
(Courtesy of Dennis McGrath <[EMAIL PROTECTED]>)
--
William Stearns ([EMAIL PROTECTED]).  Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at:   http://www.stearns.org
--


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel