Re: ARM : Kernel : Setting up of MMU in head.S

2011-03-31 Thread Dave Hylands
Hi Prakash,

On Wed, Mar 30, 2011 at 11:01 PM, Prakash K.B. prakash...@gmail.com wrote:
 Merci mate. :-)

 On Thu, Mar 31, 2011 at 3:59 AM, Dave Hylands dhyla...@gmail.com wrote:

 Hi Prakash,

 On Wed, Mar 30, 2011 at 2:35 PM, Dave Hylands dhyla...@gmail.com wrote:
...snip...
 When the MMU table is turned on, the PC is still at 0x800, so even
 though the kernel has 0xc00x mapped to 0x800x it also has to
 have 0x800x mapped to 0x800x.

 [Prakash] I think you meant to say So even though the kernel intends to map
 0xc00 to 0x800XXX in the future, it has currently mapped 0x800xxx to
 0x800xxx.

No. the create_page_table function creates a page table which has
0x800x and 0xc00x both mapped to 0x800x. The one store
intrustion saves the identity mapping (for 1 Mb) and the loop sets up
the 0xc00x to 0x800x mapping.

The identity portion is used as we discussed, and a few instructions
after turning on the MMU, the CPU then does a jump from the 0x800x
space to the 0xc00x space. After that, the identity mapping is no
longer needed. Shortly after this, head.S calls into the start_kernel
function (from init/main.c) and the paging_init function reinitializes
the MMU removing the identity mapping.


 Now that I know this identity mapping is done on purpose, I hope to make
 good progress with the succeeding sequence.

 Do you confirm that only one entry is written into this L1 table because
 both mmu_enable and enable_mmu_end are on the same section?

Yeah - essentially, that one mapping entry covers 1Mb of code space,
which is sufficient to cover all of head.S, which is always at the
front of the kernel image.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Debug Kernel Crash

2011-03-31 Thread swathi suresh
Hello All,

 I wanted to know what is the best way to generate the kernel crash
dump on kernel panic,
after doing some searching, i came to know we can use kexec to load a new
kernel on the kernel,
i followed the instruction from the following links
http://www.dedoimedo.com/computers/kdump.html
http://www.developertutorials.com/tutorials/linux/reboot-linux-faster-072204-1358/

I do found that the  kernel load properly with the, kexec -l option followed
by kexec -e option,
but when i set the kernel to be loaded on kernel panic using the option
kexec -p, i see that after
kernel crash, the system just hangs, it wont even try to load the new
kernel. following are the
commands am using. Can some one point, if there is any thing wrong with
this.

chkconfig kdump on
/etc/init.d/kdump start
kexec -l --append=`cat /proc/cmdline`
--initrd=/boot/initrd.img-2.6.35.10-kdump /boot/vmlinuz-2.6.35.10-kdump
kexec -e

works fine and loads the kernel successfully, i will be able to see *starting
new kernel* in the shell
*
*
*
chkconfig kdump on
/etc/init.d/kdump start
*
kexec -p --append=`cat /proc/cmdline` --initrd=/boot/initrd.img-2.6.35.10*
-kdump
**
 /boot/vmlinuz-2.6.35.10
-kdump
*
*

*
i simulate the panic by using
echo 1  /proc/sys/kernel/sysrq
echo c  /proc/sysrq-trigger

which just crash the kernel and system hangs, and it does not show any
message *starting new kernel.*
*
*
Thanks,
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [virtual memory] page_table_lock mmap_sem

2011-03-31 Thread Rik van Riel
On 03/29/2011 06:30 PM, Venkatram Tummala wrote:
 Hi,

 Why do we need both page_table_lock  mmap_sem in the kernel. Why isn't
 mmap_sem good enough for serialization. As far as i see it, all attempts
 to change the page table hierarchy in the kernel is done after holding
 the write lock on mmap_sem. As we are already holding the write lock, we
 do we need an extra page_table_lock (spinlock) ? Are there any code
 paths in the kernel which attempt to modify the page table hierarchy
 without holding the write lock on mmap_sem ?

Yes, there are.

Look at the page fault code, which takes a read lock
on mmap_sem.

This allows multiple threads in a multi-threaded process
to handle page faults simultaneously.

-- 
All rights reversed.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: ARM : Kernel : Setting up of MMU in head.S

2011-03-31 Thread Prakash K.B.
Merci mate. :-)

