Linux-Development-Sys Digest #574, Volume #8 Sat, 17 Mar 01 19:13:11 EST
Contents:
copy_to_user() question ("Jim Fischer")
Re: 2.4.1pre and 2.4.0ac problem: __buggy_fxsr_alignment undefined (Marc D. Williams)
Book suggestions (Arnaud Westenberg)
Re: PORTIMG PRBLEMS FOR A DEVICE DRIVER
4GB memory limit ("Ryan Storgaard")
Re: Book suggestions
preloading into ramfs ([EMAIL PROTECTED])
delivering POSIX signals problem (Mattias Busck)
Re: linux kernel #, linux release #, ??? (John Kelly)
Re: Kernel Panic!! (Help!!!!) (John Kelly)
Re: copy_to_user() question
Spacetec Spaceball and xfree86 (Torsten Blank)
Understanding the page lists ("Joseph A. Knapka")
----------------------------------------------------------------------------
From: "Jim Fischer" <[EMAIL PROTECTED]>
Subject: copy_to_user() question
Date: Fri, 16 Mar 2001 21:49:23 -0800
I'm a newby kernel hacker who's unable to get the copy_to_user() function to
write data from kernel space to user space. I'm working with a 2.4.2 smp
kernel and am compiling the module code with the following command line:
gcc -O2 -D__KERNEL__ -DMODULE -c xyz.c
I can insmod and rmmod the resulting "xyz.o" module file w/o any problems.
The module code is straightforward: I have a char buffer in kernel space
whose contents I'd like to copy to a char buffer in user space. I *can*
write a for() loop that uses the put_char() kernel function to copy the
contents of the kernel buffer into the user buffer one byte at a time --
e.g.,
static char kbuf[ SIZE ];
...
static ssize_t device_read (
struct file *file, /* not used */
char *ubuf,
size_t ubuf_len,
loff_t *offset /* not used */
)
{
ssize_t i, len ;
const char *kp = kbuf ;
/* validation & range check code here... */
/* Copy the contents of the kernel-space buffer to
* the user-space buffer
*/
for ( i = 0; i < len; ++i, ++kp, ++ubuf ) {
put_user( *kp, ubuf );
}
return i ;
}
This code works as expected; the contents of kbuf get copied to user space
w/o error.
However, if I replace the above for() loop with the kernel function call,
i = copy_to_user( ubuf, kbuf, len );
the copy_to_user() function returns 0 (zero) and the contents of kbuf are
not copied to the user-space buffer pointed to by 'ubuf'. FWIW, I've also
tried,
if ( access_ok( VERIFY_WRITE, ubuf, len ) ) {
i = -1;
i = __copy_to_user( ubuf, kbuf, len );
printk ( "<2>__copy_to_user() returned %u\n", i );
} else {
printk ( "<2>:: ERROR :: access_ok() failed\n" );
}
When I perform a device read the above code emits the printk() message,
<2>__copy_to_user() returned 0
and again, nothing is copied from the the kernel buffer to the user-space
buffer.
So what am I missing here? Tks...
Jim
------------------------------
From: [EMAIL PROTECTED] (Marc D. Williams)
Subject: Re: 2.4.1pre and 2.4.0ac problem: __buggy_fxsr_alignment undefined
Date: Sat, 17 Mar 2001 09:03:28 -0000
Reply-To: [EMAIL PROTECTED]
On Mon, 05 Mar 2001 23:09:03 +0100, deepblur wrote:
>hijo there,
>
>> Went grepping around for stuff like cpu_has_fxsr (and its corresponding
>> X86_FEATURE_FXSR) and came across disable_x86_fxsr in
>> arch/i386/kernel/setup.c.
>>
>> At line 150 is
>> static int disable_x86_fxsr __initdata = 0;
>>
>> Disabled is what I want for this Athlon (at least I think I do :-)
>> so I change it to 1 and recompile. Still the kernel build fails
>> with the undefined reference to __buggy_fxsr_alignment.
>> Okay, so I just comment out that section in bugs.h (above), recompile
>> and reboot. The kernel booted just fine.
>>
>
>thats what i found on some mailing list when figuring with the
>same problem, also with an athlon
>it even occured in the 2.4.2 kernel release
>
>so i will disable fxsr alignment as you mentioned above...
>according to the mailing list entry, the error is thrown to notify the
>user where the kernel panic comes from (when removing it)
>so it might be better to disable it. (what i was searching for)
>
It's been pointed out that the errors occur when not using standard
gcc but stuff like pgcc/athlongcc. They call them buggy compilers.
I haven't felt like going back to regular gcc so I still do the
disable fxsr thing.
Still hasn't hurt anything but that could change. :-)
Marc
------------------------------
Date: Sat, 17 Mar 2001 13:28:37 +0100
From: Arnaud Westenberg <[EMAIL PROTECTED]>
Subject: Book suggestions
Hi all,
I know this must have been discussed a 1000 times but could you please
answer it for the 1001st time?
I'm looking for a good Unix internals book. The things it should discuss
at least are; processes, IPC, Kernel mechanisms, daemons!, drivers, etc.
The daemons part is mandatory since this is the main reason I want the
book. Maybe some network basics?
Prefferebly it should contain code snippets.
Thanks!
Regards Arnaud
------------------------------
From: <[EMAIL PROTECTED]>
Subject: Re: PORTIMG PRBLEMS FOR A DEVICE DRIVER
Date: Sat, 17 Mar 2001 07:20:51 -0800
Well Josef:
As I said yesterday, you need to determine where your program is first
going off the track. I usually find that when I write an entire program
(like your throttle/position sensor project), that something simple in
initialization gets me and I assume the error is further on. What I would
suggest is that you sit down today and test each functioning statement, or
run through it with a single step debugger until you find some subroutine
call that doesn't work as you expect and then you call for help. It seems to
me that your problem is not a linux system development issue, but perhaps a
c programming issue. I wish I had the time to analyze your program, but I
can't really give it any more then a quick glance.
------------------------------
From: "Ryan Storgaard" <[EMAIL PROTECTED]>
Subject: 4GB memory limit
Date: Sat, 17 Mar 2001 15:21:40 GMT
Hi all,
I am running the 2.4 kernel, and originally compiled support for 64GB of
memory and then put 6GB of RAM in the box. Linux ran fine, but I have an
application (unfortunately I'm not at liberty to say what application) that
upon install said "error, you have support for more than 4GB of RAM". I had
to recompile with support for only 4GB of RAM and everything went fine. I
really need this application to support more RAM though.
I'm a sys engineer, not a programmer, so I need some of your insight...
If an application was originally developed to support 4GB of RAM, what is
involved in order to allow it to handle more than 4GB? ( I mean in
general... is it a simple switch or parameter during the compiling of the
application or is it a complex rewrite of the entire application ....)
Excuse my programming incompetence and the reference to windoze but in NT,
for example, NT tells every app that it has access to 4GB of RAM... What
does linux do (in the 2.4 kernel)?
Reason I ask is because the vendor mentioned it wasn't planning on
supporting more than 4GB of RAM with Linux, and to look for their Windows
2000 version to support larger amounts of RAM.... I REALLY don't want to go
down that road because that would mean I would have to purchase Win2k
DataCenter Server to handle the RAM... I want to use Linux.
cheers,
ryan
------------------------------
From: <[EMAIL PROTECTED]>
Subject: Re: Book suggestions
Date: Sat, 17 Mar 2001 07:28:41 -0800
Well, try one or all of "Understand the Linux Kernel" by Bovet, "Linux
Internals" by Bar, "Linux Kernel Internals" by Beck, et al or, online you
can read "The Linux Kernel - The Book" which is not yet finished at
http://kernelbook.sourceforge.net/ They all have a piece of the puzzle, none
of them has written the entire puzzle down in a way that allows me to be
exclaim EUREKA at any point, I just have to slug my way through'em.
"Arnaud Westenberg" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Hi all,
>
> I know this must have been discussed a 1000 times but could you please
> answer it for the 1001st time?
>
> I'm looking for a good Unix internals book. The things it should discuss
> at least are; processes, IPC, Kernel mechanisms, daemons!, drivers, etc.
> The daemons part is mandatory since this is the main reason I want the
> book. Maybe some network basics?
>
> Prefferebly it should contain code snippets.
>
> Thanks!
>
>
> Regards Arnaud
>
------------------------------
From: [EMAIL PROTECTED]
Subject: preloading into ramfs
Date: Sat, 17 Mar 2001 17:24:43 -0000
I previously wrote an init program for advanced CD booting. It was the
only file in initrd, it set up ramfs, found the boot CD, mounted the CD,
loaded a tar file into ramfs, and pivoted the ramfs to be the root fs.
This expanded the limits of what can be loaded in ram from a CD to the
lesser of your available ram or the CD space to put the tar file. It
could have even used compression, though I didn't go that far this time.
What I am thinking about now is a similar thing for a hard drive based
system. Part of the idea came from seeing how the Ascend GRF-400 router,
which was FreeBSD based, loaded everything from flash RAM. My idea is
to have the partition which the kernel initially mounts read-only as
root contain /dev/console and /sbin/init which will have my init code.
My code will then set up the ramfs, find the files to be preloaded, then
pivot the ramfs to be the root fs and execve() to the loaded /sbin/init.
The source files to be loaded could come from a number of places, such
as the same partition or a different one, and as a tree of files or as a
tar file.
There are a couple of intentions that get me thinking about this.
One thought is that some things would just be faster if they are in ram,
and this is one sure way to get them in ram. Given that many systems
have a lot of ram these days, loading 8 to 32 meg of stuff into ram
wouldn't be all that much of a hit. It would depend on the judgement of
the administrator if they want to take advantage of it, and just how much.
Another thought is a simple layer of security aspect to it. While it sure
won't be resistant to sophisticated attacks, many times the holes the
crackers do find somewhere aren't big enough for anything but very trivial
initial attacks.
And this could surely help prevent some disasterous accidents where critical
system startup files get clobbered. If the ram preload alone can get the
system up, networked, and running sshd, then anything else that can be
repaired remotely, or possibly even automatically repaired.
What are you thoughts on this?
I was looking at how ramfs was implemented, and am left wondering if there
are any issues in doing things like memory mapping files from ramfs. That
could have an impact on library usage if there are issues. For example,
does CoW work right for files memory mapped from ramfs? What would happen
if a CoW was needed for a library mapped from ramfs when swap was full?
Would it be a graceful process kill, or would the system seize up?
--
=================================================================
| Phil Howard - KA9WGN | Dallas | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/ |
=================================================================
------------------------------
From: [EMAIL PROTECTED] (Mattias Busck)
Crossposted-To: linux.dev.kernel
Subject: delivering POSIX signals problem
Reply-To: [EMAIL PROTECTED]
Date: Sat, 17 Mar 2001 18:50:23 GMT
Hi all!
I am writing a device driver where I want to send a process
a SIGIO signal at certain events. I userspace i want to use
the File Descriptor field in siginfo_t to read the file descriptor
that caused the signal. However, this doesn't seem to work as I am
just receiving garbage in "int si_fd /* File descriptor */".
My kernel version is 2.2.14 standard Redhat 6.2.
relevant? parts of the code:
void sigio_handler (int sig, siginfo_t *siginfoPtr, void *voidPtr){
printf("SIG_IO\n");
printf("sig = %d\n",sig);
printf("si_signo = %d\n",siginfoPtr -> si_signo);
printf("si_band = %d\n",siginfoPtr -> si_band);
printf("si_fd = %X\n",siginfoPtr -> si_fd);
//cnd.
return;
}
void _init (void) {
struct sigaction io_act;
io_act.sa_sigaction = sigio_handler;
sigemptyset(&io_act.sa_mask);
/* Use sigaction & restart system calls for this signal */
io_act.sa_flags = SA_SIGINFO | SA_RESTART;
if (sigaction(SIGIO, &io_act, NULL) != 0) {
printf("Failed to register signal handler! (@_init)\n");
}
return;
}
In the module I do:
int myFasync (int fd, struct file *filp, int mode)
{
int retval;
OpenFileNode *fileNodePtr;
fileNodePtr = filp -> private_data;
DEBUG(1,"fasynchelper 0x%X 0x%X 0x%X 0x%X\n",
fd, filp, mode, &(fileNodePtr -> asyncQ));
retval = fasync_helper(fd, filp, mode, &(fileNodePtr -> asyncQ));
if (retval < 0) return retval;
return 0;
}
kill_fasync(fileNodePtr -> asyncQ, SIGIO, POLL_IN);
--
/ Mattias Busck < [EMAIL PROTECTED] >
------------------------------
From: John Kelly <[EMAIL PROTECTED]>
Subject: Re: linux kernel #, linux release #, ???
Date: Sat, 17 Mar 2001 12:19:11 -0700
I only know the answer for RedHat....
The best thing to do is install the RedHat kernel SRPM and have a look at the
.spec file. It starts with the base linux distribution and adds numerous
patches--you also get the source for all the patches so you can look it over.
Mostly, it seems they add drivers and change default settings. There are some
add-ons, like I2C. If you do that, there are also a flag you can set (in the
.spec file) to enable KDB.
-jk
johng12 wrote:
> i wanted to know more about
> 1 different linux distributions like red hat, suse, etc etc have their
> versions of linux OS. what is the difference between them
> 2 how to find, or what are the differences between variuos linux kernels eg
> kernel 2.0.34
> if linux is an open source software , then its kernel is code is free...
> right ??
>
> eg rehat calls its Linux release 5.1 as Manhattan. what are the differences
> between each release.
> Please point me to relevant docs.
------------------------------
From: John Kelly <[EMAIL PROTECTED]>
Subject: Re: Kernel Panic!! (Help!!!!)
Date: Sat, 17 Mar 2001 12:24:20 -0700
Are you installing lilo to the MBR or your root partition?
(i.e., boot=/dev/hda or boot=/dev/hda1)?
David wrote:
> I recently downloaded the 2.2.18 kernel from kernel.org. I compiled it and installed
>it on my Debian 2.2 (Potato) system. I configured and ran lilo (I'm no newbie at
>these things). I tried it and it worked well for a few days.
>
> I have a dual boot (Win98 SE) system and one day I booted Windows to play flight
>simulator. During the boot, Norton reported that my MBR had been changed and asked if
>I wanted it (Norton) to repair it. Without thinking, I hit "yes". Probably a dumb
>thing to do.
>
> Later, I decided that I wanted to try the reiserfs so I downloaded the patch for me
>spanking new kernel. Yes, I'm sure I got the right patch. I applied it and
>recompiled. Reinstalled lilo. Tried to reboot the new kernel. The new image
>uncompressed and started booting, then I got:
>
> VFS: Cannot open root device 03:03
> Kernel panic: VFS : Unable to mount root fs on 03:03
>
> So I rebooted with the old kernel (still worked!) and messed around a bit with
>lilo's settings. Reran lilo. Still no dice. COMPLETELY changed my lilo settings to
>the point where I would notice the changes at the lilo prompt. Reran lilo. WAIT A
>MINUTE!! Nothing changed at the lilo prompt as it should have! Something flaky going
>on here! Reran lilo again. Still no expected changes!
>
> Decided to install grub. Did so successfully. New kernel now gives me the the same
>error messages except it substitutes 00:00 for the 03:03's.
>
> What the heck can I do to get me new kernel to work again? I'm still using ext2 and
>yes, ext2 is switched on in the kernel (not as a module).
>
> Help!!
>
> David
>
> --
> Posted via CNET Help.com
> http://www.help.com/
------------------------------
From: [EMAIL PROTECTED] ()
Subject: Re: copy_to_user() question
Date: Sat, 17 Mar 2001 19:48:14 -0000
In article <98uv5n$8k2$[EMAIL PROTECTED]>,
Jim Fischer <[EMAIL PROTECTED]> wrote:
>So what am I missing here? Tks...
Where does the value of "len" get set?
--
http://www.spinics.net/linux
------------------------------
From: Torsten Blank <[EMAIL PROTECTED]>
Subject: Spacetec Spaceball and xfree86
Date: 17 Mar 2001 23:02:18 +0100
Hi all!
I want to get a Spacetec Spaceball (and after that, some more input
devices) working with XFree 4. I have seen that the Linux kernel
supports this device as a "joystick". I think, with a
joystick-device, you have a generic device (/dev/joy?), which you can
read out transparently, no matter what physical device is
connected. So its a great concept. My question is: Is there a
joystick-driver for Xfree 4. I mean this sort of (n Axis, m Buttons)
generic joystick, not the 2-Axis-Joystick-driver "xf86Jstk.so". If
there isnt such a driver in XFree 4: Why not?
Torsten Blank
--
Torsten Blank
Institut fuer Theoretische Physik der Uni Karlsruhe
Tel: 0721 / 608 6365 Fax: 0721 / 608 3582
Web: http://www-itp.physik.uni-karlsruhe.de/~tb
------------------------------
From: "Joseph A. Knapka" <[EMAIL PROTECTED]>
Subject: Understanding the page lists
Date: Sat, 17 Mar 2001 23:37:55 GMT
Hi,
I am working on fairly detailed documentation for the Linux 2.4 MM
subsystem, and I am running into some confusing issues. The code
that manages the page lists (active, inactive_dirty, inactive_clean)
is far from transparent, and I am having a hard time convincing
myself that everything works as expected by looking at the code.
(Obviously it *does* work, or people's boxes would be crashing
left and right, but it's not totally obvious to me why.) Don't
really want to bother the linux-mm list with this unless all
else fails...
Specifically, I'm trying at the moment to understand how the
page LRU lists interact with the zone allocator. It seems that
inactive_clean pages are *supposed* to be 100% freeable and not
in use by any process VM - yet reclaim_page() appears to be
prepared for the possibility that they aren't (vmscan.c:455).
However, it doesn't take any special measures when this
occurs, just goes ahead and hands a possibly-in-use page
back to the caller as if the page was free. That can't be
right, but I've been dredging through all the code that
touches the page lists and I can't see anything that for
100% damn sure *guarantees* that we'll never end up with
an in-use page on the inactive clean list. refill_inactive_scan()
and page_launder() check to be sure that the pages they admit
to the lists have a reference count of 1, but how do we know that
that reference isn't from some process that is eg about to fork()
and thus produce another reference to the page?
I'm also a bit confused about the term "page cache". Does
this just refer to the LRU lists? I know there's also the
swap cache, which I believe contains clean-but-not-yet-
discarded pages; is that what's meant by "page cache"?
I would appreciate it if someone who understands this could
give me a brief explanation. Credit will be given where due
in my documentation effort.
-- Joe Knapka
"It was just a maddened crocodile hidden in a flower bed. It could
have happened to anyone." -- Pratchett
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
* Evolution is an "unproven theory" in the same sense that gravity is. *
------------------------------
** FOR YOUR REFERENCE **
The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:
Internet: [EMAIL PROTECTED]
You can send mail to the entire list by posting to the
comp.os.linux.development.system newsgroup.
Linux may be obtained via one of these FTP sites:
ftp.funet.fi pub/Linux
tsx-11.mit.edu pub/linux
sunsite.unc.edu pub/Linux
End of Linux-Development-System Digest
******************************