Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to vmap kernel module's memory?
    text
    copied!<p>Is there any constraint to the mapping kernel module's memory via the <code>vmap</code>? On my system I write a simple KMOD, that maps a kernel-function (printk) and a module-function (printx) and check if mappings are equals. The result shows me that there is a problem with mapping module's <code>printx</code> - the mapping and the function's code does not equals. Could someone explain me what I do wrong? And here is the code:</p> <p>// vmap-test.c</p> <pre><code>#include &lt;linux/module.h&gt; #include &lt;linux/kernel.h&gt; #include &lt;linux/mm.h&gt; int printx(void) { return 0; } void vmap_action(unsigned long address) { void * mapping; struct page * page; page = virt_to_page(address); mapping = vmap(&amp;page, 1, VM_MAP, PAGE_KERNEL); if (mapping) { int i = 0; void * data = mapping + offset_in_page(address); printk("VMAP: src %p -&gt; dst %p\n", (void *)address, data); for (i=0; i&lt;16; i++) { printk("%.02x %.02x\n", ((u8 *)address)[i], ((u8 *)data)[i]); } vunmap(mapping); } } int my_module_init(void) { vmap_action((unsigned long)printk); vmap_action((unsigned long)printx); return 0; } module_init(my_module_init); void my_module_exit(void) { } module_exit(my_module_exit); </code></pre> <p>And the result with <code>dmesg</code> is:</p> <p>vmap(printk)</p> <pre><code>[88107.398146] VMAP: src ffffffff813dfaef -&gt; dst ffffc900117ddaef [88107.398148] 55 55 [88107.398149] 48 48 [88107.398150] 89 89 [88107.398151] e5 e5 [88107.398152] 48 48 [88107.398153] 83 83 [88107.398154] ec ec [88107.398155] 50 50 [88107.398156] 0f 0f [88107.398156] 1f 1f [88107.398157] 44 44 [88107.398158] 00 00 [88107.398159] 00 00 [88107.398160] 48 48 [88107.398161] 8d 8d [88107.398162] 45 45 </code></pre> <p>vmap(printx)</p> <pre><code>[88107.398164] VMAP: src ffffffffa009a010 -&gt; dst ffffc900117fd010 [88107.398166] 55 35 [88107.398167] 48 fb [88107.398168] 89 53 [88107.398169] e5 d5 [88107.398170] 0f f7 [88107.398171] 1f 97 [88107.398171] 44 ee [88107.398172] 00 fd [88107.398173] 00 d5 [88107.398174] 31 2d [88107.398175] c0 bf [88107.398176] 5d f6 [88107.398177] c3 2d [88107.398178] 0f bd [88107.398179] 1f b7 [88107.398180] 00 99 </code></pre> <p>Any suggestions are welcome :) Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload