<div dir="ltr"><font size="4">Sorry, forgive me. I don't know how to reply the email like you.</font><div><font size="4">My linux kernel version is 3.11, and I do not touch the kvm makefile. Now let me show you in detail.</font></div>
<div><font size="4">First I put the files of my module in " /arch/x86/logger ", "logger" is the directory I create. The Makefile in " /arch/x86/kvm/" I think is the Makefile of kvm. It is like this:</font></div>
<div><div><br></div><div>ccflags-y += -Ivirt/kvm -Iarch/x86/kvm</div><div><br></div><div>CFLAGS_x86.o := -I.</div><div>CFLAGS_svm.o := -I.</div><div>CFLAGS_vmx.o := -I.</div><div><br></div><div>KVM := ../../../virt/kvm</div>
<div><br></div><div>kvm-y<span class="" style="white-space:pre">                        </span>+= $(KVM)/kvm_main.o $(KVM)/ioapic.o \</div><div><span class="" style="white-space:pre">                                </span>$(KVM)/coalesced_mmio.o $(KVM)/irq_comm.o \</div>
<div><span class="" style="white-space:pre">                                </span>$(KVM)/eventfd.o $(KVM)/irqchip.o</div><div>kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)<span class="" style="white-space:pre">        </span>+= $(KVM)/assigned-dev.o $(KVM)/iommu.o</div>
<div>kvm-$(CONFIG_KVM_ASYNC_PF)<span class="" style="white-space:pre">        </span>+= $(KVM)/async_pf.o</div><div><br></div><div>kvm-y<span class="" style="white-space:pre">                        </span>+= x86.o mmu.o emulate.o i8259.o irq.o lapic.o \</div>
<div><span class="" style="white-space:pre">                        </span> i8254.o cpuid.o pmu.o</div><div>kvm-intel-y<span class="" style="white-space:pre">                </span>+= vmx.o</div><div>kvm-amd-y<span class="" style="white-space:pre">                </span>+= svm.o</div>
<div><br></div><div>obj-$(CONFIG_KVM)<span class="" style="white-space:pre">        </span>+= kvm.o</div><div>obj-$(CONFIG_KVM_INTEL)<span class="" style="white-space:pre">        </span>+= kvm-intel.o</div><div>obj-$(CONFIG_KVM_AMD)<span class="" style="white-space:pre">        </span>+= kvm-amd.o</div>
</div><div><br></div><div><font size="4">And the Makefile of my module in "/arch/x86/logger" is like this:</font></div><div><br></div><div><div>ifneq ($(KERNELRELEASE),)</div><div><span class="" style="white-space:pre">        </span>obj-m := logger.o</div>
<div><span class="" style="white-space:pre">        </span>logger-objs := logger_main.o</div><div>else<br></div><div><br></div><div>KERNELDIR ?= /lib/modules/$(shell uname -r)/build</div><div>PWD := $(shell pwd)</div><div><br></div>
<div>modules:<br></div><div><span class="" style="white-space:pre">        </span>$(MAKE) -C $(KERNELDIR) M=$(PWD) modules</div><div>endif</div><div><br></div><div>clean:</div><div><span class="" style="white-space:pre">        </span>rm -rf *.o *.ko *.mod.c</div>
</div><div><br></div><div><font size="4">So I compile my module first by running "make", then insmod it. I don't install it because I don't know if it is necessary. Then I go to the root of my linux code, and run a shell containing "make modules". Then it will show that :</font></div>
<div><div><br></div><div>make -j 16 modules</div><div>make[1]: Nothing to be done for `all'.</div><div> CHK include/generated/uapi/linux/version.h</div><div>make[1]: Nothing to be done for `relocs'.</div><div>
CHK include/generated/utsrelease.h</div><div> CALL scripts/checksyscalls.sh</div><div> CC [M] arch/x86/kvm/x86.o</div><div> LD [M] arch/x86/kvm/kvm.o</div><div> LD [M] arch/x86/kvm/kvm-intel.o</div><div> LD [M] arch/x86/kvm/kvm-amd.o</div>
<div> Building modules, stage 2.</div><div> MODPOST 2832 modules</div><div>ERROR: "print_record" [arch/x86/kvm/kvm.ko] undefined!</div><div>make[1]: *** [__modpost] Error 1</div><div>make: *** [modules] Error 2</div>
<div>rmmod kvm_intel</div><div>rmmod kvm</div><div>cp /home/tanle/study/replay/linux-log/linux-3.11-replay/arch/x86/kvm/kvm.ko /lib/modules/3.11.0+/kernel/arch/x86/kvm/kvm.ko</div><div>cp /home/tanle/study/replay/linux-log/linux-3.11-replay/arch/x86/kvm/kvm-intel.ko /lib/modules/3.11.0+/kernel/arch/x86/kvm/kvm-intel.ko</div>
<div>modprobe kvm</div><div>modprobe kvm_intel</div></div><div><br></div><div><font size="4">Notice that I add two sentences to the /arch/x86/kvm/x86.c:</font></div><div><br></div><div>extern void print_record(char *format); //This functino is defined in my module, this sentence is global</div>
<div><br></div><div>print_record(NULL); //Call this function in the vcpu_enter_guest() function</div><div><br></div><div><font size="4">So I don't know how to deal with this. I have poor knowledge about makefile and KBuild. </font></div>
<div><font size="4">Thanks for helping me again!</font></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/14 Chetan Nanda <span dir="ltr"><<a href="mailto:chetannanda@gmail.com" target="_blank">chetannanda@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Tue, Jan 14, 2014 at 12:38 PM, Le Tan <span dir="ltr"><<a href="mailto:tamlokveer@gmail.com" target="_blank">tamlokveer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font size="4">Thanks very much! I will try that later. What you mentioned is another amazing sight. But I am confused that why it can't work if I export a function from my module and call it in the kvm? Do I have to modify the makefile of kvm? How? I have referenced to the doc of KBuild. It said that :</font><div>
<div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
Sometimes, an external module uses exported symbols from</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
another external module. kbuild needs to have full knowledge of</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
all symbols to avoid spliitting out warnings about undefined</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
symbols. <font color="#ff0000">Three solutions exist for this situation.</font></div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
NOTE: The method with a top-level kbuild file is recommended</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
but may be impractical in certain situations.</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<font color="#ff0000">Use a top-level kbuild file</font></div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
If you have two modules, foo.ko and bar.ko, where</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
foo.ko needs symbols from bar.ko, you can use a</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
common top-level kbuild file so both modules are</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
compiled in the same build. Consider the following</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
directory layout:</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
./foo/ <= contains foo.ko</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
./bar/ <= contains bar.ko</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
The top-level kbuild file would then look like:</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
#./Kbuild (or ./Makefile):</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
obj-y := foo/ bar/</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
And executing</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
$ make -C $KDIR M=$PWD</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
will then do the expected and compile both modules with</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
full knowledge of symbols from either module.</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<font color="#ff0000"> Use an extra Module.symvers file</font></div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
When an external module is built, a Module.symvers file</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
is generated containing all exported symbols which are</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
not defined in the kernel. To get access to symbols</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
from bar.ko, copy the Module.symvers file from the</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
compilation of bar.ko to the directory where foo.ko is</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
built. During the module build, kbuild will read the</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
Module.symvers file in the directory of the external</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
module, and when the build is finished, a new</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
Module.symvers file is created containing the sum of</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
all symbols defined and not part of the kernel.</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<font color="#ff0000"> Use "make" variable KBUILD_EXTRA_SYMBOLS</font></div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
If it is impractical to copy Module.symvers from</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
another module, you can assign a space separated list</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
of files to KBUILD_EXTRA_SYMBOLS in your build file.</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
These files will be loaded by modpost during the</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
initialization of its symbol tables.</div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<span style="font-size:large;font-family:arial;line-height:normal;color:rgb(34,34,34)"><br></span></div><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<span style="font-size:large;font-family:arial;line-height:normal;color:rgb(34,34,34)">But I have tried those methods. They don't work. Why?</span></div></div><div style="line-height:20px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<font size="4">Thanks for your help very much!</font></div></div></blockquote><div> </div></div></div><div>Please show your kvm module makefile, </div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
<span style="font-family:arial;font-size:small;line-height:normal"> </span><br></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div style="line-height:20px;font-size:14.285715103149414px;font-family:'Microsoft YaHei UI','Microsoft YaHei',SimSun,'Segoe UI',Tahoma,Helvetica,sans-serif,'Microsoft YaHei',Georgia,Helvetica,Arial,sans-serif,宋体,PMingLiU,serif">
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/14 Henrique Rodrigues <span dir="ltr"><<a href="mailto:henriquesilvar@gmail.com" target="_blank">henriquesilvar@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Le,<div><br></div><div>You can do that by exporting a function pointer from the kvm code that is only called if it is not null. Then, when you load your module, you set that exported function pointer (I'm assuming that you want to call your module's function from the kvm code... ). Here is a post on how to do that:</div>
<div><br></div><div><a href="http://stackoverflow.com/questions/11463184/how-to-use-exported-symbols-in-the-linux-kernel" target="_blank">http://stackoverflow.com/questions/11463184/how-to-use-exported-symbols-in-the-linux-kernel</a><br>
</div><div><a href="http://stackoverflow.com/questions/1196944/can-i-replace-a-linux-kernel-function-with-a-module" target="_blank">http://stackoverflow.com/questions/1196944/can-i-replace-a-linux-kernel-function-with-a-module</a><br>
</div>
<div><div><br></div><div>Best,</div></div><div class="gmail_extra"><div><div dir="ltr"><div>--</div>Henrique Rodrigues<br><div><a href="http://www.dcc.ufmg.br/~hsr" target="_blank">http://www.dcc.ufmg.br/~hsr</a></div></div>
</div>
<br><br><div class="gmail_quote"><div><div>On Mon, Jan 13, 2014 at 2:47 AM, Le Tan <span dir="ltr"><<a href="mailto:tamlokveer@gmail.com" target="_blank">tamlokveer@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">Hello! I am writing a device driver module. I define some functions in the module, for example print_record(). I am doing something in the kvm, so I want to call print_record() in the file of kvm module, for example, I may call print_record() in file /arch/x86/kvm/x86.c to put something into my device driver module.<div>
Now comes the question.</div><div>1. Where should I put the codes of my device driver module? It's the first time I write the device driver.</div><div>2. After compiling my module, I encounter an error when I compile the kvm module.</div>
<div> ERROR: "print_record" [arch/x86/kvm/kvm.ko] undefined!</div><div> I use EXPORT_SYMBOL(print_record) in my module file. I use "extern" to declare print_record() and then call print_record() in file x86.c. </div>
<div> To solve this problem, I have tried to copy the Module.symvers from my module folder to /arch/x86/kvm/. But it doesn't work. I have also tried to add <strong style="vertical-align:baseline;line-height:18px;font-size:14px;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;margin:0px;border:0px;padding:0px">KBUILD_EXTRA_SYMBOLS </strong>to the Makefile of kvm. It doesn't work either.</div>
<div> I cat /proc/kallsyms and find that the type of symbol "print_record" is "t" ( local text). What should I do? How to call functions defined in my own module from kvm? Maybe there is something wrong in Makefiles?</div>
<div><br></div><div>Any suggestion is appreciated!</div><div>Thanks!</div></div>
<br></div></div>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>