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? |
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. |
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. |
kmap
kmap(page) and kunmap(page) do the trick
http://kneuro.net/linux-mm/index.php?file=kmap.html |
All times are GMT -5. The time now is 05:25 AM. |