On Thu, Mar 31, 2011 at 3:59 AM, Dave Hylands dhyla...@gmail.com wrote:

 Hi Prakash,

 On Wed, Mar 30, 2011 at 2:35 PM, Dave Hylands dhyla...@gmail.com wrote:
  Hi Prakash,
 
  On Wed, Mar 30, 2011 at 8:19 AM, Prakash K.B. prakash...@gmail.com
 wrote:
  Hello.
 
  Please do not hesitate to let me know if this must be posted elsewhere.
 
  I have been trying to understand the code that sets up the MMU. I do
 have a
  fair understanding of the way MMU is meant to be setup, but something in
 the
  kernel code is tripping me.

 Some further explanation is due.

 When the kernel starts, the MMU is off, and ther ARM is running with
 an implicit identity mapping (i.e. each virtual address maps to the
 same physical address).

[Prakash] Aha...So what I ignored as a routine code comment had a deeper
meaning.. :-)


 If your physical memory starts at 0x8000, then the PC will be
 0x800x.

[Prakash] Agreed.


 When the MMU table is turned on, the PC is still at 0x800, so even
 though the kernel has 0xc00x mapped to 0x800x it also has to
 have 0x800x mapped to 0x800x.

[Prakash] I think you meant to say So even though the kernel intends to map
0xc00 to 0x800XXX in the future, it has currently mapped 0x800xxx to
0x800xxx.

Now that I know this identity mapping is done on purpose, I hope to make
good progress with the succeeding sequence.

Do you confirm that only one entry is written into this L1 table because
both mmu_enable and enable_mmu_end are on the same section?


 So this mapping of 0x800x to 0x800x is the identity portion
 and is needed while switching the MMU on. The 0xc00x to 0x800x
 mapping is what's used while the kernel is running.

 --
 Dave Hylands
 Shuswap, BC, Canada
 http://www.davehylands.com


-Prakash
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Debug Kernel Crash

2011-03-31 Thread Thayumanavar S
 kernel. following are the
 commands am using. Can some one point, if there is any thing wrong with
 this.
 chkconfig kdump on
 /etc/init.d/kdump start
 kexec -l --append=`cat /proc/cmdline`
 --initrd=/boot/initrd.img-2.6.35.10-kdump /boot/vmlinuz-2.6.35.10-kdump
 kexec -e
 works fine and loads the kernel successfully, i will be able to see starting
 new kernel in the shell
 chkconfig kdump on
 /etc/init.d/kdump start
 kexec -p --append=`cat /proc/cmdline` --initrd=/boot/initrd.img-2.6.35.10
 -kdump
  /boot/vmlinuz-2.6.35.10
 -kdump
 i simulate the panic by using
 echo 1  /proc/sys/kernel/sysrq
 echo c  /proc/sysrq-trigger
 which just crash the kernel and system hangs, and it does not show any
 message starting new kernel.
does /var/crash or kdump target directory as mentioned in
/etc/kdump.conf exists?
sometime it may be a while before it starts to dump if memory on
machine is huge and
you have set kdump level to dump everything.

thx,thayumanavar s.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: mapping address pointer to page structure

2011-03-31 Thread swathi suresh
On Wed, Mar 30, 2011 at 10:42 PM, sk.syed2 sk.sy...@gmail.com wrote:

  struct page *page = virt_to_page(skb-data);
  int offset = (unsigned long) skb-data - (unsigned long)
 page_address(page);
  skb_add_rx_frag(master_skb, skb_shinfo(master_skb)-nr_frags, page,
 offset,
  skb-len)
  .
  .
  is this the right way to do ?
 This will work if skb-len  PAGE_SIZE, otherwise it means it spans
 more than a page and you need to do skb_add_rx_frag for each PAGE_SIZE
 data present. Refer to Understanding Linux network internals By
 Christian Benvenuti p 488/489.


Thanks Syed, skb-len is always smaller then PAGE_SIZE because i have set
the mtu size as 1500 from my network driver.
But am facing kernel panic, if i just the moment the driver call
dev_queue_xmit, so i guess this may not  be right way to get
the page.

Anyways thanks for the support.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Snooping on sockets/file descriptors

2011-03-31 Thread Vimal
Hi,

Is it possible for an application (say snoop, with sufficient
privileges) to monitor data on any socket/file descriptor in the
system?

Here's an example:  suppose we have a browser and it creates a tcp
socket to connect to a URL.  Whenever the browser issues a read() and
data is pushed to user space, I want snoop to get notified and made
available a copy of the same data that the browser read.

