Hollis already pointed me to the mkasm-values patches which are the 
continuation of the mkasm-offset discussion on lkml Hollis last patch was based 
on.
As stated before by Xiantao and Hollis in this thread the mkasm-value patches 
are not yet accepted upstream, but may be useful for us.
Based on Hollis old mkasm-offsets patch, the further discussion on lkml and 
Xiantaos suggestion about the FORCE target I created a mkasm-values patch that 
now is at least able to do what we need for ppc and should fit the ia64 needs 
too.
We might use it internally until mkasm-values is accepted in any way or in a 
local form like ia64 that currently use their own script - let us at least use 
a common one together and mkasm-values may be a good base for that ;-)
The current patch is for discussion only because it won't fit git head of avi's 
tree - I need to rebase Hollis tree first and I'll send an update once I get 
around to do it.

The patch work to create, and re-generate asm-values.h as we need it and since now every 
architecture has its own arch/kvm&asm directory we can even keep the name 
"asm-values.h" the lkml patches expect. Because these preview patches are for 
discussion only I attach both to this mail instead of sending standard [patch][x/y] mails.

@Zhang Wai - afaik you use Hollis kvmppc development tree, you can just remove 
the old mkasm-offset patch and add these two to get the offset stuff to work 
for now

--

Grüsse / regards, Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization
+49 7031/16-3385
[EMAIL PROTECTED]
[EMAIL PROTECTED]

IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen Geschäftsführung: Herbert Kircher Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
diff -r 78da6ce942cc include/asm-generic/asm-values.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/include/asm-generic/asm-values.h  Mon Dec 17 13:38:19 2007 +0100
@@ -0,0 +1,7 @@
+#define DEFINE(sym, val) \
+       asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+
+#define BLANK() asm volatile("\n->" : : )
+
+#define OFFSET(sym, str, mem) \
+       DEFINE(sym, offsetof(struct str, mem));
diff -r 78da6ce942cc scripts/Makefile.asm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/Makefile.asm      Tue Dec 18 10:36:48 2007 +0100
@@ -0,0 +1,29 @@
+# ==========================================================================
+# Help generate definitions needed by assembly language modules.
+# ==========================================================================
+
+include scripts/Kbuild.include
+
+ifndef asm-values_h
+    asm-values := $(shell test -e $(srctree)/$(src)/asm-values.c && echo ok)
+    ifneq ($(asm-values),)
+       asm-values_h := asm-values.h
+       asm-values   := asm-values.s
+    endif
+endif
+
+always         += $(asm-values_h)
+targets                += $(asm-values_h) $(asm-values)
+mkasm-values   := $(srctree)/scripts/mkasm-values.sh
+
+quiet_cmd_mkasm-values = GEN     $@
+      cmd_mkasm-values = $(CONFIG_SHELL) $(mkasm-values) $< $@ $(2)
+
+quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
+      cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
+
+$(obj)/asm-values.h: $(obj)/asm-values.s
+       $(call cmd,mkasm-values,$(ASM_NS))
+
+$(obj)/%.s: $(src)/%.c
+       $(call if_changed_dep,cc_s_c)
diff -r 78da6ce942cc scripts/mkasm-values.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/mkasm-values.sh   Mon Dec 17 13:38:19 2007 +0100
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# Input file "*.s", made by Kbuild from a "*.c" source, where values of
+# interest are calculated, is processed in a suitable output header file.
+#
+# $1 - input filename;
+# $2 - output filename;
+# $3 - generate (private) file with given namespace (optional)
+
+set -e
+
+[ -z "$1" ] || [ -z "$2" ] && {
+       echo "$0:
+
+Two parameters needed. Exiting.
+"
+       exit 1
+}
+
+NS=`echo $3 | tr a-z A-Z`
+case $NS in
+       MIPS)
+SED_SCRIPT='
+/^@@@/{
+s|^@@@||;
+s| #.*$||;
+p;
+}'     ;;
+       *)
+TAB="`printf '\t'`"
+SED_SCRIPT="
+/^->/{
+s|^->||;
+s|^\([^ ]*\) [\$#]*\([^ ]*\) \([^$TAB]*\).*|#define \1 \2$TAB/* \3 */|;
+p;
+}"     ;;
+esac
+
+NS=__ASM_VALUES_${NS:=H}__
+
+exec 1>$2
+echo "\
+#if !defined($NS)
+#define $NS
+
+/*
+ * $2
+ * was generated from
+ * $1
+ */
+"
+sed -ne "$SED_SCRIPT" $1
+
+echo "
+#endif"
diff -r 1b4814a8e0ed drivers/kvm/Makefile
--- a/drivers/kvm/Makefile      Tue Dec 18 10:37:21 2007 +0100
+++ b/drivers/kvm/Makefile      Tue Dec 18 10:37:37 2007 +0100
@@ -14,7 +14,7 @@ kvm-amd-objs = svm.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
 
+include $(srctree)/scripts/Makefile.asm
+FORCE: $(obj)/asm-values.h
 kvm-powerpc-objs := powerpc.o ppc_emulate.o ppc_tlb.o ppc_44x_exceptions.o
 obj-$(CONFIG_KVM_POWERPC) += kvm-powerpc.o
-
-AFLAGS_ppc_44x_exceptions.o := -I$(obj)
diff -r 1b4814a8e0ed drivers/kvm/ppc-offsets.c
--- a/drivers/kvm/ppc-offsets.c Tue Dec 18 10:37:21 2007 +0100
+++ b/drivers/kvm/ppc-offsets.c Tue Dec 18 10:37:37 2007 +0100
@@ -21,38 +21,36 @@
 #include <linux/stddef.h>
 #include <linux/types.h>
 #include "kvm.h"
-
-#define DEFINE(sym, val) \
-       asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+#include <asm-generic/asm-values.h>
 
 int main(void)
 {
        DEFINE(TLBE_BYTES, sizeof(struct tlbe));
 
-       DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, host_stack));
-       DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, host_pid));
-       DEFINE(VCPU_HOST_TLB, offsetof(struct kvm_vcpu, host_tlb));
-       DEFINE(VCPU_SHADOW_TLB, offsetof(struct kvm_vcpu, shadow_tlb));
-       DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, gpr));
-       DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, lr));
-       DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, cr));
-       DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, xer));
-       DEFINE(VCPU_CTR, offsetof(struct kvm_vcpu, ctr));
-       DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, pc));
-       DEFINE(VCPU_GUEST_MSR, offsetof(struct kvm_vcpu, guest_msr));
-       DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, shadow_msr));
-       DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, sprg4));
-       DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, sprg5));
-       DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, sprg6));
-       DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, sprg7));
-       DEFINE(VCPU_PID, offsetof(struct kvm_vcpu, pid));
+       OFFSET(VCPU_HOST_STACK, struct kvm_vcpu, host_stack);
+       OFFSET(VCPU_HOST_PID, struct kvm_vcpu, host_pid);
+       OFFSET(VCPU_HOST_TLB, struct kvm_vcpu, host_tlb);
+       OFFSET(VCPU_SHADOW_TLB, struct kvm_vcpu, shadow_tlb);
+       OFFSET(VCPU_GPRS, struct kvm_vcpu, gpr);
+       OFFSET(VCPU_LR, struct kvm_vcpu, lr);
+       OFFSET(VCPU_CR, struct kvm_vcpu, cr);
+       OFFSET(VCPU_XER, struct kvm_vcpu, xer);
+       OFFSET(VCPU_CTR, struct kvm_vcpu, ctr);
+       OFFSET(VCPU_PC, struct kvm_vcpu, pc);
+       OFFSET(VCPU_GUEST_MSR, struct kvm_vcpu, guest_msr);
+       OFFSET(VCPU_SHADOW_MSR, struct kvm_vcpu, shadow_msr);
+       OFFSET(VCPU_SPRG4, struct kvm_vcpu, sprg4);
+       OFFSET(VCPU_SPRG5, struct kvm_vcpu, sprg5);
+       OFFSET(VCPU_SPRG6, struct kvm_vcpu, sprg6);
+       OFFSET(VCPU_SPRG7, struct kvm_vcpu, sprg7);
+       OFFSET(VCPU_PID, struct kvm_vcpu, pid);
 
