kvm-userspace: ppc: userspace fixes for powerpc
cover 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 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
---
[diffstat]
main-ppc.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
[diff]
user/main-ppc.c +12 -20
@@ -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 __threadint vcpu;static sigset_t kernel_sigmask;static sigset_t ipi_sigmask;
@@ -220,16 +220,8 @@ void sync_caches(void *mem, unsigned lon asmvolatile ("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,0xf0000000 ,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 ; }
PATCH 2/5 user: ppc: better error reporting in load_file
In reply to [email protected]From: Hollis Blanchard <[email protected]>
Fancy description.
---
[diffstat]
main-ppc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
[diff]
user/main-ppc.c +2 -1
@@ -183,7 +183,7 @@ static struct kvm_callbacks test_callbacstatic 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 *memif (r =-1 ) {perror ("read" ); +printf ("read %d bytes\n" , bytes);exit (1 ); }
A message that is not in the archive (sent off-list or not yet received): 1225184902-25769-1-git-send-email-ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
PATCH 3/5 user: ppc: implement PowerPC 44x libcflat
From: Hollis Blanchard <hollisb-r/[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).
---
[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]
user/config-powerpc-44x.mak new file +14 -0
@@ -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
user/config-powerpc.mak +31 -15
57 lines not on this page · raw message
user/test/lib/powerpc/44x/map.c new file +51 -0
51 lines not on this page · raw message
user/test/lib/powerpc/44x/tlbwe.S new file +29 -0
@@ -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 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 <hollisb-r/[email protected]> + */ + +#define SPRN_MMUCR 0x3b2 + +/* tlbwe(uint index, uint8_t tid, uint word0, uint word1, uint word2) */ +.global tlbwe +tlbwe: + mtspr SPRN_MMUCR, r4 + tlbwe r5, r3, 0 + tlbwe r6, r3, 1 + tlbwe r7, r3, 2 + blr
user/test/lib/powerpc/io.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* 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 <hollisb-r/[email protected]> +*/ + +#include "libcflat.h" + +#define BASE 0xf0000000 +#define _putc ((volatile char *)(BASE)) +#define _exit ((volatile char *)(BASE+1)) + +void puts (const char *s) +{ +while (*s !='\0' ) + *_putc = *s++; +} + +void exit (int code) +{ + *_exit = code; +}
user/test/powerpc/cstart.S new file +38 -0
@@ -0,0 +1,38 @@ +/* + * 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 <hollisb-r/[email protected]> + */ + +#define OUTPUT_VADDR 0xf0000000 +#define OUTPUT_PADDR 0xf0000000 + +.globl _start +_start: + /* In the future we might need to assign a stack and zero BSS here. */ + + /* Map the debug page 1:1. */ + lis r3, OUTPUT_VADDR@h + ori r3, r3, OUTPUT_VADDR@l + lis r4, OUTPUT_PADDR@h + ori r4, r4, OUTPUT_PADDR@l + bl map + + /* Call main() and pass return code to exit(). */ + bl main + bl exit + + b .
user/test/powerpc/exit.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* 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 <hollisb-r/[email protected]> +*/ + +int main (void ) +{ +return 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
In reply to a message not in the archiveFrom: Hollis Blanchard <hollisb-r/[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.
---
[diffstat]
main-ppc.c | 6 ++++++ 1 file changed, 6 insertions(+)
[diff]
user/main-ppc.c +6 -0
@@ -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
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.
Quoted 35 lines · [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.cwhile 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 tomain-ppc.c.[patches in series]
[PATCH 1/5] user: ppc: fix threading bugs inmain-ppc.c[PATCH 2/5] user: ppc: better error reporting inload_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
Signature · 7 lines
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 4/5 libcflat: ppc: add timebase accessor
In reply to [email protected]Provide a timebase accessor for ppc testcases.
[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]
user/config-powerpc-44x.mak +2 -1
@@ -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 \
user/test/lib/powerpc/44x/timebase.S new file +28 -0
@@ -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 + cmpw r3, r5 + bne mftb + blr
user/test/lib/powerpc/44x/timebase.h new file +25 -0
@@ -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__ */