All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chai Wen <chaiw.fnst@cn.fujitsu.com>
To: Mathew Li <mathew.li100@gmail.com>
Cc: <kvm@vger.kernel.org>
Subject: Re: Naive questions regarding KVM
Date: Fri, 23 May 2014 13:51:01 +0800	[thread overview]
Message-ID: <537EE1C5.9020304@cn.fujitsu.com> (raw)
In-Reply-To: <CALU2kfnXbafsbdofD7jUo3ne9FKDAwGa+NBgJsRfXhgj-J05PA@mail.gmail.com>

On 05/23/2014 12:57 PM, Mathew Li wrote:

> Hi All,
> 
> I want to learn KVM code. Apologies for asking really simple
> questions. I have Ubuntu 12.04 32bit installed on my laptop. As I
> understand there are two modules of the KVM. One is called kvm.ko and
> other arch specific e.g. in my case it is kvm-intel.ko. These modules
> are already present in my system. I can do modinfo and it lists them.
> 
> What I want to do is modify KVM code to add print statements to
> understand things better. But I don't know what code to modify and how
> to rebuild these two modules for my system, so that they have my print
> statements. Could you please guide me what code do I need to download
> and how to compile that to get the modules regenerated for my system?
> If I need to download the whole Linux kernel then where in Linux
> kernel KVM code lives? I don't want to compile the whole linux kernel,
> I just want to compile these modules for my system.
> 
> Thanks a lot for any help you could provide.
>


Hi Li:

I happend to have an similar example for kernel-3.3.3.
If you want to build kvm modules out of a kernel tree you can copy files in kernel root dirs:
'arch/x86/kvm' and 'virt/kvm' to a dedicated dir like '/home/wrok/kvm_debug'.
Its Makefile could be like below.
Building command is some command like "make -C ../linux-3.3.3 M=`pwd` modules" in dir 'kvm_debug'

And trace.h & mmutrace.h need a littile change:
# [root@chaiw kvm_debug]# diff -U 5 trace.h ../linux-3.3.3/arch/x86/kvm/trace.h
# --- trace.h   2014-05-05 15:25:16.319200716 +0800
# +++ ../linux-3.3.3/arch/x86/kvm/trace.h       2012-04-23 06:39:43.000000000 +0800
# @@ -820,11 +820,11 @@
#                 __entry->gpa_match ? "GPA" : "GVA")
#  );
#  #endif /* _TRACE_KVM_H */
#
#  #undef TRACE_INCLUDE_PATH
# -#define TRACE_INCLUDE_PATH /home/work/kvm_debug
# +#define TRACE_INCLUDE_PATH arch/x86/kvm
#  #undef TRACE_INCLUDE_FILE
#  #define TRACE_INCLUDE_FILE trace
#
#  /* This part must be outside protection */
#  #include <trace/define_trace.h>
#
# [root@chaiw kvm_debug]# diff -U 5 mmutrace.h ../linux-3.3.3/arch/x86/kvm/mmutrace.h
# --- mmutrace.h        2014-05-05 15:28:19.300189943 +0800
# +++ ../linux-3.3.3/arch/x86/kvm/mmutrace.h    2012-04-23 06:39:43.000000000 +0800
# @@ -244,11 +244,11 @@
#                 __entry->access)
#  );
#  #endif /* _TRACE_KVMMMU_H */
#
#  #undef TRACE_INCLUDE_PATH
# -#define TRACE_INCLUDE_PATH /home/work/kvm_debug
# +#define TRACE_INCLUDE_PATH .
#  #undef TRACE_INCLUDE_FILE
#  #define TRACE_INCLUDE_FILE mmutrace
#
#  /* This part must be outside protection */
#  #include <trace/define_trace.h>


------- Makefile ---------
# depended on kernel-3.3.3
# for kvm module
kvm-y += kvm_main.o ioapic.o coalesced_mmio.o irq_comm.o eventfd.o \
         assigned-dev.o
kvm-$(CONFIG_IOMMU_API) += iommu.o
kvm-$(CONFIG_KVM_ASYNC_PF) += async_pf.o
kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o i8254.o timer.o \
         cpuid.o pmu.o
obj-m := kvm.o

# for kvm_intel & kvm_amd modules
kvm_intel-y += vmx.o
kvm_amd-y += svm.o
obj-m += kvm_intel.o
obj-m += kvm_amd.o

clean:
        @-rm -f *.o
        @-rm -f *mod*
        @-rm -f *.ko


thanks
chai wen

 
> Thanks!
> Matt
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



-- 
Regards

Chai Wen

      parent reply	other threads:[~2014-05-23  5:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23  4:57 Naive questions regarding KVM Mathew Li
2014-05-23  5:12 ` Jidong Xiao
2014-05-23  5:23   ` Mathew Li
2014-05-23  5:51 ` Chai Wen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=537EE1C5.9020304@cn.fujitsu.com \
    --to=chaiw.fnst@cn.fujitsu.com \
    --cc=kvm@vger.kernel.org \
    --cc=mathew.li100@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.