LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-15-2012, 09:46 PM   #1
cmccullo
Member
 
Registered: Jan 2011
Posts: 31

Rep: Reputation: 0
Kernel panic - not syncing


I am working in the kernel. Iím trying to read and write data directly to a page frame. I know the frame is in physical memory at the time I try to read and write. Here is a short example.

char *in, c;
struct page *page;
in = (char *)page_to_phys(page);
c = *in;

As near as I can tell, it crashes whenever I try to read from the page. If I leave out the last line, it does not crash.

When it crashes, I get this error message:
Kernel panic - not syncing: Segfault with no mm
082898dc: [<081f0ef4>] dump_stack+0x1c/0x20
082898f4: [<081f0fb8>] panic+0x4b/0x12d
08289928: [<0805a148>] segv+0x10a/0x234
082899d0: [<0805a2b7>] segv_handler+0x45/0x4f
082899f8: [<08065e14>] sig_handler_common+0x61/0x70
08289a70: [<08065eef>] sig_handler+0x31/0x3e
08289a7c: [<08065bdc>] handle_signal+0x4e/0x7b
08289a9c: [<080675d3>] hard_handler+0xf/0x14
08289aac: [<b7801400>] 0xb7801400


EIP: 0073:[<b7801424>] CPU: 0 Not tainted ESP: 007b:bf8bf398 EFLAGS: 00200292
Not tainted
EAX: 00000000 EBX: 00006505 ECX: 00000013 EDX: 00006505
ESI: 00006501 EDI: 0000001c EBP: bf8bf3c4 DS: 007b ES: 007b
0828988c: [<0806adf6>] show_regs+0xc5/0xcb
082898b8: [<0805a4c7>] panic_exit+0x23/0x39
082898cc: [<080892d8>] notifier_call_chain+0x25/0x4a
082898f4: [<0808932b>] atomic_notifier_call_chain+0x15/0x17
08289904: [<081f0fd3>] panic+0x66/0x12d
08289928: [<0805a148>] segv+0x10a/0x234
082899d0: [<0805a2b7>] segv_handler+0x45/0x4f
082899f8: [<08065e14>] sig_handler_common+0x61/0x70
08289a70: [<08065eef>] sig_handler+0x31/0x3e
08289a7c: [<08065bdc>] handle_signal+0x4e/0x7b
08289a9c: [<080675d3>] hard_handler+0xf/0x14
08289aac: [<b7801400>] 0xb7801400

Terminated

How do I properly read from and write to a page frame from inside the kernel?
 
Old 01-16-2012, 08:01 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 1,565

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Why are you trying to access using the physical page address? Kernel code uses kernel virtual addresses. Physical addresses are used by devices that don't go through memory management, like PCI bus masters.

Edit: your example would crash anyway, because you haven't allocated page.

Last edited by smallpond; 01-16-2012 at 08:11 AM. Reason: add note
 
Old 01-17-2012, 05:04 PM   #3
cmccullo
Member
 
Registered: Jan 2011
Posts: 31

Original Poster
Rep: Reputation: 0
I am working on a masters thesis project. I'm not an operating systems expert, I am in Information Assurance. Thus the odd request.

At the point in the kernel I am adding my code, the page is allocated and the page is physically in memory. If there is a better way to access it, through it's virtual address, its pte, or some other way, that is what I am looking for. I suspect my example above is using the wrong pointers and is trying to access the wrong area anyway. I know what the target page contains and want to verify that I am pointing correctly by reading the page.
 
Old 01-22-2012, 10:29 AM   #4
cmccullo
Member
 
Registered: Jan 2011
Posts: 31

Original Poster
Rep: Reputation: 0
kmap

kmap(page) and kunmap(page) do the trick
http://kneuro.net/linux-mm/index.php?file=kmap.html
 
  


Reply

Tags
kernel panic


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Kernel panic - not syncing vttay03 Slackware 7 01-01-2010 09:14 PM
Kernel Panic - not syncing lazylogic Slackware 10 04-18-2008 04:13 AM
kernel panic - not syncing kgandhi5 Linux - Newbie 5 12-08-2007 09:48 PM
Kernel panic-not syncing PowersurgeX Linux - Newbie 5 09-14-2006 02:27 PM
kernel panic - not syncing gentoo_user Linux - Hardware 1 06-01-2006 08:48 PM


All times are GMT -5. The time now is 03:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration