[uml-devel] system call accessing the host os

2006-04-05 Thread Olivier Crameri

Hi,

I'm currently working on a project in which we are using UML to  
access the host os and perform some operations.
More precisely, we would like to have a system call in UML that  
parses a file in the host os.


Since the UML kernel is a host process, I naively thought that I  
could use regular C directly. Indeed, I was able to create my system  
call, and then have some other C files compiled using host os headers  
such as  and  by putting them in the USER_OBJS  
list of the Makefile.


Unfortunately, I'm having some weird issues that I can't really  
understand. I can read the file using fread, but only in a buffer  
that I allocated using um_kmalloc. If I use a buffer allocated by  
malloc, the fread fails. Then, even if I replace all  my mallocs by  
um_kmallocs, some libc functions (such as sscanf) don't seem to work  
properly. I guess I'm missing something, but I can't figure out what.


If anyone of you can help me, I'd really appreciate,

With best regards,

Olivier

P.S.: I'm using 2.6.15.6 with the latest 2.6.15 patch and the guest  
kernel runs in skas3 mode.



---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&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] system call accessing the host os

2006-04-05 Thread Olivier Crameri

Well, yes, I could use this.

But what I'm actually trying to understand is how to properly execute  
regular C within the UML kernel to access the host OS.


Thks,

Olivier

On 5 avr. 06, at 19:18, D. Bahi wrote:


what about this?

http://user-mode-linux.sourceforge.net/iomem.html

Olivier Crameri wrote:

Hi,

I'm currently working on a project in which we are using UML to  
access

the host os and perform some operations.
More precisely, we would like to have a system call in UML that  
parses

a file in the host os.

Since the UML kernel is a host process, I naively thought that I  
could

use regular C directly. Indeed, I was able to create my system call,
and then have some other C files compiled using host os headers such
as  and  by putting them in the USER_OBJS list of
the Makefile.

Unfortunately, I'm having some weird issues that I can't really
understand. I can read the file using fread, but only in a buffer  
that

I allocated using um_kmalloc. If I use a buffer allocated by malloc,
the fread fails. Then, even if I replace all  my mallocs by
um_kmallocs, some libc functions (such as sscanf) don't seem to work
properly. I guess I'm missing something, but I can't figure out what.

If anyone of you can help me, I'd really appreciate,

With best regards,

Olivier

P.S.: I'm using 2.6.15.6 with the latest 2.6.15 patch and the guest
kernel runs in skas3 mode.


---
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel? 
cmd=lnk&kid=110944&bid=241720&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







---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&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] system call accessing the host os

2006-04-05 Thread Olivier Crameri
Thanks for the answer. I bumped CONFIG_KERNEL_STACK_ORDER to 3, but it
doesn't help.

I have a system call that does nothing but execute my code to parse my
file in the host.
When I said that using malloc didn't work, I meant the following: I'm
using malloc to allocate a buffer in the UML kernel. I'm not passing a
user level buffer to the system call. Then, when I use fread to read
my file into this buffer, if I read a small number of bytes, it works.
However when I try to fread the entire file (38k), fread returns 0.
The same thing using a buffer returned by um_kmalloc works perfectly
(i.e. returns 1 and the buffer is filled with the file data).

Later on, I use sscanf to parse my buffer. No matter what happens,
sscanf returns 0, which is wrong even if there is no error. The exact
same code compiled in the host works perfectly.

Again, thank you for your help, I really appreciate.
Olivier

On 4/5/06, Jeff Dike <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 05, 2006 at 07:16:22PM +0200, Olivier Crameri wrote:
> > Unfortunately, I'm having some weird issues that I can't really
> > understand. I can read the file using fread, but only in a buffer
> > that I allocated using um_kmalloc. If I use a buffer allocated by
> > malloc, the fread fails. Then, even if I replace all  my mallocs by
> > um_kmallocs, some libc functions (such as sscanf) don't seem to work
> > properly. I guess I'm missing something, but I can't figure out what.
>
> Define "fails" and "don't seem to work properly".
>
> If your buffers are larger than 128K, then libc malloc gets turned into
> UML kernel vmalloc.  In this case, the buffer isn't mapped, and
> passing it into a system call will make it return -EFAULT.  The
> easiest workaround for this is to memset the thing immediately after
> allocating it.
>
> Also, if you're using the libc things you're talking about, watch out
> for your stack consumption.  By default, you get two pages (8K).
> printf will completely use it up, so it is unusable in kernel code.
>
> UML kernel stack size is configurable - CONFIG_KERNEL_STACK_ORDER -
> bumping that to 3 will double the kernel stack size.  If problems then
> go away, then you know that libc is overflowing your stack.
>
> Jeff
>


---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
___
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] system call accessing the host os

2006-04-06 Thread Olivier Crameri



Then, when I use fread to read
my file into this buffer, if I read a small number of bytes, it  
works.

However when I try to fread the entire file (38k), fread returns 0.


What's the break point between working and non-working?


It looks like it's on a page boundary. 4095 bytes is ok, 4096 is not
I'm using 2.6.15.6 with the latest 2.6.15 patch from Blaisorblade's  
website.


Regards,

Olivier


---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&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] system call accessing the host os

2006-04-07 Thread Olivier Crameri
Great, thanks a lot. Now I understand what's happening. It was  
actually calling um_vmalloc


Olivier


On 7 avr. 06, at 01:42, Jeff Dike wrote:


On Fri, Apr 07, 2006 at 02:20:00AM +0200, Blaisorblade wrote:

No, I made it "greater than 4k" in 2.4.24 time... in fact it's what's
happening to him (see his last mail):


Oh yeah.  In that case, the memset thing I mentioned earlier might  
help.


Jeff




---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&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