Re: [kvm-devel] [RFC] Reworking KVM_DEBUG_GUEST
On Wed, 2008-05-14 at 17:28 +0200, Jan Kiszka wrote: > Jerone Young wrote: > > On Mon, 2008-05-12 at 13:34 +0200, Jan Kiszka wrote: > >> Hi, > >> > >> before going wild with my idea, I would like to collect some comments on > >> this approach: > >> > >> While doing first kernel debugging with my debug register patches for > >> kvm, I quickly ran into the 4-breakpoints-only limitation that comes > >> from the fact that we blindly map software to hardware breakpoints. > >> Unhandy, simply suboptimal. Also, having 4 breakpoint slots hard-coded > >> in the generic interface is not fair to arch that may support more. > >> Moreover, we do not support watchpoints although this would easily be > >> feasible. But if we supported watchpoints (via debug registers on x86), > >> we would need the break out of the 4 slots limitations even earlier. In > >> short, I came to the conclusion that a rewrite of the KVM_DEBUG_GUEST > >> interface is required. > > So embedded power is also limited to 4 hardware registers for break > > points. But there are 2 sepreate registers fro watch points. The reason > > to use the registers is the hardware does the work for you and (at least > > on Power) will throw an exception or trap. Then you deal with it. > > > > But you still face the fact that you can only have a small number of > > breakpoints & watch points. Also you cannot use gdb in the guest at the > > sametime while using the gdb stub on the guest itself (as there is only > > one set of registers). > > So gdb on power relies only on those few hw-breakpoints? With x86 you > can perfectly run gdb (with soft BPs) in parallel with the gdbstub > (currently based on hw-BPs, but the same would be true for soft-BPs > inserted by the gdbstub). > > > > > > >> Why do we set breakpoints in the kernel? Why not simply catching all > >> debug traps, inserting software breakpoint ops into the guest code, and > >> handling all this stuff as normal debuggers do? And the hardware > >> breakpoints should just be pushed through the kernel interface like > >> ptrace does. > > > > See above...But the cpu basically does the work for you. So you don't > > have to try and go through and first insert a trap into the code in > > memory. But then you have to remember the code that you replaced with > > the trap and execute it after you handle the trap. This can get a little > > hairy. > > I cannot imaging that this is so hairy. It is basically daily (x86-) > debugger business. Maybe we need to handle it differently if other > arches prefer their own way. But for x86 I don't see a need to restrict > our self to use hw-BPs _only_. > > > > > Currently I'm actually implementing breakpoint support now in Power. But > > you do have to create some mappings to handle traps and see if you put > > the trap there, and execute the code you replaced. Also what if the > > breakpoint is removed. Then you have to go back through and actually > > replace the trap code. Doesn't sound hard, but I'm not sure of all the > > pitfalls. > > Again, this /should/ not be different from what gdb does to applications > or kgdb does to the kernel. (Looks like I need to get my feet wet soon. :) ) > > > > >> The new KVM_DEBUG_GUEST interface I currently have in mind would look > >> like this: > >> > >> #define KVM_DBGGUEST_ENABLE0x01 > >> #define KVM_DBGGUEST_SINGLESTEP0x02 > >> > >> struct kvm_debug_guest { > >>__u32 control; > >>struct kvm_debug_guest_arch arch; > >> } > > > > > >> Setting KVM_DBGGUEST_ENABLE would forward all debug-related traps to > >> userspace first, which can then decide to handle or re-inject them. > >> KVM_DBGGUEST_SINGLESTEP would work as before. And the extension for x86 > >> would look like this: > >> > >> struct kvm_debug_guest_arch { > >>__u32 use_hw_breakpoints; > >>__u64 debugreg[8]; > >> } > >> > >> If use_hw_breakpoints is non-zero, KVM would completely overwrite the > >> guest's debug registers with the content of debugreg, giving full > >> control of this feature to the host-side debugger (faking the content of > >> debug registers, effectively disabling them for the guest - as we now do > >> all the time). > > > > Hmmm...so today at least the gdbstub in qemu does not inject traps and > > track code that it trapped (I could b
Re: [kvm-devel] [RFC] Reworking KVM_DEBUG_GUEST
On Mon, 2008-05-12 at 13:34 +0200, Jan Kiszka wrote: > Hi, > > before going wild with my idea, I would like to collect some comments on > this approach: > > While doing first kernel debugging with my debug register patches for > kvm, I quickly ran into the 4-breakpoints-only limitation that comes > from the fact that we blindly map software to hardware breakpoints. > Unhandy, simply suboptimal. Also, having 4 breakpoint slots hard-coded > in the generic interface is not fair to arch that may support more. > Moreover, we do not support watchpoints although this would easily be > feasible. But if we supported watchpoints (via debug registers on x86), > we would need the break out of the 4 slots limitations even earlier. In > short, I came to the conclusion that a rewrite of the KVM_DEBUG_GUEST > interface is required. So embedded power is also limited to 4 hardware registers for break points. But there are 2 sepreate registers fro watch points. The reason to use the registers is the hardware does the work for you and (at least on Power) will throw an exception or trap. Then you deal with it. But you still face the fact that you can only have a small number of breakpoints & watch points. Also you cannot use gdb in the guest at the sametime while using the gdb stub on the guest itself (as there is only one set of registers). > > Why do we set breakpoints in the kernel? Why not simply catching all > debug traps, inserting software breakpoint ops into the guest code, and > handling all this stuff as normal debuggers do? And the hardware > breakpoints should just be pushed through the kernel interface like > ptrace does. See above...But the cpu basically does the work for you. So you don't have to try and go through and first insert a trap into the code in memory. But then you have to remember the code that you replaced with the trap and execute it after you handle the trap. This can get a little hairy. Currently I'm actually implementing breakpoint support now in Power. But you do have to create some mappings to handle traps and see if you put the trap there, and execute the code you replaced. Also what if the breakpoint is removed. Then you have to go back through and actually replace the trap code. Doesn't sound hard, but I'm not sure of all the pitfalls. > > The new KVM_DEBUG_GUEST interface I currently have in mind would look > like this: > > #define KVM_DBGGUEST_ENABLE 0x01 > #define KVM_DBGGUEST_SINGLESTEP 0x02 > > struct kvm_debug_guest { > __u32 control; > struct kvm_debug_guest_arch arch; > } > Setting KVM_DBGGUEST_ENABLE would forward all debug-related traps to > userspace first, which can then decide to handle or re-inject them. > KVM_DBGGUEST_SINGLESTEP would work as before. And the extension for x86 > would look like this: > > struct kvm_debug_guest_arch { > __u32 use_hw_breakpoints; > __u64 debugreg[8]; > } > > If use_hw_breakpoints is non-zero, KVM would completely overwrite the > guest's debug registers with the content of debugreg, giving full > control of this feature to the host-side debugger (faking the content of > debug registers, effectively disabling them for the guest - as we now do > all the time). Hmmm...so today at least the gdbstub in qemu does not inject traps and track code that it trapped (I could be mistaken). This whould all need to be implemented as well. > > Questions: > - Does anyone see traps and pitfalls in this approach? > - May I replace the existing interface with this one, or am I overseeing > some use case that already worked with the current code so that ABI > compatibility is required (most debug stuff should have been simply > broken so far, also due to bugs in userland)? > > Jan > > - > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > ___ kvm-devel mailing list > kvm-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/kvm-devel - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 2] Fix memory defined in device tree by declaring it dynamically for bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1210003411 18000 # Branch merge # Node ID c455452c9b217abed8a2e6147bbeb91f33ff1799 # Parent cf3ccc3add69052aade695c746151b1cb8812252 Fix memory defined in device tree by declaring it dynamically for bamboo board model This fixes a issue where the amount of memory is not properly being defined in the device tree. It currently is hardcoded for 144MB. The result is that if you specify a memory size below the hardcoded size, the guest crashes. This patch now dynamically changes the device tree to the memory value specified. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -50,6 +50,7 @@ void bamboo_init(ram_addr_t ram_size, in int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; + uint32_t mem_reg_property[]={0, 0, ram_size}; printf("%s: START\n", __func__); @@ -73,6 +74,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("WARNING: %i MB left over memory is ram\n", bytes_to_mb((int)tmp_ram_size)); ram_size -= tmp_ram_size; + mem_reg_property[2] = ram_size; } /* Setup CPU */ @@ -159,6 +161,8 @@ void bamboo_init(ram_addr_t ram_size, in /* manipulate device tree in memory */ dt_cell(fdt, "/cpus/[EMAIL PROTECTED]", "clock-frequency", cpu_freq); dt_cell(fdt, "/cpus/[EMAIL PROTECTED]", "timebase-frequency", timebase_freq); + dt_cell_multi(fdt, "/memory", "reg", mem_reg_property, + sizeof(mem_reg_property)); dt_cell(fdt, "/chosen", "linux,initrd-start", initrd_base); dt_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 2] Add function dt_cell_multi to hw/device_tree.c
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1210003408 18000 # Branch merge # Node ID cf3ccc3add69052aade695c746151b1cb8812252 # Parent 97e439fdd4e91c3fb1ef9055f073add55084d69f Add function dt_cell_multi to hw/device_tree.c This patch adds function dt_cell_multi to allow for manipulation of device tree properties that contain mulitiple 32bit values. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c --- a/qemu/hw/device_tree.c +++ b/qemu/hw/device_tree.c @@ -162,6 +162,21 @@ void dt_cell(void *fdt, char *node_path, } } +/* This function is to manipulate a cell with multiple values */ +void dt_cell_multi(void *fdt, char *node_path, char *property, + uint32_t *val_array, int size) +{ + int offset; + int ret; + offset = get_offset_of_node(fdt, node_path); + ret = fdt_setprop(fdt, offset, property, val_array, size); + if (ret < 0) { + printf("Unable to set device tree property '%s'\n", + property); + exit(1); + } +} + void dt_string(void *fdt, char *node_path, char *property, char *string) { diff --git a/qemu/hw/device_tree.h b/qemu/hw/device_tree.h --- a/qemu/hw/device_tree.h +++ b/qemu/hw/device_tree.h @@ -19,6 +19,8 @@ void dump_device_tree_to_file(void *fdt, void dump_device_tree_to_file(void *fdt, char *filename); void dt_cell(void *fdt, char *node_path, char *property, uint32_t val); +void dt_cell_multi(void *fdt, char *node_path, char *property, + uint32_t *val_array, int size); void dt_string(void *fdt, char *node_path, char *property, char *string); void dt_node(void *fdt, char *node_parent_path, char *name); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 2] [RESEND] [PowerPC] Fix setting memory for bamboo board model
These patches fell through the cracks. This set of patches fixes setting memory for PowerPC bamboo board model. Besides just setting memory in qemu, you must also set it in the device tree. This sets the memory in the device tree so that it can be something other then the hard coded memory size of 144MB. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Fix kvm-userspace configure script so that cc=gcc
On Wed, 2008-04-30 at 16:14 -0500, Hollis Blanchard wrote: > On Wednesday 30 April 2008 15:53:47 Jerone Young wrote: > > 1 file changed, 1 insertion(+), 1 deletion(-) > > configure |2 +- > > > > > > This fixes compilation for cross compilers as many do not create a > ${cross_prefix}cc link. But the do a ${cross_prefix}gcc. This is what the > kernel does so this will work for everyone. This breaks some who do not have > a cc link (cross tools does not create), when I put a patch to remove libkvm > dependence on test config.mak. The explanation came out awful :-) . But yes the issue is that by default cross tools does not create a ${cross_prefix}cc symlink. So you have to say gcc. > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/configure b/configure > > --- a/configure > > +++ b/configure > > @@ -2,7 +2,7 @@ > > > > prefix=/usr/local > > kerneldir=/lib/modules/$(uname -r)/build > > -cc=cc > > +cc=gcc > > ld=ld > > objcopy=objcopy > > want_module=1 > > To clarify: there is no such thing as "${cross_prefix}cc", so the configure > script is currently broken for cross-compiling. > - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] Fix kvm-userspace configure script so that cc=gcc
1 file changed, 1 insertion(+), 1 deletion(-) configure |2 +- This fixes compilation for cross compilers as many do not create a ${cross_prefix}cc link. But the do a ${cross_prefix}gcc. This is what the kernel does so this will work for everyone. This breaks some who do not have a cc link (cross tools does not create), when I put a patch to remove libkvm dependence on test config.mak. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2,7 +2,7 @@ prefix=/usr/local kerneldir=/lib/modules/$(uname -r)/build -cc=cc +cc=gcc ld=ld objcopy=objcopy want_module=1 - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [RESEND] Update kernel/Makefile and remove x86 only entries
1 file changed, 23 insertions(+), 13 deletions(-) kernel/Makefile | 36 +++- This patch removes static x86 entries and makes things work for multiple archs. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,7 @@ include ../config.mak include ../config.mak + +ARCH_DIR=$(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH)) +ARCH_CONFIG=$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) @@ -18,10 +21,19 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ + unifdef -DCONFIG_$(ARCH_CONFIG) $1.orig > $1; \ [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,$T/$(strip $1)) + +hack-files-x86 = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h + +hack-files = $(hack-files-$(ARCH_DIR)) all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -49,21 +61,19 @@ header-sync: rm -rf $T rm -f include/asm - ln -sf asm-x86 include/asm - ln -sf asm-x86 include-compat/asm + ln -sf asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm source-sync: rm -rf $T rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ - "$(LINUX)"/virt/kvm/./*.[ch] \ - $T/ - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) +"$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ +"$(LINUX)"/virt/kvm/./*.[ch] \ +$T/ + + for i in $(hack-files); \ + do $(call hack, $$i); done + for i in $$(find $T -type f -printf '%P '); \ do cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T @@ -72,7 +82,7 @@ install: mkdir -p $(DESTDIR)/$(INSTALLDIR) cp *.ko $(DESTDIR)/$(INSTALLDIR) for i in $(ORIGMODDIR)/drivers/kvm/*.ko \ -$(ORIGMODDIR)/arch/x86/kvm/*.ko; do \ +$(ORIGMODDIR)/arch/$(ARCH_DIR)/kvm/*.ko; do \ if [ -f "$$i" ]; then mv "$$i" "$$i.orig"; fi; \ done /sbin/depmod -a - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 2 of 3] Add function dt_cell_multi to hw/device_tree.c
On Tue, 2008-04-29 at 10:06 -0500, Hollis Blanchard wrote: > On Monday 28 April 2008 16:23:04 Jerone Young wrote: > > +/* This function is to manipulate a cell with multiple values */ > > +void dt_cell_multi(void *fdt, char *node_path, char *property, > > + uint32_t *val_array, int size) > > +{ > > + > > + int offset; > > + int ret; > > Could you please be more careful with your whitespace? Hmmm..I'm looking at the patch on my local machine and it doesn't have any whitespace damage. If there is whitespace damage it was caused by something else (like hg email is doing something). I've attached the orginal patch to this email. > Add function dt_cell_multi to hw/device_tree.c This patch adds function dt_cell_multi to allow for manipulation of device tree properties that contain mulitiple 32bit values. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c --- a/qemu/hw/device_tree.c +++ b/qemu/hw/device_tree.c @@ -162,6 +162,22 @@ void dt_cell(void *fdt, char *node_path, } } +/* This function is to manipulate a cell with multiple values */ +void dt_cell_multi(void *fdt, char *node_path, char *property, + uint32_t *val_array, int size) +{ + + int offset; + int ret; + offset = get_offset_of_node(fdt, node_path); + ret = fdt_setprop(fdt, offset, property, val_array, size); + if (ret < 0) { + printf("Unable to set device tree property '%s'\n", + property); + exit(1); + } +} + void dt_string(void *fdt, char *node_path, char *property, char *string) { diff --git a/qemu/hw/device_tree.h b/qemu/hw/device_tree.h --- a/qemu/hw/device_tree.h +++ b/qemu/hw/device_tree.h @@ -19,6 +19,8 @@ void dump_device_tree_to_file(void *fdt, void dump_device_tree_to_file(void *fdt, char *filename); void dt_cell(void *fdt, char *node_path, char *property, uint32_t val); +void dt_cell_multi(void *fdt, char *node_path, char *property, + uint32_t *val_array, int size); void dt_string(void *fdt, char *node_path, char *property, char *string); void dt_node(void *fdt, char *node_parent_path, char *name); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 3] Remove dynamic allocation of /hypervisor node from device tree in memory
1 file changed, 1 deletion(-) qemu/hw/ppc440_bamboo.c |1 - In 2.6.26 wait is now enabled by default. With this the /hypervisor node will not be need to be idetified to enable the guest to go into wait state while idle. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -163,7 +163,6 @@ void bamboo_init(ram_addr_t ram_size, in dt_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); dt_string(fdt, "/chosen", "bootargs", (char *)kernel_cmdline); - dt_node(fdt, "/", "hypervisor"); #endif if (kvm_enabled()) { - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 3] Fixes for PowerPC Qemu KVM
This set of patches contain fixes for bamboo board model, as well as provides more functionality for device tree manipulation. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> 3 files changed, 22 insertions(+), 1 deletion(-) qemu/hw/device_tree.c | 16 qemu/hw/device_tree.h |2 ++ qemu/hw/ppc440_bamboo.c |5 - - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 3] Add function dt_cell_multi to hw/device_tree.c
2 files changed, 18 insertions(+) qemu/hw/device_tree.c | 16 qemu/hw/device_tree.h |2 ++ This patch adds function dt_cell_multi to allow for manipulation of device tree properties that contain mulitiple 32bit values. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c --- a/qemu/hw/device_tree.c +++ b/qemu/hw/device_tree.c @@ -162,6 +162,22 @@ void dt_cell(void *fdt, char *node_path, } } +/* This function is to manipulate a cell with multiple values */ +void dt_cell_multi(void *fdt, char *node_path, char *property, + uint32_t *val_array, int size) +{ + + int offset; + int ret; + offset = get_offset_of_node(fdt, node_path); + ret = fdt_setprop(fdt, offset, property, val_array, size); + if (ret < 0) { + printf("Unable to set device tree property '%s'\n", + property); + exit(1); + } +} + void dt_string(void *fdt, char *node_path, char *property, char *string) { diff --git a/qemu/hw/device_tree.h b/qemu/hw/device_tree.h --- a/qemu/hw/device_tree.h +++ b/qemu/hw/device_tree.h @@ -19,6 +19,8 @@ void dump_device_tree_to_file(void *fdt, void dump_device_tree_to_file(void *fdt, char *filename); void dt_cell(void *fdt, char *node_path, char *property, uint32_t val); +void dt_cell_multi(void *fdt, char *node_path, char *property, + uint32_t *val_array, int size); void dt_string(void *fdt, char *node_path, char *property, char *string); void dt_node(void *fdt, char *node_parent_path, char *name); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 3] Fix memory defined in device tree by declaring it dynamically for bamboo board model
1 file changed, 4 insertions(+) qemu/hw/ppc440_bamboo.c |4 This fixes a issue where the amount of memory is not properly being defined in the device tree. It currently is hardcoded for 144MB. The result is that if you specify a memory size below the hardcoded size, the guest crashes. This patch now dynamically changes the device tree to the memory value specified. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -50,6 +50,7 @@ void bamboo_init(ram_addr_t ram_size, in int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; + uint32_t mem_reg_property[]={0, 0, ram_size}; printf("%s: START\n", __func__); @@ -73,6 +74,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("WARNING: %i MB left over memory is ram\n", bytes_to_mb((int)tmp_ram_size)); ram_size -= tmp_ram_size; + mem_reg_property[2] = ram_size; } /* Setup CPU */ @@ -159,6 +161,8 @@ void bamboo_init(ram_addr_t ram_size, in /* manipulate device tree in memory */ dt_cell(fdt, "/cpus/[EMAIL PROTECTED]", "clock-frequency", cpu_freq); dt_cell(fdt, "/cpus/[EMAIL PROTECTED]", "timebase-frequency", timebase_freq); + dt_cell_multi(fdt, "/memory", "reg", mem_reg_property, + sizeof(mem_reg_property)); dt_cell(fdt, "/chosen", "linux,initrd-start", initrd_base); dt_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] Update kernel/Makefile and remove x86 only entries
1 file changed, 25 insertions(+), 13 deletions(-) kernel/Makefile | 38 +- This patch removes static x86 entries and makes things work for multiple archs. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ARCH_DIR=$(ARCH) +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' + ARCH_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -18,10 +23,19 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ + unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') $1.orig > $1; \ [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,$T/$(strip $1)) + +ifneq '$(filter $(ARCH_DIR), x86)' '' +HACK_FILES = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h +endif all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -49,21 +63,19 @@ header-sync: rm -rf $T rm -f include/asm - ln -sf asm-x86 include/asm - ln -sf asm-x86 include-compat/asm + ln -sf asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm source-sync: rm -rf $T rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ - "$(LINUX)"/virt/kvm/./*.[ch] \ - $T/ - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) +"$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ +"$(LINUX)"/virt/kvm/./*.[ch] \ +$T/ + + for i in $(HACK_FILES); \ + do $(call hack, $$i); done + for i in $$(find $T -type f -printf '%P '); \ do cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T @@ -72,7 +84,7 @@ install: mkdir -p $(DESTDIR)/$(INSTALLDIR) cp *.ko $(DESTDIR)/$(INSTALLDIR) for i in $(ORIGMODDIR)/drivers/kvm/*.ko \ -$(ORIGMODDIR)/arch/x86/kvm/*.ko; do \ +$(ORIGMODDIR)/arch/$(ARCH_DIR)/kvm/*.ko; do \ if [ -f "$$i" ]; then mv "$$i" "$$i.orig"; fi; \ done /sbin/depmod -a - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 2] Add idle wait support for 44x platforms
2 files changed, 68 insertions(+), 1 deletion(-) arch/powerpc/platforms/44x/Makefile |2 - arch/powerpc/platforms/44x/idle.c | 67 +++ This patch has been accepted upstream and will be in 2.6.26. So it will eventually need to be removed when we move to 2.6.26rc. This patch adds the ability for the CPU to go into wait state while in cpu_idle loop. This helps virtulization solutions know when the guest Linux kernel is in an idle state. There are two ways to do it. Command line options: idle=spin <-- CPU will spin By default will go into wait mode. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/arch/powerpc/platforms/44x/Makefile b/arch/powerpc/platforms/44x/Makefile --- a/arch/powerpc/platforms/44x/Makefile +++ b/arch/powerpc/platforms/44x/Makefile @@ -1,4 +1,4 @@ obj-$(CONFIG_44x) := misc_44x.o -obj-$(CONFIG_44x) := misc_44x.o +obj-$(CONFIG_44x) := misc_44x.o idle.o obj-$(CONFIG_EBONY)+= ebony.o obj-$(CONFIG_TAISHAN) += taishan.o obj-$(CONFIG_BAMBOO) += bamboo.o diff --git a/arch/powerpc/platforms/44x/idle.c b/arch/powerpc/platforms/44x/idle.c new file mode 100644 --- /dev/null +++ b/arch/powerpc/platforms/44x/idle.c @@ -0,0 +1,67 @@ +/* + * Copyright 2008 IBM Corp. + * + * Based on arch/powerpc/platforms/pasemi/idle.c: + * Copyright (C) 2006-2007 PA Semi, Inc + * + * Added by: Jerone Young <[EMAIL PROTECTED]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include + +static int mode_spin; + +static void ppc44x_idle(void) +{ + unsigned long msr_save; + + msr_save = mfmsr(); + /* set wait state MSR */ + mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE); + isync(); + /* return to initial state */ + mtmsr(msr_save); + isync(); +} + +int __init ppc44x_idle_init(void) +{ + if (!mode_spin) { + /* If we are not setting spin mode + then we set to wait mode */ + ppc_md.power_save = &ppc44x_idle; + } + + return 0; +} + +arch_initcall(ppc44x_idle_init); + +static int __init idle_param(char *p) +{ + + if (!strcmp("spin", p)) { + mode_spin = 1; + ppc_md.power_save = NULL; + } + + return 0; +} + +early_param("idle", idle_param); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 2] Add PowerPC KVM guest wait handling support
2 files changed, 23 insertions(+), 3 deletions(-) arch/powerpc/kvm/emulate.c | 14 ++ arch/powerpc/kvm/powerpc.c | 12 +--- This patch handles a guest that is in a wait state & wake up guest that end up being recheduled and go to sleep. This ensures that the guest is not allways eating up 100% cpu when it is idle. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c --- a/arch/powerpc/kvm/emulate.c +++ b/arch/powerpc/kvm/emulate.c @@ -235,6 +235,13 @@ int kvmppc_emulate_instruction(struct kv case 50:/* rfi */ kvmppc_emul_rfi(vcpu); advance = 0; + + /* Handle guest vcpu that is in wait state. +* This will implicitly wake up when it is ready. +*/ + if (vcpu->arch.msr & MSR_WE) { + kvm_vcpu_block(vcpu); + } break; default: @@ -265,6 +272,13 @@ int kvmppc_emulate_instruction(struct kv case 146: /* mtmsr */ rs = get_rs(inst); kvmppc_set_msr(vcpu, vcpu->arch.gpr[rs]); + + /* Handle guest vcpu that is in wait state +* This will implicitly wake up when it is ready. +*/ + if (vcpu->arch.msr & MSR_WE) { + kvm_vcpu_block(vcpu); + } break; case 163: /* wrteei */ diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -36,13 +36,12 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t int kvm_cpu_has_interrupt(struct kvm_vcpu *v) { - /* XXX implement me */ - return 0; + return !!(v->arch.pending_exceptions); } int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) { - return 1; + return !(v->arch.msr & MSR_WE); } @@ -213,6 +212,9 @@ static void kvmppc_decrementer_func(unsi { struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; + if (waitqueue_active(&vcpu->wq)) + wake_up_interruptible(&vcpu->wq); + kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_DECREMENTER); } @@ -339,6 +341,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v int r; sigset_t sigsaved; + vcpu_load(vcpu); + if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); @@ -362,6 +366,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); + + vcpu_put(vcpu); return r; } - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 2] [v2] Fix guest eating 100% cpu when guest is idle on PowerPC
* This update consolidates patches, adds more explicit comments, and add wait check when rfi instruction is emulated. This set of patches fixes 100% CPU usage when a guest is idle on PowerPC. Idle CPU usage is now at ~15-16% CPU time. An improvment. Signed-off-by: Jeorne Young <[EMAIL PROTECTED]> 4 files changed, 91 insertions(+), 4 deletions(-) arch/powerpc/kvm/emulate.c | 14 +++ arch/powerpc/kvm/powerpc.c | 12 -- arch/powerpc/platforms/44x/Makefile |2 - arch/powerpc/platforms/44x/idle.c | 67 +++ - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 0 of 3] Fix guest eating 100% cpu when guest is idle on PowerPC
On Fri, 2008-04-25 at 09:00 -0500, Hollis Blanchard wrote: > On Friday 25 April 2008 00:56:01 Jerone Young wrote: > > This set of patches fixes 100% CPU usage when a guest is idle on PowerPC. > This time it uses common kvm functions to sleep the guest. > > Looking much better now, with just a few minor issues to correct. With these > patches applied, about how much CPU *does* an idling guest consume? With the current patch *as is* idle guest are eating about 16% CPU. Better then 100%, but more then the other patch. I'll see if by removing the vcpu_loads & vcpu_puts if that goes down. > > By the way, you don't explicitly *unset* MSR[WE]. I think this works > implicitly because of the way we deliver interrupts; could you add a comment > explaining that? Yes it is unset implicity. I can add a comment on this. > - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 3] Add PowerPC KVM guest wait handling support
2 files changed, 7 insertions(+), 3 deletions(-) arch/powerpc/kvm/emulate.c |5 + arch/powerpc/kvm/powerpc.c |5 ++--- This patch handles a guest that is in a wait state. This ensures that the guest is not allways eating up 100% cpu when it is idle. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c --- a/arch/powerpc/kvm/emulate.c +++ b/arch/powerpc/kvm/emulate.c @@ -265,6 +265,11 @@ int kvmppc_emulate_instruction(struct kv case 146: /* mtmsr */ rs = get_rs(inst); kvmppc_set_msr(vcpu, vcpu->arch.gpr[rs]); + + /* handle guest vcpu that is in wait state */ + if (vcpu->arch.msr & MSR_WE) { + kvm_vcpu_block(vcpu); + } break; case 163: /* wrteei */ diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -36,13 +36,12 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t int kvm_cpu_has_interrupt(struct kvm_vcpu *v) { - /* XXX implement me */ - return 0; + return !!(v->arch.pending_exceptions); } int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) { - return 1; + return !(v->arch.msr & MSR_WE); } - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 3] Add idle wait support for 44x platforms
2 files changed, 68 insertions(+), 1 deletion(-) arch/powerpc/platforms/44x/Makefile |2 - arch/powerpc/platforms/44x/idle.c | 67 +++ This patch has been accepted upstream and will be in 2.6.26. So it will eventually need to be removed when we move to 2.6.26rc. This patch adds the ability for the CPU to go into wait state while in cpu_idle loop. This helps virtulization solutions know when the guest Linux kernel is in an idle state. There are two ways to do it. Command line options: idle=spin <-- CPU will spin By default will go into wait mode. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/arch/powerpc/platforms/44x/Makefile b/arch/powerpc/platforms/44x/Makefile --- a/arch/powerpc/platforms/44x/Makefile +++ b/arch/powerpc/platforms/44x/Makefile @@ -1,4 +1,4 @@ obj-$(CONFIG_44x) := misc_44x.o -obj-$(CONFIG_44x) := misc_44x.o +obj-$(CONFIG_44x) := misc_44x.o idle.o obj-$(CONFIG_EBONY)+= ebony.o obj-$(CONFIG_TAISHAN) += taishan.o obj-$(CONFIG_BAMBOO) += bamboo.o diff --git a/arch/powerpc/platforms/44x/idle.c b/arch/powerpc/platforms/44x/idle.c new file mode 100644 --- /dev/null +++ b/arch/powerpc/platforms/44x/idle.c @@ -0,0 +1,67 @@ +/* + * Copyright 2008 IBM Corp. + * + * Based on arch/powerpc/platforms/pasemi/idle.c: + * Copyright (C) 2006-2007 PA Semi, Inc + * + * Added by: Jerone Young <[EMAIL PROTECTED]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include + +static int mode_spin; + +static void ppc44x_idle(void) +{ + unsigned long msr_save; + + msr_save = mfmsr(); + /* set wait state MSR */ + mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE); + isync(); + /* return to initial state */ + mtmsr(msr_save); + isync(); +} + +int __init ppc44x_idle_init(void) +{ + if (!mode_spin) { + /* If we are not setting spin mode + then we set to wait mode */ + ppc_md.power_save = &ppc44x_idle; + } + + return 0; +} + +arch_initcall(ppc44x_idle_init); + +static int __init idle_param(char *p) +{ + + if (!strcmp("spin", p)) { + mode_spin = 1; + ppc_md.power_save = NULL; + } + + return 0; +} + +early_param("idle", idle_param); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 3] Fix guest eating 100% cpu when guest is idle on PowerPC
This set of patches fixes 100% CPU usage when a guest is idle on PowerPC. This ti me it uses common kvm functions to sleep the guest. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> 5 files changed, 91 insertions(+), 4 deletions(-) arch/powerpc/kvm/booke_guest.c |6 +++ arch/powerpc/kvm/emulate.c |5 ++ arch/powerpc/kvm/powerpc.c | 15 ++- arch/powerpc/platforms/44x/Makefile |2 - arch/powerpc/platforms/44x/idle.c | 67 +++ - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 3] Add premption handlers & properly wake sleeping guest
2 files changed, 16 insertions(+) arch/powerpc/kvm/booke_guest.c |6 ++ arch/powerpc/kvm/powerpc.c | 10 ++ This patch adds vcpu_put & vpu_load in strategic places (as x86 does it), for use of premption. This patch also adds a very critial bit need to wake up guest that end up going to being rescheduled and go to sleep. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c --- a/arch/powerpc/kvm/booke_guest.c +++ b/arch/powerpc/kvm/booke_guest.c @@ -514,6 +514,8 @@ int kvm_arch_vcpu_ioctl_get_regs(struct { int i; + vcpu_load(vcpu); + regs->pc = vcpu->arch.pc; regs->cr = vcpu->arch.cr; regs->ctr = vcpu->arch.ctr; @@ -533,6 +535,8 @@ int kvm_arch_vcpu_ioctl_get_regs(struct for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) regs->gpr[i] = vcpu->arch.gpr[i]; + + vcpu_put(vcpu); return 0; } @@ -595,6 +599,7 @@ int kvm_arch_vcpu_ioctl_translate(struct u8 pid; u8 as; + vcpu_load(vcpu); eaddr = tr->linear_address; pid = (tr->linear_address >> 32) & 0xff; as = (tr->linear_address >> 40) & 0x1; @@ -610,6 +615,7 @@ int kvm_arch_vcpu_ioctl_translate(struct tr->physical_address = tlb_xlate(gtlbe, eaddr); /* XXX what does "writeable" and "usermode" even mean? */ tr->valid = 1; + vcpu_put(vcpu); return 0; } diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -212,6 +212,9 @@ static void kvmppc_decrementer_func(unsi { struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; + if (waitqueue_active(&vcpu->wq)) + wake_up_interruptible(&vcpu->wq); + kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_DECREMENTER); } @@ -338,6 +341,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v int r; sigset_t sigsaved; + vcpu_load(vcpu); + if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); @@ -362,12 +367,17 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); + vcpu_put(vcpu); + return r; } int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) { + vcpu_load(vcpu); kvmppc_queue_exception(vcpu, BOOKE_INTERRUPT_EXTERNAL); + vcpu_put(vcpu); + return 0; } - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] Remove test suite config.mak from libkvm build
2 files changed, 6 insertions(+), 1 deletion(-) configure |6 ++ libkvm/Makefile |1 - This is a relic of the big userspace refactoring, but today libkvm does should not include settings from the test suite. This patch resolves this and removes the overwriting of setting from the main config.mak with test suite settings. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2,6 +2,9 @@ prefix=/usr/local kerneldir=/lib/modules/$(uname -r)/build +cc=cc +ld=ld +objcopy=objcopy want_module=1 qemu_cc= qemu_cflags= @@ -131,4 +134,7 @@ KERNELDIR=$kerneldir KERNELDIR=$kerneldir WANT_MODULE=$want_module CROSS_COMPILE=$cross_prefix +CC=$cross_prefix$cc +LD=$cross_prefix$ld +OBJCOPY=$cross_prefix$objcopy EOF diff --git a/libkvm/Makefile b/libkvm/Makefile --- a/libkvm/Makefile +++ b/libkvm/Makefile @@ -1,5 +1,4 @@ include ../config.mak include ../config.mak -include ../user/config.mak include config-$(ARCH).mak # cc-option - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [RESEND] [v2] Make "make sync" in kernel dir work for multiple archs
1 file changed, 37 insertions(+), 21 deletions(-) kernel/Makefile | 58 +++ - This adapts perviously sent patch to new changes to kernel/Makefile - Fixes improper check in conditional This patch add the ability for make sync in the kernel directory to work for mulitiple architectures and not just x86. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ARCH_DIR=$(ARCH) +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' + ARCH_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -18,11 +23,25 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig _unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ - [ $$? -le 1 ] && rm $1.orig + unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') $1.orig > $1; \ + [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,$T/$(strip $1)) unifdef = $(call _unifdef,$T/$(strip $1)) + +UNIFDEF_FILES = include/linux/kvm.h \ + include/linux/kvm_para.h \ + include/asm-$(ARCH_DIR)/kvm.h \ + include/asm-$(ARCH_DIR)/kvm_para.h + +ifneq '$(filter $(ARCH_DIR), x86)' '' +HACK_FILES = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h +endif all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -39,17 +58,16 @@ header-sync: rm -rf $T rsync -R \ "$(LINUX)"/./include/linux/kvm*.h \ -"$(LINUX)"/./include/asm-x86/kvm*.h \ - $T/ - mkdir -p include/linux include/asm-x86 - ln -sf asm-x86 include/asm - ln -sf asm-x86 include-compat/asm +"$(LINUX)"/./include/asm-$(ARCH_DIR)/kvm*.h \ +$T/ - $(call unifdef, include/linux/kvm.h) - $(call unifdef, include/linux/kvm_para.h) - $(call unifdef, include/asm-x86/kvm.h) - $(call unifdef, include/asm-x86/kvm_para.h) - $(call hack, include/linux/kvm.h) + mkdir -p include/linux include/asm-$(ARCH_DIR) + ln -sf asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm + + for i in $(UNIFDEF_FILES); \ + do $(call unifdef, $$i); done + for i in $$(find $T -type f -printf '%P '); \ do cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T @@ -57,15 +75,13 @@ source-sync: source-sync: rm -rf $T rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ - "$(LINUX)"/virt/kvm/./*.[ch] \ - $T/ - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) +"$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ +"$(LINUX)"/virt/kvm/./*.[ch] \ +$T/ + + for i in $(HACK_FILES); \ + do $(call hack, $$i); done + for i in $$(find $T -type f -printf '%P '); \ do cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH] [RESEND] Make "make sync" in kernel dir work for multiple archs
On Wed, 2008-04-23 at 18:02 -0500, Anthony Liguori wrote: > > diff --git a/kernel/Makefile b/kernel/Makefile > > --- a/kernel/Makefile > > +++ b/kernel/Makefile > > @@ -1,5 +1,10 @@ include ../config.mak > > include ../config.mak > > > > +ARCH_DIR=$(ARCH) > > +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' > > + ARCH_DIR=x86 > > +endif > > + > > > > This sets ARCH_DIR to x86 yeap. > > > KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) > > > > DESTDIR= > > @@ -18,11 +23,25 @@ _hack = mv $1 $1.orig && \ > > | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig > > > > _unifdef = mv $1 $1.orig && \ > > - unifdef -DCONFIG_X86 $1.orig > $1; \ > > + unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') > > $1.orig > $1; \ > >[ $$? -le 1 ] && rm $1.orig > > > > hack = $(call _hack,$T/$(strip $1)) > > unifdef = $(call _unifdef,$T/$(strip $1)) > > + > > +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' > > Doh! Yeap again. This was caused when things where need to change in a respin of the last patch. I just didn't notice it. I'll change it and resend ... again. > > And I'm not quite sure what this is supposed to do but it doesn't look > right. ARCH_DIR is going to equal 'x86' so this is going to break > things on x86 sinc ethe filter will return an empty string. > > Regards, > > Anthony Liguori > > > +UNIFDEF_FILES = include/linux/kvm.h \ > > + include/linux/kvm_para.h \ > > + include/asm-$(ARCH_DIR)/kvm.h \ > > + include/asm-x86/kvm_para.h > > + > > +HACK_FILES = kvm_main.c \ > > + mmu.c \ > > + vmx.c \ > > + svm.c \ > > + x86.c \ > > + irq.h > > +endif > > > > all:: > > # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat > > @@ -39,17 +58,16 @@ header-sync: > > rm -rf $T > > rsync -R \ > > "$(LINUX)"/./include/linux/kvm*.h \ > > -"$(LINUX)"/./include/asm-x86/kvm*.h \ > > - $T/ > > - mkdir -p include/linux include/asm-x86 > > - ln -sf asm-x86 include/asm > > - ln -sf asm-x86 include-compat/asm > > +"$(LINUX)"/./include/asm-$(ARCH_DIR)/kvm*.h \ > > +$T/ > > > > - $(call unifdef, include/linux/kvm.h) > > - $(call unifdef, include/linux/kvm_para.h) > > - $(call unifdef, include/asm-x86/kvm.h) > > - $(call unifdef, include/asm-x86/kvm_para.h) > > - $(call hack, include/linux/kvm.h) > > + mkdir -p include/linux include/asm-$(ARCH_DIR) > > + ln -s asm-$(ARCH_DIR) include/asm > > + ln -sf asm-$(ARCH_DIR) include-compat/asm > > + > > + for i in $(UNIFDEF_FILES); \ > > + do $(call unifdef, $$i); done > > + > > for i in $$(find $T -type f -printf '%P '); \ > > do cmp -s $$i $T/$$i || cp $T/$$i $$i; done > > rm -rf $T > > @@ -57,15 +75,13 @@ source-sync: > > source-sync: > > rm -rf $T > > rsync --exclude='*.mod.c' -R \ > > - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ > > - "$(LINUX)"/virt/kvm/./*.[ch] \ > > - $T/ > > - $(call hack, kvm_main.c) > > - $(call hack, mmu.c) > > - $(call hack, vmx.c) > > - $(call hack, svm.c) > > - $(call hack, x86.c) > > - $(call hack, irq.h) > > +"$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ > > +"$(LINUX)"/virt/kvm/./*.[ch] \ > > +$T/ > > + > > + for i in $(HACK_FILES); \ > > + do $(call hack, $$i); done > > + > > for i in $$(find $T -type f -printf '%P '); \ > > do cmp -s $$i $T/$$i || cp $T/$$i $$i; done > > rm -rf $T > > > > - > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > > Don't miss this year's exciting event. There's still time to save $100. > > Use priority code J8TL2D2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > > ___ > > kvm-devel mailing list > > kvm-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/kvm-devel > > > > > - > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > ___ > kvm-devel mailing list > kvm-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/kvm-devel - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-d
[kvm-devel] [PATCH] [RESEND] Make "make sync" in kernel dir work for multiple archs
1 file changed, 36 insertions(+), 20 deletions(-) kernel/Makefile | 56 +++ - This adapts perviously sent patch to new changes to kernel/Makefile This patch add the ability for make sync in the kernel directory to work for mulitiple architectures and not just x86. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ARCH_DIR=$(ARCH) +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' + ARCH_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -18,11 +23,25 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig _unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ + unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') $1.orig > $1; \ [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,$T/$(strip $1)) unifdef = $(call _unifdef,$T/$(strip $1)) + +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' +UNIFDEF_FILES = include/linux/kvm.h \ + include/linux/kvm_para.h \ + include/asm-$(ARCH_DIR)/kvm.h \ + include/asm-x86/kvm_para.h + +HACK_FILES = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h +endif all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -39,17 +58,16 @@ header-sync: rm -rf $T rsync -R \ "$(LINUX)"/./include/linux/kvm*.h \ -"$(LINUX)"/./include/asm-x86/kvm*.h \ - $T/ - mkdir -p include/linux include/asm-x86 - ln -sf asm-x86 include/asm - ln -sf asm-x86 include-compat/asm +"$(LINUX)"/./include/asm-$(ARCH_DIR)/kvm*.h \ +$T/ - $(call unifdef, include/linux/kvm.h) - $(call unifdef, include/linux/kvm_para.h) - $(call unifdef, include/asm-x86/kvm.h) - $(call unifdef, include/asm-x86/kvm_para.h) - $(call hack, include/linux/kvm.h) + mkdir -p include/linux include/asm-$(ARCH_DIR) + ln -s asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm + + for i in $(UNIFDEF_FILES); \ + do $(call unifdef, $$i); done + for i in $$(find $T -type f -printf '%P '); \ do cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T @@ -57,15 +75,13 @@ source-sync: source-sync: rm -rf $T rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ - "$(LINUX)"/virt/kvm/./*.[ch] \ - $T/ - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) +"$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ +"$(LINUX)"/virt/kvm/./*.[ch] \ +$T/ + + for i in $(HACK_FILES); \ + do $(call hack, $$i); done + for i in $$(find $T -type f -printf '%P '); \ do cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] What kernel options do I need to properly enable virtio net driver
What I am asking is do I have all the proper options in my kernel config set to use it? On Mon, 2008-04-21 at 17:13 -0500, Anthony Liguori wrote: > Jerone Young wrote: > > virtio net device does not appear to show itself in the guest. I'm > > curious of what options I may be missing. Here is my config > > You'll have to be more specific about what "does not appear to show > itself" means. What's the output of lspci? > > Regards, > > Anthony Liguori > > > > > > > - > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > > Don't miss this year's exciting event. There's still time to save $100. > > Use priority code J8TL2D2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > > > > > > ___ > > kvm-devel mailing list > > kvm-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/kvm-devel > - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] What kernel options do I need to properly enable virtio net driver
virtio net device does not appear to show itself in the guest. I'm curious of what options I may be missing. Here is my config # # Automatically generated make config: don't edit # Linux kernel version: 2.6.25-rc9 # Mon Apr 21 15:52:50 2008 # # CONFIG_PPC64 is not set # # Processor support # # CONFIG_6xx is not set # CONFIG_PPC_85xx is not set # CONFIG_PPC_8xx is not set # CONFIG_40x is not set CONFIG_44x=y # CONFIG_E200 is not set CONFIG_PPC_FPU=y CONFIG_4xx=y CONFIG_BOOKE=y CONFIG_PTE_64BIT=y CONFIG_PHYS_64BIT=y # CONFIG_PPC_MM_SLICES is not set CONFIG_NOT_COHERENT_CACHE=y CONFIG_PPC32=y CONFIG_WORD_SIZE=32 CONFIG_PPC_MERGE=y CONFIG_MMU=y CONFIG_GENERIC_CMOS_UPDATE=y CONFIG_GENERIC_TIME=y CONFIG_GENERIC_TIME_VSYSCALL=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_GENERIC_HARDIRQS=y # CONFIG_HAVE_SETUP_PER_CPU_AREA is not set CONFIG_IRQ_PER_CPU=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y CONFIG_ARCH_HAS_ILOG2_U32=y CONFIG_GENERIC_HWEIGHT=y CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_GENERIC_FIND_NEXT_BIT=y # CONFIG_ARCH_NO_VIRT_TO_BUS is not set CONFIG_PPC=y CONFIG_EARLY_PRINTK=y CONFIG_GENERIC_NVRAM=y CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y CONFIG_ARCH_MAY_HAVE_PC_FDC=y CONFIG_PPC_OF=y CONFIG_OF=y CONFIG_PPC_UDBG_16550=y # CONFIG_GENERIC_TBSYNC is not set CONFIG_AUDIT_ARCH=y CONFIG_GENERIC_BUG=y # CONFIG_DEFAULT_UIMAGE is not set CONFIG_PPC_DCR_NATIVE=y # CONFIG_PPC_DCR_MMIO is not set CONFIG_PPC_DCR=y CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" # # General setup # CONFIG_EXPERIMENTAL=y CONFIG_BROKEN_ON_SMP=y CONFIG_INIT_ENV_ARG_LIMIT=32 CONFIG_LOCALVERSION="" CONFIG_LOCALVERSION_AUTO=y CONFIG_SWAP=y CONFIG_SYSVIPC=y CONFIG_SYSVIPC_SYSCTL=y CONFIG_POSIX_MQUEUE=y # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_TASKSTATS is not set # CONFIG_AUDIT is not set # CONFIG_IKCONFIG is not set CONFIG_LOG_BUF_SHIFT=14 # CONFIG_CGROUPS is not set CONFIG_GROUP_SCHED=y CONFIG_FAIR_GROUP_SCHED=y # CONFIG_RT_GROUP_SCHED is not set CONFIG_USER_SCHED=y # CONFIG_CGROUP_SCHED is not set CONFIG_SYSFS_DEPRECATED=y CONFIG_SYSFS_DEPRECATED_V2=y CONFIG_RELAY=y # CONFIG_NAMESPACES is not set CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="/home/jerone/tmp/LINUX_RAM_DISK/" CONFIG_INITRAMFS_ROOT_UID=0 CONFIG_INITRAMFS_ROOT_GID=0 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set CONFIG_SYSCTL=y CONFIG_EMBEDDED=y CONFIG_SYSCTL_SYSCALL=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_ALL is not set # CONFIG_KALLSYMS_EXTRA_PASS is not set CONFIG_HOTPLUG=y CONFIG_PRINTK=y CONFIG_BUG=y CONFIG_ELF_CORE=y CONFIG_COMPAT_BRK=y CONFIG_BASE_FULL=y CONFIG_FUTEX=y CONFIG_ANON_INODES=y CONFIG_EPOLL=y CONFIG_SIGNALFD=y CONFIG_TIMERFD=y CONFIG_EVENTFD=y CONFIG_SHMEM=y CONFIG_VM_EVENT_COUNTERS=y CONFIG_SLUB_DEBUG=y # CONFIG_SLAB is not set CONFIG_SLUB=y # CONFIG_SLOB is not set # CONFIG_PROFILING is not set # CONFIG_MARKERS is not set CONFIG_HAVE_OPROFILE=y # CONFIG_KPROBES is not set CONFIG_HAVE_KPROBES=y CONFIG_HAVE_KRETPROBES=y CONFIG_PROC_PAGE_MONITOR=y CONFIG_SLABINFO=y CONFIG_RT_MUTEXES=y # CONFIG_TINY_SHMEM is not set CONFIG_BASE_SMALL=0 CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y # CONFIG_MODULE_FORCE_UNLOAD is not set # CONFIG_MODVERSIONS is not set # CONFIG_MODULE_SRCVERSION_ALL is not set CONFIG_KMOD=y CONFIG_BLOCK=y CONFIG_LBD=y # CONFIG_BLK_DEV_IO_TRACE is not set # CONFIG_LSF is not set # CONFIG_BLK_DEV_BSG is not set # # IO Schedulers # CONFIG_IOSCHED_NOOP=y CONFIG_IOSCHED_AS=y CONFIG_IOSCHED_DEADLINE=y CONFIG_IOSCHED_CFQ=y CONFIG_DEFAULT_AS=y # CONFIG_DEFAULT_DEADLINE is not set # CONFIG_DEFAULT_CFQ is not set # CONFIG_DEFAULT_NOOP is not set CONFIG_DEFAULT_IOSCHED="anticipatory" CONFIG_PREEMPT_NOTIFIERS=y CONFIG_CLASSIC_RCU=y # CONFIG_PPC4xx_PCI_EXPRESS is not set # # Platform support # # CONFIG_PPC_MPC512x is not set # CONFIG_PPC_MPC5121 is not set # CONFIG_PPC_CELL is not set # CONFIG_PPC_CELL_NATIVE is not set # CONFIG_PQ2ADS is not set CONFIG_BAMBOO=y # CONFIG_EBONY is not set # CONFIG_SEQUOIA is not set # CONFIG_TAISHAN is not set # CONFIG_KATMAI is not set # CONFIG_RAINIER is not set # CONFIG_WARP is not set CONFIG_440EP=y CONFIG_IBM440EP_ERR42=y # CONFIG_IPIC is not set # CONFIG_MPIC is not set # CONFIG_MPIC_WEIRD is not set # CONFIG_PPC_I8259 is not set # CONFIG_PPC_RTAS is not set # CONFIG_MMIO_NVRAM is not set # CONFIG_PPC_MPC106 is not set # CONFIG_PPC_970_NAP is not set # CONFIG_PPC_INDIRECT_IO is not set # CONFIG_GENERIC_IOMAP is not set # CONFIG_CPU_FREQ is not set # CONFIG_FSL_ULI1575 is not set # # Kernel options # # CONFIG_HIGHMEM is not set # CONFIG_TICK_ONESHOT is not set # CONFIG_NO_HZ is not set # CONFIG_HIGH_RES_TIMERS is not set CONFIG_GENERIC_CLOCKEVENTS_BUILD=y # CONFIG_HZ_100 is not set CONFIG_HZ_250=y # CONFIG_HZ_300 is not set # CONFIG_HZ_1000 is not set CONFIG_HZ=250 # CONFIG_SCHED_HRTICK is not set CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT_VOLUNTARY is not set # CONFIG_PREEMPT is not set CONFIG_BINFMT_ELF=y # CONFIG_BINFMT_MISC is not set # CONFIG_MATH_EMULATION is not set # CONFIG_IOMMU_HELPER is not set CONFIG_ARCH_ENABLE_MEMORY_
[kvm-devel] [PATCH] Fix missing decleration for kvm_enabled() in qemu for target-ppc/helper.c
1 file changed, 1 insertion(+) qemu/target-ppc/helper.c |1 + Recent change now requires target-ppc/helper.c to now include "qemu-kvm.h" to get the definition for kvm_enabled(). This fixes it so things now compile again. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/target-ppc/helper.c b/qemu/target-ppc/helper.c --- a/qemu/target-ppc/helper.c +++ b/qemu/target-ppc/helper.c @@ -29,6 +29,7 @@ #include "exec-all.h" #include "helper_regs.h" #include "qemu-common.h" +#include "qemu-kvm.h" //#define DEBUG_MMU //#define DEBUG_BATS - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [v3][kvm-userspace] Make "make sync" in kernel dir work for multiple archs
1 file changed, 31 insertions(+), 17 deletions(-) kernel/Makefile | 48 +++- - fix where $(ARCH_DIR) is lower case and for -DCONFIG_? in _unifdef macro it needs to be upper case. This patch add the ability for make sync in the kernel directory to work for mulitiple architectures and not just x86. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ARCH_DIR=$(ARCH) +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' + ARCH_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -18,11 +23,25 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig _unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ + unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') $1.orig > $1; \ [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,tmp/$(strip $1)) unifdef = $(call _unifdef,tmp/$(strip $1)) + +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' +UNIFDEF_FILES = include/linux/kvm.h \ + include/linux/kvm_para.h \ + include/asm-$(ARCH_DIR)/kvm.h \ + include/asm-x86/kvm_para.h + +HACK_FILES = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h +endif all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -34,26 +53,21 @@ sync: sync: rm -rf tmp include rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ + "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ "$(LINUX)"/virt/kvm/./*.[ch] \ "$(LINUX)"/./include/linux/kvm*.h \ -"$(LINUX)"/./include/asm-x86/kvm*.h \ +"$(LINUX)"/./include/asm-$(ARCH_DIR)/kvm*.h \ tmp/ - mkdir -p include/linux include/asm-x86 - ln -s asm-x86 include/asm - ln -sf asm-x86 include-compat/asm + mkdir -p include/linux include/asm-$(ARCH_DIR) + ln -s asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm - $(call unifdef, include/linux/kvm.h) - $(call unifdef, include/linux/kvm_para.h) - $(call unifdef, include/asm-x86/kvm.h) - $(call unifdef, include/asm-x86/kvm_para.h) - $(call hack, include/linux/kvm.h) - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) + for i in $(UNIFDEF_FILES); \ + do $(call unifdef, $$i); done + + for i in $(HACK_FILES); \ + do $(call hack, $$i); done + for i in $$(find tmp -type f -printf '%P '); \ do cmp -s $$i tmp/$$i || cp tmp/$$i $$i; done rm -rf tmp - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [v2][kvm-userspace] Make "make sync" in kernel dir work for multiple archs
1 file changed, 31 insertions(+), 17 deletions(-) kernel/Makefile | 48 +++- This patch add the ability for make sync in the kernel directory to work for mulitiple architectures and not just x86. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ARCH_DIR=$(ARCH) +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' + ARCH_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -18,11 +23,25 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig _unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ + unifdef -DCONFIG_$(ARCH_DIR) $1.orig > $1; \ [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,tmp/$(strip $1)) unifdef = $(call _unifdef,tmp/$(strip $1)) + +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' +UNIFDEF_FILES = include/linux/kvm.h \ + include/linux/kvm_para.h \ + include/asm-$(ARCH_DIR)/kvm.h \ + include/asm-x86/kvm_para.h + +HACK_FILES = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h +endif all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -34,26 +53,21 @@ sync: sync: rm -rf tmp include rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ + "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ "$(LINUX)"/virt/kvm/./*.[ch] \ "$(LINUX)"/./include/linux/kvm*.h \ -"$(LINUX)"/./include/asm-x86/kvm*.h \ +"$(LINUX)"/./include/asm-$(ARCH_DIR)/kvm*.h \ tmp/ - mkdir -p include/linux include/asm-x86 - ln -s asm-x86 include/asm - ln -sf asm-x86 include-compat/asm + mkdir -p include/linux include/asm-$(ARCH_DIR) + ln -s asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm - $(call unifdef, include/linux/kvm.h) - $(call unifdef, include/linux/kvm_para.h) - $(call unifdef, include/asm-x86/kvm.h) - $(call unifdef, include/asm-x86/kvm_para.h) - $(call hack, include/linux/kvm.h) - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) + for i in $(UNIFDEF_FILES); \ + do $(call unifdef, $$i); done + + for i in $(HACK_FILES); \ + do $(call hack, $$i); done + for i in $$(find tmp -type f -printf '%P '); \ do cmp -s $$i tmp/$$i || cp tmp/$$i $$i; done rm -rf tmp - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [v2][kvm-userspace] Make "make sync" in kernel dir work for multiple archs
1 file changed, 31 insertions(+), 17 deletions(-) kernel/Makefile | 48 +++- This patch add the ability for make sync in the kernel directory to work for mulitiple architectures and not just x86. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ARCH_DIR=$(ARCH) +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' + ARCH_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -18,11 +23,25 @@ _hack = mv $1 $1.orig && \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig _unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_X86 $1.orig > $1; \ + unifdef -DCONFIG_$(ARCH_DIR) $1.orig > $1; \ [ $$? -le 1 ] && rm $1.orig hack = $(call _hack,tmp/$(strip $1)) unifdef = $(call _unifdef,tmp/$(strip $1)) + +ifneq '$(filter $(ARCH_DIR), x86_64 i386)' '' +UNIFDEF_FILES = include/linux/kvm.h \ + include/linux/kvm_para.h \ + include/asm-$(ARCH_DIR)/kvm.h \ + include/asm-x86/kvm_para.h + +HACK_FILES = kvm_main.c \ + mmu.c \ + vmx.c \ + svm.c \ + x86.c \ + irq.h +endif all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat @@ -34,26 +53,21 @@ sync: sync: rm -rf tmp include rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ + "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ "$(LINUX)"/virt/kvm/./*.[ch] \ "$(LINUX)"/./include/linux/kvm*.h \ -"$(LINUX)"/./include/asm-x86/kvm*.h \ +"$(LINUX)"/./include/asm-$(ARCH_DIR)/kvm*.h \ tmp/ - mkdir -p include/linux include/asm-x86 - ln -s asm-x86 include/asm - ln -sf asm-x86 include-compat/asm + mkdir -p include/linux include/asm-$(ARCH_DIR) + ln -s asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm - $(call unifdef, include/linux/kvm.h) - $(call unifdef, include/linux/kvm_para.h) - $(call unifdef, include/asm-x86/kvm.h) - $(call unifdef, include/asm-x86/kvm_para.h) - $(call hack, include/linux/kvm.h) - $(call hack, kvm_main.c) - $(call hack, mmu.c) - $(call hack, vmx.c) - $(call hack, svm.c) - $(call hack, x86.c) - $(call hack, irq.h) + for i in $(UNIFDEF_FILES); \ + do $(call unifdef, $$i); done + + for i in $(HACK_FILES); \ + do $(call hack, $$i); done + for i in $$(find tmp -type f -printf '%P '); \ do cmp -s $$i tmp/$$i || cp tmp/$$i $$i; done rm -rf tmp - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 2] [RESEND] Fix PowerPC cpu initiliaztion
This patch apparently fell through the cracks or I didn't send the rised version to the list. These patches fix cpu initilization for PowerPC. Without them guest cannot be launched. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> 2 files changed, 6 insertions(+), 3 deletions(-) qemu/hw/ppc440_bamboo.c |3 --- qemu/qemu-kvm-powerpc.c |6 ++ - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 2] Add kvm_load_registers into qemu_arch_init for PowerPC
1 file changed, 6 insertions(+) qemu/qemu-kvm-powerpc.c |6 ++ This patch adds a call to load_kvm_registers after creation of vcpu. This is required for ppc since we are required to set certain registers before boot. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c --- a/qemu/qemu-kvm-powerpc.c +++ b/qemu/qemu-kvm-powerpc.c @@ -121,6 +121,12 @@ void kvm_arch_save_regs(CPUState *env) int kvm_arch_qemu_init_env(CPUState *cenv) { +if (cenv->cpu_index == 0) { +/* load any registers set in env into + kvm for the first guest vcpu */ +kvm_load_registers(cenv); +} + return 0; } - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 2] Remove kvm_load_registers from ppc440_bamboo board model
1 file changed, 3 deletions(-) qemu/hw/ppc440_bamboo.c |3 --- This patch removes the call to kvm_load_registers while in board platform setup code. This must now be done later in vcpu initialization. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -174,9 +174,6 @@ void bamboo_init(ram_addr_t ram_size, in env->gpr[3] = dt_base; #endif env->nip = ep; - - printf("%s: loading kvm registers\n", __func__); - kvm_load_registers(env); } for (i = 0; i < nb_nics; i++) { - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH] [kvm-userspace] Make "make sync" in kernel dir work for multiple archs
On Tue, 2008-04-15 at 09:08 -0500, Hollis Blanchard wrote: > On Monday 14 April 2008 21:46:43 Jerone Young wrote: > > 1 file changed, 13 insertions(+), 5 deletions(-) > > kernel/Makefile | 18 +- > > > > > > This patch add the ability for make sync in the kernel directory to work > > for mulitiple architectures and not just x86. > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/kernel/Makefile b/kernel/Makefile > > --- a/kernel/Makefile > > +++ b/kernel/Makefile > > @@ -1,5 +1,10 @@ include ../config.mak > > include ../config.mak > > > > +ASM_DIR=$(ARCH) > > +ifneq '$(filter $(ASM_DIR), x86_64 i386 ia64)' '' > > + ASM_DIR=x86 > > +endif > > Minor complaint: "ASM_DIR" really isn't. You use it as arch/$(ASM_DIR) and > also as include/asm-$(ASM_DIR). I think what you really meant is "ARCH_DIR" > (or similar). I can change it. Not that big of a deal. Oh left the ia64 on there by accident. > > > +ifneq '$(filter $(ASM_DIR), x86_64 i386 ia64)' '' > > $(call unifdef, include/linux/kvm.h) > > $(call unifdef, include/linux/kvm_para.h) > > $(call unifdef, include/asm-x86/kvm.h) > > @@ -54,6 +60,8 @@ sync: > > $(call hack, svm.c) > > $(call hack, x86.c) > > $(call hack, irq.h) > > +endif > > + > > Why are you keeping IA64 touching asm-x86? Accident. Cut and past error from the first mistake. > > What happened to my suggestion of creating a per-arch HACK_FILES and > UNIFDEF_FILES variables, and looping over those? These macros are only for x86. We don't want them or need them. So I just left them be as not to accidentally miss or break anything. > - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [kvm-userspace] Make "make sync" in kernel dir work for multiple archs
1 file changed, 13 insertions(+), 5 deletions(-) kernel/Makefile | 18 +- This patch add the ability for make sync in the kernel directory to work for mulitiple architectures and not just x86. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,10 @@ include ../config.mak include ../config.mak +ASM_DIR=$(ARCH) +ifneq '$(filter $(ASM_DIR), x86_64 i386 ia64)' '' + ASM_DIR=x86 +endif + KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= @@ -34,15 +39,16 @@ sync: sync: rm -rf tmp include rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/x86/kvm/./*.[ch] \ + "$(LINUX)"/arch/$(ASM_DIR)/kvm/./*.[ch] \ "$(LINUX)"/virt/kvm/./*.[ch] \ "$(LINUX)"/./include/linux/kvm*.h \ -"$(LINUX)"/./include/asm-x86/kvm*.h \ +"$(LINUX)"/./include/asm-$(ASM_DIR)/kvm*.h \ tmp/ - mkdir -p include/linux include/asm-x86 - ln -s asm-x86 include/asm - ln -sf asm-x86 include-compat/asm + mkdir -p include/linux include/asm-$(ASM_DIR) + ln -s asm-$(ASM_DIR) include/asm + ln -sf asm-$(ASM_DIR) include-compat/asm +ifneq '$(filter $(ASM_DIR), x86_64 i386 ia64)' '' $(call unifdef, include/linux/kvm.h) $(call unifdef, include/linux/kvm_para.h) $(call unifdef, include/asm-x86/kvm.h) @@ -54,6 +60,8 @@ sync: $(call hack, svm.c) $(call hack, x86.c) $(call hack, irq.h) +endif + for i in $$(find tmp -type f -printf '%P '); \ do cmp -s $$i tmp/$$i || cp tmp/$$i $$i; done rm -rf tmp - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 4] Sync kernel headers to kvm-userspace
This patch does several things: - Adds "make sync" of kvm kernel headers & required linux headers to kvm-userspace directory from the kernel - Modifies build systems of libkvm, user, & qemu so that they now include headers from this now synced includes directory - Remove --kerneldir options from user as it is no longer needed. - Remove --kernel-path & other refrences used in qemu as it is no longer needed This now allows users to include headers from a kernel source that does not require any compilation. It will also work if the kernel source is compiled, as make sync can determines the correct directories to pull headers from. This patch is to address earlier email that Hollis Blanchard had as he uses O= option when compiling his kernels, so the kernel source is never modified. http://marc.info/?l=kvm-devel&m=119995898027254&w=2 Signed-off-by: Jerone Young <[EMAIL PROTECTED]> 10 files changed, 31 insertions(+), 23 deletions(-) Makefile| 21 - configure |8 +--- libkvm/Makefile |6 +++--- qemu/Makefile.target|3 +-- qemu/configure |7 +-- user/Makefile |1 + user/config-i386.mak|1 - user/config-powerpc.mak |1 - user/config-x86_64.mak |1 - user/configure |5 - - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 4] Fix user to include synced headers & remove kerneldir option
5 files changed, 1 insertion(+), 8 deletions(-) user/Makefile |1 + user/config-i386.mak|1 - user/config-powerpc.mak |1 - user/config-x86_64.mak |1 - user/configure |5 - This patch fixes user directory to now include synced headers. It also removes the kerneldir option, as it is no longer needed. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/user/Makefile b/user/Makefile --- a/user/Makefile +++ b/user/Makefile @@ -28,6 +28,7 @@ CFLAGS += $(call cc-option, -fno-stack-p CFLAGS += $(call cc-option, -fno-stack-protector, "") CFLAGS += $(call cc-option, -fno-stack-protector-all, "") CFLAGS += -I ../libkvm +CFLAGS += $(INCLUDES_DIR) LDFLAGS += $(CFLAGS) -L ../libkvm diff --git a/user/config-i386.mak b/user/config-i386.mak --- a/user/config-i386.mak +++ b/user/config-i386.mak @@ -4,7 +4,6 @@ ldarch = elf32-i386 ldarch = elf32-i386 CFLAGS += -m32 CFLAGS += -D__i386__ -CFLAGS += -I $(KERNELDIR)/include tests= diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak --- a/user/config-powerpc.mak +++ b/user/config-powerpc.mak @@ -30,7 +30,6 @@ all: kvmctl $(tests) $(simpletests) CFLAGS += -m32 CFLAGS += -D__powerpc__ -CFLAGS += -I $(KERNELDIR)/include CFLAGS += -Wa,-mregnames $(simpletests): %.bin: %.o diff --git a/user/config-x86_64.mak b/user/config-x86_64.mak --- a/user/config-x86_64.mak +++ b/user/config-x86_64.mak @@ -4,7 +4,6 @@ ldarch = elf64-x86-64 ldarch = elf64-x86-64 CFLAGS += -m64 CFLAGS += -D__x86_64__ -CFLAGS += -I $(KERNELDIR)/include tests = $(TEST_DIR)/access.flat $(TEST_DIR)/irq.flat $(TEST_DIR)/sieve.flat \ $(TEST_DIR)/simple.flat $(TEST_DIR)/stringio.flat \ diff --git a/user/configure b/user/configure --- a/user/configure +++ b/user/configure @@ -18,7 +18,6 @@ usage() { --cc=CCc compiler to use ($cc) --ld=LDld linker to use ($ld) --prefix=PREFIXwhere to install things ($prefix) - --kerneldir=DIRkernel build directory for kvm.h ($kerneldir) EOF exit 1 } @@ -33,9 +32,6 @@ while [[ "$1" = -* ]]; do case "$opt" in --prefix) prefix="$arg" - ;; - --kerneldir) - kerneldir="$arg" ;; --arch) arch="$arg" @@ -60,7 +56,6 @@ done cat < config.mak PREFIX=$prefix -KERNELDIR=$(readlink -f $kerneldir) ARCH=$arch CC=$cross_prefix$cc LD=$cross_prefix$ld - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 4 of 4] Remove kvm kernel-path option from qemu
2 files changed, 2 insertions(+), 8 deletions(-) qemu/Makefile.target |3 +-- qemu/configure |7 +-- Now that kvm headers are synced locally, qemu does not need a specific option to find the kernel headers as they can now be specified in the --extra-cflags option. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -546,8 +546,7 @@ SOUND_HW += gus.o gusemu_hal.o gusemu_mi SOUND_HW += gus.o gusemu_hal.o gusemu_mixer.o endif -ifdef CONFIG_KVM_KERNEL_INC -CFLAGS += -I $(CONFIG_KVM_KERNEL_INC) +ifeq ($(USE_KVM), 1) LIBS += -lkvm DEPLIBS += ../libkvm/libkvm.a endif diff --git a/qemu/configure b/qemu/configure --- a/qemu/configure +++ b/qemu/configure @@ -102,7 +102,6 @@ kvm="no" kvm="no" kvm_cap_pit="no" profiler="no" -kernel_path="" cocoa="no" check_gfx="yes" check_gcc="yes" @@ -305,8 +304,6 @@ for opt do ;; --enable-profiler) profiler="yes" ;; - --kernel-path=*) kernel_path="$optarg" - ;; --enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no" ;; --disable-gfx-check) check_gfx="no" @@ -418,7 +415,6 @@ echo "" echo "" echo "kqemu kernel acceleration support:" echo " --disable-kqemu disable kqemu support" -echo " --kernel-path=PATH set the kernel path (configure probes it)" echo " --disable-kvmdisable kernel virtual machine support" echo "" echo "Advanced options (experts only):" @@ -627,7 +623,7 @@ cat > $TMPC < /dev/null ; then +if $cc $ARCH_CFLAGS $CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then kvm_cap_pit="yes" fi fi @@ -1184,7 +1180,6 @@ configure_kvm() { \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then echo "#define USE_KVM 1" >> $config_h echo "USE_KVM=1" >> $config_mak -echo "CONFIG_KVM_KERNEL_INC=$kernel_path/include" >> $config_mak if test $kvm_cap_pit = "yes" ; then echo "USE_KVM_PIT=1" >> $config_mak fi - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 4] Fix libfdt to include synced headers
1 file changed, 3 insertions(+), 3 deletions(-) libkvm/Makefile |6 +++--- This modifies libfdt makefile to now include from synced header directory. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/libkvm/Makefile b/libkvm/Makefile --- a/libkvm/Makefile +++ b/libkvm/Makefile @@ -10,7 +10,7 @@ CFLAGS += $(autodepend-flags) -g -fomit- CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall CFLAGS += $(call cc-option, -fno-stack-protector, "") CFLAGS += $(call cc-option, -fno-stack-protector-all, "") -CFLAGS += -I $(KERNELDIR)/include +CFLAGS += -I $(INCLUDES_DIR) LDFLAGS += $(CFLAGS) @@ -26,9 +26,9 @@ libkvm.a: libkvm.o $(libkvm-$(ARCH)-objs install: install -D libkvm.h $(DESTDIR)/$(PREFIX)/include/libkvm.h - install -D $(KERNELDIR)/include/linux/kvm.h \ + install -D $(INCLUDES_DIR)/linux/kvm.h \ $(DESTDIR)/$(PREFIX)/include/linux/kvm.h - install -D $(KERNELDIR)/include/linux/kvm_para.h \ + install -D $(INCLUDES_DIR)/linux/kvm_para.h \ $(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 4] Add "make sync" to sync need kernel headers to kvm-userspace
2 files changed, 25 insertions(+), 4 deletions(-) Makefile | 21 - configure |8 +--- This patch adds ability for kvm-userspace build system to sync needed kernel headers locally without the need of compiled kernel source. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ rpmrelease = devel .PHONY: kernel user libkvm qemu bios vgabios extboot clean libfdt -all: libkvm qemu +all: sync libkvm qemu ifneq '$(filter $(ARCH), x86_64 i386 ia64)' '' all: $(if $(WANT_MODULE), kernel) user endif @@ -69,6 +69,24 @@ install: make -C libkvm DESTDIR="$(DESTDIR)" install make -C qemu DESTDIR="$(DESTDIR)" install + +ASM_DIR=$(ARCH) +ifneq '$(filter $(ARCH), i386 x86_64)' '' + ASM_DIR=x86 +endif + +sync: + mkdir -p $(INCLUDES_DIR) + mkdir -p $(INCLUDES_DIR)/asm-$(ASM_DIR) + mkdir -p $(INCLUDES_DIR)/linux + cp -f $(KERNELDIR)/include/asm-$(ASM_DIR)/kvm*.h \ + $(INCLUDES_DIR)/asm-$(ASM_DIR)/ + cp -f $(KERNELDIR)/include/linux/kvm*.h \ + $(KERNELDIR)/include/linux/compiler*.h \ + $(INCLUDES_DIR)/linux + ln -sf $(INCLUDES_DIR)/asm-$(ASM_DIR) $(INCLUDES_DIR)/asm + + tmpspec = .tmp.kvm.spec RPMTOPDIR = $$(pwd)/rpmtop @@ -99,3 +117,4 @@ clean: distclean: clean rm -f config.mak user/config.mak + rm -rf $(INCLUDES_DIR) diff --git a/configure b/configure --- a/configure +++ b/configure @@ -10,6 +10,7 @@ cross_prefix= cross_prefix= arch=`uname -m` target_exec= +local_kernel_includes_dir=$PWD/includes usage() { cat <<-EOF @@ -108,16 +109,16 @@ fi fi #configure user dir -(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \ +(cd user; ./configure --prefix="$prefix" \ --arch="$arch" \ ${cross_prefix:+"--cross-prefix=$cross_prefix"}) #configure qemu (cd qemu; ./configure --target-list=$target_exec \ --disable-kqemu \ ---extra-cflags="-I $PWD/../libkvm $qemu_cflags" \ +--extra-cflags="-I $PWD/../libkvm $qemu_cflags \ + -I $local_kernel_includes_dir" \ --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \ ---kernel-path="$libkvm_kerneldir" \ --prefix="$prefix" \ ${qemu_cc:+"--cc=$qemu_cc"} \ ${cross_prefix:+"--cross-prefix=$cross_prefix"} \ @@ -131,4 +132,5 @@ KERNELDIR=$kerneldir KERNELDIR=$kerneldir WANT_MODULE=$want_module CROSS_COMPILE=$cross_prefix +INCLUDES_DIR=$local_kernel_includes_dir EOF - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH] [v2] Move kvm_get_pit to libkvm.c common code
I just took the old description that was there before. A much better one would be: Remove declarations of kvm_*_pit() on architectures who do not support not have a PIT. That is what I was really intending. It removes a lot of compile warnings, when compiling anything with libkvm.h on platforms that do not have a pit. It's mainly because of the structures that are used as arguments to these function declrations. On Sun, 2008-04-13 at 17:24 +0300, Avi Kivity wrote: > Jerone Young wrote: > > - I am resending this patch removing ia64. It apprently fell through > > the cracks. > > > > Don't compile kvm_*_pit() on architectures whose currently supported > > platforms do not contain a PIT. > > > > Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h > > --- a/libkvm/libkvm.h > > +++ b/libkvm/libkvm.h > > @@ -549,6 +549,7 @@ int kvm_pit_in_kernel(kvm_context_t kvm) > > > > #ifdef KVM_CAP_PIT > > > > +#if defined(__i386__) || defined(__x86_64__) > > /*! > > * \brief Get in kernel PIT of the virtual domain > > * > > @@ -569,6 +570,7 @@ int kvm_get_pit(kvm_context_t kvm, struc > > * \param s PIT state of the virtual domain > > */ > > int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s); > > +#endif > > > > #endif > > Patch is okay, but doesn't match the description at all. Is this what > you intended to send? > - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 3] [V2] Fix loading of registers preboot for PowerPC
So this now moves code away from common code to arch specific kvm_qemu_arch_init(). Also added is a removal of duplicate calls to kvm_qemu_init_env() in common code. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> 3 files changed, 6 insertions(+), 4 deletions(-) qemu/hw/ppc440_bamboo.c |3 --- qemu/qemu-kvm-powerpc.c |6 ++ qemu/qemu-kvm.c |1 - - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 3] Add kvm_load_registers into qemu_arch_init for PowerPC
1 file changed, 6 insertions(+) qemu/qemu-kvm-powerpc.c |6 ++ This patch adds a call to load_kvm_registers after creation of vcpu. This is required for ppc since we are required to set certain registers before boot. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c --- a/qemu/qemu-kvm-powerpc.c +++ b/qemu/qemu-kvm-powerpc.c @@ -121,6 +121,12 @@ void kvm_arch_save_regs(CPUState *env) int kvm_arch_qemu_init_env(CPUState *cenv) { +if (cenv->cpu_index == 0) { +/* load any registers set in env into + kvm for the first guest vcpu */ +kvm_load_registers(cenv); +} + return 0; } - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 3] Remove duplicate kvm_qemu_init() calls
1 file changed, 1 deletion(-) qemu/qemu-kvm.c |1 - kvm_qemu_init is called in ap_main_loop() , when ap_main_loop() calls kvm_main_loop_cpu(), kvm_qemu_init() is run for a second time. It should only be called in kvm_main_loop_cpu(). Signed-off-by: Jerone Young <[EMAIL PROTECTED]> ~ diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -353,7 +353,6 @@ static void *ap_main_loop(void *_env) sigdelset(&signals, SIG_IPI); sigprocmask(SIG_BLOCK, &signals, NULL); kvm_create_vcpu(kvm_context, env->cpu_index); -kvm_qemu_init_env(env); if (kvm_irqchip_in_kernel(kvm_context)) env->hflags &= ~HF_HALTED_MASK; kvm_main_loop_cpu(env); - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 3] Remove kvm_load_registers from ppc440_bamboo board model
1 file changed, 3 deletions(-) qemu/hw/ppc440_bamboo.c |3 --- This patch removes the call to kvm_load_registers while in board platform setup code. This must now be done later in vcpu initialization. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -174,9 +174,6 @@ void bamboo_init(ram_addr_t ram_size, in env->gpr[3] = dt_base; #endif env->nip = ep; - - printf("%s: loading kvm registers\n", __func__); - kvm_load_registers(env); } for (i = 0; i < nb_nics; i++) { - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 1 of 2] Add kvm_load_registers after first vcpu creation
On Thu, 2008-04-10 at 18:35 -0300, Marcelo Tosatti wrote: > On Thu, Apr 10, 2008 at 04:04:47PM -0500, Jerone Young wrote: > > 1 file changed, 5 insertions(+) > > qemu/qemu-kvm.c |5 + > > > > > > This patch adds a call to load_kvm_registers after creation of > > vcpu. This is required for ppc since we are required to set certain > > registers before boot. This should not have any effect on the curren > > x86 code (though I need to test this to make sure). > > > > What I would like though are some comments on the fix. Is this the > > right place for this? We had this in our platform setup code, but with > > recent code changes it will not work there anymore). > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c > > --- a/qemu/qemu-kvm.c > > +++ b/qemu/qemu-kvm.c > > @@ -353,6 +353,11 @@ static void *ap_main_loop(void *_env) > > sigdelset(&signals, SIG_IPI); > > sigprocmask(SIG_BLOCK, &signals, NULL); > > kvm_create_vcpu(kvm_context, env->cpu_index); > > +if (env->cpu_index == 0) { > > + /* load any registers set in env into > > +kvm for the first guest vcpu */ > > +kvm_load_registers(env); > > +} > > kvm_qemu_init_env(env); > > if (kvm_irqchip_in_kernel(kvm_context)) > > env->hflags &= ~HF_HALTED_MASK; > > Hi Jerone, > > You can hook into PPC's kvm_arch_qemu_init_env(). That would be a much better place. I also noticed that kvm_qemu_init_env() is called in ap_main_loop and the kvm_main_loop_cpu. ap_main_loop calls kvm_main_loop_cpu, so one them should be removed. I'll submit another patch for that. > - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 2] Fix loading of registers preboot for PowerPC
These patches fix issue with brining up bamboo board model for PowerPC. We need to load certain registers in the first vcp preboot. I have not tested this on x86, but it should work without issue. Does anyone not like this being where it is? 2 files changed, 5 insertions(+), 3 deletions(-) qemu/hw/ppc440_bamboo.c |3 --- qemu/qemu-kvm.c |5 + - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 1 of 2] Add kvm_load_registers after first vcpu creation
1 file changed, 5 insertions(+) qemu/qemu-kvm.c |5 + This patch adds a call to load_kvm_registers after creation of vcpu. This is required for ppc since we are required to set certain registers before boot. This should not have any effect on the curren x86 code (though I need to test this to make sure). What I would like though are some comments on the fix. Is this the right place for this? We had this in our platform setup code, but with recent code changes it will not work there anymore). Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -353,6 +353,11 @@ static void *ap_main_loop(void *_env) sigdelset(&signals, SIG_IPI); sigprocmask(SIG_BLOCK, &signals, NULL); kvm_create_vcpu(kvm_context, env->cpu_index); +if (env->cpu_index == 0) { + /* load any registers set in env into +kvm for the first guest vcpu */ +kvm_load_registers(env); +} kvm_qemu_init_env(env); if (kvm_irqchip_in_kernel(kvm_context)) env->hflags &= ~HF_HALTED_MASK; - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 2] Remove kvm_load_registers from ppc440_bamboo board model
1 file changed, 3 deletions(-) qemu/hw/ppc440_bamboo.c |3 --- This patch removes the call to kvm_load_registers while in board platform setup code. This must now be done later in vcpu initialization. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -174,9 +174,6 @@ void bamboo_init(ram_addr_t ram_size, in env->gpr[3] = dt_base; #endif env->nip = ep; - - printf("%s: loading kvm registers\n", __func__); - kvm_load_registers(env); } for (i = 0; i < nb_nics; i++) { - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [v2] Move kvm_get_pit to libkvm.c common code
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1207692873 18000 # Branch merge # Node ID 8ddf560729aac228cd84068e1227e601e68a6840 # Parent 94cbc19df0f0fcab150599b10d859f1a3bc1b7cb [v2] Move kvm_get_pit to libkvm.c common code - I am resending this patch removing ia64. It apprently fell through the cracks. Don't compile kvm_*_pit() on architectures whose currently supported platforms do not contain a PIT. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -549,6 +549,7 @@ int kvm_pit_in_kernel(kvm_context_t kvm) #ifdef KVM_CAP_PIT +#if defined(__i386__) || defined(__x86_64__) /*! * \brief Get in kernel PIT of the virtual domain * @@ -569,6 +570,7 @@ int kvm_get_pit(kvm_context_t kvm, struc * \param s PIT state of the virtual domain */ int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s); +#endif #endif - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] [mq]: add_kvm_guest_wait_handlers
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1206732207 18000 # Node ID 82daf2163e7a8eb26b446550937e517be86c297c # Parent e48cf2ad6c85c457ff64c04b83960fc305420842 [mq]: add_kvm_guest_wait_handlers - 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
Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Add -Werror to libkvm compile
Yeah. This could "potentially" cause hell for users (non developers) down the road. I'm just going to keep this patch in my queue for myself, so no one will complain about warnings from my patches anymore. I think having a --developer flag to configure could work, but we would then need separate file for including the CFLAG, this would just clutter things more. On Tue, 2008-03-25 at 19:08 +0200, Avi Kivity wrote: > Jerone Young wrote: > > It does work with gcc 4.2.3 . Though no idea if gcc-4.3 & 4.4 would > > workout. Though they should. I'll need to to compile them and give them > > a try. > > > > While I'm a fan of -Werror, I have to agree with Anthony it can cause no > end of pain to users if they have a slightly different configuration. > > Maybe enable it conditionally based on ./configure --developer as > Anthony suggests (but I'll forget to use it myself, I'm sure). > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] buliding and testing PowerPC KVM
* Sorry was going for paste, and somehow hit send. So it's actually really easy using cross compiler to build everything. I use my laptop and then copy over to our nfs root that our boards use. Here are some instructions I wrote up for someone earlier. Excuse the parts but it is enough to get you going: This is a run through of how to build kvmppc kernel & kvm-userspace You will need (all will have info how to get and install): - cross tools - zlib - Linux kernel with KVM powerpc patches - kvm-userspace tools 1) Grabbing need tools === 1a) Cross Tools - If you are running on an x86 based machine you need these tools - cross tools can be found at: http://www.kegel.com/crosstool/crosstool-0.43.tar.gz Installation - Untar tarball and go into folder - If you are using Ubuntu linux .. replace /bin/sh symlink: sudo ln -sf /bin/bash /bin/sh - As root, create folder /opt/crosstool. Then change the permissions to allow everyone write access..this can be done by running: "chmod 777 /opt/crosstool" - As a normal user run: ./demo-powerpc-405.sh - Once done you should have directory in that is something like: /opt/crosstool/gcc--glibc- - Now you want to add the bin direcotry to your $PATH /opt/crosstool/gcc--glibc-/powerpc-405-linux-gnu/bin - Done 1b) Zlib - Now you need to compile a version of Zlib for powerpc - This will be used when building qemu while building kvm-userspace - zlib source can be found at: http://www.zlib.net/zlib-1.2.3.tar.gz Installation - Untar tarball and go into folder - Type the following in the follwoing. type in: CC=powerpc405-linux-gnu-gcc ./configure - The run: make - DO NOT INSTALL - You will now want to keep this directory around for later. 1c) Linux kernel with KVM PPC - - Currently patches are not upstream yet. You will need to get source from Hollis Blanchard or myself 1d) Kvm-userspace -- - You will need to get the bleeding edge latest version of kvm-userspace tools to work for powerpc. - To get these you will have to grab them from the git repository. - You must first install git tools that can be found here: http://git.or.cz/ - Now you can grab the folder by running the command: git clone git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git 2) Compiling Linux Kernel with kvm powerpc == - Untar and go into directory 2a) Compiling a host kernel --- - You will first need to copy over the default configuration for the board you are running on. -For 440EP Bamboo: cp arch/powerpc/configs/bamboo_defconfig .config -For 440EPx Sequioa: cp arch/powerpc/configs/sequoia_defconfig .config - Now go into the menuconfiguration with the follwoing command: make ARCH=powerpc CROSS_COMPILE=powerpc405-linux-gnu- menuconfig - Once in menu, enable menu option "Virtualization" - Then enable Virtualization->Kernel-based Virtual Machine (KVM) support - Also enable Virtualization->KVM guest support for PowerPC 440 - Save configuration - Now to compile your kernel -For 440EP Bamboo: - make ARCH=powerpc CROSS_COMPILE=powerpc405-linux-gnu- treeImage -For 440EPx Sequioa: - make ARCH=powerpc CROSS_COMPILE=powerpc440-linux-gnu- cuImage - Once compilation is done you will find kernel in proper format in arch/powerpc/boot/ -For 440EP Bamboo it will be "treeImage" -For 440EPx Sequioa it will be "cuImage" 2b) Compiling a guest kernel for KVM - 3) Builing kvm-userspace - you will need a zlib compiled for powerpc - you will need a complied copy of Linux kernel with kvm powerpc 3a) Compiling kvm-userspace --- - Go into kvm-userspace directory - To configure kvm-userspace you need to run the follwing command. NOTE to fill in areas where there is : ./configure --arch=powerpc --cross-prefix=powerpc-405-linux-gnu- \ --with-patched-kernel --kerneldir= \
Re: [kvm-devel] buliding and testing PowerPC KVM
So it's actually really easy using cross compiler to build everything. I use my laptop and then copy over to our nfs root that our boards use. Here are some instructions I wrote up for someone earlier. Excuse the parts but it is enough to get you going: On Tue, 2008-03-25 at 18:56 +0200, Avi Kivity wrote: > Hollis Blanchard wrote: > > On Fri, 2008-03-21 at 13:02 +0200, Avi Kivity wrote: > > > >> Other than that, and the few minor comments that popped up, this > >> (very > >> nice) patchset will be very easy to merge. IIRC you mentioned it is > >> possible for me to get an s390 account; this will be very useful in > >> avoiding breaking this port, as happens quite often with ppc and > >> ia64. > >> I'd like to be able to do both build and run testing. > >> > > > > As for building the PowerPC code, cross-compiling is easy with > > http://kegel.com/crosstool . There are also a number of servers offering > > remote PowerPC ssh access: see http://penguinppc.org/dev/#remote . > > > > > > I now have a ppc account. Once you point me at the ppc kernel repo I > can start build testing. > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Add -Werror to libkvm compile
It does work with gcc 4.2.3 . Though no idea if gcc-4.3 & 4.4 would workout. Though they should. I'll need to to compile them and give them a try. On Mon, 2008-03-24 at 20:42 +0100, Segher Boessenkool wrote: > > This patch adds -Werror to CFLAGS for compilation of libkvm. This > > should stop complaints about Warnings. > > Does libkvm build without warnings using GCC-4.3 (or even GCC-4.4) > on all supported platforms? If not, please fix that first :-) > > > Segher > > > - > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > ___ > kvm-devel mailing list > kvm-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/kvm-devel - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][QEMU] Use a separate device for in-kernel PIT (v2)
Fixes issues with pit for PPC. Acked-by: Jerone Young <[EMAIL PROTECTED]> On Mon, 2008-03-24 at 13:54 -0500, Anthony Liguori wrote: > Part of the feedback we received from Fabrice about the KVM patches for QEMU > is that we should create a separate device for the in-kernel APIC to avoid > having lots of if (kvm_enabled()) within the APIC code that were difficult to > understand why there were needed. > > This patch separates the in-kernel PIT into a separate device. It also > introduces some configure logic to only compile in support for the in-kernel > PIT if it's available. > > The result of this is that we now only need a single if (kvm_enabled()) to > determine which device to use. Besides making it more upstream friendly, I > think this makes the code much easier to understand. > > Since v1=>v2, we make sure to use common code for save/restore between > in-kernel pit and in-qemu pit. > > This patch also fixes the build for PPC. > > Signed-off-by: Anthony Liguori <[EMAIL PROTECTED]> > > diff --git a/qemu/Makefile.target b/qemu/Makefile.target > index e29bbeb..a947147 100644 > --- a/qemu/Makefile.target > +++ b/qemu/Makefile.target > @@ -587,6 +587,9 @@ OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o > OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o > OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o > OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o extboot.o > +ifeq ($(USE_KVM_PIT), 1) > +OBJS+= i8254-kvm.o > +endif > CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE > endif > ifeq ($(TARGET_BASE_ARCH), ia64) > diff --git a/qemu/configure b/qemu/configure > index bbedddc..bfbbae9 100755 > --- a/qemu/configure > +++ b/qemu/configure > @@ -100,6 +100,7 @@ bsd="no" > linux="no" > kqemu="no" > kvm="no" > +kvm_cap_pit="no" > profiler="no" > kernel_path="" > cocoa="no" > @@ -612,6 +613,22 @@ int main(void) { > EOF > > ## > +# KVM probe > + > +if test "$kvm" = "yes" ; then > +cat > $TMPC < +#include > +#ifndef KVM_CAP_PIT > +#error "kvm no pit capability" > +#endif > +int main(void) { return 0; } > +EOF > +if $cc $ARCH_CFLAGS $CFLAGS -I"$kernel_path"/include -o $TMPE > ${OS_CFLAGS} $TMPC 2> /dev/null ; then > + kvm_cap_pit="yes" > +fi > +fi > + > +## > # SDL probe > > sdl_too_old=no > @@ -1136,6 +1153,9 @@ configure_kvm() { > echo "#define USE_KVM 1" >> $config_h > echo "USE_KVM=1" >> $config_mak > echo "CONFIG_KVM_KERNEL_INC=$kernel_path/include" >> $config_mak > +if test $kvm_cap_pit = "yes" ; then > + echo "USE_KVM_PIT=1" >> $config_mak > +fi > disable_cpu_emulation >fi > } > diff --git a/qemu/hw/i8254-kvm.c b/qemu/hw/i8254-kvm.c > new file mode 100644 > index 000..b40af4a > --- /dev/null > +++ b/qemu/hw/i8254-kvm.c > @@ -0,0 +1,108 @@ > +/* > + * QEMU 8253/8254 interval timer emulation > + * > + * Copyright (c) 2003-2004 Fabrice Bellard > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > +#include "hw.h" > +#include "pc.h" > +#include "isa.h" > +#include "i8254.h" > + > +#include "qemu-kvm.h" > + > +static PITState pit_state; > + > +static void kvm_pit_save(QEMUFile *f, void *opaque) > +{
[kvm-devel] [PATCH] Add -Werror to libkvm compile
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1206384205 18000 # Branch merge # Node ID e23a26d1da04a6dbb831da7d03922abf95de7b30 # Parent 972f62b6acae693c388d7b05d3a9ba7ef26ab4a0 Add -Werror to libkvm compile This patch adds -Werror to CFLAGS for compilation of libkvm. This should stop complaints about Warnings. Often I miss these warnings as they scroll right by with everything else during a big compile. This will help catch them. For qemu this using -Werror is not possible as a lot of qemu throw a gcc warning of some sort. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/libkvm/Makefile b/libkvm/Makefile --- a/libkvm/Makefile +++ b/libkvm/Makefile @@ -11,6 +11,7 @@ CFLAGS += $(call cc-option, -fno-stack-p CFLAGS += $(call cc-option, -fno-stack-protector, "") CFLAGS += $(call cc-option, -fno-stack-protector-all, "") CFLAGS += -I $(KERNELDIR)/include +CFLAGS += -Werror LDFLAGS += $(CFLAGS) - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205956788 18000 # Branch merge # Node ID 127fe3c94ee7f90397b6f921d600c4a6f7237a10 # Parent 947b9350740ee49956b4e4720c313ac8a18b811e Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model This patch adds code to dynamically manipulate the device tree when loaded into memory. This allows us to finally have the ability to manipulate the kernel command line & initrd from the qemu command line. This will also let us setup different settings for the board. This patch also now uses new uboot loader load_uimage() to load kernel image. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o -OBJS+= ppc440.o ppc440_bamboo.o +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o endif ifeq ($(TARGET_BASE_ARCH), mips) OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c new file mode 100644 --- /dev/null +++ b/qemu/hw/device_tree.c @@ -0,0 +1,178 @@ +/* + * Functions to help device tree manipulation using libfdt. + * It also provides functions to read entries from device tree proc + * interface. + * + * Copyright 2008 IBM Corporation. + * Authors: Jerone Young <[EMAIL PROTECTED]> + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "ppc440.h" + +#ifdef CONFIG_LIBFDT +#include "libfdt.h" +#endif + +#define DT_PROC_INTERFACE_PATH "/proc/device-tree" + +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */ + +/* This function reads device-tree property files that are of + * a single cell size + */ +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree) +{ + char *buf = NULL; + int i; + uint32_t num; + FILE *stream; + + i = asprintf(&buf, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + if (i < 0) { + printf("%s: Unable to malloc string buffer buf\n", + __func__); + exit(1); + } + + stream = fopen(buf, "rb"); + + if (stream == NULL) { + printf("%s: Unable to open '%s'\n", __func__, buf); + exit(1); + } + + fread(&num, sizeof(num), 1, stream); + fclose(stream); + free(buf); + + return num; +} + +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */ + +#ifdef CONFIG_LIBFDT +/* support functions */ +static int get_offset_of_node(void *fdt, char *node_path) +{ + int node_offset; + node_offset = fdt_path_offset(fdt, node_path); + if (node_offset < 0) { + printf("Unable to find node in device tree '%s'\n", + node_path); + exit(1); + } + return node_offset; +} + +/* public functions */ +void *load_device_tree(char *filename_path, unsigned long load_addr) +{ + int dt_file_size; + int dt_file_load_size; + int new_dt_size; + int ret; + void *dt_file = NULL; + void *fdt; + + dt_file_size = get_image_size(filename_path); + if (dt_file_size < 0) { + printf("Unable to get size of device tree file '%s'\n", + filename_path); + goto fail; + } + + /* First allocate space in qemu for device tree */ + dt_file = qemu_malloc(dt_file_size); + if (dt_file == NULL) { + printf("Unable to allocate memory in qemu for device tree\n"); + goto fail; + } + memset(dt_file, 0, dt_file_size); + + dt_file_load_size = load_image(filename_path, dt_file); + + + /* XXX Second we place new copy of 2x size in guest memory +* This give us enough room for manipulation. +*/ + new_dt_size = dt_file_size * 2; + + fdt = (void *)load_addr; + + ret = fdt_open_into(dt_file, fdt, new_dt_size); + if (ret) { + printf("Unable to copy device tree in memory\n"); + goto fail; + } + + /* Check sanity of device tree */ + if (fdt_check_header(fdt)) { + printf ("Device tree file loaded into memory is invalid: %s\n", + filename_path); + goto fail; + } + /* free qemu memory with old device tree */ + qemu_free(dt_file); + return fdt; + +fail: + if (dt_file) +
[kvm-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205956788 18000 # Branch merge # Node ID e106ad4ec36334a0e2158a1396b4cbfbfeeb552e # Parent cd9ca907432cd14522809f098cc64d5a2b88705b Create new load_uimage() & gunzip support to uboot loader in Qemu This patch adds the ability for the load address to be caputred when loading a uImage or cuImage. It also adds a better return code as the size can be an usigned long. This is done by creating a new function prototype and calling it load_uimage. To keep compatibility with code already using the old load_uboot() a wrapper function has been created so current callers will not break. Also added is gunzip support to allow for loading of uimages with a compressed kenrel images. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/loader.c b/qemu/loader.c --- a/qemu/loader.c +++ b/qemu/loader.c @@ -26,6 +26,8 @@ #include "sysemu.h" #include "uboot_image.h" +#include + /* return the size or -1 if error */ int get_image_size(const char *filename) { @@ -263,14 +265,106 @@ static void bswap_uboot_header(uboot_ima } /* Load a U-Boot image. */ -int load_uboot(const char *filename, target_ulong *ep, int *is_linux) -{ - + +/* gunzip functionality is derived from gunzip function + * in uboot source code + */ + +#defineZALLOC_ALIGNMENT16 + +static void *zalloc(void *x, unsigned items, unsigned size) +{ + void *p; + + size *= items; + size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); + + p = malloc (size); + + return (p); +} + +static void zfree(void *x, void *addr, unsigned nb) +{ + free (addr); +} + + +#define HEAD_CRC 2 +#define EXTRA_FIELD4 +#define ORIG_NAME 8 +#define COMMENT0x10 +#define RESERVED 0xe0 + +#define DEFLATED 8 + +static int gunzip(void *dst, int dstlen, unsigned char *src, + unsigned long *lenp) +{ + z_stream s; + int r, i, flags; + + /* skip header */ + i = 10; + flags = src[3]; + if (src[2] != DEFLATED || (flags & RESERVED) != 0) { + puts ("Error: Bad gzipped data\n"); + return -1; + } + if ((flags & EXTRA_FIELD) != 0) + i = 12 + src[10] + (src[11] << 8); + if ((flags & ORIG_NAME) != 0) + while (src[i++] != 0) + ; + if ((flags & COMMENT) != 0) + while (src[i++] != 0) + ; + if ((flags & HEAD_CRC) != 0) + i += 2; + if (i >= *lenp) { + puts ("Error: gunzip out of data in header\n"); + return -1; + } + + s.zalloc = zalloc; + s.zfree = (free_func)zfree; + + r = inflateInit2(&s, -MAX_WBITS); + if (r != Z_OK) { + printf ("Error: inflateInit2() returned %d\n", r); + return (-1); + } + s.next_in = src + i; + s.avail_in = *lenp - i; + s.next_out = dst; + s.avail_out = dstlen; + r = inflate(&s, Z_FINISH); + if (r != Z_OK && r != Z_STREAM_END) { + printf ("Error: inflate() returned %d\n", r); + return -1; + } + *lenp = s.next_out - (unsigned char *) dst; + inflateEnd(&s); + + return 0; +} + + +#define MAX_KERNEL_SIZE 8<<20 //8MB +/* This functions can load uImage & cuImage files */ +int load_uimage(const char *filename, target_ulong *ep, +target_ulong *load_address, +target_ulong *loaded_image_size, +int *is_linux) +{ int fd; int size; +int ret; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; +uint8_t *uncompressed_data = NULL; +unsigned long tmp_loaded_image_size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -291,13 +385,14 @@ int load_uboot(const char *filename, tar goto fail; } -/* TODO: Implement compressed images. */ -if (hdr->ih_comp != IH_COMP_NONE) { -fprintf(stderr, "Unable to load compressed u-boot images\n"); +/* TODO bzip2 support */ +if (hdr->ih_comp == IH_COMP_BZIP2) { +fprintf(stderr, "Unable to load bzip2 compressed u-boot images\n"); goto fail; } /* TODO: Check CPU type. */ + if (is_linux) { if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX) *is_linux = 1; @@ -306,6 +401,7 @@ int load_uboot(const char *filename, tar } *ep = hdr->ih_ep; + data = qemu_malloc(hdr->ih_size); if (!data) goto fail; @@ -315,9 +411,34 @@ int load_uboot(const char *filename, tar goto fail; } -cpu_physical_memory_write_rom(hdr->ih_load,
[kvm-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205956788 18000 # Branch merge # Node ID 51914bbfa0257601c5074a632da11463c26e8f06 # Parent ce00438069e7a2fe5be55270b99583e8577ccd50 Add ability to specify ram on command line for bamboo board model This patch adds the ability to now specify ram sizes on the command line. Due to the nature of the code there are restictions on exactly how much ram and the multiple that the size must match. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -15,6 +15,8 @@ #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" +#define bytes_to_mb(a) (a>>20) + void bamboo_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, @@ -23,7 +25,7 @@ void bamboo_init(ram_addr_t ram_size, in const char *cpu_model) { char *buf=NULL; - target_phys_addr_t ram_bases[2], ram_sizes[2]; + target_phys_addr_t ram_bases[4], ram_sizes[4]; qemu_irq *pic; CPUState *env; target_ulong ep=0; @@ -35,31 +37,36 @@ void bamboo_init(ram_addr_t ram_size, in target_ulong dt_base=0; void *fdt; int ret; + int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20, + 32<<20, 16<<20, 8<<20 }; /* in bytes */ + ram_addr_t tmp_ram_size; + int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; printf("%s: START\n", __func__); /* Setup Memory */ - if (ram_size) { - printf("Ram size specified on command line is %i bytes\n", - (int)ram_size); - printf("WARNING: RAM is hard coded to 144MB\n"); - } - else { - printf("Using defualt ram size of %iMB\n", - ((int)ram_size/1024)/1024); + printf("Ram size passed is: %i MB\n", + bytes_to_mb((int)ram_size)); + + tmp_ram_size = ram_size; + + for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) { + for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) { + if ((tmp_ram_size/ram_stick_sizes[k]) > 0) { + ram_sizes[i] = ram_stick_sizes[k]; + tmp_ram_size -= ram_stick_sizes[k]; + break; + } + } } - /* Each bank can only have memory in configurations of -* 16MB, 32MB, 64MB, 128MB, or 256MB -*/ - ram_bases[0] = 0x0; - ram_sizes[0] = 0x0800; - ram_bases[1] = 0x0; - ram_sizes[1] = 0x0100; - - printf("Ram size of domain is %d bytes\n", (int)ram_size); + if (tmp_ram_size) { + printf("WARNING: %i MB left over memory is ram\n", + bytes_to_mb((int)tmp_ram_size)); + ram_size -= tmp_ram_size; + } /* Setup CPU */ env = cpu_ppc_init("440"); @@ -76,7 +83,7 @@ void bamboo_init(ram_addr_t ram_size, in /* Register mem */ cpu_register_physical_memory(0, ram_size, 0); if (kvm_enabled()) - kvm_cpu_register_physical_memory(0, ram_size, 0); + kvm_cpu_register_physical_memory(0, ram_size, 0); /* load kernel with uboot loader */ printf("%s: load kernel\n", __func__); - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 7] Add libfdt support to qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205956788 18000 # Branch merge # Node ID cd9ca907432cd14522809f098cc64d5a2b88705b # Parent af2d7781613d1bde6d0d48cf400b8b18ded19009 Add libfdt support to qemu This patch libfdt support into the qemu configuation script. There is a portion for libfdt probing that is has some "XXX". The code commented out is how to properly do probing for a library, the issue is that with kvm-userspace we do not build libfdt before configuring qemu. So to pervent this check from failing everytime we just do a simple test with the libfdt header. Once this can be resolved elgantly then we can uncomment the place commented out and remove the lines below them. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -555,6 +555,11 @@ ifdef CONFIG_VNC_TLS ifdef CONFIG_VNC_TLS CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS) LIBS += $(CONFIG_VNC_TLS_LIBS) +endif + +ifdef CONFIG_LIBFDT +LIBS += -lfdt +DEPLIBS += libfdt.a endif # SCSI layer diff --git a/qemu/configure b/qemu/configure --- a/qemu/configure +++ b/qemu/configure @@ -112,6 +112,7 @@ uname_release="" uname_release="" curses="yes" cpu_emulation="yes" +device_tree_support="" # OS specific targetos=`uname -s` @@ -345,6 +346,8 @@ for opt do ;; --disable-cpu-emulation) cpu_emulation="no" ;; + --disable-libfdt) device_tree_support="no" + ;; *) echo "ERROR: unknown option $opt"; exit 1 ;; esac @@ -449,6 +452,7 @@ echo " --enable-uname-release=R Return echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-cpu-emulation disables use of qemu cpu emulation code" +echo " --disable-libfdt disables use of libfdt support for device tree" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -732,6 +736,31 @@ else binsuffix="/bin" fi +## +# libfdt probe +# +if test -z "$device_tree_support" -a \ + "$cpu" = "powerpc"; then + device_tree_support="no" + cat > $TMPC << EOF +#include +/* XXX uncomment later when libfdt is built before this test */ +//int main(void) { void *fdt; return fdt_create(fdt, 1024); } +int main (void) {return 0;} +EOF +# XXX for now do not try to link to libfdt and just check for header */ +# if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC -lfdt 2> /dev/null ; then + if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC 2> /dev/null; then + device_tree_support="yes" + else +echo +echo "Error: Could not find libfdt" +echo "Make sure to have the libfdt libs and headers installed." +echo +exit 1 + fi +fi + echo "Install prefix$prefix" echo "BIOS directory$prefix$datasuffix" echo "binary directory $prefix$binsuffix" @@ -793,6 +822,9 @@ echo "kqemu support $kqemu" echo "kqemu support $kqemu" echo "kvm support $kvm" echo "CPU emulation $cpu_emulation" +if test $cpu = "powerpc"; then +echo "libfdt support$device_tree_support" +fi echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \ echo "uname -r $uname_release" @@ -1186,6 +1218,10 @@ elif test "$target_cpu" = "ppcemb" ; the echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPCEMB 1" >> $config_h + if test "$device_tree_support" = "yes" ; then + echo "#define CONFIG_LIBFDT 1" >> $config_h + echo "CONFIG_LIBFDT=1" >> $config_mak + fi configure_kvm elif test "$target_cpu" = "ppc64" ; then echo "TARGET_ARCH=ppc64" >> $config_mak - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205956788 18000 # Branch merge # Node ID 947b9350740ee49956b4e4720c313ac8a18b811e # Parent e106ad4ec36334a0e2158a1396b4cbfbfeeb552e Add PPC 440EP bamboo board device tree source & binary into qemu This patch places the bamboo device tree for the PPC 440EP bamboo board into the pc-bios directory of the qemu source. This also adds a rule into the pc-bios/Makefile to build device tree files. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile b/qemu/Makefile --- a/qemu/Makefile +++ b/qemu/Makefile @@ -195,7 +195,8 @@ endif mkdir -p "$(DESTDIR)$(datadir)" for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ video.x openbios-sparc32 pxe-ne2k_pci.bin \ - pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin; \ + pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin \ + bamboo.dtb; \ do \ $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \ done diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile --- a/qemu/pc-bios/Makefile +++ b/qemu/pc-bios/Makefile @@ -12,6 +12,9 @@ all: $(TARGETS) %.o: %.S $(CC) $(DEFINES) -c -o $@ $< +%.dtb: %.dts + dtc -O dtb -I dts -o $@ $< + clean: - rm -f $(TARGETS) *.o *~ + rm -f $(TARGETS) *.o *~ *.dtb diff --git a/qemu/pc-bios/bamboo.dtb b/qemu/pc-bios/bamboo.dtb new file mode 100644 index ..e02fa8e0bf23b992b04fe87dfce37d4cc08777a6 GIT binary patch literal 2663 zc$~FXOKa6Y6h7&LdnW9X_Yk([EMAIL PROTECTED]>9}pJL zM>[EMAIL PROTECTED]>>Jv&[EMAIL PROTECTED]|3x*(9n1CQu([EMAIL PROTECTED] zRX%1N(`%;=)p>7N2oe=G;`xsF{YL$2@)[EMAIL PROTECTED];&zso~hZ)`=%c3Sb{ zGRd!&dm8)FuQsFnw%^3Gg>;*ZAFm(FdWl!W zX`z~lhq6m-EZbqVj*GYs%OgsEL&[EMAIL PROTECTED] z6>iC1owbfQH|94E#lF>s z9D(`X9q4d[EMAIL PROTECTED]>!v4CS--Kln8N zhED_YVIHCSp656NR+eNX?8UdcE>wDU8Eg?++&A-zU#2ezDrgrFDjcT-#^>kY{Ot!Z z^K)B%-)m3K`7cnu6LZ9}A{NIwWv&~;T[EMAIL PROTECTED])yN=Ivkru3)MA?+o z1Hicyw`&[EMAIL PROTECTED](ocgdU8AO?UeJr+<`3v52$S`X{M0}h7a^>O} hww)+RiJO_zG!pI5 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +/ { + #address-cells = <2>; + #size-cells = <1>; + model = "amcc,bamboo"; + compatible = "amcc,bamboo"; + dcr-parent = <&/cpus/[EMAIL PROTECTED]>; + + aliases { + serial0 = &UART0; + serial1 = &UART1; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + [EMAIL PROTECTED] { + device_type = "cpu"; + model = "PowerPC,440EP"; + reg = <0>; + clock-frequency = <1fca0550>; + timebase-frequency = <017d7840>; + i-cache-line-size = <20>; + d-cache-line-size = <20>; + i-cache-size = <8000>; + d-cache-size = <8000>; + dcr-controller; + dcr-access-method = "native"; + }; + }; + + memory { + device_type = "memory"; + reg = <0 0 900>; + }; + + UIC0: interrupt-controller0 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <0>; + dcr-reg = <0c0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + }; +/* + UIC1: interrupt-controller1 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <1>; + dcr-reg = <0d0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + interrupts = <1e 4 1f 4>; + interrupt-parent = <&UIC0>; + }; +*/ + + SDR0: sdr { + compatible = "ibm,sdr-440ep"; + dcr-reg = <00e 002>; + }; + + CPR0: cpr { + compatible = "ibm,cpr-440ep"; + dcr-reg = <00c 002>; + }; + + plb { + compatible = "ibm,plb-440ep", "ibm,plb-440gp", "ibm,plb4"; +
[kvm-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205956788 18000 # Branch merge # Node ID ce00438069e7a2fe5be55270b99583e8577ccd50 # Parent 127fe3c94ee7f90397b6f921d600c4a6f7237a10 Modify PPC bamboo & ppc440 board models This patch renames pp440_init to ppc440ep_init, as ppc440 is the name of the core and ppc440ep is the name of the SOC. When we init we are initializing the SOC. Also in this patch we now call cpu_ppc_init for bamboo with string 440 .. as 440 is the core. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -10,7 +10,7 @@ #include "ppc440.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -20,7 +20,7 @@ #include "exec-all.h" #include "boards.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -62,8 +62,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("Ram size of domain is %d bytes\n", (int)ram_size); /* Setup CPU */ - /* XXX We cheat for now and use 405 */ - env = cpu_ppc_init("405"); + env = cpu_ppc_init("440"); if (!env) { fprintf(stderr, "Unable to initilize CPU!\n"); exit(1); @@ -71,7 +70,7 @@ void bamboo_init(ram_addr_t ram_size, in /* call init */ printf("Calling function ppc440_init\n"); - ppc440_init(env, ram_bases, ram_sizes, &pic,1); + ppc440ep_init(env, ram_bases, ram_sizes, &pic,1); printf("Done calling ppc440_init\n"); /* Register mem */ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 7] [v6] PowerPC kvm-userspace patches
Fix big bug found by Anthony, as well formating comments that he commented on. Bombs away! This set of patches enables the following: -Device tree Support - Add libfdt to kvm-userspace - Add bamboo device tree to qemu source - Detection of host Device Tree attributes - Device tree loading - Ability to specify initrd on the command line - Ability to add kernel arguments on the command line - Ability to load compressed uImages - Ability to specify memory on the command line Signed-off-by: Jerone Young <[EMAIL PROTECTED]> - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
On Wed, 2008-03-19 at 14:30 -0500, Anthony Liguori wrote: > Jerone Young wrote: > > # HG changeset patch > > # User Jerone Young <[EMAIL PROTECTED]> > > # Date 1205953012 18000 > > # Branch merge > > # Node ID 8e9da5ddf159eb6cf5a292ccbf5f735103b493ef > > # Parent 03925441312877b8350e4af68e475d5d746304d4 > > Add dynamic device tree manipulation & change uboot loader for PPC bamboo > > board model > > > > This patch adds code to dynamically manipulate the device tree when loaded > > into memory. This allows us to finally have the ability to manipulate the > > kernel command line & initrd from the qemu command line. This will also let > > us setup different settings for the board. > > > > This patch also now uses new uboot loader load_uimage() to load kernel > > image. > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/qemu/Makefile.target b/qemu/Makefile.target > > --- a/qemu/Makefile.target > > +++ b/qemu/Makefile.target > > @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o > > OBJS+= unin_pci.o ppc_chrp.o > > # PowerPC 4xx boards > > OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o > > -OBJS+= ppc440.o ppc440_bamboo.o > > +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o > > endif > > ifeq ($(TARGET_BASE_ARCH), mips) > > OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o > > diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c > > new file mode 100644 > > --- /dev/null > > +++ b/qemu/hw/device_tree.c > > @@ -0,0 +1,181 @@ > > +/* > > + * Functions to help device tree manipulation using libfdt. > > + * It also provides functions to read entries from device tree proc > > + * interface. > > + * > > + * Copyright 2008 IBM Corporation. > > + * Authors: Jerone Young <[EMAIL PROTECTED]> > > + * > > + * This work is licensed under the GNU GPL license version 2 or later. > > + * > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "config.h" > > +#include "ppc440.h" > > + > > +#ifdef CONFIG_LIBFDT > > +#include "libfdt.h" > > +#endif > > + > > +#define DT_PROC_INTERFACE_PATH "/proc/device-tree" > > + > > +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */ > > + > > +/* This function reads device-tree property files that are of > > + * a single cell size > > + */ > > +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree) > > +{ > > + char *buf = NULL; > > + int i; > > + uint32_t num; > > + FILE *stream; > > + > > + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH, > > + path_in_device_tree); > > + > > + buf = (char *)malloc(i); > > + if (buf == NULL) { > > + printf("%s: Unable to malloc string buffer buf\n", > > + __func__); > > + exit(1); > > + } > > + > > + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH, > > + path_in_device_tree); > > > > asprintf() is the right thing to do here. You allocate 'i' bytes but > then snprintf() to 'i + 1' bytes, that's a buffer overflow. Ouch! Yes this has to be fixed. Not sure why I did this, but > > > +fail: > > + if (dt_file) > > + qemu_free(dt_file); > > + return NULL; > > +} > > + > > +void dump_device_tree_to_file(void *fdt, char *filename) > > +{ > > + int fd; > > + fd = open(filename, O_RDWR|O_CREAT); > > > > Need to pass a permission mask when using O_CREAT. I'll fix this also. > > Regards, > > Anthony LIguori > > - > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > ___ > kvm-devel mailing list > kvm-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/kvm-devel - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205953014 18000 # Branch merge # Node ID 1facd867795ba61a65f451047a2982457b9e02ab # Parent f625aa6f92329c0069492849a389f41d024d479b Add ability to specify ram on command line for bamboo board model This patch adds the ability to now specify ram sizes on the command line. Due to the nature of the code there are restictions on exactly how much ram and the multiple that the size must match. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -15,6 +15,8 @@ #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" +#define bytes_to_mb(a) (a>>20) + void bamboo_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, @@ -23,7 +25,7 @@ void bamboo_init(ram_addr_t ram_size, in const char *cpu_model) { char *buf=NULL; - target_phys_addr_t ram_bases[2], ram_sizes[2]; + target_phys_addr_t ram_bases[4], ram_sizes[4]; qemu_irq *pic; CPUState *env; target_ulong ep=0; @@ -35,31 +37,36 @@ void bamboo_init(ram_addr_t ram_size, in target_ulong dt_base=0; void *fdt; int ret; + int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20, + 32<<20, 16<<20, 8<<20 }; /* in bytes */ + ram_addr_t tmp_ram_size; + int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; printf("%s: START\n", __func__); /* Setup Memory */ - if (ram_size) { - printf("Ram size specified on command line is %i bytes\n", - (int)ram_size); - printf("WARNING: RAM is hard coded to 144MB\n"); - } - else { - printf("Using defualt ram size of %iMB\n", - ((int)ram_size/1024)/1024); + printf("Ram size passed is: %i MB\n", + bytes_to_mb((int)ram_size)); + + tmp_ram_size = ram_size; + + for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) { + for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) { + if ((tmp_ram_size/ram_stick_sizes[k]) > 0) { + ram_sizes[i] = ram_stick_sizes[k]; + tmp_ram_size -= ram_stick_sizes[k]; + break; + } + } } - /* Each bank can only have memory in configurations of -* 16MB, 32MB, 64MB, 128MB, or 256MB -*/ - ram_bases[0] = 0x0; - ram_sizes[0] = 0x0800; - ram_bases[1] = 0x0; - ram_sizes[1] = 0x0100; - - printf("Ram size of domain is %d bytes\n", (int)ram_size); + if (tmp_ram_size) { + printf("WARNING: %i MB left over memory is ram\n", + bytes_to_mb((int)tmp_ram_size)); + ram_size -= tmp_ram_size; + } /* Setup CPU */ env = cpu_ppc_init("440"); @@ -76,7 +83,7 @@ void bamboo_init(ram_addr_t ram_size, in /* Register mem */ cpu_register_physical_memory(0, ram_size, 0); if (kvm_enabled()) - kvm_cpu_register_physical_memory(0, ram_size, 0); + kvm_cpu_register_physical_memory(0, ram_size, 0); /* load kernel with uboot loader */ printf("%s: load kernel\n", __func__); - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205953012 18000 # Branch merge # Node ID 8e9da5ddf159eb6cf5a292ccbf5f735103b493ef # Parent 03925441312877b8350e4af68e475d5d746304d4 Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model This patch adds code to dynamically manipulate the device tree when loaded into memory. This allows us to finally have the ability to manipulate the kernel command line & initrd from the qemu command line. This will also let us setup different settings for the board. This patch also now uses new uboot loader load_uimage() to load kernel image. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o -OBJS+= ppc440.o ppc440_bamboo.o +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o endif ifeq ($(TARGET_BASE_ARCH), mips) OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c new file mode 100644 --- /dev/null +++ b/qemu/hw/device_tree.c @@ -0,0 +1,181 @@ +/* + * Functions to help device tree manipulation using libfdt. + * It also provides functions to read entries from device tree proc + * interface. + * + * Copyright 2008 IBM Corporation. + * Authors: Jerone Young <[EMAIL PROTECTED]> + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "ppc440.h" + +#ifdef CONFIG_LIBFDT +#include "libfdt.h" +#endif + +#define DT_PROC_INTERFACE_PATH "/proc/device-tree" + +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */ + +/* This function reads device-tree property files that are of + * a single cell size + */ +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree) +{ + char *buf = NULL; + int i; + uint32_t num; + FILE *stream; + + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + buf = (char *)malloc(i); + if (buf == NULL) { + printf("%s: Unable to malloc string buffer buf\n", + __func__); + exit(1); + } + + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + stream = fopen(buf, "rb"); + + if (stream == NULL) { + printf("%s: Unable to open '%s'\n", __func__, buf); + exit(1); + } + + fread(&num, sizeof(num), 1, stream); + fclose(stream); + + return num; +} + +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */ + +#ifdef CONFIG_LIBFDT +/* support functions */ +static int get_offset_of_node(void *fdt, char *node_path) +{ + int node_offset; + node_offset = fdt_path_offset(fdt, node_path); + if (node_offset < 0) { + printf("Unable to find node in device tree '%s'\n", + node_path); + exit(1); + } + return node_offset; +} + +/* public functions */ +void *load_device_tree(char *filename_path, unsigned long load_addr) +{ + int dt_file_size; + int dt_file_load_size; + int new_dt_size; + int ret; + void *dt_file = NULL; + void *fdt; + + dt_file_size = get_image_size(filename_path); + if (dt_file_size < 0) { + printf("Unable to get size of device tree file '%s'\n", + filename_path); + goto fail; + } + + /* First allocate space in qemu for device tree */ + dt_file = qemu_malloc(dt_file_size); + if (dt_file == NULL) { + printf("Unable to allocate memory in qemu for device tree\n"); + goto fail; + } + memset(dt_file, 0, dt_file_size); + + dt_file_load_size = load_image(filename_path, dt_file); + + + /* XXX Second we place new copy of 2x size in guest memory +* This give us enough room for manipulation. +*/ + new_dt_size = dt_file_size * 2; + + fdt = (void *)load_addr; + + ret = fdt_open_into(dt_file, fdt, new_dt_size); + if (ret) { + printf("Unable to copy device tree in memory\n"); + goto fail; + } + + /* Check sanity of device tree */ + if (fdt_check_header(fdt)) { + printf ("Device tree file loaded into memory is invalid: %s\n", + filename_path); + goto fail; +
[kvm-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205953011 18000 # Branch merge # Node ID 03925441312877b8350e4af68e475d5d746304d4 # Parent 05d6146c77066b2bc0dd8349ee39636bc303628d Add PPC 440EP bamboo board device tree source & binary into qemu This patch places the bamboo device tree for the PPC 440EP bamboo board into the pc-bios directory of the qemu source. This also adds a rule into the pc-bios/Makefile to build device tree files. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile b/qemu/Makefile --- a/qemu/Makefile +++ b/qemu/Makefile @@ -195,7 +195,8 @@ endif mkdir -p "$(DESTDIR)$(datadir)" for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ video.x openbios-sparc32 pxe-ne2k_pci.bin \ - pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin; \ + pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin \ + bamboo.dtb; \ do \ $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \ done diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile --- a/qemu/pc-bios/Makefile +++ b/qemu/pc-bios/Makefile @@ -12,6 +12,9 @@ all: $(TARGETS) %.o: %.S $(CC) $(DEFINES) -c -o $@ $< +%.dtb: %.dts + dtc -O dtb -I dts -o $@ $< + clean: - rm -f $(TARGETS) *.o *~ + rm -f $(TARGETS) *.o *~ *.dtb diff --git a/qemu/pc-bios/bamboo.dtb b/qemu/pc-bios/bamboo.dtb new file mode 100644 index ..e02fa8e0bf23b992b04fe87dfce37d4cc08777a6 GIT binary patch literal 2663 zc$~FXOKa6Y6h7&LdnW9X_Yk([EMAIL PROTECTED]>9}pJL zM>[EMAIL PROTECTED]>>Jv&[EMAIL PROTECTED]|3x*(9n1CQu([EMAIL PROTECTED] zRX%1N(`%;=)p>7N2oe=G;`xsF{YL$2@)[EMAIL PROTECTED];&zso~hZ)`=%c3Sb{ zGRd!&dm8)FuQsFnw%^3Gg>;*ZAFm(FdWl!W zX`z~lhq6m-EZbqVj*GYs%OgsEL&[EMAIL PROTECTED] z6>iC1owbfQH|94E#lF>s z9D(`X9q4d[EMAIL PROTECTED]>!v4CS--Kln8N zhED_YVIHCSp656NR+eNX?8UdcE>wDU8Eg?++&A-zU#2ezDrgrFDjcT-#^>kY{Ot!Z z^K)B%-)m3K`7cnu6LZ9}A{NIwWv&~;T[EMAIL PROTECTED])yN=Ivkru3)MA?+o z1Hicyw`&[EMAIL PROTECTED](ocgdU8AO?UeJr+<`3v52$S`X{M0}h7a^>O} hww)+RiJO_zG!pI5 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +/ { + #address-cells = <2>; + #size-cells = <1>; + model = "amcc,bamboo"; + compatible = "amcc,bamboo"; + dcr-parent = <&/cpus/[EMAIL PROTECTED]>; + + aliases { + serial0 = &UART0; + serial1 = &UART1; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + [EMAIL PROTECTED] { + device_type = "cpu"; + model = "PowerPC,440EP"; + reg = <0>; + clock-frequency = <1fca0550>; + timebase-frequency = <017d7840>; + i-cache-line-size = <20>; + d-cache-line-size = <20>; + i-cache-size = <8000>; + d-cache-size = <8000>; + dcr-controller; + dcr-access-method = "native"; + }; + }; + + memory { + device_type = "memory"; + reg = <0 0 900>; + }; + + UIC0: interrupt-controller0 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <0>; + dcr-reg = <0c0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + }; +/* + UIC1: interrupt-controller1 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <1>; + dcr-reg = <0d0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + interrupts = <1e 4 1f 4>; + interrupt-parent = <&UIC0>; + }; +*/ + + SDR0: sdr { + compatible = "ibm,sdr-440ep"; + dcr-reg = <00e 002>; + }; + + CPR0: cpr { + compatible = "ibm,cpr-440ep"; + dcr-reg = <00c 002>; + }; + + plb { + compatible = "ibm,plb-440ep", "ibm,plb-440gp", "ibm,plb4"; +
[kvm-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205953013 18000 # Branch merge # Node ID f625aa6f92329c0069492849a389f41d024d479b # Parent 8e9da5ddf159eb6cf5a292ccbf5f735103b493ef Modify PPC bamboo & ppc440 board models This patch renames pp440_init to ppc440ep_init, as ppc440 is the name of the core and ppc440ep is the name of the SOC. When we init we are initializing the SOC. Also in this patch we now call cpu_ppc_init for bamboo with string 440 .. as 440 is the core. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -10,7 +10,7 @@ #include "ppc440.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -20,7 +20,7 @@ #include "exec-all.h" #include "boards.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -62,8 +62,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("Ram size of domain is %d bytes\n", (int)ram_size); /* Setup CPU */ - /* XXX We cheat for now and use 405 */ - env = cpu_ppc_init("405"); + env = cpu_ppc_init("440"); if (!env) { fprintf(stderr, "Unable to initilize CPU!\n"); exit(1); @@ -71,7 +70,7 @@ void bamboo_init(ram_addr_t ram_size, in /* call init */ printf("Calling function ppc440_init\n"); - ppc440_init(env, ram_bases, ram_sizes, &pic,1); + ppc440ep_init(env, ram_bases, ram_sizes, &pic,1); printf("Done calling ppc440_init\n"); /* Register mem */ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 7] Add libfdt support to qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205952857 18000 # Branch merge # Node ID be1aa50ab7de0a9e0441e46769e2a40a582fc3c0 # Parent 20c62a22bfaeca9f01439b96b7159b725fff0dcd Add libfdt support to qemu This patch libfdt support into the qemu configuation script. There is a portion for libfdt probing that is has some "XXX". The code commented out is how to properly do probing for a library, the issue is that with kvm-userspace we do not build libfdt before configuring qemu. So to pervent this check from failing everytime we just do a simple test with the libfdt header. Once this can be resolved elgantly then we can uncomment the place commented out and remove the lines below them. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -555,6 +555,11 @@ ifdef CONFIG_VNC_TLS ifdef CONFIG_VNC_TLS CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS) LIBS += $(CONFIG_VNC_TLS_LIBS) +endif + +ifdef CONFIG_LIBFDT +LIBS += -lfdt +DEPLIBS += libfdt.a endif # SCSI layer diff --git a/qemu/configure b/qemu/configure --- a/qemu/configure +++ b/qemu/configure @@ -112,6 +112,7 @@ uname_release="" uname_release="" curses="yes" cpu_emulation="yes" +device_tree_support="" # OS specific targetos=`uname -s` @@ -345,6 +346,8 @@ for opt do ;; --disable-cpu-emulation) cpu_emulation="no" ;; + --disable-libfdt) device_tree_support="no" + ;; *) echo "ERROR: unknown option $opt"; exit 1 ;; esac @@ -449,6 +452,7 @@ echo " --enable-uname-release=R Return echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-cpu-emulation disables use of qemu cpu emulation code" +echo " --disable-libfdt disables use of libfdt support for device tree" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -732,6 +736,31 @@ else binsuffix="/bin" fi +## +# libfdt probe +# +if test -z "$device_tree_support" -a \ + "$cpu" = "powerpc"; then + device_tree_support="no" + cat > $TMPC << EOF +#include +/* XXX uncomment later when libfdt is built before this test */ +//int main(void) { void *fdt; return fdt_create(fdt, 1024); } +int main (void) {return 0;} +EOF +# XXX for now do not try to link to libfdt and just check for header */ +# if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC -lfdt 2> /dev/null ; then + if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC 2> /dev/null; then + device_tree_support="yes" + else +echo +echo "Error: Could not find libfdt" +echo "Make sure to have the libfdt libs and headers installed." +echo +exit 1 + fi +fi + echo "Install prefix$prefix" echo "BIOS directory$prefix$datasuffix" echo "binary directory $prefix$binsuffix" @@ -793,6 +822,9 @@ echo "kqemu support $kqemu" echo "kqemu support $kqemu" echo "kvm support $kvm" echo "CPU emulation $cpu_emulation" +if test $cpu = "powerpc"; then +echo "libfdt support$device_tree_support" +fi echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \ echo "uname -r $uname_release" @@ -1186,6 +1218,10 @@ elif test "$target_cpu" = "ppcemb" ; the echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPCEMB 1" >> $config_h + if test "$device_tree_support" = "yes" ; then + echo "#define CONFIG_LIBFDT 1" >> $config_h + echo "CONFIG_LIBFDT=1" >> $config_mak + fi configure_kvm elif test "$target_cpu" = "ppc64" ; then echo "TARGET_ARCH=ppc64" >> $config_mak - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205953006 18000 # Branch merge # Node ID 05d6146c77066b2bc0dd8349ee39636bc303628d # Parent be1aa50ab7de0a9e0441e46769e2a40a582fc3c0 Create new load_uimage() & gunzip support to uboot loader in Qemu This patch adds the ability for the load address to be caputred when loading a uImage or cuImage. It also adds a better return code as the size can be an usigned long. This is done by creating a new function prototype and calling it load_uimage. To keep compatibility with code already using the old load_uboot() a wrapper function has been created so current callers will not break. Also added is gunzip support to allow for loading of uimages with a compressed kenrel images. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/loader.c b/qemu/loader.c --- a/qemu/loader.c +++ b/qemu/loader.c @@ -26,6 +26,8 @@ #include "sysemu.h" #include "uboot_image.h" +#include + /* return the size or -1 if error */ int get_image_size(const char *filename) { @@ -263,14 +265,106 @@ static void bswap_uboot_header(uboot_ima } /* Load a U-Boot image. */ -int load_uboot(const char *filename, target_ulong *ep, int *is_linux) -{ - + +/* gunzip functionality is derived from gunzip function + * in uboot source code + */ + +#defineZALLOC_ALIGNMENT16 + +static void *zalloc(void *x, unsigned items, unsigned size) +{ + void *p; + + size *= items; + size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); + + p = malloc (size); + + return (p); +} + +static void zfree(void *x, void *addr, unsigned nb) +{ + free (addr); +} + + +#define HEAD_CRC 2 +#define EXTRA_FIELD4 +#define ORIG_NAME 8 +#define COMMENT0x10 +#define RESERVED 0xe0 + +#define DEFLATED 8 + +static int gunzip(void *dst, int dstlen, unsigned char *src, + unsigned long *lenp) +{ + z_stream s; + int r, i, flags; + + /* skip header */ + i = 10; + flags = src[3]; + if (src[2] != DEFLATED || (flags & RESERVED) != 0) { + puts ("Error: Bad gzipped data\n"); + return -1; + } + if ((flags & EXTRA_FIELD) != 0) + i = 12 + src[10] + (src[11] << 8); + if ((flags & ORIG_NAME) != 0) + while (src[i++] != 0) + ; + if ((flags & COMMENT) != 0) + while (src[i++] != 0) + ; + if ((flags & HEAD_CRC) != 0) + i += 2; + if (i >= *lenp) { + puts ("Error: gunzip out of data in header\n"); + return -1; + } + + s.zalloc = zalloc; + s.zfree = (free_func)zfree; + + r = inflateInit2(&s, -MAX_WBITS); + if (r != Z_OK) { + printf ("Error: inflateInit2() returned %d\n", r); + return (-1); + } + s.next_in = src + i; + s.avail_in = *lenp - i; + s.next_out = dst; + s.avail_out = dstlen; + r = inflate(&s, Z_FINISH); + if (r != Z_OK && r != Z_STREAM_END) { + printf ("Error: inflate() returned %d\n", r); + return -1; + } + *lenp = s.next_out - (unsigned char *) dst; + inflateEnd(&s); + + return 0; +} + + +#define MAX_KERNEL_SIZE 8<<20 //8MB +/* This functions can load uImage & cuImage files */ +int load_uimage(const char *filename, target_ulong *ep, +target_ulong *load_address, +target_ulong *loaded_image_size, +int *is_linux) +{ int fd; int size; +int ret; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; +uint8_t *uncompressed_data = NULL; +unsigned long tmp_loaded_image_size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -291,13 +385,14 @@ int load_uboot(const char *filename, tar goto fail; } -/* TODO: Implement compressed images. */ -if (hdr->ih_comp != IH_COMP_NONE) { -fprintf(stderr, "Unable to load compressed u-boot images\n"); +/* TODO bzip2 support */ +if (hdr->ih_comp == IH_COMP_BZIP2) { +fprintf(stderr, "Unable to load bzip2 compressed u-boot images\n"); goto fail; } /* TODO: Check CPU type. */ + if (is_linux) { if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX) *is_linux = 1; @@ -306,6 +401,7 @@ int load_uboot(const char *filename, tar } *ep = hdr->ih_ep; + data = qemu_malloc(hdr->ih_size); if (!data) goto fail; @@ -315,9 +411,35 @@ int load_uboot(const char *filename, tar goto fail; } -cpu_physical_memory_write_rom(hdr->ih_load,
[kvm-devel] [PATCH 0 of 7] [v5] PowerPC kvm-userspace patches
This addresses a bug that was introduced with memory changes as well as compiler warnings that were fixed by casting. This should stop the spam fest ;-) This set of patches enables the following: -Device tree Support - Add libfdt to kvm-userspace - Add bamboo device tree to qemu source - Detection of host Device Tree attributes - Device tree loading - Ability to specify initrd on the command line - Ability to add kernel arguments on the command line - Ability to load compressed uImages - Ability to specify memory on the command line Signed-off-by: Jerone Young <[EMAIL PROTECTED]> - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH] Fix undefined refrence of qemu_system_device_hot_add for non x86 archs
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205942671 18000 # Branch merge # Node ID 782ef2276af9ca360e25e07ec5ac0ec387428397 # Parent 972f62b6acae693c388d7b05d3a9ba7ef26ab4a0 Fix undefined refrence of qemu_system_device_hot_add for non x86 archs This patch fixes it so that functions that depend on qemu_system_device_hot_add() are only compiled for x86 archs. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/device-hotplug.c b/qemu/hw/device-hotplug.c --- a/qemu/hw/device-hotplug.c +++ b/qemu/hw/device-hotplug.c @@ -140,6 +140,7 @@ static PCIDevice *qemu_system_hot_add_st return opaque; } +#if defined(TARGET_I386) || defined(TARGET_X86_64) void device_hot_add(int pcibus, const char *type, const char *opts) { PCIDevice *dev = NULL; @@ -171,6 +172,7 @@ void device_hot_remove(int pcibus, int s qemu_system_device_hot_add(pcibus, slot, 0); } +#endif static void destroy_nic(int slot) { diff --git a/qemu/monitor.c b/qemu/monitor.c --- a/qemu/monitor.c +++ b/qemu/monitor.c @@ -1359,6 +1359,7 @@ static term_cmd_t term_cmds[] = { { "migrate_set_speed", "s", do_migrate_set_speed, "value", "set maximum speed (in bytes) for migrations" }, { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" }, +#if defined(TARGET_I386) || defined(TARGET_X86_64) { "drive_add", "iss", drive_hot_add, "pcibus pcidevfn [file=file][,if=type][,bus=n]\n" "[,unit=m][,media=d][index=i]\n" "[,cyls=c,heads=h,secs=s[,trans=t]]\n" @@ -1366,6 +1367,7 @@ static term_cmd_t term_cmds[] = { "add drive to PCI storage controller" }, { "pci_add", "iss", device_hot_add, "bus nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" }, { "pci_del", "ii", device_hot_remove, "bus slot-number", "hot remove PCI device" }, +#endif { NULL, NULL, }, }; - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205937726 18000 # Branch merge # Node ID c0a71393d66916148a96e3f2f91d29478fb5d063 # Parent 257410f0c4f7c6fb23d93defb00d92d0ec066fc3 Modify PPC bamboo & ppc440 board models This patch renames pp440_init to ppc440ep_init, as ppc440 is the name of the core and ppc440ep is the name of the SOC. When we init we are initializing the SOC. Also in this patch we now call cpu_ppc_init for bamboo with string 440 .. as 440 is the core. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -10,7 +10,7 @@ #include "ppc440.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -20,7 +20,7 @@ #include "exec-all.h" #include "boards.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -62,8 +62,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("Ram size of domain is %d bytes\n", (int)ram_size); /* Setup CPU */ - /* XXX We cheat for now and use 405 */ - env = cpu_ppc_init("405"); + env = cpu_ppc_init("440"); if (!env) { fprintf(stderr, "Unable to initilize CPU!\n"); exit(1); @@ -71,7 +70,7 @@ void bamboo_init(ram_addr_t ram_size, in /* call init */ printf("Calling function ppc440_init\n"); - ppc440_init(env, ram_bases, ram_sizes, &pic,1); + ppc440ep_init(env, ram_bases, ram_sizes, &pic,1); printf("Done calling ppc440_init\n"); /* Register mem */ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 7] PowerPC kvm-userspace patches
Addresses even more issues disscussed with Hollis. One thing not changed was a changing division to logical comparison in patch 3/7. This doesn't seem like it would work over a divsion, also I don't want to mess around and break code that has been tested and works anymore. This set of patches enables the following: -Device tree Support - Add libfdt to kvm-userspace - Add bamboo device tree to qemu source - Detection of host Device Tree attributes - Device tree loading - Ability to specify initrd on the command line - Ability to add kernel arguments on the command line - Ability to load compressed uImages - Ability to specify memory on the command line Signed-off-by: Jerone Young <[EMAIL PROTECTED]> - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205937724 18000 # Branch merge # Node ID 257410f0c4f7c6fb23d93defb00d92d0ec066fc3 # Parent 4a064f92d8fa574cebac4d9b703d0a93c6387cea Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model This patch adds code to dynamically manipulate the device tree when loaded into memory. This allows us to finally have the ability to manipulate the kernel command line & initrd from the qemu command line. This will also let us setup different settings for the board. This patch also now uses new uboot loader load_uimage() to load kernel image. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o -OBJS+= ppc440.o ppc440_bamboo.o +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o endif ifeq ($(TARGET_BASE_ARCH), mips) OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c new file mode 100644 --- /dev/null +++ b/qemu/hw/device_tree.c @@ -0,0 +1,181 @@ +/* + * Functions to help device tree manipulation using libfdt. + * It also provides functions to read entries from device tree proc + * interface. + * + * Copyright 2008 IBM Corporation. + * Authors: Jerone Young <[EMAIL PROTECTED]> + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "ppc440.h" + +#ifdef CONFIG_LIBFDT +#include "libfdt.h" +#endif + +#define DT_PROC_INTERFACE_PATH "/proc/device-tree" + +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */ + +/* This function reads device-tree property files that are of + * a single cell size + */ +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree) +{ + char *buf = NULL; + int i; + uint32_t num; + FILE *stream; + + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + buf = (char *)malloc(i); + if (buf == NULL) { + printf("%s: Unable to malloc string buffer buf\n", + __func__); + exit(1); + } + + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + stream = fopen(buf, "rb"); + + if (stream == NULL) { + printf("%s: Unable to open '%s'\n", __func__, buf); + exit(1); + } + + fread(&num, sizeof(num), 1, stream); + fclose(stream); + + return num; +} + +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */ + +#ifdef CONFIG_LIBFDT +/* support functions */ +static int get_offset_of_node(void *fdt, char *node_path) +{ + int node_offset; + node_offset = fdt_path_offset(fdt, node_path); + if (node_offset < 0) { + printf("Unable to find node in device tree '%s'\n", + node_path); + exit(1); + } + return node_offset; +} + +/* public functions */ +void *load_device_tree(char *filename_path, unsigned long load_addr) +{ + int dt_file_size; + int dt_file_load_size; + int new_dt_size; + int ret; + void *dt_file = NULL; + void *fdt; + + dt_file_size = get_image_size(filename_path); + if (dt_file_size < 0) { + printf("Unable to get size of device tree file '%s'\n", + filename_path); + goto fail; + } + + /* First allocate space in qemu for device tree */ + dt_file = qemu_malloc(dt_file_size); + if (dt_file == NULL) { + printf("Unable to allocate memory in qemu for device tree\n"); + goto fail; + } + memset(dt_file, 0, dt_file_size); + + dt_file_load_size = load_image(filename_path, dt_file); + + + /* XXX Second we place new copy of 2x size in guest memory +* This give us enough room for manipulation. +*/ + new_dt_size = dt_file_size * 2; + + fdt = (void *)load_addr; + + ret = fdt_open_into(dt_file, fdt, new_dt_size); + if (ret) { + printf("Unable to copy device tree in memory\n"); + goto fail; + } + + /* Check sanity of device tree */ + if (fdt_check_header(fdt)) { + printf ("Device tree file loaded into memory is invalid: %s\n", + filename_path); + goto fail; +
[kvm-devel] [PATCH 2 of 7] Add libfdt support to qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205936671 18000 # Branch merge # Node ID 5371763b15da496413c4e818fb87a92c5e66eb56 # Parent 444d6f28441da70464ba36e9c9ffd863d1c58403 Add libfdt support to qemu This patch libfdt support into the qemu configuation script. There is a portion for libfdt probing that is has some "XXX". The code commented out is how to properly do probing for a library, the issue is that with kvm-userspace we do not build libfdt before configuring qemu. So to pervent this check from failing everytime we just do a simple test with the libfdt header. Once this can be resolved elgantly then we can uncomment the place commented out and remove the lines below them. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -555,6 +555,11 @@ ifdef CONFIG_VNC_TLS ifdef CONFIG_VNC_TLS CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS) LIBS += $(CONFIG_VNC_TLS_LIBS) +endif + +ifdef CONFIG_LIBFDT +LIBS += -lfdt +DEPLIBS += libfdt.a endif # SCSI layer diff --git a/qemu/configure b/qemu/configure --- a/qemu/configure +++ b/qemu/configure @@ -112,6 +112,7 @@ uname_release="" uname_release="" curses="yes" cpu_emulation="yes" +device_tree_support="" # OS specific targetos=`uname -s` @@ -345,6 +346,8 @@ for opt do ;; --disable-cpu-emulation) cpu_emulation="no" ;; + --disable-libfdt) device_tree_support="no" + ;; *) echo "ERROR: unknown option $opt"; exit 1 ;; esac @@ -449,6 +452,7 @@ echo " --enable-uname-release=R Return echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-cpu-emulation disables use of qemu cpu emulation code" +echo " --disable-libfdt disables use of libfdt support for device tree" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -732,6 +736,31 @@ else binsuffix="/bin" fi +## +# libfdt probe +# +if test -z "$device_tree_support" -a \ + "$cpu" = "powerpc"; then + device_tree_support="no" + cat > $TMPC << EOF +#include +/* XXX uncomment later when libfdt is built before this test */ +//int main(void) { void *fdt; return fdt_create(fdt, 1024); } +int main (void) {return 0;} +EOF +# XXX for now do not try to link to libfdt and just check for header */ +# if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC -lfdt 2> /dev/null ; then + if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC 2> /dev/null; then + device_tree_support="yes" + else +echo +echo "Error: Could not find libfdt" +echo "Make sure to have the libfdt libs and headers installed." +echo +exit 1 + fi +fi + echo "Install prefix$prefix" echo "BIOS directory$prefix$datasuffix" echo "binary directory $prefix$binsuffix" @@ -793,6 +822,9 @@ echo "kqemu support $kqemu" echo "kqemu support $kqemu" echo "kvm support $kvm" echo "CPU emulation $cpu_emulation" +if test $cpu = "powerpc"; then +echo "libfdt support$device_tree_support" +fi echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \ echo "uname -r $uname_release" @@ -1186,6 +1218,10 @@ elif test "$target_cpu" = "ppcemb" ; the echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPCEMB 1" >> $config_h + if test "$device_tree_support" = "yes" ; then + echo "#define CONFIG_LIBFDT 1" >> $config_h + echo "CONFIG_LIBFDT=1" >> $config_mak + fi configure_kvm elif test "$target_cpu" = "ppc64" ; then echo "TARGET_ARCH=ppc64" >> $config_mak - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205937723 18000 # Branch merge # Node ID 4a064f92d8fa574cebac4d9b703d0a93c6387cea # Parent 6bc8a342745dd8fefbe229cc4626144b19786117 Add PPC 440EP bamboo board device tree source & binary into qemu This patch places the bamboo device tree for the PPC 440EP bamboo board into the pc-bios directory of the qemu source. This also adds a rule into the pc-bios/Makefile to build device tree files. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile b/qemu/Makefile --- a/qemu/Makefile +++ b/qemu/Makefile @@ -195,7 +195,8 @@ endif mkdir -p "$(DESTDIR)$(datadir)" for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ video.x openbios-sparc32 pxe-ne2k_pci.bin \ - pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin; \ + pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin \ + bamboo.dtb; \ do \ $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \ done diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile --- a/qemu/pc-bios/Makefile +++ b/qemu/pc-bios/Makefile @@ -12,6 +12,9 @@ all: $(TARGETS) %.o: %.S $(CC) $(DEFINES) -c -o $@ $< +%.dtb: %.dts + dtc -O dtb -I dts -o $@ $< + clean: - rm -f $(TARGETS) *.o *~ + rm -f $(TARGETS) *.o *~ *.dtb diff --git a/qemu/pc-bios/bamboo.dtb b/qemu/pc-bios/bamboo.dtb new file mode 100644 index ..e02fa8e0bf23b992b04fe87dfce37d4cc08777a6 GIT binary patch literal 2663 zc$~FXOKa6Y6h7&LdnW9X_Yk([EMAIL PROTECTED]>9}pJL zM>[EMAIL PROTECTED]>>Jv&[EMAIL PROTECTED]|3x*(9n1CQu([EMAIL PROTECTED] zRX%1N(`%;=)p>7N2oe=G;`xsF{YL$2@)[EMAIL PROTECTED];&zso~hZ)`=%c3Sb{ zGRd!&dm8)FuQsFnw%^3Gg>;*ZAFm(FdWl!W zX`z~lhq6m-EZbqVj*GYs%OgsEL&[EMAIL PROTECTED] z6>iC1owbfQH|94E#lF>s z9D(`X9q4d[EMAIL PROTECTED]>!v4CS--Kln8N zhED_YVIHCSp656NR+eNX?8UdcE>wDU8Eg?++&A-zU#2ezDrgrFDjcT-#^>kY{Ot!Z z^K)B%-)m3K`7cnu6LZ9}A{NIwWv&~;T[EMAIL PROTECTED])yN=Ivkru3)MA?+o z1Hicyw`&[EMAIL PROTECTED](ocgdU8AO?UeJr+<`3v52$S`X{M0}h7a^>O} hww)+RiJO_zG!pI5 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +/ { + #address-cells = <2>; + #size-cells = <1>; + model = "amcc,bamboo"; + compatible = "amcc,bamboo"; + dcr-parent = <&/cpus/[EMAIL PROTECTED]>; + + aliases { + serial0 = &UART0; + serial1 = &UART1; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + [EMAIL PROTECTED] { + device_type = "cpu"; + model = "PowerPC,440EP"; + reg = <0>; + clock-frequency = <1fca0550>; + timebase-frequency = <017d7840>; + i-cache-line-size = <20>; + d-cache-line-size = <20>; + i-cache-size = <8000>; + d-cache-size = <8000>; + dcr-controller; + dcr-access-method = "native"; + }; + }; + + memory { + device_type = "memory"; + reg = <0 0 900>; + }; + + UIC0: interrupt-controller0 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <0>; + dcr-reg = <0c0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + }; +/* + UIC1: interrupt-controller1 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <1>; + dcr-reg = <0d0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + interrupts = <1e 4 1f 4>; + interrupt-parent = <&UIC0>; + }; +*/ + + SDR0: sdr { + compatible = "ibm,sdr-440ep"; + dcr-reg = <00e 002>; + }; + + CPR0: cpr { + compatible = "ibm,cpr-440ep"; + dcr-reg = <00c 002>; + }; + + plb { + compatible = "ibm,plb-440ep", "ibm,plb-440gp", "ibm,plb4"; +
[kvm-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205937719 18000 # Branch merge # Node ID 6bc8a342745dd8fefbe229cc4626144b19786117 # Parent 5371763b15da496413c4e818fb87a92c5e66eb56 Create new load_uimage() & gunzip support to uboot loader in Qemu This patch adds the ability for the load address to be caputred when loading a uImage or cuImage. It also adds a better return code as the size can be an usigned long. This is done by creating a new function prototype and calling it load_uimage. To keep compatibility with code already using the old load_uboot() a wrapper function has been created so current callers will not break. Also added is gunzip support to allow for loading of uimages with a compressed kenrel images. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/loader.c b/qemu/loader.c --- a/qemu/loader.c +++ b/qemu/loader.c @@ -26,6 +26,8 @@ #include "sysemu.h" #include "uboot_image.h" +#include + /* return the size or -1 if error */ int get_image_size(const char *filename) { @@ -263,14 +265,106 @@ static void bswap_uboot_header(uboot_ima } /* Load a U-Boot image. */ -int load_uboot(const char *filename, target_ulong *ep, int *is_linux) -{ - + +/* gunzip functionality is derived from gunzip function + * in uboot source code + */ + +#defineZALLOC_ALIGNMENT16 + +static void *zalloc(void *x, unsigned items, unsigned size) +{ + void *p; + + size *= items; + size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); + + p = malloc (size); + + return (p); +} + +static void zfree(void *x, void *addr, unsigned nb) +{ + free (addr); +} + + +#define HEAD_CRC 2 +#define EXTRA_FIELD4 +#define ORIG_NAME 8 +#define COMMENT0x10 +#define RESERVED 0xe0 + +#define DEFLATED 8 + +static int gunzip(void *dst, int dstlen, unsigned char *src, + unsigned long *lenp) +{ + z_stream s; + int r, i, flags; + + /* skip header */ + i = 10; + flags = src[3]; + if (src[2] != DEFLATED || (flags & RESERVED) != 0) { + puts ("Error: Bad gzipped data\n"); + return -1; + } + if ((flags & EXTRA_FIELD) != 0) + i = 12 + src[10] + (src[11] << 8); + if ((flags & ORIG_NAME) != 0) + while (src[i++] != 0) + ; + if ((flags & COMMENT) != 0) + while (src[i++] != 0) + ; + if ((flags & HEAD_CRC) != 0) + i += 2; + if (i >= *lenp) { + puts ("Error: gunzip out of data in header\n"); + return -1; + } + + s.zalloc = zalloc; + s.zfree = zfree; + + r = inflateInit2(&s, -MAX_WBITS); + if (r != Z_OK) { + printf ("Error: inflateInit2() returned %d\n", r); + return (-1); + } + s.next_in = src + i; + s.avail_in = *lenp - i; + s.next_out = dst; + s.avail_out = dstlen; + r = inflate(&s, Z_FINISH); + if (r != Z_OK && r != Z_STREAM_END) { + printf ("Error: inflate() returned %d\n", r); + return -1; + } + *lenp = s.next_out - (unsigned char *) dst; + inflateEnd(&s); + + return 0; +} + + +#define MAX_KERNEL_SIZE 8<<20 //8MB +/* This functions can load uImage & cuImage files */ +int load_uimage(const char *filename, target_ulong *ep, +target_ulong *load_address, +target_ulong *loaded_image_size, +int *is_linux) +{ int fd; int size; +int ret; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; +uint8_t *uncompressed_data = NULL; +unsigned long tmp_loaded_image_size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -291,13 +385,14 @@ int load_uboot(const char *filename, tar goto fail; } -/* TODO: Implement compressed images. */ -if (hdr->ih_comp != IH_COMP_NONE) { -fprintf(stderr, "Unable to load compressed u-boot images\n"); +/* TODO bzip2 support */ +if (hdr->ih_comp == IH_COMP_BZIP2) { +fprintf(stderr, "Unable to load bzip2 compressed u-boot images\n"); goto fail; } /* TODO: Check CPU type. */ + if (is_linux) { if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX) *is_linux = 1; @@ -306,6 +401,7 @@ int load_uboot(const char *filename, tar } *ep = hdr->ih_ep; + data = qemu_malloc(hdr->ih_size); if (!data) goto fail; @@ -315,9 +411,35 @@ int load_uboot(const char *filename, tar goto fail; } -cpu_physical_memory_write_rom(hdr->ih_load,
[kvm-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205937727 18000 # Branch merge # Node ID 17ae5b5f4fbfc2ac365b747ffa864afef67220d7 # Parent c0a71393d66916148a96e3f2f91d29478fb5d063 Add ability to specify ram on command line for bamboo board model This patch adds the ability to now specify ram sizes on the command line. Due to the nature of the code there are restictions on exactly how much ram and the multiple that the size must match. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -15,6 +15,8 @@ #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" +#define bytes_to_mb(a) (a>>20) + void bamboo_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, @@ -23,7 +25,7 @@ void bamboo_init(ram_addr_t ram_size, in const char *cpu_model) { char *buf; - target_phys_addr_t ram_bases[2], ram_sizes[2]; + target_phys_addr_t ram_bases[4], ram_sizes[4]; qemu_irq *pic; CPUState *env; target_ulong ep=0; @@ -35,31 +37,36 @@ void bamboo_init(ram_addr_t ram_size, in target_ulong dt_base=0; void *fdt; int ret; + int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20, + 32<<20, 16<<20, 8<<20 }; /* in bytes */ + ram_addr_t tmp_ram_size; + int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; printf("%s: START\n", __func__); /* Setup Memory */ - if (ram_size) { - printf("Ram size specified on command line is %i bytes\n", - (int)ram_size); - printf("WARNING: RAM is hard coded to 144MB\n"); - } - else { - printf("Using defualt ram size of %iMB\n", - ((int)ram_size/1024)/1024); + printf("Ram size passed is: %i MB\n", + bytes_to_mb((int)ram_size)); + + tmp_ram_size = ram_size; + + for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) { + for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) { + if ((ram_size/ram_stick_sizes[k]) > 0) { + ram_sizes[i] = ram_stick_sizes[k]; + tmp_ram_size -= ram_stick_sizes[k]; + break; + } + } } - /* Each bank can only have memory in configurations of -* 16MB, 32MB, 64MB, 128MB, or 256MB -*/ - ram_bases[0] = 0x0; - ram_sizes[0] = 0x0800; - ram_bases[1] = 0x0; - ram_sizes[1] = 0x0100; - - printf("Ram size of domain is %d bytes\n", (int)ram_size); + if (tmp_ram_size) { + printf("WARNING: %i MB left over memory is ram\n", + bytes_to_mb((int)tmp_ram_size)); + ram_size -= tmp_ram_size; + } /* Setup CPU */ env = cpu_ppc_init("440"); @@ -76,7 +83,7 @@ void bamboo_init(ram_addr_t ram_size, in /* Register mem */ cpu_register_physical_memory(0, ram_size, 0); if (kvm_enabled()) - kvm_cpu_register_physical_memory(0, ram_size, 0); + kvm_cpu_register_physical_memory(0, ram_size, 0); /* load kernel with uboot loader */ printf("%s: load kernel\n", __func__); - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 2 of 7] Add libfdt support to qemu
Well this can not go upstream. If it were to go into upstream qemu we would need for them to take in libfdt (which they most likely will have big issue with). Also we wouldn't do the probing if they did take it in. But for the forseable future we are not getting stuff into qemu yet. If we do then will cross this road and remove this completely. Or if libfdt ever is packaged separately. For now this is what we have to do for probing On Tue, 2008-03-18 at 16:28 -0500, Hollis Blanchard wrote: > OK, if that's acceptable to the qemu folks, could you put that in the > patch description? > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu
On Tue, 2008-03-18 at 16:14 -0500, Hollis Blanchard wrote: > On Tue, 2008-03-18 at 15:06 -0500, Jerone Young wrote: > > +tmp_loaded_image_size = hdr->ih_size; > > + > > +if (hdr->ih_comp == IH_COMP_GZIP) { > > + uncompressed_data = qemu_malloc(MAX_KERNEL_SIZE); > > + ret = gunzip(uncompressed_data, MAX_KERNEL_SIZE, > > +(unsigned char *) data, > > +&tmp_loaded_image_size); > > + > > + if (ret < 0) { > > +fprintf(stderr, "Unable to decompress gziped image! > \n"); > > +goto fail; > > +} > > + > > +qemu_free(data); > > +cpu_physical_memory_write_rom(hdr->ih_load, > uncompressed_data, > > + tmp_loaded_image_size); > > + > > +} > > +else { > > +cpu_physical_memory_write_rom(hdr->ih_load, data, > > + tmp_loaded_image_size); > > +} > > + > > +if (loaded_image_size != NULL) > > +*loaded_image_size = tmp_loaded_image_size; > > + > > +if ( load_address != NULL) > > + *load_address = hdr->ih_load; > > Your whitespace in here is all over the place. Please fix. Actually this matches the style of this entire file. I see the one white space. I see also I used a tab one place. The problem is there is no set style in qemu. So I followed the style of the already created file. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
On Tue, 2008-03-18 at 16:25 -0500, Hollis Blanchard wrote: > On Tue, 2008-03-18 at 15:06 -0500, Jerone Young wrote: > > # HG changeset patch > > # User Jerone Young <[EMAIL PROTECTED]> > > # Date 1205870472 18000 > > # Branch merge > > # Node ID 3e87db599895937824b9bf3369eb67ea7f5a7595 > > # Parent ba2876c3e8916ba9c19b75c4464cbb8dc6858fbd > > Add dynamic device tree manipulation & change uboot loader for PPC bamboo > > board model > > > > This patch adds code to dynamically manipulate the device tree when > > loaded into memory. This allows us to finally have the ability to > > manipulate the kernel command line & initrd from the qemu command > > line. This will also let us setup different settings for the board. > > > > This patch also now uses new uboot loader load_image() to load kernel > > image. > > Again, the load_uimage part (which you've misspelled here) should be a > separate patch? > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/qemu/Makefile.target b/qemu/Makefile.target > > --- a/qemu/Makefile.target > > +++ b/qemu/Makefile.target > > @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o > > OBJS+= unin_pci.o ppc_chrp.o > > # PowerPC 4xx boards > > OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o > > -OBJS+= ppc440.o ppc440_bamboo.o > > +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o > > endif > > ifeq ($(TARGET_BASE_ARCH), mips) > > OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o > > diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c > > new file mode 100644 > > --- /dev/null > > +++ b/qemu/hw/device_tree.c > > @@ -0,0 +1,181 @@ > > +/* > > + * Functions to help device tree manipulation using libfdt. > > + * It also provides functions to read entries from device tree proc > > + * interface. > > + * > > + * Copyright 2008 IBM Corporation. > > + * Authors: Jerone Young <[EMAIL PROTECTED]> > > + * > > + * This work is licensed under the GNU GPL license version 2 or later. > > + * > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "config.h" > > +#include "ppc440.h" > > + > > +#ifdef CONFIG_LIBFDT > > + #include "libfdt.h" > > +#endif > > Again, don't indent this. > > > +#define DT_PROC_INTERFACE_PATH "/proc/device-tree" > > + > > +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */ > > + > > +/* This function reads device-tree property files that are of > > + * a single cell size > > + */ > > +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree) > > +{ > > + char *buf = NULL; > > + int i; > > + uint32_t num; > > + FILE *stream; > > + > > + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH, > > + path_in_device_tree); > > + > > + buf = (char *)malloc(i); > > + if (buf == NULL) > > + { > > + printf("%s: Unable to malloc string buffer buf\n", > > + __func__); > > + exit(1); > > + } > > Braces. What is the deal. They are braces. They are done diffrenent through outt the qemu code. This > > > + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH, > > + path_in_device_tree); > > + > > + stream = fopen(buf, "rb"); > > + > > + if (stream == NULL) > > + { > > + printf("%s: Unable to open '%s'\n", __func__, buf); > > + exit(1); > > + } > > Braces. > > > + fread(&num, sizeof(num), 1, stream); > > + fclose(stream); > > + > > + return num; > > +} > > + > > +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */ > > + > > +#ifdef CONFIG_LIBFDT > > +/* support functions */ > > +static int get_offset_of_node(void *fdt, char *node_path) > > +{ > > + int node_offset; > > + node_offset = fdt_path_offset(fdt, node_path); > > + if (node_offset < 0) { > > + printf("Unable to find node in device tree '%s'\n", > > + node_path); > > + exit(1); > > + } > > + return node_offset; > > +} > > + > > +/* public functions */ > > +void *load_device_tree(char *filename_path, unsigned
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 2 of 7] Add libfdt support to qemu
So this is the code Anthony asked for for probing libfdt. The problem is that if you do ./configure at kvm-userpace top directory for the first time or after a clean you do not have libfdt.a. When qemu configure is run this probe would allways fail. So to check we just check for the header. So we compile a very simple program that include libfdt.h as the test. All the XXX are if we ever do break libfdt out then we can do the proper probing for it (and the code for it is ready to be uncommented). On Tue, 2008-03-18 at 16:16 -0500, Hollis Blanchard wrote: > On Tue, 2008-03-18 at 15:06 -0500, Jerone Young wrote: > > +## > > +# libfdt probe > > +# > > +if test -z "$device_tree_support" -a \ > > + "$cpu" = "powerpc"; then > > + device_tree_support="no" > > + cat > $TMPC << EOF > > +#include > > +/* XXX uncomment later when libfdt is built before this test */ > > +//int main(void) { void *fdt; return fdt_create(fdt, 1024); } > > +int main (void) {return 0;} > > +EOF > > +# XXX for now do not try to link to libfdt and just check for header */ > > +# if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC -lfdt 2> /dev/null ; > > then > > + if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC 2> /dev/null; then > > + device_tree_support="yes" > > + else > > +echo > > +echo "Error: Could not find libfdt" > > +echo "Make sure to have the libfdt libs and headers installed." > > +echo > > +exit 1 > > + fi > > +fi > > What is the problem here? Should you describe it in the patch > description? Did you mean to fix this before committing? > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
On Tue, 2008-03-18 at 16:03 -0500, Hollis Blanchard wrote: > On Tue, 2008-03-18 at 15:06 -0500, Jerone Young wrote: > > # HG changeset patch > > # User Jerone Young <[EMAIL PROTECTED]> > > # Date 1205870472 18000 > > # Branch merge > > # Node ID 4f90f7d25186f55bfb1503764af5264201df067f > > # Parent ac0fc9dfd78d2eddd083326e9b635a9286fc3b19 > > Add ability to specify ram on command line for bamboo board model > > > > This patch adds the ability to now specify ram sizes on the command line. > > Due to the nature of the code there are restictions on exactly how > > much ram and the multiple that the size must match. > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c > > --- a/qemu/hw/ppc440_bamboo.c > > +++ b/qemu/hw/ppc440_bamboo.c > > @@ -15,6 +15,9 @@ > > > > #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" > > > > +#define bytes_to_mb(a) (a>>20) > > +#define mb_to_bytes(a) (a<<20) > > + > > /* PPC 440 refrence demo board > > * > > * 440 PowerPC CPU > > @@ -28,7 +31,7 @@ void bamboo_init(ram_addr_t ram_size, in > > const char *cpu_model) > > { > > char buf[1024]; > > - target_phys_addr_t ram_bases[2], ram_sizes[2]; > > + target_phys_addr_t ram_bases[2], ram_sizes[2]; > > qemu_irq *pic; > > CPUState *env; > > target_ulong ep=0; > > Here you have added a trailing space. ok > > > @@ -40,32 +43,39 @@ void bamboo_init(ram_addr_t ram_size, in > > target_ulong dt_base=0; > > void *fdt; > > int ret; > > + int ram_stick_sizes[] = {256, 128, 64, 32, 16, 8 }; /* in Mega bytes */ > > + ram_addr_t tmp_ram_size; > > + int i=0, k=0; > > Define ram_stick_sizes[] in MB and then remove all the shifting inside > the loops. You must mean define them in bytes. That can be done also. > > > uint32_t cpu_freq; > > uint32_t timebase_freq; > > > > printf("%s: START\n", __func__); > > > > - /* Setup Memory */ > > - if (ram_size) { > > - printf("Ram size specified on command line is %i bytes\n", > > - (int)ram_size); > > - printf("WARNING: RAM is hard coded to 144MB\n"); > > - } > > - else { > > - printf("Using defualt ram size of %iMB\n", > > - ((int)ram_size/1024)/1024); > > + /* Setup Memory */ > > + printf("Ram size passed is: %i MB\n", > > + bytes_to_mb((int)ram_size)); > > + > > + tmp_ram_size = ram_size; > > + > > + for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) > > + { > > + for (k=0; k < > > (sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) > > + { > > + if ((bytes_to_mb(ram_size)/ram_stick_sizes[k]) > 0) > > + { > > Don't divide, just use a logical comparison. This can be done. Though it really doesn't matter. Both ways work. > Also, put all the open-braces on the previous lines. ok > > > + ram_sizes[i] = mb_to_bytes(ram_stick_sizes[k]); > > + tmp_ram_size -= mb_to_bytes(ram_stick_sizes[k]); > > + break; > > + } > > + } > > } > > - /* Each bank can only have memory in configurations of > > -* 16MB, 32MB, 64MB, 128MB, or 256MB > > -*/ > > - ram_bases[0] = 0x0; > > - ram_sizes[0] = 0x0800; > > - ram_bases[1] = 0x0; > > - ram_sizes[1] = 0x0100; > > - > > - printf("Ram size of domain is %d bytes\n", (int)ram_size); > > + if (tmp_ram_size) { > > + printf("WARNING: %i MB left over memory is ram\n", > > + bytes_to_mb((int)tmp_ram_size)); > > + ram_size -= tmp_ram_size; > > + } > > > > /* Setup CPU */ > > env = cpu_ppc_init("440"); > > Remove tmp_ram_size completely. Just decrement ram_size in the loop > and > check if it's non-zero at the end. tmp_ram_size is needed because we use ram_size later used allocate memory. > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205870472 18000 # Branch merge # Node ID ba2876c3e8916ba9c19b75c4464cbb8dc6858fbd # Parent 25515e6983ba1e070cbdcb7be1527426a097048b Add PPC 440EP bamboo board device tree source & binary into qemu This patch places the bamboo device tree for the PPC 440EP bamboo board into the pc-bios directory of the qemu source. This also adds a rule into the pc-bios/Makefile to build device tree files. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile b/qemu/Makefile --- a/qemu/Makefile +++ b/qemu/Makefile @@ -195,7 +195,8 @@ endif mkdir -p "$(DESTDIR)$(datadir)" for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ video.x openbios-sparc32 pxe-ne2k_pci.bin \ - pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin; \ + pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin \ + bamboo.dtb; \ do \ $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \ done diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile --- a/qemu/pc-bios/Makefile +++ b/qemu/pc-bios/Makefile @@ -12,6 +12,9 @@ all: $(TARGETS) %.o: %.S $(CC) $(DEFINES) -c -o $@ $< +%.dtb: %.dts + dtc -O dtb -I dts -o $@ $< + clean: - rm -f $(TARGETS) *.o *~ + rm -f $(TARGETS) *.o *~ *.dtb diff --git a/qemu/pc-bios/bamboo.dtb b/qemu/pc-bios/bamboo.dtb new file mode 100644 index ..e02fa8e0bf23b992b04fe87dfce37d4cc08777a6 GIT binary patch literal 2663 zc$~FXOKa6Y6h7&LdnW9X_Yk([EMAIL PROTECTED]>9}pJL zM>[EMAIL PROTECTED]>>Jv&[EMAIL PROTECTED]|3x*(9n1CQu([EMAIL PROTECTED] zRX%1N(`%;=)p>7N2oe=G;`xsF{YL$2@)[EMAIL PROTECTED];&zso~hZ)`=%c3Sb{ zGRd!&dm8)FuQsFnw%^3Gg>;*ZAFm(FdWl!W zX`z~lhq6m-EZbqVj*GYs%OgsEL&[EMAIL PROTECTED] z6>iC1owbfQH|94E#lF>s z9D(`X9q4d[EMAIL PROTECTED]>!v4CS--Kln8N zhED_YVIHCSp656NR+eNX?8UdcE>wDU8Eg?++&A-zU#2ezDrgrFDjcT-#^>kY{Ot!Z z^K)B%-)m3K`7cnu6LZ9}A{NIwWv&~;T[EMAIL PROTECTED])yN=Ivkru3)MA?+o z1Hicyw`&[EMAIL PROTECTED](ocgdU8AO?UeJr+<`3v52$S`X{M0}h7a^>O} hww)+RiJO_zG!pI5 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +/ { + #address-cells = <2>; + #size-cells = <1>; + model = "amcc,bamboo"; + compatible = "amcc,bamboo"; + dcr-parent = <&/cpus/[EMAIL PROTECTED]>; + + aliases { + serial0 = &UART0; + serial1 = &UART1; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + [EMAIL PROTECTED] { + device_type = "cpu"; + model = "PowerPC,440EP"; + reg = <0>; + clock-frequency = <1fca0550>; + timebase-frequency = <017d7840>; + i-cache-line-size = <20>; + d-cache-line-size = <20>; + i-cache-size = <8000>; + d-cache-size = <8000>; + dcr-controller; + dcr-access-method = "native"; + }; + }; + + memory { + device_type = "memory"; + reg = <0 0 900>; + }; + + UIC0: interrupt-controller0 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <0>; + dcr-reg = <0c0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + }; +/* + UIC1: interrupt-controller1 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <1>; + dcr-reg = <0d0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + interrupts = <1e 4 1f 4>; + interrupt-parent = <&UIC0>; + }; +*/ + + SDR0: sdr { + compatible = "ibm,sdr-440ep"; + dcr-reg = <00e 002>; + }; + + CPR0: cpr { + compatible = "ibm,cpr-440ep"; + dcr-reg = <00c 002>; + }; + + plb { + compatible = "ibm,plb-440ep", "ibm,plb-440gp", "ibm,plb4"; +
[kvm-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205870472 18000 # Branch merge # Node ID ac0fc9dfd78d2eddd083326e9b635a9286fc3b19 # Parent 3e87db599895937824b9bf3369eb67ea7f5a7595 Modify PPC bamboo & ppc440 board models This patch renames pp440_init to ppc440ep_init, as ppc440 is the name of the core and ppc440ep is the name of the SOC. When we init we are initializing the SOC. Also in this patch we now call cpu_ppc_init for bamboo with string 440 .. as 440 is the core. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -10,7 +10,7 @@ #include "ppc440.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -20,7 +20,7 @@ #include "exec-all.h" #include "boards.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -68,8 +68,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("Ram size of domain is %d bytes\n", (int)ram_size); /* Setup CPU */ - /* XXX We cheat for now and use 405 */ - env = cpu_ppc_init("405"); + env = cpu_ppc_init("440"); if (!env) { fprintf(stderr, "Unable to initilize CPU!\n"); exit(1); @@ -77,7 +76,7 @@ void bamboo_init(ram_addr_t ram_size, in /* call init */ printf("Calling function ppc440_init\n"); - ppc440_init(env, ram_bases, ram_sizes, &pic,1); + ppc440ep_init(env, ram_bases, ram_sizes, &pic,1); printf("Done calling ppc440_init\n"); /* Register mem */ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 0 of 7] [v3] PowerPC kvm-userspace patches
This set address issues disscussed by Hollis & Anthony on the second go around. As well as some minor fixes. This set of patches enables the following: -Device tree Support - Add libfdt to kvm-userspace - Add bamboo device tree to qemu source - Detection of host Device Tree attributes - Device tree loading - Ability to specify initrd on the command line - Ability to add kernel arguments on the command line - Ability to load compressed uImages - Ability to specify memory on the command line Signed-off-by: Jerone Young <[EMAIL PROTECTED]> - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 2 of 7] Add libfdt support to qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205870472 18000 # Branch merge # Node ID aa10b5ca2f11cd571ae8a06c1e92425b7f7407ca # Parent 499d36637c8b4fcc0cd0008186d7974bb28369ab Add libfdt support to qemu This patch adds needed configuration options to compile in libfdt support into qemu. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -555,6 +555,11 @@ ifdef CONFIG_VNC_TLS ifdef CONFIG_VNC_TLS CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS) LIBS += $(CONFIG_VNC_TLS_LIBS) +endif + +ifdef CONFIG_LIBFDT +LIBS += -lfdt +DEPLIBS += libfdt.a endif # SCSI layer diff --git a/qemu/configure b/qemu/configure --- a/qemu/configure +++ b/qemu/configure @@ -112,6 +112,7 @@ uname_release="" uname_release="" curses="yes" cpu_emulation="yes" +device_tree_support="" # OS specific targetos=`uname -s` @@ -345,6 +346,8 @@ for opt do ;; --disable-cpu-emulation) cpu_emulation="no" ;; + --disable-libfdt) device_tree_support="no" + ;; *) echo "ERROR: unknown option $opt"; exit 1 ;; esac @@ -449,6 +452,7 @@ echo " --enable-uname-release=R Return echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-cpu-emulation disables use of qemu cpu emulation code" +echo " --disable-libfdt disables use of libfdt support for device tree" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -732,6 +736,31 @@ else binsuffix="/bin" fi +## +# libfdt probe +# +if test -z "$device_tree_support" -a \ + "$cpu" = "powerpc"; then + device_tree_support="no" + cat > $TMPC << EOF +#include +/* XXX uncomment later when libfdt is built before this test */ +//int main(void) { void *fdt; return fdt_create(fdt, 1024); } +int main (void) {return 0;} +EOF +# XXX for now do not try to link to libfdt and just check for header */ +# if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC -lfdt 2> /dev/null ; then + if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC 2> /dev/null; then + device_tree_support="yes" + else +echo +echo "Error: Could not find libfdt" +echo "Make sure to have the libfdt libs and headers installed." +echo +exit 1 + fi +fi + echo "Install prefix$prefix" echo "BIOS directory$prefix$datasuffix" echo "binary directory $prefix$binsuffix" @@ -793,6 +822,9 @@ echo "kqemu support $kqemu" echo "kqemu support $kqemu" echo "kvm support $kvm" echo "CPU emulation $cpu_emulation" +if test $cpu = "powerpc"; then +echo "libfdt support$device_tree_support" +fi echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \ echo "uname -r $uname_release" @@ -1186,6 +1218,10 @@ elif test "$target_cpu" = "ppcemb" ; the echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPCEMB 1" >> $config_h + if test "$device_tree_support" = "yes" ; then + echo "#define CONFIG_LIBFDT 1" >> $config_h + echo "CONFIG_LIBFDT=1" >> $config_mak + fi configure_kvm elif test "$target_cpu" = "ppc64" ; then echo "TARGET_ARCH=ppc64" >> $config_mak - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205870472 18000 # Branch merge # Node ID 25515e6983ba1e070cbdcb7be1527426a097048b # Parent aa10b5ca2f11cd571ae8a06c1e92425b7f7407ca Create new load_uimage() & gunzip support to uboot loader in Qemu This patch adds the ability for the load address to be caputred when loading a uImage or cuImage. It also adds a better return code as the size can be an usigned long. This is done by creating a new function prototype and calling it load_uimage. To keep compatibility with code already using the old load_uboot a wrapper function has been created so current callers will not break them. Also added is gunzip support to allow for loading of uimages with a compressed kenrel images. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/loader.c b/qemu/loader.c --- a/qemu/loader.c +++ b/qemu/loader.c @@ -26,6 +26,8 @@ #include "sysemu.h" #include "uboot_image.h" +#include + /* return the size or -1 if error */ int get_image_size(const char *filename) { @@ -263,14 +265,106 @@ static void bswap_uboot_header(uboot_ima } /* Load a U-Boot image. */ -int load_uboot(const char *filename, target_ulong *ep, int *is_linux) -{ - + +/* gunzip functionality is derived from gunzip function + * in uboot source code + */ + +#defineZALLOC_ALIGNMENT16 + +static void *zalloc(void *x, unsigned items, unsigned size) +{ + void *p; + + size *= items; + size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); + + p = malloc (size); + + return (p); +} + +static void zfree(void *x, void *addr, unsigned nb) +{ + free (addr); +} + + +#define HEAD_CRC 2 +#define EXTRA_FIELD4 +#define ORIG_NAME 8 +#define COMMENT0x10 +#define RESERVED 0xe0 + +#define DEFLATED 8 + +static int gunzip(void *dst, int dstlen, unsigned char *src, + unsigned long *lenp) +{ + z_stream s; + int r, i, flags; + + /* skip header */ + i = 10; + flags = src[3]; + if (src[2] != DEFLATED || (flags & RESERVED) != 0) { + puts ("Error: Bad gzipped data\n"); + return -1; + } + if ((flags & EXTRA_FIELD) != 0) + i = 12 + src[10] + (src[11] << 8); + if ((flags & ORIG_NAME) != 0) + while (src[i++] != 0) + ; + if ((flags & COMMENT) != 0) + while (src[i++] != 0) + ; + if ((flags & HEAD_CRC) != 0) + i += 2; + if (i >= *lenp) { + puts ("Error: gunzip out of data in header\n"); + return -1; + } + + s.zalloc = zalloc; + s.zfree = zfree; + + r = inflateInit2(&s, -MAX_WBITS); + if (r != Z_OK) { + printf ("Error: inflateInit2() returned %d\n", r); + return (-1); + } + s.next_in = src + i; + s.avail_in = *lenp - i; + s.next_out = dst; + s.avail_out = dstlen; + r = inflate(&s, Z_FINISH); + if (r != Z_OK && r != Z_STREAM_END) { + printf ("Error: inflate() returned %d\n", r); + return -1; + } + *lenp = s.next_out - (unsigned char *) dst; + inflateEnd(&s); + + return 0; +} + + +#define MAX_KERNEL_SIZE 8*1024*1024 //8MB +/* This functions can load uImage & cuImage files */ +int load_uimage(const char *filename, target_ulong *ep, + target_ulong *load_address, + target_ulong *loaded_image_size, + int *is_linux) +{ int fd; int size; +int ret; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; +uint8_t *uncompressed_data = NULL; +unsigned long tmp_loaded_image_size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -291,13 +385,14 @@ int load_uboot(const char *filename, tar goto fail; } -/* TODO: Implement compressed images. */ -if (hdr->ih_comp != IH_COMP_NONE) { -fprintf(stderr, "Unable to load compressed u-boot images\n"); +/* TODO bzip2 support */ +if (hdr->ih_comp == IH_COMP_BZIP2) { +fprintf(stderr, "Unable to load bzip2 compressed u-boot images\n"); goto fail; } /* TODO: Check CPU type. */ + if (is_linux) { if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX) *is_linux = 1; @@ -306,6 +401,7 @@ int load_uboot(const char *filename, tar } *ep = hdr->ih_ep; + data = qemu_malloc(hdr->ih_size); if (!data) goto fail; @@ -315,9 +411,36 @@ int load_uboot(const char *filename, tar goto fail; } -cpu_physical_memory_write_rom(hdr-&g
[kvm-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205870472 18000 # Branch merge # Node ID 3e87db599895937824b9bf3369eb67ea7f5a7595 # Parent ba2876c3e8916ba9c19b75c4464cbb8dc6858fbd Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model This patch adds code to dynamically manipulate the device tree when loaded into memory. This allows us to finally have the ability to manipulate the kernel command line & initrd from the qemu command line. This will also let us setup different settings for the board. This patch also now uses new uboot loader load_image() to load kernel image. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile.target b/qemu/Makefile.target --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o -OBJS+= ppc440.o ppc440_bamboo.o +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o endif ifeq ($(TARGET_BASE_ARCH), mips) OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c new file mode 100644 --- /dev/null +++ b/qemu/hw/device_tree.c @@ -0,0 +1,181 @@ +/* + * Functions to help device tree manipulation using libfdt. + * It also provides functions to read entries from device tree proc + * interface. + * + * Copyright 2008 IBM Corporation. + * Authors: Jerone Young <[EMAIL PROTECTED]> + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "ppc440.h" + +#ifdef CONFIG_LIBFDT + #include "libfdt.h" +#endif + +#define DT_PROC_INTERFACE_PATH "/proc/device-tree" + +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */ + +/* This function reads device-tree property files that are of + * a single cell size + */ +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree) +{ + char *buf = NULL; + int i; + uint32_t num; + FILE *stream; + + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + buf = (char *)malloc(i); + if (buf == NULL) + { + printf("%s: Unable to malloc string buffer buf\n", + __func__); + exit(1); + } + + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH, + path_in_device_tree); + + stream = fopen(buf, "rb"); + + if (stream == NULL) + { + printf("%s: Unable to open '%s'\n", __func__, buf); + exit(1); + } + + fread(&num, sizeof(num), 1, stream); + fclose(stream); + + return num; +} + +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */ + +#ifdef CONFIG_LIBFDT +/* support functions */ +static int get_offset_of_node(void *fdt, char *node_path) +{ + int node_offset; + node_offset = fdt_path_offset(fdt, node_path); + if (node_offset < 0) { + printf("Unable to find node in device tree '%s'\n", + node_path); + exit(1); + } + return node_offset; +} + +/* public functions */ +void *load_device_tree(char *filename_path, unsigned long load_addr) +{ + int dt_file_size; + int dt_file_load_size; + int new_dt_size;int ret; + void *dt_file = NULL; + void *fdt; + + dt_file_size = get_image_size(filename_path); + if (dt_file_size < 0) { + printf("Unable to get size of device tree file"); + goto fail; + } + + /* First allocate space in qemu for device tree */ + dt_file = qemu_malloc(dt_file_size); + if (dt_file == NULL) { + printf("Unable to allocate memory in qemu for device tree\n"); + goto fail; + } + memset(dt_file, 0, dt_file_size); + + dt_file_load_size = load_image(filename_path, dt_file); + + + /* XXX Second we place new copy of 2x size in guest memory +* This give us enough room for manipulation. +*/ + new_dt_size = dt_file_size * 2; + + fdt = (void *)load_addr; + + ret = fdt_open_into(dt_file, fdt, new_dt_size); + if (ret) { + printf("Unable to copy device tree in memory\n"); + goto fail; + } + + /* Check sanity of device tree */ + if (fdt_check_header(fdt)) { + printf ("Device tree file loaded into memory is invalid: %s\n", + filename_path); + goto fail; + } + /* free qemu memory with old device
[kvm-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205870472 18000 # Branch merge # Node ID 4f90f7d25186f55bfb1503764af5264201df067f # Parent ac0fc9dfd78d2eddd083326e9b635a9286fc3b19 Add ability to specify ram on command line for bamboo board model This patch adds the ability to now specify ram sizes on the command line. Due to the nature of the code there are restictions on exactly how much ram and the multiple that the size must match. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -15,6 +15,9 @@ #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" +#define bytes_to_mb(a) (a>>20) +#define mb_to_bytes(a) (a<<20) + /* PPC 440 refrence demo board * * 440 PowerPC CPU @@ -28,7 +31,7 @@ void bamboo_init(ram_addr_t ram_size, in const char *cpu_model) { char buf[1024]; - target_phys_addr_t ram_bases[2], ram_sizes[2]; + target_phys_addr_t ram_bases[2], ram_sizes[2]; qemu_irq *pic; CPUState *env; target_ulong ep=0; @@ -40,32 +43,39 @@ void bamboo_init(ram_addr_t ram_size, in target_ulong dt_base=0; void *fdt; int ret; + int ram_stick_sizes[] = {256, 128, 64, 32, 16, 8 }; /* in Mega bytes */ + ram_addr_t tmp_ram_size; + int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; printf("%s: START\n", __func__); - /* Setup Memory */ - if (ram_size) { - printf("Ram size specified on command line is %i bytes\n", - (int)ram_size); - printf("WARNING: RAM is hard coded to 144MB\n"); - } - else { - printf("Using defualt ram size of %iMB\n", - ((int)ram_size/1024)/1024); + /* Setup Memory */ + printf("Ram size passed is: %i MB\n", + bytes_to_mb((int)ram_size)); + + tmp_ram_size = ram_size; + + for (i=0; i < (sizeof(ram_sizes)/sizeof(ram_sizes[0])); i++) + { + for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(ram_stick_sizes[0])); k++) + { + if ((bytes_to_mb(ram_size)/ram_stick_sizes[k]) > 0) + { + ram_sizes[i] = mb_to_bytes(ram_stick_sizes[k]); + tmp_ram_size -= mb_to_bytes(ram_stick_sizes[k]); + break; + } + } } - /* Each bank can only have memory in configurations of -* 16MB, 32MB, 64MB, 128MB, or 256MB -*/ - ram_bases[0] = 0x0; - ram_sizes[0] = 0x0800; - ram_bases[1] = 0x0; - ram_sizes[1] = 0x0100; - - printf("Ram size of domain is %d bytes\n", (int)ram_size); + if (tmp_ram_size) { + printf("WARNING: %i MB left over memory is ram\n", + bytes_to_mb((int)tmp_ram_size)); + ram_size -= tmp_ram_size; + } /* Setup CPU */ env = cpu_ppc_init("440"); - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
On Fri, 2008-03-14 at 14:16 -0500, Hollis Blanchard wrote: > On Fri, 2008-03-14 at 12:09 -0500, Jerone Young wrote: > > # HG changeset patch > > # User Jerone Young <[EMAIL PROTECTED]> > > # Date 1205514174 18000 > > # Branch merge > > # Node ID 3060b75a9597d4ab67c23871df41fc5e5476df2b > > # Parent 63237bde74818a5dc3cdb1baee781dab101290ce > > Add ability to specify ram on command line for bamboo board model > > > > This patch adds the ability to now specify ram sizes on the command line. > > Due to the nature of the code there are restictions on exactly how > > much ram and the multiple that the size must match. > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c > > --- a/qemu/hw/ppc440_bamboo.c > > +++ b/qemu/hw/ppc440_bamboo.c > > @@ -40,32 +40,50 @@ void bamboo_init(ram_addr_t ram_size, in > > target_ulong dt_base=0; > > void *fdt; > > int ret; > > + unsigned long ram_sticks[] = {0, 0}; /* Value will be in bytes */ > > + ram_addr_t tmp_ram_size; > > + int ram_stick_sizes[] = {256, 128, 64, 32, 16, 8 }; /* in Mega bytes */ > > + int i=0, k=0; > > > > uint32_t cpu_freq; > > uint32_t timebase_freq; > > > > printf("%s: START\n", __func__); > > > > - /* Setup Memory */ > > - if (ram_size) { > > - printf("Ram size specified on command line is %i bytes\n", > > - (int)ram_size); > > - printf("WARNING: RAM is hard coded to 144MB\n"); > > - } > > - else { > > - printf("Using defualt ram size of %iMB\n", > > - ((int)ram_size/1024)/1024); > > + /* Setup Memory */ > > + printf("Ram size passed is: %i MB\n", > > + ((int)ram_size/1024)/1024); > > + > > + tmp_ram_size = ram_size; > > + > > + for (i=0; i < (sizeof(ram_sticks)/sizeof(unsigned long)); i++) > > + { > > + for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) > > + { > > + if tmp_ram_size/1024)/1024)/ram_stick_sizes[k]) > 0) > > + { > > + ram_sticks[i] = ram_stick_sizes[k]*1024*1024; > > + tmp_ram_size -= ram_stick_sizes[k]*1024*1024; > > + break; > > + } > > + } > > + > > } > > Please match the curly brace syntax used everywhere else. > > Also, I don't think it makes any sense to multiply and divide by > 1024*1024 everywhere; just use the proper units to begin with. Try N<<20 > to represent N MB. > > "tmp_ram_size" is also unnecessary; just subtract from "ram_size" and > see if it's non-zero at the end. > > > - /* Each bank can only have memory in configurations of > > -* 16MB, 32MB, 64MB, 128MB, or 256MB > > -*/ > > - ram_bases[0] = 0x0; > > - ram_sizes[0] = 0x0800; > > - ram_bases[1] = 0x0; > > - ram_sizes[1] = 0x0100; > > + if (tmp_ram_size) > > + printf("WARNING: %i left over memory is ram\n", > > + (tmp_ram_size/1024)/1024); > > > > - printf("Ram size of domain is %d bytes\n", (int)ram_size); > > + /* Each bank can only have memory in configurations of > > +* 4MB, 8MB, 16MB, 32MB, 64MB, 128MB, or 256MB > > +* why? see sdram_bcr() > > +* > > +* Max of 512MB > > +*/ > > + ram_bases[0] = 0x0; > > + ram_sizes[0] = ram_sticks[0]; > > + ram_bases[1] = 0x0; > > + ram_sizes[1] = ram_sticks[1]; > > Why keep a separate ram_sticks[] array? Just operate directly on > ram_sizes[], and while you're at it stop hardcoding 2 entries: the SDRAM > controller can emulate all 4. Sure can just manipulate these directly. As for the ram_bases have been this way since day 1. If it's works don't break it :-). I'll look into the SDRAM controller doing 4 slots. > > Also, ram_bases[1] here is very wrong; that definitely needs to be > fixed. I need to see exactly what these ram_bases mean in the emulation code. This could be right, as I believe this is how it's done in other qemu code? I'll look and see. > - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [kvm-ppc-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu
On Fri, 2008-03-14 at 14:06 -0500, Hollis Blanchard wrote: > There is no zImage, so those comments do not make sense. "Filled in by > loader" would be more accurate. Currently the values there are hard coded. But I do still need to know what values are filled in by zImage, that we are currently not filling in yet. This can be changed. > > You left MAL0 and EMAC0 commented out; please remove them. I left these out. > > You left PCI0 uncommented; please comment it out until qemu actually > emulates the PCI controller. oh forgot about this. Since I have the PCI stuff in my local repo. I'll do this again. > > -- > Hollis Blanchard > IBM Linux Technology Center > > On Fri, 2008-03-14 at 12:09 -0500, Jerone Young wrote: > > # HG changeset patch > > # User Jerone Young <[EMAIL PROTECTED]> > > # Date 1205514170 18000 > > # Branch merge > > # Node ID 60d8930ecedd292053f9c5340c95704b20e10c65 > > # Parent 8b68dc88abc897e7502e2c73ca1e40eb2084104f > > Add PPC 440EP bamboo board device tree source & binary into qemu > > > > This patch places the bamboo device tree for the PPC 440EP bamboo board > > into the pc-bios directory of the qemu source. This also adds a rule into > > the pc-bios/Makefile to build device tree files. > > > > Signed-off-by: Jerone Young <[EMAIL PROTECTED]> > > > > diff --git a/qemu/Makefile b/qemu/Makefile > > --- a/qemu/Makefile > > +++ b/qemu/Makefile > > @@ -195,7 +195,8 @@ endif > > mkdir -p "$(DESTDIR)$(datadir)" > > for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ > > video.x openbios-sparc32 pxe-ne2k_pci.bin \ > > - pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin; \ > > + pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin \ > > + bamboo.dtb; \ > > do \ > > $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x > > "$(DESTDIR)$(datadir)"; \ > > done > > diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile > > --- a/qemu/pc-bios/Makefile > > +++ b/qemu/pc-bios/Makefile > > @@ -12,6 +12,9 @@ all: $(TARGETS) > > %.o: %.S > > $(CC) $(DEFINES) -c -o $@ $< > > > > +%.dtb: %.dts > > + dtc -O dtb -I dts -o $@ $< > > + > > clean: > > - rm -f $(TARGETS) *.o *~ > > + rm -f $(TARGETS) *.o *~ *.dtb > > > > diff --git a/qemu/pc-bios/bamboo.dtb b/qemu/pc-bios/bamboo.dtb > > new file mode 100644 > > index > > ..c7b964a26657d9cc5f7d3c6d0d9873bdfa44b9e0 > > GIT binary patch > > literal 3175 > > zc$~FXPm3Kz5U+XJup8Ozt|DSg#J8*x4{z8>e4Fe^AByb7!$O3dMEmvh&KolS?3uUj > > zE(j}LbMXs^;6?BYc#n~S5;m0tLo`L4=+D` > > z46qsjz%IaZKjZgJ?9XH0c>4IqGXU>fl;4NN=9%vW>`P`mAb8!_D7=dODoZ&ZO<6k4 > > zb0G4~9=V!7GV?u_#H > zcrh<~a`B*>3mDr;(6!w|nZ;`=&;9%}A@|=KjmN?J`(4{RPMo{1{d#eq;[EMAIL PROTECTED] > > z_94Od9sD)GDfRa~!K(dW#>?1$$ygO1icb7TCeMMbMJm!<9yc~>-ku{{C3(OlQpY%} > > [EMAIL PROTECTED]&SOz8O!`(LClp) > zw+`L^@)6Cq45hVQv;0tI_$|a > zzp3Gn=<[EMAIL PROTECTED]|e|)Q)czotS^)iPX;ac(Z|Pi>[EMAIL PROTECTED] > > z)xU22pp5u2C~A;f3wOU-JT$dv+NtTz*m6^xmW`jLel~`f@&%qKBRma?8sygR1!vvP > > zSw|h4a=Qrap7nZ;zh>XoI+`17X621rJ39fD-8uV2hgxYlcsGr#&HuXx1bc6T_Y=h* > > zkQ^*eFmo4pj{h^yr5>J3|ID*p+h_6gD9`vNuSwqS+$H*)N8Q5O$DOmxpr}C(f0Zu0 > > zcn+UIFQ482gU`yp;j>Knh?H^vB#q;mRcKf#d-dP$DV47;f&<3eyXLy([EMAIL PROTECTED] > > z!|}4h-LsQpbROvD)&zBQz3E=Ed&}K>[EMAIL PROTECTED] > > z)[EMAIL PROTECTED]|w72>TDVq$KN>LA+(Py+kUqLui(~wf4U}0 > > zhjQ;rL!Guk?O!Q2`gB)o-OGKtS8Cm`Pj{u(k-K!3mm+KUpx*oHoHw4GdufY>p%i85 > > zbCDz^Y?bkeFyk~2MFKoe3w--b69FNYe!-;3DyY2%=6eG|aTs&)adlh>kRk$} > zAjPM1k?~`w;#5rWAxcEC&l#TyKZ!HptFRC*NUTjqT?6FOzLYd%oU24qQO)uY(8>I0 > > zRLocwBK5xK6{s|EzlGvR&sV&[EMAIL PROTECTED]@VJxdTOSCzkOH~fPEQAP25L2Z> > > f#wo+spSs3fM}Eo*?B%_#$nY+!FrO > > > diff --git a/qemu/pc-bios/bamboo.dts b/qemu/pc-bios/bamboo.dts > > new file mode 100644 > > --- /dev/null > > +++ b/qemu/pc-bios/bamboo.dts > > @@ -0,0 +1,301 @@ > > +/* > > + * Device Tree Source for AMCC Bamboo > > + * > > + * Copyright (c) 2006, 2007 IBM Corp. > > + * Josh Boyer <[EMAIL PROTECTED]> > > + * > > + * This file is licensed under the terms of the GNU General Public > > + * License version 2. This program is licensed "as is" without > > + * any warranty of any kind, whether express or implied. > > + */ > > + > > +/ { > > + #add
[kvm-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205514174 18000 # Branch merge # Node ID 3060b75a9597d4ab67c23871df41fc5e5476df2b # Parent 63237bde74818a5dc3cdb1baee781dab101290ce Add ability to specify ram on command line for bamboo board model This patch adds the ability to now specify ram sizes on the command line. Due to the nature of the code there are restictions on exactly how much ram and the multiple that the size must match. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -40,32 +40,50 @@ void bamboo_init(ram_addr_t ram_size, in target_ulong dt_base=0; void *fdt; int ret; + unsigned long ram_sticks[] = {0, 0}; /* Value will be in bytes */ + ram_addr_t tmp_ram_size; + int ram_stick_sizes[] = {256, 128, 64, 32, 16, 8 }; /* in Mega bytes */ + int i=0, k=0; uint32_t cpu_freq; uint32_t timebase_freq; printf("%s: START\n", __func__); - /* Setup Memory */ - if (ram_size) { - printf("Ram size specified on command line is %i bytes\n", - (int)ram_size); - printf("WARNING: RAM is hard coded to 144MB\n"); - } - else { - printf("Using defualt ram size of %iMB\n", - ((int)ram_size/1024)/1024); + /* Setup Memory */ + printf("Ram size passed is: %i MB\n", + ((int)ram_size/1024)/1024); + + tmp_ram_size = ram_size; + + for (i=0; i < (sizeof(ram_sticks)/sizeof(unsigned long)); i++) + { + for (k=0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) + { + if tmp_ram_size/1024)/1024)/ram_stick_sizes[k]) > 0) + { + ram_sticks[i] = ram_stick_sizes[k]*1024*1024; + tmp_ram_size -= ram_stick_sizes[k]*1024*1024; + break; + } + } + } - /* Each bank can only have memory in configurations of -* 16MB, 32MB, 64MB, 128MB, or 256MB -*/ - ram_bases[0] = 0x0; - ram_sizes[0] = 0x0800; - ram_bases[1] = 0x0; - ram_sizes[1] = 0x0100; + if (tmp_ram_size) + printf("WARNING: %i left over memory is ram\n", + (tmp_ram_size/1024)/1024); - printf("Ram size of domain is %d bytes\n", (int)ram_size); + /* Each bank can only have memory in configurations of +* 4MB, 8MB, 16MB, 32MB, 64MB, 128MB, or 256MB +* why? see sdram_bcr() +* +* Max of 512MB +*/ + ram_bases[0] = 0x0; + ram_sizes[0] = ram_sticks[0]; + ram_bases[1] = 0x0; + ram_sizes[1] = ram_sticks[1]; /* Setup CPU */ env = cpu_ppc_init("440"); - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205514170 18000 # Branch merge # Node ID 60d8930ecedd292053f9c5340c95704b20e10c65 # Parent 8b68dc88abc897e7502e2c73ca1e40eb2084104f Add PPC 440EP bamboo board device tree source & binary into qemu This patch places the bamboo device tree for the PPC 440EP bamboo board into the pc-bios directory of the qemu source. This also adds a rule into the pc-bios/Makefile to build device tree files. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/Makefile b/qemu/Makefile --- a/qemu/Makefile +++ b/qemu/Makefile @@ -195,7 +195,8 @@ endif mkdir -p "$(DESTDIR)$(datadir)" for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ video.x openbios-sparc32 pxe-ne2k_pci.bin \ - pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin; \ + pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin extboot.bin \ + bamboo.dtb; \ do \ $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \ done diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile --- a/qemu/pc-bios/Makefile +++ b/qemu/pc-bios/Makefile @@ -12,6 +12,9 @@ all: $(TARGETS) %.o: %.S $(CC) $(DEFINES) -c -o $@ $< +%.dtb: %.dts + dtc -O dtb -I dts -o $@ $< + clean: - rm -f $(TARGETS) *.o *~ + rm -f $(TARGETS) *.o *~ *.dtb diff --git a/qemu/pc-bios/bamboo.dtb b/qemu/pc-bios/bamboo.dtb new file mode 100644 index ..c7b964a26657d9cc5f7d3c6d0d9873bdfa44b9e0 GIT binary patch literal 3175 zc$~FXPm3Kz5U+XJup8Ozt|DSg#J8*x4{z8>e4Fe^AByb7!$O3dMEmvh&KolS?3uUj zE(j}LbMXs^;6?BYc#n~S5;m0tLo`L4=+D` z46qsjz%IaZKjZgJ?9XH0c>4IqGXU>fl;4NN=9%vW>`P`mAb8!_D7=dODoZ&ZO<6k4 zb0G4~9=V!7GV?u_#H3mDr;(6!w|nZ;`=&;9%}A@|=KjmN?J`(4{RPMo{1{d#eq;[EMAIL PROTECTED] z_94Od9sD)GDfRa~!K(dW#>?1$$ygO1icb7TCeMMbMJm!<9yc~>-ku{{C3(OlQpY%} [EMAIL PROTECTED]&SOz8O!`(LClp)[EMAIL PROTECTED] z)xU22pp5u2C~A;f3wOU-JT$dv+NtTz*m6^xmW`jLel~`f@&%qKBRma?8sygR1!vvP zSw|h4a=Qrap7nZ;zh>XoI+`17X621rJ39fD-8uV2hgxYlcsGr#&HuXx1bc6T_Y=h* zkQ^*eFmo4pj{h^yr5>J3|ID*p+h_6gD9`vNuSwqS+$H*)N8Q5O$DOmxpr}C(f0Zu0 zcn+UIFQ482gU`yp;j>Knh?H^vB#q;mRcKf#d-dP$DV47;f&<3eyXLy([EMAIL PROTECTED] z!|}4h-LsQpbROvD)&zBQz3E=Ed&}K>[EMAIL PROTECTED] z)[EMAIL PROTECTED]|w72>TDVq$KN>LA+(Py+kUqLui(~wf4U}0 zhjQ;rL!Guk?O!Q2`gB)o-OGKtS8Cm`Pj{u(k-K!3mm+KUpx*oHoHw4GdufY>p%i85 zbCDz^Y?bkeFyk~2MFKoe3w--b69FNYe!-;3DyY2%=6eG|aTs&)adlh>kRk$}I0 zRLocwBK5xK6{s|EzlGvR&sV&[EMAIL PROTECTED]@VJxdTOSCzkOH~fPEQAP25L2Z> f#wo+spSs3fM}Eo*?B%_#$nY+!FrO + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +/ { + #address-cells = <2>; + #size-cells = <1>; + model = "amcc,bamboo"; + compatible = "amcc,bamboo"; + dcr-parent = <&/cpus/[EMAIL PROTECTED]>; + + aliases { + serial0 = &UART0; + serial1 = &UART1; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + [EMAIL PROTECTED] { + device_type = "cpu"; + model = "PowerPC,440EP"; + reg = <0>; + clock-frequency = <1fca0550>; + timebase-frequency = <017d7840>; + i-cache-line-size = <20>; + d-cache-line-size = <20>; + i-cache-size = <8000>; + d-cache-size = <8000>; + dcr-controller; + dcr-access-method = "native"; + }; + }; + + memory { + device_type = "memory"; + reg = <0 0 900>; + }; + + UIC0: interrupt-controller0 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <0>; + dcr-reg = <0c0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + }; +/* + UIC1: interrupt-controller1 { + compatible = "ibm,uic-440ep","ibm,uic"; + interrupt-controller; + cell-index = <1>; + dcr-reg = <0d0 009>; + #address-cells = <0>; + #size-cells = <0>; + #interrupt-cells = <2>; + interrupts = <1e 4 1f 4>; +
[kvm-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205514173 18000 # Branch merge # Node ID 63237bde74818a5dc3cdb1baee781dab101290ce # Parent 9dd933f712ce2983997be94bae401572d5bba8f2 Modify PPC bamboo & ppc440 board models This patch renames pp440_init to ppc440ep_init, as ppc440 is the name of the core and ppc440ep is the name of the SOC. When we init we are initializing the SOC. Also in this patch we now call cpu_ppc_init for bamboo with string 440 .. as 440 is the core. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -10,7 +10,7 @@ #include "ppc440.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -20,7 +20,7 @@ #include "exec-all.h" #include "boards.h" -void ppc440_init(CPUState *env, +void ppc440ep_init(CPUState *env, target_phys_addr_t ram_bases[2], target_phys_addr_t ram_sizes[2], qemu_irq **picp, diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c --- a/qemu/hw/ppc440_bamboo.c +++ b/qemu/hw/ppc440_bamboo.c @@ -68,8 +68,7 @@ void bamboo_init(ram_addr_t ram_size, in printf("Ram size of domain is %d bytes\n", (int)ram_size); /* Setup CPU */ - /* XXX We cheat for now and use 405 */ - env = cpu_ppc_init("405"); + env = cpu_ppc_init("440"); if (!env) { fprintf(stderr, "Unable to initilize CPU!\n"); exit(1); @@ -77,7 +76,7 @@ void bamboo_init(ram_addr_t ram_size, in /* call init */ printf("Calling function ppc440_init\n"); - ppc440_init(env, ram_bases, ram_sizes, &pic,1); + ppc440ep_init(env, ram_bases, ram_sizes, &pic,1); printf("Done calling ppc440_init\n"); /* Register mem */ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 3 of 7] Create new load_uboot() & gunzip support to uboot loader in Qemu
# HG changeset patch # User Jerone Young <[EMAIL PROTECTED]> # Date 1205507804 18000 # Branch merge # Node ID 8b68dc88abc897e7502e2c73ca1e40eb2084104f # Parent d96091321011ee86681f00bbaf72337ebc937791 Create new load_uboot() & gunzip support to uboot loader in Qemu This patch adds the ability for the load address to be caputred when loading a uImage or cuImage. It also adds a better return code as the size can be an usigned long. This is done by creating a new function prototype and calling it load_uboot_l . To keep compatibility with code already using the old load_uboot a wrapper function has been created so current callers will not break them. Also added is gunzip support to allow for loading of uimages with a compressed kenrel imagexs. Signed-off-by: Jerone Young <[EMAIL PROTECTED]> diff --git a/qemu/loader.c b/qemu/loader.c --- a/qemu/loader.c +++ b/qemu/loader.c @@ -26,6 +26,8 @@ #include "sysemu.h" #include "uboot_image.h" +#include + /* return the size or -1 if error */ int get_image_size(const char *filename) { @@ -263,14 +265,106 @@ static void bswap_uboot_header(uboot_ima } /* Load a U-Boot image. */ -int load_uboot(const char *filename, target_ulong *ep, int *is_linux) -{ - + +/* gunzip functionality is derived from gunzip function + * in uboot source code + */ + +#defineZALLOC_ALIGNMENT16 + +static void *zalloc(void *x, unsigned items, unsigned size) +{ + void *p; + + size *= items; + size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); + + p = malloc (size); + + return (p); +} + +static void zfree(void *x, void *addr, unsigned nb) +{ + free (addr); +} + + +#define HEAD_CRC 2 +#define EXTRA_FIELD4 +#define ORIG_NAME 8 +#define COMMENT0x10 +#define RESERVED 0xe0 + +#define DEFLATED 8 + +static int gunzip(void *dst, int dstlen, unsigned char *src, + unsigned long *lenp) +{ + z_stream s; + int r, i, flags; + + /* skip header */ + i = 10; + flags = src[3]; + if (src[2] != DEFLATED || (flags & RESERVED) != 0) { + puts ("Error: Bad gzipped data\n"); + return -1; + } + if ((flags & EXTRA_FIELD) != 0) + i = 12 + src[10] + (src[11] << 8); + if ((flags & ORIG_NAME) != 0) + while (src[i++] != 0) + ; + if ((flags & COMMENT) != 0) + while (src[i++] != 0) + ; + if ((flags & HEAD_CRC) != 0) + i += 2; + if (i >= *lenp) { + puts ("Error: gunzip out of data in header\n"); + return -1; + } + + s.zalloc = zalloc; + s.zfree = zfree; + + r = inflateInit2(&s, -MAX_WBITS); + if (r != Z_OK) { + printf ("Error: inflateInit2() returned %d\n", r); + return (-1); + } + s.next_in = src + i; + s.avail_in = *lenp - i; + s.next_out = dst; + s.avail_out = dstlen; + r = inflate(&s, Z_FINISH); + if (r != Z_OK && r != Z_STREAM_END) { + printf ("Error: inflate() returned %d\n", r); + return -1; + } + *lenp = s.next_out - (unsigned char *) dst; + inflateEnd(&s); + + return 0; +} + + +#define MAX_KERNEL_SIZE 8*1024*1024 //8MB +/* This functions can load uImage & cuImage files */ +int load_uimage(const char *filename, target_ulong *ep, + target_ulong *load_address, + target_ulong *loaded_image_size, + int *is_linux) +{ int fd; int size; +int ret; uboot_image_header_t h; uboot_image_header_t *hdr = &h; uint8_t *data = NULL; +uint8_t *uncompressed_data = NULL; +unsigned long tmp_loaded_image_size; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -291,13 +385,14 @@ int load_uboot(const char *filename, tar goto fail; } -/* TODO: Implement compressed images. */ -if (hdr->ih_comp != IH_COMP_NONE) { -fprintf(stderr, "Unable to load compressed u-boot images\n"); +/* TODO bzip2 support */ +if (hdr->ih_comp == IH_COMP_BZIP2) { +fprintf(stderr, "Unable to load bzip2 compressed u-boot images\n"); goto fail; } /* TODO: Check CPU type. */ + if (is_linux) { if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX) *is_linux = 1; @@ -306,6 +401,7 @@ int load_uboot(const char *filename, tar } *ep = hdr->ih_ep; + data = qemu_malloc(hdr->ih_size); if (!data) goto fail; @@ -315,9 +411,36 @@ int load_uboot(const char *filename, tar goto fail; } -cpu_physical_memory_write_rom(hdr-&g