-       DEFINE(VCPU_TRAMPOLINE, offsetof(struct kvm_vcpu, trampoline));
-       DEFINE(VCPU_TRAMPOLINE_TLBE, offsetof(struct kvm_vcpu, 
trampoline_tlbe));
-       DEFINE(VCPU_LINEAR, offsetof(struct kvm_vcpu, linear));
-       DEFINE(VCPU_RESUME_GUEST, offsetof(struct kvm_vcpu, resume_guest));
-       DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, last_inst));
-       DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, fault_dear));
-       DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, fault_esr));
+       OFFSET(VCPU_TRAMPOLINE, struct kvm_vcpu, trampoline);
+       OFFSET(VCPU_TRAMPOLINE_TLBE, struct kvm_vcpu, trampoline_tlbe);
+       OFFSET(VCPU_LINEAR, struct kvm_vcpu, linear);
+       OFFSET(VCPU_RESUME_GUEST, struct kvm_vcpu, resume_guest);
+       OFFSET(VCPU_LAST_INST, struct kvm_vcpu, last_inst);
+       OFFSET(VCPU_FAULT_DEAR, struct kvm_vcpu, fault_dear);
+       OFFSET(VCPU_FAULT_ESR, struct kvm_vcpu, fault_esr);
        return 0;
 }
diff -r 1b4814a8e0ed drivers/kvm/ppc_44x_exceptions.S
--- a/drivers/kvm/ppc_44x_exceptions.S  Tue Dec 18 10:37:21 2007 +0100
+++ b/drivers/kvm/ppc_44x_exceptions.S  Tue Dec 18 10:37:37 2007 +0100
@@ -24,7 +24,7 @@
 #include <asm/page.h>
 
 #include "powerpc.h"
-#include "ppc-offsets.h"
+#include "asm-values.h"
 
 #define VCPU_GPR(n)     (VCPU_GPRS + (n * 4))
 
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to