ptrace can be used to do it, but then there are several ways the app
can read data.  It could use read(), or recv() or recvmsg().  Is there
a better way to deal with this complexity?

It's like the action of tee on any socket/file descriptor in the system.

-- 
Vimal

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Snooping on sockets/file descriptors

2011-03-31 Thread Daniel Baluta
On Thu, Mar 31, 2011 at 10:29 PM, Vimal j.vi...@gmail.com wrote:
 Hi,

 Is it possible for an application (say snoop, with sufficient
 privileges) to monitor data on any socket/file descriptor in the
 system?

 Here's an example:  suppose we have a browser and it creates a tcp
 socket to connect to a URL.  Whenever the browser issues a read() and
 data is pushed to user space, I want snoop to get notified and made
 available a copy of the same data that the browser read.

 ptrace can be used to do it, but then there are several ways the app
 can read data.  It could use read(), or recv() or recvmsg().  Is there
 a better way to deal with this complexity?

 It's like the action of tee on any socket/file descriptor in the system.

How about tcpdump?

thanks,
Daniel.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Snooping on sockets/file descriptors

2011-03-31 Thread Vimal
Hi Daniel,


 How about tcpdump?


Thanks for the suggestion.

tcpdump is good, but it doesn't solve all problems.  There are a few reasons:

* TCP packets could arrive out of order
* The data needn't belong to a valid TCP connection
* The app could just discard data (close/flush/etc)

In short, there is a lot of state and complex logic which act on the
packets before it is seen by the application.

Given the complexity (such as wide variations in TCP implementation),
I am not sure if reimplementing them is a good idea, even if it's
possible.

Thanks,
-- 
Vimal

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Snooping on sockets/file descriptors

2011-03-31 Thread Mulyadi Santosa
On Fri, Apr 1, 2011 at 03:04, Vimal j.vi...@gmail.com wrote:
 Hi Daniel,


 How about tcpdump?


 Thanks for the suggestion.

 tcpdump is good, but it doesn't solve all problems.  There are a few reasons:

 * TCP packets could arrive out of order
 * The data needn't belong to a valid TCP connection
 * The app could just discard data (close/flush/etc)

 In short, there is a lot of state and complex logic which act on the
 packets before it is seen by the application.

then, something like dtrace or systemtap? IMO you're looking for kinda
combo of kernel mode + user land sniffer... the user land sniffer,
in it's very simple form, is by using LD_PRELOAD ...

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Requirement of Linux port

2011-03-31 Thread Jacky Lam
Hi All,

 Is there any document on web summarized the hardware (especially, 
CPU) that a Linux depends on. For example, if a CPU doesn't support 
misaligned access (no exception will be generated when misalignment 
access), can Linux run on that?

Thanks.

BR,
Jacky

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Debug Kernel Crash

2011-03-31 Thread swathi suresh
Hi,

does /var/crash or kdump target directory as mentioned in
 /etc/kdump.conf exists?


One thing i forgot to mention is in my root there is not configuration file
/etc/sysconfig/kdump or
/etc/kdump.conf, is this anything to do with this and not even /var/crash, i
got the latest kexec-tool
source from the git and build it.


 sometime it may be a while before it starts to dump if memory on
 machine is huge and


i almost left my system for an hour, but it was in the same hang state.


 you have set kdump level to dump everything.


Where else can be the configuration file other then /etc/sysconfig/kdump or
/etc/kdump.conf.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Requirement of Linux port

2011-03-31 Thread Michael Blizek
Hi!

On 11:30 Fri 01 Apr , Jacky Lam wrote:
 Hi All,
 
  Is there any document on web summarized the hardware (especially, 
 CPU) that a Linux depends on. For example, if a CPU doesn't support 
 misaligned access (no exception will be generated when misalignment 
 access), can Linux run on that?

I do not know of such a document, but I have not looked for one so far. But
basically:
- CPUs which do not support misaligned access are supported.
- CPUs less than 32 bit are not supported. When compiling with gcc, int is
  always 32 bit, long is 32/64 bit (depending on 32/64 bit CPU) and long long
  is always 64 bit. You can also use __u8 __u16 __u32 __u64 __s8 __s16 __s32
  and __s64, if you want to.
- Both big endian and little endian is supported.

The interesting stuff starts if you want to port a program to/from other OSes.
Then you have to take care of missing libs/syscalls (like I/O multiplexer and
a lot of GUIs stuff) or syscalls which behave differently (like fsync())...

-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies