* [PATCH 1/4] Add kvm_trace.c to hack-files-x86
2008-09-22 17:52 [PATCH 0/4] Allow enabling kvm_trace on external module Eduardo Habkost
@ 2008-09-22 17:52 ` Eduardo Habkost
2008-09-22 17:52 ` [PATCH 2/4] Hack DEFINE_SIMPLE_ATTRIBUTE for lost_records_get() also Eduardo Habkost
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Eduardo Habkost @ 2008-09-22 17:52 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Eduardo Habkost
We will add some hacks for kvm_trace.c on hack-module.awk
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
kernel/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/Makefile b/kernel/Makefile
index 3f5f6da..151183a 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -28,7 +28,7 @@ unifdef = mv $1 $1.orig && \
hack = $(call _hack,$T/$(strip $1))
-hack-files-x86 = kvm_main.c mmu.c vmx.c svm.c x86.c irq.h lapic.c i8254.c
+hack-files-x86 = kvm_main.c mmu.c vmx.c svm.c x86.c irq.h lapic.c i8254.c kvm_trace.c
hack-files-ia64 = kvm_main.c kvm_fw.c
hack-files = $(hack-files-$(ARCH_DIR))
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/4] Hack DEFINE_SIMPLE_ATTRIBUTE for lost_records_get() also
2008-09-22 17:52 [PATCH 0/4] Allow enabling kvm_trace on external module Eduardo Habkost
2008-09-22 17:52 ` [PATCH 1/4] Add kvm_trace.c to hack-files-x86 Eduardo Habkost
@ 2008-09-22 17:52 ` Eduardo Habkost
2008-09-22 17:52 ` [PATCH 3/4] relay_open() compat Eduardo Habkost
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Eduardo Habkost @ 2008-09-22 17:52 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Eduardo Habkost
Change the DEFINE_SIMPLE_ATTRIBUTE pattern to match the lost_records_get()
definition also, so kvm_trace can compile on older kernels.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
kernel/x86/hack-module.awk | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/x86/hack-module.awk b/kernel/x86/hack-module.awk
index 3f364f8..7f59483 100644
--- a/kernel/x86/hack-module.awk
+++ b/kernel/x86/hack-module.awk
@@ -42,11 +42,11 @@ BEGIN { split("INIT_WORK tsc_khz desc_struct ldttss_desc64 desc_ptr " \
$0 = "\t.VMA_OPS_FAULT(fault) = VMA_OPS_FAULT_FUNC(" fcn "),"
}
-/^static int .*_stat_get/ {
+/^static int (.*_stat_get|lost_records_get)/ {
$3 = "__" $3
}
-/DEFINE_SIMPLE_ATTRIBUTE.*_stat_get/ {
+/DEFINE_SIMPLE_ATTRIBUTE.*(_stat_get|lost_records_get)/ {
name = gensub(/,/, "", "g", $2);
print "MAKE_SIMPLE_ATTRIBUTE_GETTER(" name ")"
}
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/4] relay_open() compat
2008-09-22 17:52 [PATCH 0/4] Allow enabling kvm_trace on external module Eduardo Habkost
2008-09-22 17:52 ` [PATCH 1/4] Add kvm_trace.c to hack-files-x86 Eduardo Habkost
2008-09-22 17:52 ` [PATCH 2/4] Hack DEFINE_SIMPLE_ATTRIBUTE for lost_records_get() also Eduardo Habkost
@ 2008-09-22 17:52 ` Eduardo Habkost
2008-09-24 13:50 ` Avi Kivity
2008-09-22 17:52 ` [PATCH 4/4] Add --with-kvm-trace arg to configure Eduardo Habkost
2008-09-24 13:48 ` [PATCH 0/4] Allow enabling kvm_trace on external module Avi Kivity
4 siblings, 1 reply; 9+ messages in thread
From: Eduardo Habkost @ 2008-09-22 17:52 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Eduardo Habkost
On 2.6.21 a new parameter was added to relay_open(). Handle this parameter
on kvm_relay_open() if needed.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
kernel/external-module-compat-comm.h | 19 +++++++++++++++++++
kernel/external-module-compat.c | 22 ++++++++++++++++++++++
kernel/x86/hack-module.awk | 2 ++
3 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/kernel/external-module-compat-comm.h b/kernel/external-module-compat-comm.h
index 8b417d4..e07a6b6 100644
--- a/kernel/external-module-compat-comm.h
+++ b/kernel/external-module-compat-comm.h
@@ -533,3 +533,22 @@ struct pci_dev;
struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+
+#include <linux/relay.h>
+
+/* relay_open() interface has changed on 2.6.21 */
+
+struct rchan *kvm_relay_open(const char *base_filename,
+ struct dentry *parent,
+ size_t subbuf_size,
+ size_t n_subbufs,
+ struct rchan_callbacks *cb,
+ void *private_data);
+
+#else
+
+#define kvm_relay_open relay_open
+
+#endif
diff --git a/kernel/external-module-compat.c b/kernel/external-module-compat.c
index 4b9a9f2..c0a0355 100644
--- a/kernel/external-module-compat.c
+++ b/kernel/external-module-compat.c
@@ -276,3 +276,25 @@ int intel_iommu_found()
}
#endif
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+
+/* relay_open() interface has changed on 2.6.21 */
+
+struct rchan *kvm_relay_open(const char *base_filename,
+ struct dentry *parent,
+ size_t subbuf_size,
+ size_t n_subbufs,
+ struct rchan_callbacks *cb,
+ void *private_data)
+{
+ struct rchan *chan = relay_open(base_filename, parent,
+ subbuf_size, n_subbufs,
+ cb);
+ if (chan)
+ chan->private_data = private_data;
+ return chan;
+}
+
+#endif
diff --git a/kernel/x86/hack-module.awk b/kernel/x86/hack-module.awk
index 7f59483..3a491cd 100644
--- a/kernel/x86/hack-module.awk
+++ b/kernel/x86/hack-module.awk
@@ -73,6 +73,8 @@ BEGIN { split("INIT_WORK tsc_khz desc_struct ldttss_desc64 desc_ptr " \
}
}
+{ sub(/relay_open/, "kvm_relay_open") }
+
{ print }
/kvm_x86_ops->run/ {
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/4] Add --with-kvm-trace arg to configure
2008-09-22 17:52 [PATCH 0/4] Allow enabling kvm_trace on external module Eduardo Habkost
` (2 preceding siblings ...)
2008-09-22 17:52 ` [PATCH 3/4] relay_open() compat Eduardo Habkost
@ 2008-09-22 17:52 ` Eduardo Habkost
2008-09-24 13:48 ` [PATCH 0/4] Allow enabling kvm_trace on external module Avi Kivity
4 siblings, 0 replies; 9+ messages in thread
From: Eduardo Habkost @ 2008-09-22 17:52 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Eduardo Habkost
./configure --with-kvm-trace will set a CONFIG_KVM_TRACE option on a
kernel/config.kbuild file. This file can be included from the Kbuild
files to get kvm-specific CONFIG_* definitions.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
.gitignore | 1 +
configure | 11 +++++++++++
kernel/Makefile | 7 ++++++-
kernel/x86/Kbuild | 4 ++++
4 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/.gitignore b/.gitignore
index bc54832..474faa0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ vgabios/*.txt
extboot/extboot.bin
extboot/extboot.img
extboot/signrom
+kernel/config.kbuild
kernel/modules.order
kernel/Module.symvers
kernel/Modules.symvers
diff --git a/configure b/configure
index 3bb10ce..78c2f9c 100755
--- a/configure
+++ b/configure
@@ -8,6 +8,7 @@ objcopy=objcopy
want_module=1
qemu_cflags=
qemu_ldflags=
+kvm_trace=
qemu_opts=()
cross_prefix=
arch=`uname -m`
@@ -22,6 +23,7 @@ usage() {
--cross-prefix=PREFIX prefix for cross compile
--prefix=PREFIX where to install things ($prefix)
--with-patched-kernel don't use external module
+ --with-kvm-trace Enable kvm_trace
--kerneldir=DIR kernel build directory ($kerneldir)
--qemu-cflags=CFLAGS CFLAGS to add to qemu configuration
--qemu-ldflags=LDFLAGS LDFLAGS to add to qemu configuration
@@ -56,6 +58,9 @@ while [[ "$1" = -* ]]; do
--with-patched-kernel)
want_module=
;;
+ --with-kvm-trace)
+ kvm_trace=y
+ ;;
--qemu-cflags)
qemu_cflags="$arg"
;;
@@ -131,3 +136,9 @@ CC=$cross_prefix$cc
LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy
EOF
+
+if [ -n "$want_module" ];then
+cat <<EOF > kernel/config.kbuild
+CONFIG_KVM_TRACE=$kvm_trace
+EOF
+fi
diff --git a/kernel/Makefile b/kernel/Makefile
index 151183a..9842dab 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -1,4 +1,5 @@
include ../config.mak
+include config.kbuild
ARCH_DIR = $(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH))
ARCH_CONFIG := $(shell echo $(ARCH_DIR) | tr '[:lower:]' '[:upper:]')
@@ -33,12 +34,16 @@ hack-files-ia64 = kvm_main.c kvm_fw.c
hack-files = $(hack-files-$(ARCH_DIR))
+ifeq ($(CONFIG_KVM_TRACE),y)
+module_defines += -DCONFIG_KVM_TRACE=y
+endif
+
all:: header-link prerequisite
# include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat
$(MAKE) -C $(KERNELDIR) M=`pwd` \
LINUXINCLUDE="-I`pwd`/include -Iinclude -Iarch/${ARCH_DIR}/include -I`pwd`/include-compat \
-include include/linux/autoconf.h \
- -include `pwd`/$(ARCH_DIR)/external-module-compat.h"
+ -include `pwd`/$(ARCH_DIR)/external-module-compat.h $(module_defines)"
"$$@"
sync: header-sync source-sync header-link
diff --git a/kernel/x86/Kbuild b/kernel/x86/Kbuild
index 8dc0483..bc584f9 100644
--- a/kernel/x86/Kbuild
+++ b/kernel/x86/Kbuild
@@ -1,3 +1,7 @@
+# trick to get the kvm-specific CONFIG_KVM_* definitions,
+# because the kernel source tree won't have them
+include $(obj)/../config.kbuild
+
obj-m := kvm.o kvm-intel.o kvm-amd.o
kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o ../anon_inodes.o irq.o i8259.o \
lapic.o ioapic.o preempt.o i8254.o coalesced_mmio.o \
--
1.5.5.GIT
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 0/4] Allow enabling kvm_trace on external module
2008-09-22 17:52 [PATCH 0/4] Allow enabling kvm_trace on external module Eduardo Habkost
` (3 preceding siblings ...)
2008-09-22 17:52 ` [PATCH 4/4] Add --with-kvm-trace arg to configure Eduardo Habkost
@ 2008-09-24 13:48 ` Avi Kivity
2008-09-24 17:26 ` Eduardo Habkost
4 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2008-09-24 13:48 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: kvm
Eduardo Habkost wrote:
> This series adds compat code to allow enabling kvm_trace when building
> KVM as an external module on older kernels.
>
> The most hackish part is the last patch, that adds --with-kvm-trace to
> configure and adds an include to a generated file on kernel/x86/Kbuild. It
> doesn't look pretty, so suggestions on how to make this better are
> welcome.
>
Applied all, thanks. We could improve Kbuild by having kernel/Makefile
include config.mak and pass some variable to Kbuild somehow, but diving
into Kbuild isn't my idea of a week well spent.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/4] Allow enabling kvm_trace on external module
2008-09-24 13:48 ` [PATCH 0/4] Allow enabling kvm_trace on external module Avi Kivity
@ 2008-09-24 17:26 ` Eduardo Habkost
2008-09-25 11:25 ` Avi Kivity
0 siblings, 1 reply; 9+ messages in thread
From: Eduardo Habkost @ 2008-09-24 17:26 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Wed, Sep 24, 2008 at 04:48:35PM +0300, Avi Kivity wrote:
> Eduardo Habkost wrote:
>> This series adds compat code to allow enabling kvm_trace when building
>> KVM as an external module on older kernels.
>>
>> The most hackish part is the last patch, that adds --with-kvm-trace to
>> configure and adds an include to a generated file on kernel/x86/Kbuild. It
>> doesn't look pretty, so suggestions on how to make this better are
>> welcome.
>>
>
> Applied all, thanks. We could improve Kbuild by having kernel/Makefile
> include config.mak and pass some variable to Kbuild somehow, but diving
> into Kbuild isn't my idea of a week well spent.
Oops. I've just noticed I broke './configure --with-patched-kernel'. Fix below.
---
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Wed, 24 Sep 2008 14:11:42 -0300
Subject: Always generate config.kbuild
When implementing --with-kvm-trace, I supposed make would never enter
the 'kernel' directory when compiling with --with-patched-kernel. I was
wrong and broke --with-patched-kernel.
Change configure to always generate config.kbuild on the kernel
directory. Otherwise make will explode on 'make header-sync', that runs
even when --with-patched-kernel was used.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
configure | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 78c2f9c..3b27364 100755
--- a/configure
+++ b/configure
@@ -137,8 +137,6 @@ LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy
EOF
-if [ -n "$want_module" ];then
cat <<EOF > kernel/config.kbuild
CONFIG_KVM_TRACE=$kvm_trace
EOF
-fi
--
1.5.5.GIT
--
Eduardo
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/4] Allow enabling kvm_trace on external module
2008-09-24 17:26 ` Eduardo Habkost
@ 2008-09-25 11:25 ` Avi Kivity
0 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2008-09-25 11:25 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: kvm
Eduardo Habkost wrote:
> From: Eduardo Habkost <ehabkost@redhat.com>
> Date: Wed, 24 Sep 2008 14:11:42 -0300
> Subject: Always generate config.kbuild
>
> When implementing --with-kvm-trace, I supposed make would never enter
> the 'kernel' directory when compiling with --with-patched-kernel. I was
> wrong and broke --with-patched-kernel.
>
> Change configure to always generate config.kbuild on the kernel
> directory. Otherwise make will explode on 'make header-sync', that runs
> even when --with-patched-kernel was used.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread