Re: [Qemu-devel] [PATCH 3/3] Add KVM support to QEMU
Hollis Blanchard wrote: Just a quick skim... On Tue, Oct 28, 2008 at 3:13 PM, Anthony Liguori <[EMAIL PROTECTED]> wrote: +int kvm_cpu_exec(CPUState *env) +{ +struct kvm_run *run = env->kvm_run; +int ret; + +dprintf("kvm_cpu_exec()\n"); + +do { +kvm_arch_pre_run(env, run); + +if ((env->interrupt_request & CPU_INTERRUPT_EXIT)) { +dprintf("interrupt exit requested\n"); +ret = 0; +break; +} + +dprintf("setting tpr\n"); +run->cr8 = cpu_get_apic_tpr(env); This belongs in the arch_pre_run hook above. Good catch, I've updated the patch. How did you decide which exit handlers should go into architecture-specific code? Looking at just the KVM architecture set: Based on whether the implementation required target-specific code. IO: x86 and ia64, not PowerPC or s390 cpu_{in,out}[bwl] are defined in vl.c and are available for all architectures. They are no-ops on most architectures because they are never used. MMIO: everybody except s390 cpu_physical_memory_rw() is defined by everyone. DCRs: PowerPC only This will have to be an architecture specific handler. IRQ window: not sure It's a no-op implementation. I would think that this would be needed on PPC. If you want to inject an interrupt, but the guest is unable to handle an interrupt, you need to exit to userspace when the guest re-enables interrupts. Otherwise, you may never return to userspace for the interrupt to be injected. How do you handle that now? Does PPC have something that makes this unnecessary? Regards, Anthony Liguori -Hollis -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [PATCH 3/3] Add KVM support to QEMU
Just a quick skim... On Tue, Oct 28, 2008 at 3:13 PM, Anthony Liguori <[EMAIL PROTECTED]> wrote: > +int kvm_cpu_exec(CPUState *env) > +{ > +struct kvm_run *run = env->kvm_run; > +int ret; > + > +dprintf("kvm_cpu_exec()\n"); > + > +do { > +kvm_arch_pre_run(env, run); > + > +if ((env->interrupt_request & CPU_INTERRUPT_EXIT)) { > +dprintf("interrupt exit requested\n"); > +ret = 0; > +break; > +} > + > +dprintf("setting tpr\n"); > +run->cr8 = cpu_get_apic_tpr(env); This belongs in the arch_pre_run hook above. > +ret = kvm_vcpu_ioctl(env, KVM_RUN, 0); > +kvm_arch_post_run(env, run); > + > +if (ret == -EINTR || ret == -EAGAIN) { > +dprintf("io window exit\n"); > +ret = 0; > +break; > +} > + > +if (ret < 0) { > +dprintf("kvm run failed %s\n", strerror(-ret)); > +abort(); > +} > + > +ret = 0; /* exit loop */ > +switch (run->exit_reason) { > +case KVM_EXIT_IO: > +dprintf("handle_io\n"); > +ret = kvm_handle_io(env, run->io.port, > +(uint8_t *)run + run->io.data_offset, > +run->io.direction, > +run->io.size, > +run->io.count); > +break; > +case KVM_EXIT_MMIO: > +dprintf("handle_mmio\n"); > +cpu_physical_memory_rw(run->mmio.phys_addr, > + run->mmio.data, > + run->mmio.len, > + run->mmio.is_write); > +ret = 1; > +break; > +case KVM_EXIT_IRQ_WINDOW_OPEN: > +dprintf("irq_window_open\n"); > +break; > +case KVM_EXIT_SHUTDOWN: > +dprintf("shutdown\n"); > +qemu_system_reset_request(); > +ret = 1; > +break; > +case KVM_EXIT_UNKNOWN: > +dprintf("kvm_exit_unknown\n"); > +break; > +case KVM_EXIT_FAIL_ENTRY: > +dprintf("kvm_exit_fail_entry\n"); > +break; > +case KVM_EXIT_EXCEPTION: > +dprintf("kvm_exit_exception\n"); > +break; > +case KVM_EXIT_DEBUG: > +dprintf("kvm_exit_debug\n"); > +break; > +default: > +dprintf("kvm_arch_handle_exit\n"); > +ret = kvm_arch_handle_exit(env, run); > +break; > +} > +} while (ret > 0); > + > +return ret; > +} How did you decide which exit handlers should go into architecture-specific code? Looking at just the KVM architecture set: IO: x86 and ia64, not PowerPC or s390 MMIO: everybody except s390 DCRs: PowerPC only IRQ window: not sure -Hollis -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [PATCH] qemu: ppc: xer access prototypes no more used & implemented
From: Christian Ehrhardt <[EMAIL PROTECTED]> Revision 5500 of the qemu repository removed all code using ppc_load_xer & ppc_store_xer as well as their implementation. Another patch fixes it's usage in kvm-userspace for powerpc, but I think that header can now be cleaned up, therefore this patch to qemu-devel. Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] cpu.h |2 -- 1 file changed, 2 deletions(-) [diff] diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h --- a/qemu/target-ppc/cpu.h +++ b/qemu/target-ppc/cpu.h @@ -725,8 +725,6 @@ #endif void do_store_sr (CPUPPCState *env, int srnum, target_ulong value); #endif /* !defined(CONFIG_USER_ONLY) */ -target_ulong ppc_load_xer (CPUPPCState *env); -void ppc_store_xer (CPUPPCState *env, target_ulong value); void ppc_store_msr (CPUPPCState *env, target_ulong value); void cpu_ppc_reset (void *opaque); -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05 of 10] [PATCH] libcflat: ppc: add timebase accessor
Provide a timebase accessor for ppc testcases. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> [diffstat] config-powerpc-44x.mak |3 ++- test/lib/powerpc/44x/timebase.S | 28 test/lib/powerpc/44x/timebase.h | 25 + 3 files changed, 55 insertions(+), 1 deletion(-) [diff] diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak --- a/user/config-powerpc-44x.mak +++ b/user/config-powerpc-44x.mak @@ -5,7 +5,8 @@ cflatobjs += \ test/lib/powerpc/44x/map.o \ - test/lib/powerpc/44x/tlbwe.o + test/lib/powerpc/44x/tlbwe.o \ + test/lib/powerpc/44x/timebase.o simpletests += \ test/powerpc/44x/tlbsx.bin \ diff --git a/user/test/lib/powerpc/44x/timebase.S b/user/test/lib/powerpc/44x/timebase.S new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/timebase.S @@ -0,0 +1,28 @@ +/* + * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + */ + +/* unsigned long long mftb(void); */ +.global mftb +mftb: + mftbu r5 + mftbl r4 + mftbu r3 + cmpwr3, r5 + bne mftb + blr diff --git a/user/test/lib/powerpc/44x/timebase.h b/user/test/lib/powerpc/44x/timebase.h new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/timebase.h @@ -0,0 +1,25 @@ +/* + * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + */ + +#ifndef __TIMEBASE_H__ +#define __TIMEBASE_H__ + +unsigned long long mftb(void); + +#endif /* __TIMEBASE_H__ */ -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04 of 10] [PATCH] user: ppc: implement PowerPC 44x libcflat
From: Hollis Blanchard <[EMAIL PROTECTED]> - Create a 44x-specific makefile. - Reorganize PowerPC makefiles to separate "simple" tests from those which link with libcflat. - Create a minimal libcflat testcase (which just exits). Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] config-powerpc-44x.mak | 14 +++ config-powerpc.mak | 46 ++ test/lib/powerpc/44x/map.c | 51 +++ test/lib/powerpc/44x/tlbwe.S | 29 test/lib/powerpc/io.c| 35 + test/powerpc/cstart.S| 38 test/powerpc/exit.c | 23 +++ 7 files changed, 221 insertions(+), 15 deletions(-) [diff] diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak new file mode 100644 --- /dev/null +++ b/user/config-powerpc-44x.mak @@ -0,0 +1,14 @@ + + +# for some reason binutils hates tlbsx unless we say we're 405 :( +CFLAGS += -Wa,-m405 -I test/lib/powerpc/44x + +cflatobjs += \ + test/lib/powerpc/44x/map.o \ + test/lib/powerpc/44x/tlbwe.o + +simpletests += \ + test/powerpc/44x/tlbsx.bin \ + test/powerpc/44x/tlbwe_16KB.bin \ + test/powerpc/44x/tlbwe_hole.bin \ + test/powerpc/44x/tlbwe.bin diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak --- a/user/config-powerpc.mak +++ b/user/config-powerpc.mak @@ -1,26 +1,42 @@ +platform := 44x + CFLAGS += -m32 CFLAGS += -D__powerpc__ CFLAGS += -I $(KERNELDIR)/include -# for some reaons binutils hates tlbsx unless we say we're 405 :( -CFLAGS += -Wa,-mregnames,-m405 +CFLAGS += -Wa,-mregnames -I test/lib -%.bin: %.o - $(OBJCOPY) -O binary $^ $@ +cstart := test/powerpc/cstart.o -testobjs := \ - io.bin \ - spin.bin \ - sprg.bin \ - 44x/tlbsx.bin \ - 44x/tlbwe_16KB.bin \ - 44x/tlbwe_hole.bin \ - 44x/tlbwe.bin +cflatobjs += \ + test/lib/powerpc/io.o -tests := $(addprefix test/powerpc/, $(testobjs)) +$(libcflat): LDFLAGS += -nostdlib +$(libcflat): CFLAGS += -ffreestanding -all: kvmtrace kvmctl $(tests) +# these tests do not use libcflat +simpletests := \ + test/powerpc/spin.bin \ + test/powerpc/io.bin \ + test/powerpc/sprg.bin + +# theses tests use cstart.o, libcflat, and libgcc +tests := \ + test/powerpc/exit.bin + +include config-powerpc-$(platform).mak + + +all: kvmtrace kvmctl $(libcflat) $(simpletests) $(tests) + +$(simpletests): %.bin: %.o + $(CC) -nostdlib $^ -Wl,-T,flat.lds -o $@ + +$(tests): %.bin: $(cstart) %.o $(libcflat) + $(CC) -nostdlib $^ $(libgcc) -Wl,-T,flat.lds -o $@ kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a arch_clean: - rm -f $(tests) + $(RM) $(simpletests) $(tests) $(cstart) + $(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests)) + $(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests)) diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/map.c @@ -0,0 +1,51 @@ +/* + * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + */ + +#include "libcflat.h" + +#define TLB_SIZE 64 + +extern void tlbwe(unsigned int index, + unsigned char tid, + unsigned int word0, + unsigned int word1, + unsigned int word2); + +unsigned int next_free_index; + +#define PAGE_SHIFT 12 +#define PAGE_MASK (~((1<= TLB_SIZE) + panic("TLB overflow"); + + w0 = (vaddr & PAGE_MASK) | V; + w1 = paddr & PAGE_MASK; + w2 = 0x3; + + tlbwe(next_free_index, 0, w0, w1, w2); +} diff --git a/user/test/lib/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/tlbwe.S @@ -0,0 +1,29 @@ +/* + * 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 w
[PATCH 10 of 10] [PATCH] kvm-userspace: ppc: fix initial ppc memory setup
From: Christian Ehrhardt <[EMAIL PROTECTED]> The old memory initialization code was broken for all cases not fitting in one ram stick. This patch fixes the ram_stick calculation, now sets the proper base adresses per stick and removes the old workaround. Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] ppc440.c| 12 +--- ppc440.h|8 ++-- ppc440_bamboo.c | 30 -- 3 files changed, 31 insertions(+), 19 deletions(-) [diff] diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -3,6 +3,7 @@ * * Copyright 2007 IBM Corporation. * Authors: Jerone Young <[EMAIL PROTECTED]> + * Christian Ehrhardt <[EMAIL PROTECTED]> * * This work is licensed under the GNU GPL license version 2 or later. * @@ -24,15 +25,15 @@ void ppc440ep_init(CPUState *env, - target_phys_addr_t ram_bases[2], - target_phys_addr_t ram_sizes[2], + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS], + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS], + int nbanks, qemu_irq **picp, ppc4xx_pci_t **pcip, int do_init) { ppc4xx_mmio_t *mmio; qemu_irq *pic, *irqs; - ram_addr_t offset; ppc4xx_pci_t *pci; int i; @@ -55,10 +56,7 @@ /* SDRAM controller */ printf("trying to setup sdram controller\n"); /* XXX 440EP's ECC interrupts are on UIC1 */ - ppc405_sdram_init(env, pic[14], 2, ram_bases, ram_sizes, do_init); - offset = 0; - for (i = 0; i < 2; i++) - offset += ram_sizes[i]; + ppc405_sdram_init(env, pic[14], nbanks, ram_bases, ram_sizes, do_init); /* PCI */ pci = ppc4xx_pci_init(env, pic, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -3,6 +3,7 @@ * * Copyright 2007 IBM Corporation. * Authors: Jerone Young <[EMAIL PROTECTED]> + * Christian Ehrhardt <[EMAIL PROTECTED]> * * This work is licensed under the GNU GPL licence version 2 or later * @@ -20,9 +21,12 @@ #include "exec-all.h" #include "boards.h" +#define PPC440_MAX_RAM_SLOTS 4 + void ppc440ep_init(CPUState *env, - target_phys_addr_t ram_bases[2], - target_phys_addr_t ram_sizes[2], + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS], + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS], + int nbanks, qemu_irq **picp, ppc4xx_pci_t **pcip, int do_init); 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 @@ -2,7 +2,9 @@ * Qemu PowerPC 440 board emualtion * * Copyright 2007 IBM Corporation. - * Authors: Jerone Young <[EMAIL PROTECTED]> + * Authors: + * Jerone Young <[EMAIL PROTECTED]> + * Christian Ehrhardt <[EMAIL PROTECTED]> * * This work is licensed under the GNU GPL license version 2 or later. * @@ -30,7 +32,8 @@ const char *cpu_model) { char *buf=NULL; - target_phys_addr_t ram_bases[4], ram_sizes[4]; + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS]; + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS]; NICInfo *nd; qemu_irq *pic; ppc4xx_pci_t *pci; @@ -46,6 +49,8 @@ int ret; int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20, 32<<20, 16<<20, 8<<20 }; /* in bytes */ + int nbanks = 0; /* number of used memory banks */ + int next_bank_offset = 0; ram_addr_t tmp_ram_size; int i=0, k=0; uint32_t cpu_freq; @@ -55,15 +60,22 @@ printf("%s: START\n", __func__); /* Setup Memory */ - printf("Ram size passed is: %i MB\n", - bytes_to_mb((int)ram_size)); + if (ram_size < 8<<20) { + printf("ERROR: ram size too small (min 8mb)\n"); + exit(1); + } else + 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++) { + for (i = 0; i < PPC440_MAX_RAM_SLOTS; i++) { + for (k = 0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) { if ((tmp_ram_size/ram_stick_sizes[k]) > 0) { ram_sizes[i] = ram_stick_sizes[k]; + ram_bases[i] = next_bank_offset; + next_bank_offset += ram_stick_sizes[k]; + nbanks++; tmp_ram_size -= ram_stick_sizes[k]; break;
[PATCH 08 of 10] [PATCH] qemu: ppc: if not a uImage, try to load kernel as ELF
From: Hollis Blanchard <[EMAIL PROTECTED]> This allows qemu to load "bare metal" ELF kernels, useful for standalone benchmarks and testcases. We could/should also load the specified file as a flat binary, if both uImage and ELF loaders fail. (See hw/arm_boot.c.) Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] ppc440_bamboo.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) [diff] 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 @@ -35,8 +35,8 @@ qemu_irq *pic; ppc4xx_pci_t *pci; CPUState *env; - target_ulong ep=0; - target_ulong la=0; + uint64_t ep=0; + uint64_t la=0; int is_linux=1; /* Will assume allways is Linux for now */ target_long kernel_size=0; target_ulong initrd_base=0; @@ -97,6 +97,9 @@ /* load kernel with uboot loader */ printf("%s: load kernel\n", __func__); ret = load_uimage(kernel_filename, &ep, &la, &kernel_size, &is_linux); + if (ret < 0) + ret = load_elf(kernel_filename, 0, &ep, &la, NULL); + if (ret < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02 of 10] [PATCH] user: ppc: fix threading bugs in main-ppc.c
From: Hollis Blanchard <[EMAIL PROTECTED]> - call io_table_register() before any vcpus have started - wait for all vcpus to exit before exiting the parent thread Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] main-ppc.c | 32 1 file changed, 12 insertions(+), 20 deletions(-) [diff] diff --git a/user/main-ppc.c b/user/main-ppc.c --- a/user/main-ppc.c +++ b/user/main-ppc.c @@ -51,7 +51,7 @@ struct io_table mmio_table; static int ncpus = 1; -static sem_t init_sem; +static sem_t exited_sem; static __thread int vcpu; static sigset_t kernel_sigmask; static sigset_t ipi_sigmask; @@ -220,16 +220,8 @@ asm volatile ("sync; isync"); } -static void init_vcpu(int n, unsigned long entry) +static void init_vcpu(int n) { - /* XXX must set initial TLB state and stack - struct kvm_regs regs = { - .pc = entry, - }; - - kvm_set_regs(kvm, 0, ®s); - */ - sigemptyset(&ipi_sigmask); sigaddset(&ipi_sigmask, IPI_SIGNAL); sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL); @@ -237,7 +229,6 @@ vcpus[n].tid = gettid(); vcpu = n; kvm_set_signal_mask(kvm, n, &kernel_sigmask); - sem_post(&init_sem); } static void *do_create_vcpu(void *_n) @@ -245,8 +236,9 @@ int n = (long)_n; kvm_create_vcpu(kvm, n); - init_vcpu(n, 0x0); + init_vcpu(n); kvm_run(kvm, n); + sem_post(&exited_sem); return NULL; } @@ -368,14 +360,14 @@ len = load_file(vm_mem, argv[optind], 1); sync_caches(vm_mem, len); - sem_init(&init_sem, 0, 0); - init_vcpu(0, 0x0); - for (i = 1; i < ncpus; ++i) - start_vcpu(i); - for (i = 0; i < ncpus; ++i) - sem_wait(&init_sem); - io_table_register(&mmio_table, 0xf000, 64, mmio_handler, NULL); - return kvm_run(kvm, 0); + sem_init(&exited_sem, 0, 0); + for (i = 0; i < ncpus; ++i) + start_vcpu(i); + /* Wait for all vcpus to exit. */ + for (i = 0; i < ncpus; ++i) + sem_wait(&exited_sem); + + return 0; } -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07 of 10] [PATCH] qemu: ppc: define maximum SMP limit as 1 for Bamboo
From: Christian Ehrhardt <[EMAIL PROTECTED]> Fix for qemu runtime error. Full error message: Number of SMP cpus requested (1), exceeds max cpus supported by machine `bamboo' (0) Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> --- [diffstat] ppc440_bamboo.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) [diff] 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 @@ -202,7 +202,8 @@ } QEMUMachine bamboo_machine = { - "bamboo", - "bamboo", - bamboo_init, + .name = "bamboo", + .desc = "bamboo", + .init = bamboo_init, + .max_cpus = 1, }; -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06 of 10] [PATCH] user: ppc: add stub nmi handler
From: Hollis Blanchard <[EMAIL PROTECTED]> Adding a nmi stub handler for user/main-ppc.c Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] main-ppc.c |6 ++ 1 file changed, 6 insertions(+) [diff] diff --git a/user/main-ppc.c b/user/main-ppc.c --- a/user/main-ppc.c +++ b/user/main-ppc.c @@ -83,6 +83,11 @@ } static int test_try_push_interrupts(void *opaque) +{ + return 0; +} + +static int test_try_push_nmi(void *opaque) { return 0; } @@ -175,6 +180,7 @@ .halt= test_halt, .io_window = test_io_window, .try_push_interrupts = test_try_push_interrupts, + .try_push_nmi = test_try_push_nmi, .post_kvm_run = test_post_kvm_run, .pre_kvm_run = test_pre_kvm_run, .powerpc_dcr_read = test_dcr_read, -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03 of 10] [PATCH] user: ppc: better error reporting in load_file
From: Hollis Blanchard <[EMAIL PROTECTED]> Fancy description. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] main-ppc.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) [diff] diff --git a/user/main-ppc.c b/user/main-ppc.c --- a/user/main-ppc.c +++ b/user/main-ppc.c @@ -183,7 +183,7 @@ static unsigned long load_file(void *mem, const char *fname, int inval_icache) { - int r; + ssize_t r; int fd; unsigned long bytes = 0; @@ -200,6 +200,7 @@ if (r == -1) { perror("read"); + printf("read %d bytes\n", bytes); exit(1); } -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09 of 10] [PATCH] kvm: external module: Treat NONARCH_CONFIG as a list
From: Hollis Blanchard <[EMAIL PROTECTED] As discussed on the list the unifdef changes break powerpc (and more ?). A fix is to treat NONARCH_CONFIG as a list instead of a single item. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] Makefile |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) [diff] diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -25,8 +25,9 @@ gawk -v version=$(version) -f $(ARCH_DIR)/hack-module.awk $1.orig \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig +unifdef_uflags = $(foreach arch, $(NONARCH_CONFIG), -UCONFIG_$(arch)) unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_$(ARCH_CONFIG) -UCONFIG_$(NONARCH_CONFIG) $1.orig > $1; \ + unifdef -DCONFIG_$(ARCH_CONFIG) $(unifdef_uflags) $1.orig > $1; \ [ $$? -le 2 ] && rm $1.orig hack = $(call _hack,$T/$(strip $1)) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 00 of 10] kvm-userspace: ppc: userspace fixes for powerpc
From: Christian Ehrhardt <[EMAIL PROTECTED]> This is a set of various fixes in kvm-userspace for powerpc. This time without the split between user/* and the rest and without the qemu patch (sent separate to qemu-devel now). Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> b/kernel/Makefile |3 + b/qemu/hw/ppc440.c | 12 +++ b/qemu/hw/ppc440.h |8 +++-- b/qemu/hw/ppc440_bamboo.c |7 ++-- b/qemu/qemu-kvm-powerpc.c |4 +- b/user/config-powerpc-44x.mak | 14 + b/user/config-powerpc.mak | 46 - b/user/main-ppc.c | 32 +++- b/user/test/lib/powerpc/44x/map.c | 51 + b/user/test/lib/powerpc/44x/timebase.S | 28 ++ b/user/test/lib/powerpc/44x/timebase.h | 25 b/user/test/lib/powerpc/44x/tlbwe.S| 29 ++ b/user/test/lib/powerpc/io.c | 35 ++ b/user/test/powerpc/cstart.S | 38 b/user/test/powerpc/exit.c | 23 ++ qemu/hw/ppc440_bamboo.c| 36 +++ user/config-powerpc-44x.mak|3 + user/main-ppc.c|9 + 18 files changed, 339 insertions(+), 64 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01 of 10] [PATCH] kvm-userspace: powerpc: fix env->xer access
From: Christian Ehrhardt <[EMAIL PROTECTED]> Since qemu revision 5500 which was merged with the last qemu merge env->xer is accessed directly. Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] qemu-kvm-powerpc.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) [diff] 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 @@ -57,7 +57,7 @@ regs.ctr = env->ctr; regs.lr = env->lr; -regs.xer = ppc_load_xer(env); +regs.xer = env->xer; regs.msr = env->msr; regs.srr0 = env->spr[SPR_SRR0]; @@ -93,7 +93,7 @@ env->ctr =regs.ctr; env->lr = regs.lr; -ppc_store_xer(env,regs.xer); +env->xer = regs.xer; env->msr = regs.msr; /* calculate hflags based on the current msr using the ppc qemu helper */ hreg_compute_hflags(env); -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc
Ok I should have send these two series with some minutes in between to not intermix them :-/ Additionally I have the wrong header in this one it should be [0/5] :-/++ Overall it is a patch series of three patches for powerpc kvm-userspace, a five patch series for kvm-suerspace/user/ and a single patch I just submitted while cleaning our userspace repo to get the missing things upstream. Avi, let me know if I confused you and I'll send them once again with some time in between to order them easier. [EMAIL PROTECTED] wrote: From: Christian Ehrhardt <[EMAIL PROTECTED]> This is a set of fixes for the powerpc tests kvm-userspace/user. Patch 1&2 fix main-ppc.c while patch 3 introduces libcflat for powerpc. Further on patch 4 provides a timebase accessor for the ppc testcases (not used yet) and patch 5 finally adds a stub nmi handler to main-ppc.c. [patches in series] [PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c [PATCH 2/5] user: ppc: better error reporting in load_file [PATCH 3/5] user: ppc: implement PowerPC 44x libcflat [PATCH 4/5] libcflat: ppc: add timebase accessor [PATCH 5/5] user: ppc: add stub nmi handler --- [diffstat] b/user/config-powerpc-44x.mak | 14 + b/user/config-powerpc.mak | 46 - b/user/main-ppc.c | 32 +++- b/user/test/lib/powerpc/44x/map.c | 51 + b/user/test/lib/powerpc/44x/timebase.S | 28 ++ b/user/test/lib/powerpc/44x/timebase.h | 25 b/user/test/lib/powerpc/44x/tlbwe.S| 29 ++ b/user/test/lib/powerpc/io.c | 35 ++ b/user/test/powerpc/cstart.S | 38 b/user/test/powerpc/exit.c | 23 ++ user/config-powerpc-44x.mak|3 + user/main-ppc.c|9 + 12 files changed, 296 insertions(+), 37 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html -- Grüsse / regards, Christian Ehrhardt IBM Linux Technology Center, Open Virtualization -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] kvm-userspace: ppc: fix initial ppc memory setup
From: Christian Ehrhardt <[EMAIL PROTECTED]> The old memory initialization code was broken for all cases not fitting in one ram stick. This patch fixes the ram_stick calculation, now sets the proper base adresses per stick and removes the old workaround. Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] ppc440.c| 12 +--- ppc440.h|8 ++-- ppc440_bamboo.c | 30 -- 3 files changed, 31 insertions(+), 19 deletions(-) [diff] diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c --- a/qemu/hw/ppc440.c +++ b/qemu/hw/ppc440.c @@ -3,6 +3,7 @@ * * Copyright 2007 IBM Corporation. * Authors: Jerone Young <[EMAIL PROTECTED]> + * Christian Ehrhardt <[EMAIL PROTECTED]> * * This work is licensed under the GNU GPL license version 2 or later. * @@ -24,15 +25,15 @@ void ppc440ep_init(CPUState *env, - target_phys_addr_t ram_bases[2], - target_phys_addr_t ram_sizes[2], + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS], + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS], + int nbanks, qemu_irq **picp, ppc4xx_pci_t **pcip, int do_init) { ppc4xx_mmio_t *mmio; qemu_irq *pic, *irqs; - ram_addr_t offset; ppc4xx_pci_t *pci; int i; @@ -55,10 +56,7 @@ /* SDRAM controller */ printf("trying to setup sdram controller\n"); /* XXX 440EP's ECC interrupts are on UIC1 */ - ppc405_sdram_init(env, pic[14], 2, ram_bases, ram_sizes, do_init); - offset = 0; - for (i = 0; i < 2; i++) - offset += ram_sizes[i]; + ppc405_sdram_init(env, pic[14], nbanks, ram_bases, ram_sizes, do_init); /* PCI */ pci = ppc4xx_pci_init(env, pic, diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h --- a/qemu/hw/ppc440.h +++ b/qemu/hw/ppc440.h @@ -3,6 +3,7 @@ * * Copyright 2007 IBM Corporation. * Authors: Jerone Young <[EMAIL PROTECTED]> + * Christian Ehrhardt <[EMAIL PROTECTED]> * * This work is licensed under the GNU GPL licence version 2 or later * @@ -20,9 +21,12 @@ #include "exec-all.h" #include "boards.h" +#define PPC440_MAX_RAM_SLOTS 4 + void ppc440ep_init(CPUState *env, - target_phys_addr_t ram_bases[2], - target_phys_addr_t ram_sizes[2], + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS], + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS], + int nbanks, qemu_irq **picp, ppc4xx_pci_t **pcip, int do_init); 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 @@ -2,7 +2,9 @@ * Qemu PowerPC 440 board emualtion * * Copyright 2007 IBM Corporation. - * Authors: Jerone Young <[EMAIL PROTECTED]> + * Authors: + * Jerone Young <[EMAIL PROTECTED]> + * Christian Ehrhardt <[EMAIL PROTECTED]> * * This work is licensed under the GNU GPL license version 2 or later. * @@ -30,7 +32,8 @@ const char *cpu_model) { char *buf=NULL; - target_phys_addr_t ram_bases[4], ram_sizes[4]; + target_phys_addr_t ram_bases[PPC440_MAX_RAM_SLOTS]; + target_phys_addr_t ram_sizes[PPC440_MAX_RAM_SLOTS]; NICInfo *nd; qemu_irq *pic; ppc4xx_pci_t *pci; @@ -46,6 +49,8 @@ int ret; int ram_stick_sizes[] = {256<<20, 128<<20, 64<<20, 32<<20, 16<<20, 8<<20 }; /* in bytes */ + int nbanks = 0; /* number of used memory banks */ + int next_bank_offset = 0; ram_addr_t tmp_ram_size; int i=0, k=0; uint32_t cpu_freq; @@ -55,15 +60,22 @@ printf("%s: START\n", __func__); /* Setup Memory */ - printf("Ram size passed is: %i MB\n", - bytes_to_mb((int)ram_size)); + if (ram_size < 8<<20) { + printf("ERROR: ram size too small (min 8mb)\n"); + exit(1); + } else + 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++) { + for (i = 0; i < PPC440_MAX_RAM_SLOTS; i++) { + for (k = 0; k < (sizeof(ram_stick_sizes)/sizeof(int)); k++) { if ((tmp_ram_size/ram_stick_sizes[k]) > 0) { ram_sizes[i] = ram_stick_sizes[k]; + ram_bases[i] = next_bank_offset; + next_bank_offset += ram_stick_sizes[k]; + nbanks++; tmp_ram_size -= ram_stick_sizes[k]; break;
[PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc
From: Christian Ehrhardt <[EMAIL PROTECTED]> This is a set of various functional fixes in kvm-userspace for powerpc. Patch 1 fullfils the requirement to provide a max smp cpu in the machine struct, without that value qemu denies to run the guest (cpu 1 > maxcpu 0) Patch 2 is a intermediate fix to allow ppc (and hopefully all others to build) until we changed the unifdef to sed'ing files as avi suggested. Until then it would be nice if that patch could fix the build issues for all of us in the unifdef style. Patch3 is a rework of the powerpc 440 guest memory initialization. I looked at it because the -m option did not work sometimes but it came up that the memory setup is broken and only running due to a workaround. qemu-devel is on cc for patch 1/3 [patches in series] [PATCH 1/3] qemu: ppc: define maximum SMP limit as 1 for Bamboo [PATCH 2/3] kvm: external module: Treat NONARCH_CONFIG as a list [PATCH 3/3] kvm-userspace: ppc: fix initial ppc memory setup --- [diffstat] b/kernel/Makefile |3 ++- b/qemu/hw/ppc440.c| 12 +--- b/qemu/hw/ppc440.h|8 ++-- b/qemu/hw/ppc440_bamboo.c |7 --- qemu/hw/ppc440_bamboo.c | 30 -- 5 files changed, 37 insertions(+), 23 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] qemu: ppc: if not a uImage, try to load kernel as ELF
From: Hollis Blanchard <[EMAIL PROTECTED]> This allows qemu to load "bare metal" ELF kernels, useful for standalone benchmarks and testcases. We could/should also load the specified file as a flat binary, if both uImage and ELF loaders fail. (See hw/arm_boot.c.) Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] ppc440_bamboo.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) [diff] 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 @@ -35,8 +35,8 @@ void bamboo_init(ram_addr_t ram_size, in qemu_irq *pic; ppc4xx_pci_t *pci; CPUState *env; - target_ulong ep=0; - target_ulong la=0; + uint64_t ep=0; + uint64_t la=0; int is_linux=1; /* Will assume allways is Linux for now */ target_long kernel_size=0; target_ulong initrd_base=0; @@ -98,6 +98,9 @@ void bamboo_init(ram_addr_t ram_size, in /* load kernel with uboot loader */ printf("%s: load kernel\n", __func__); ret = load_uimage(kernel_filename, &ep, &la, &kernel_size, &is_linux); + if (ret < 0) + ret = load_elf(kernel_filename, 0, &ep, &la, NULL); + if (ret < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c
From: Hollis Blanchard <[EMAIL PROTECTED]> - call io_table_register() before any vcpus have started - wait for all vcpus to exit before exiting the parent thread Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] main-ppc.c | 32 1 file changed, 12 insertions(+), 20 deletions(-) [diff] diff --git a/user/main-ppc.c b/user/main-ppc.c --- a/user/main-ppc.c +++ b/user/main-ppc.c @@ -51,7 +51,7 @@ struct io_table mmio_table; struct io_table mmio_table; static int ncpus = 1; -static sem_t init_sem; +static sem_t exited_sem; static __thread int vcpu; static sigset_t kernel_sigmask; static sigset_t ipi_sigmask; @@ -220,16 +220,8 @@ void sync_caches(void *mem, unsigned lon asm volatile ("sync; isync"); } -static void init_vcpu(int n, unsigned long entry) +static void init_vcpu(int n) { - /* XXX must set initial TLB state and stack - struct kvm_regs regs = { - .pc = entry, - }; - - kvm_set_regs(kvm, 0, ®s); - */ - sigemptyset(&ipi_sigmask); sigaddset(&ipi_sigmask, IPI_SIGNAL); sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL); @@ -237,7 +229,6 @@ static void init_vcpu(int n, unsigned lo vcpus[n].tid = gettid(); vcpu = n; kvm_set_signal_mask(kvm, n, &kernel_sigmask); - sem_post(&init_sem); } static void *do_create_vcpu(void *_n) @@ -245,8 +236,9 @@ static void *do_create_vcpu(void *_n) int n = (long)_n; kvm_create_vcpu(kvm, n); - init_vcpu(n, 0x0); + init_vcpu(n); kvm_run(kvm, n); + sem_post(&exited_sem); return NULL; } @@ -368,14 +360,14 @@ int main(int argc, char **argv) len = load_file(vm_mem, argv[optind], 1); sync_caches(vm_mem, len); - sem_init(&init_sem, 0, 0); - init_vcpu(0, 0x0); - for (i = 1; i < ncpus; ++i) - start_vcpu(i); - for (i = 0; i < ncpus; ++i) - sem_wait(&init_sem); - io_table_register(&mmio_table, 0xf000, 64, mmio_handler, NULL); - return kvm_run(kvm, 0); + sem_init(&exited_sem, 0, 0); + for (i = 0; i < ncpus; ++i) + start_vcpu(i); + /* Wait for all vcpus to exit. */ + for (i = 0; i < ncpus; ++i) + sem_wait(&exited_sem); + + return 0; } -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc
From: Christian Ehrhardt <[EMAIL PROTECTED]> This is a set of fixes for the powerpc tests kvm-userspace/user. Patch 1&2 fix main-ppc.c while patch 3 introduces libcflat for powerpc. Further on patch 4 provides a timebase accessor for the ppc testcases (not used yet) and patch 5 finally adds a stub nmi handler to main-ppc.c. [patches in series] [PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c [PATCH 2/5] user: ppc: better error reporting in load_file [PATCH 3/5] user: ppc: implement PowerPC 44x libcflat [PATCH 4/5] libcflat: ppc: add timebase accessor [PATCH 5/5] user: ppc: add stub nmi handler --- [diffstat] b/user/config-powerpc-44x.mak | 14 + b/user/config-powerpc.mak | 46 - b/user/main-ppc.c | 32 +++- b/user/test/lib/powerpc/44x/map.c | 51 + b/user/test/lib/powerpc/44x/timebase.S | 28 ++ b/user/test/lib/powerpc/44x/timebase.h | 25 b/user/test/lib/powerpc/44x/tlbwe.S| 29 ++ b/user/test/lib/powerpc/io.c | 35 ++ b/user/test/powerpc/cstart.S | 38 b/user/test/powerpc/exit.c | 23 ++ user/config-powerpc-44x.mak|3 + user/main-ppc.c|9 + 12 files changed, 296 insertions(+), 37 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/5] libcflat: ppc: add timebase accessor
Provide a timebase accessor for ppc testcases. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> [diffstat] config-powerpc-44x.mak |3 ++- test/lib/powerpc/44x/timebase.S | 28 test/lib/powerpc/44x/timebase.h | 25 + 3 files changed, 55 insertions(+), 1 deletion(-) [diff] diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak --- a/user/config-powerpc-44x.mak +++ b/user/config-powerpc-44x.mak @@ -5,7 +5,8 @@ cflatobjs += \ test/lib/powerpc/44x/map.o \ - test/lib/powerpc/44x/tlbwe.o + test/lib/powerpc/44x/tlbwe.o \ + test/lib/powerpc/44x/timebase.o simpletests += \ test/powerpc/44x/tlbsx.bin \ diff --git a/user/test/lib/powerpc/44x/timebase.S b/user/test/lib/powerpc/44x/timebase.S new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/timebase.S @@ -0,0 +1,28 @@ +/* + * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + */ + +/* unsigned long long mftb(void); */ +.global mftb +mftb: + mftbu r5 + mftbl r4 + mftbu r3 + cmpwr3, r5 + bne mftb + blr diff --git a/user/test/lib/powerpc/44x/timebase.h b/user/test/lib/powerpc/44x/timebase.h new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/timebase.h @@ -0,0 +1,25 @@ +/* + * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + */ + +#ifndef __TIMEBASE_H__ +#define __TIMEBASE_H__ + +unsigned long long mftb(void); + +#endif /* __TIMEBASE_H__ */ -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/5] user: ppc: better error reporting in load_file
From: Hollis Blanchard <[EMAIL PROTECTED]> Fancy description. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] main-ppc.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) [diff] diff --git a/user/main-ppc.c b/user/main-ppc.c --- a/user/main-ppc.c +++ b/user/main-ppc.c @@ -183,7 +183,7 @@ static struct kvm_callbacks test_callbac static unsigned long load_file(void *mem, const char *fname, int inval_icache) { - int r; + ssize_t r; int fd; unsigned long bytes = 0; @@ -200,6 +200,7 @@ static unsigned long load_file(void *mem if (r == -1) { perror("read"); + printf("read %d bytes\n", bytes); exit(1); } -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/5] user: ppc: add stub nmi handler
From: Hollis Blanchard <[EMAIL PROTECTED]> Adding a nmi stub handler for user/main-ppc.c. We already pushed a stub for qemu but not for the test suite in the user dir. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] main-ppc.c |6 ++ 1 file changed, 6 insertions(+) [diff] diff --git a/user/main-ppc.c b/user/main-ppc.c --- a/user/main-ppc.c +++ b/user/main-ppc.c @@ -83,6 +83,11 @@ static int test_io_window(void *opaque) } static int test_try_push_interrupts(void *opaque) +{ + return 0; +} + +static int test_try_push_nmi(void *opaque) { return 0; } @@ -175,6 +180,7 @@ static struct kvm_callbacks test_callbac .halt= test_halt, .io_window = test_io_window, .try_push_interrupts = test_try_push_interrupts, + .try_push_nmi = test_try_push_nmi, .post_kvm_run = test_post_kvm_run, .pre_kvm_run = test_pre_kvm_run, .powerpc_dcr_read = test_dcr_read, -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/5] user: ppc: implement PowerPC 44x libcflat
From: Hollis Blanchard <[EMAIL PROTECTED]> - Create a 44x-specific makefile. - Reorganize PowerPC makefiles to separate "simple" tests from those which link with libcflat. - Create a minimal libcflat testcase (which just exits). Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] config-powerpc-44x.mak | 14 +++ config-powerpc.mak | 46 ++ test/lib/powerpc/44x/map.c | 51 +++ test/lib/powerpc/44x/tlbwe.S | 29 test/lib/powerpc/io.c| 35 + test/powerpc/cstart.S| 38 test/powerpc/exit.c | 23 +++ 7 files changed, 221 insertions(+), 15 deletions(-) [diff] diff --git a/user/config-powerpc-44x.mak b/user/config-powerpc-44x.mak new file mode 100644 --- /dev/null +++ b/user/config-powerpc-44x.mak @@ -0,0 +1,14 @@ + + +# for some reason binutils hates tlbsx unless we say we're 405 :( +CFLAGS += -Wa,-m405 -I test/lib/powerpc/44x + +cflatobjs += \ + test/lib/powerpc/44x/map.o \ + test/lib/powerpc/44x/tlbwe.o + +simpletests += \ + test/powerpc/44x/tlbsx.bin \ + test/powerpc/44x/tlbwe_16KB.bin \ + test/powerpc/44x/tlbwe_hole.bin \ + test/powerpc/44x/tlbwe.bin diff --git a/user/config-powerpc.mak b/user/config-powerpc.mak --- a/user/config-powerpc.mak +++ b/user/config-powerpc.mak @@ -1,26 +1,42 @@ +platform := 44x + CFLAGS += -m32 CFLAGS += -D__powerpc__ CFLAGS += -I $(KERNELDIR)/include -# for some reaons binutils hates tlbsx unless we say we're 405 :( -CFLAGS += -Wa,-mregnames,-m405 +CFLAGS += -Wa,-mregnames -I test/lib -%.bin: %.o - $(OBJCOPY) -O binary $^ $@ +cstart := test/powerpc/cstart.o -testobjs := \ - io.bin \ - spin.bin \ - sprg.bin \ - 44x/tlbsx.bin \ - 44x/tlbwe_16KB.bin \ - 44x/tlbwe_hole.bin \ - 44x/tlbwe.bin +cflatobjs += \ + test/lib/powerpc/io.o -tests := $(addprefix test/powerpc/, $(testobjs)) +$(libcflat): LDFLAGS += -nostdlib +$(libcflat): CFLAGS += -ffreestanding -all: kvmtrace kvmctl $(tests) +# these tests do not use libcflat +simpletests := \ + test/powerpc/spin.bin \ + test/powerpc/io.bin \ + test/powerpc/sprg.bin + +# theses tests use cstart.o, libcflat, and libgcc +tests := \ + test/powerpc/exit.bin + +include config-powerpc-$(platform).mak + + +all: kvmtrace kvmctl $(libcflat) $(simpletests) $(tests) + +$(simpletests): %.bin: %.o + $(CC) -nostdlib $^ -Wl,-T,flat.lds -o $@ + +$(tests): %.bin: $(cstart) %.o $(libcflat) + $(CC) -nostdlib $^ $(libgcc) -Wl,-T,flat.lds -o $@ kvmctl_objs = main-ppc.o iotable.o ../libkvm/libkvm.a arch_clean: - rm -f $(tests) + $(RM) $(simpletests) $(tests) $(cstart) + $(RM) $(patsubst %.bin, %.elf, $(simpletests) $(tests)) + $(RM) $(patsubst %.bin, %.o, $(simpletests) $(tests)) diff --git a/user/test/lib/powerpc/44x/map.c b/user/test/lib/powerpc/44x/map.c new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/map.c @@ -0,0 +1,51 @@ +/* + * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2008 + * + * Authors: Hollis Blanchard <[EMAIL PROTECTED]> + */ + +#include "libcflat.h" + +#define TLB_SIZE 64 + +extern void tlbwe(unsigned int index, + unsigned char tid, + unsigned int word0, + unsigned int word1, + unsigned int word2); + +unsigned int next_free_index; + +#define PAGE_SHIFT 12 +#define PAGE_MASK (~((1<= TLB_SIZE) + panic("TLB overflow"); + + w0 = (vaddr & PAGE_MASK) | V; + w1 = paddr & PAGE_MASK; + w2 = 0x3; + + tlbwe(next_free_index, 0, w0, w1, w2); +} diff --git a/user/test/lib/powerpc/44x/tlbwe.S b/user/test/lib/powerpc/44x/tlbwe.S new file mode 100644 --- /dev/null +++ b/user/test/lib/powerpc/44x/tlbwe.S @@ -0,0 +1,29 @@ +/* + * 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 w
[PATCH 2/3] kvm: external module: Treat NONARCH_CONFIG as a list
From: Hollis Blanchard <[EMAIL PROTECTED]> As discussed on the list the unifdef changes break powerpc (and more ?). A fix is to treat NONARCH_CONFIG as a list instead of a single item. Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> --- [diffstat] Makefile |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) [diff] diff --git a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile +++ b/kernel/Makefile @@ -25,8 +25,9 @@ gawk -v version=$(version) -f $(ARCH_DIR)/hack-module.awk $1.orig \ | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig +unifdef_uflags = $(foreach arch, $(NONARCH_CONFIG), -UCONFIG_$(arch)) unifdef = mv $1 $1.orig && \ - unifdef -DCONFIG_$(ARCH_CONFIG) -UCONFIG_$(NONARCH_CONFIG) $1.orig > $1; \ + unifdef -DCONFIG_$(ARCH_CONFIG) $(unifdef_uflags) $1.orig > $1; \ [ $$? -le 2 ] && rm $1.orig hack = $(call _hack,$T/$(strip $1)) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] qemu: ppc: define maximum SMP limit as 1 for Bamboo
From: Christian Ehrhardt <[EMAIL PROTECTED]> Fix for qemu runtime error. Full error message: Number of SMP cpus requested (1), exceeds max cpus supported by machine `bamboo' (0) Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]> Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> --- [diffstat] ppc440_bamboo.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) [diff] 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 @@ -203,7 +203,8 @@ void bamboo_init(ram_addr_t ram_size, in } QEMUMachine bamboo_machine = { - "bamboo", - "bamboo", - bamboo_init, + .name = "bamboo", + .desc = "bamboo", + .init = bamboo_init, + .max_cpus = 1, }; -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html