All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-08 18:53 ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

It's been a loooong time since I posted v1 of this series, but thanks
to Thomas' poking, and even volunteering to help move v2 along, I've
finally picked it back up.

v2:
  Besides rebasing on latest master, v2 addresses all of David's comments
    - assembler cleanup
    - jump into the RTAS blob we get from DT, instead of reproducing it
    - don't store the RTAS root node, always hunt it down

  v2 didn't address debug-exit, and we still need a solution for that.
  Plugging chr-testdev into an spapr vty is probably what we should
  investigate first (as was suggested by Alex Graf under the v1 review).
  For this v2 I just kept the hack from v1, but simplified it and
  explicitly call it out as the hack that it is.

Additional known issues:
  Latest F22 cross-compiler (gcc5 based) doesn't generate working
  code with this series. I didn't try to debug. The 4.9 based compiler
  I initially used on v1 works, so I reverted to that one.

Testing:
  I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
  try to get a machine to test with real hardware (and KVM) unless
  someone (hi Thomas :-) beats me to it.

Standard cover-letter summary:
  This series brings basic setup; starts a test's C entry point, main(),
  and printf, exit, and malloc work. Three more series should follow this
  one which must bring; vector support, mmu support, and smp support, at
  which point I believe the framework could just evolve with the creation
  of unit tests.

Patches also available here
https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2


Andrew Jones (14):
  lib: asm-generic: add missing casts
  lib: share arm-selftest utility functions
  config: no need to mix arch makefiles
  powerpc/ppc64: start skeleton framework
  powerpc/pp64: ppc-ify makefiles and linker script
  powerpc/ppc64: add boot rom source
  powerpc/ppc64: add bootloader to bounce into memory
  powerpc/ppc64: add HV putchar
  powerpc/ppc64: adapt arm's setup
  powerpc/ppc64: relocate linker VMAs
  powerpc/ppc64: add run script and unittests.cfg
  mkstandalone: add support for powerpc
  powerpc/ppc64: add RTAS support
  powerpc/ppc64: HACK: make a fake debug-exit

 Makefile                                           |   2 +-
 README                                             |   3 +-
 arm/Makefile                                       |   1 +
 config/config-arm.mak => arm/Makefile.arm          |   2 +-
 config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
 .../config-arm-common.mak => arm/Makefile.common   |   3 +-
 arm/selftest.c                                     |  45 +++-----
 configure                                          |   6 ++
 lib/asm-generic/io.h                               |  12 +--
 lib/libcflat.h                                     |  11 +-
 lib/powerpc/.gitignore                             |   1 +
 lib/powerpc/asm/rtas.h                             |  26 +++++
 lib/powerpc/asm/setup.h                            |  27 +++++
 lib/powerpc/io.c                                   |  37 +++++++
 lib/powerpc/mmu.c                                  |   0
 lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
 lib/powerpc/setup.c                                |  91 ++++++++++++++++
 lib/powerpc/smp.c                                  |   0
 lib/ppc64/.gitignore                               |   1 +
 lib/ppc64/asm-offsets.c                            |  12 +++
 lib/ppc64/asm/asm-offsets.h                        |   1 +
 lib/ppc64/asm/io.h                                 |   5 +
 lib/ppc64/asm/page.h                               |   1 +
 lib/ppc64/asm/rtas.h                               |   1 +
 lib/ppc64/asm/setup.h                              |   1 +
 lib/ppc64/asm/spinlock.h                           |  11 ++
 lib/ppc64/processor.c                              |   0
 lib/ppc64/spinlock.c                               |  11 ++
 lib/report.c                                       |  16 +++
 lib/util.c                                         |  18 ++++
 lib/util.h                                         |  23 ++++
 powerpc/Makefile                                   |   1 +
 powerpc/Makefile.common                            |  65 +++++++++++
 powerpc/Makefile.ppc64                             |  21 ++++
 powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
 powerpc/cstart64.S                                 |  86 +++++++++++++++
 powerpc/flat.lds                                   |  44 ++++++++
 powerpc/reloc64.c                                  |  55 ++++++++++
 powerpc/rom/.gitignore                             |   1 +
 powerpc/rom/Makefile                               |  36 +++++++
 powerpc/rom/header.img                             |   1 +
 powerpc/rom/rom.ffs                                |   4 +
 powerpc/rom/stage1.S                               |   5 +
 powerpc/run                                        |  60 +++++++++++
 powerpc/selftest.c                                 |  65 +++++++++++
 powerpc/unittests.cfg                              |  30 ++++++
 {config => scripts}/asm-offsets.mak                |   0
 scripts/mkstandalone.sh                            |   5 +
 x86/Makefile                                       |   1 +
 .../config-x86-common.mak => x86/Makefile.common   |   0
 config/config-i386.mak => x86/Makefile.i386        |   2 +-
 config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
 52 files changed, 924 insertions(+), 50 deletions(-)
 create mode 100644 arm/Makefile
 rename config/config-arm.mak => arm/Makefile.arm (90%)
 rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
 rename config/config-arm-common.mak => arm/Makefile.common (96%)
 create mode 100644 lib/powerpc/.gitignore
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/powerpc/io.c
 create mode 100644 lib/powerpc/mmu.c
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/powerpc/setup.c
 create mode 100644 lib/powerpc/smp.c
 create mode 100644 lib/ppc64/.gitignore
 create mode 100644 lib/ppc64/asm-offsets.c
 create mode 100644 lib/ppc64/asm/asm-offsets.h
 create mode 100644 lib/ppc64/asm/io.h
 create mode 100644 lib/ppc64/asm/page.h
 create mode 100644 lib/ppc64/asm/rtas.h
 create mode 100644 lib/ppc64/asm/setup.h
 create mode 100644 lib/ppc64/asm/spinlock.h
 create mode 100644 lib/ppc64/processor.c
 create mode 100644 lib/ppc64/spinlock.c
 create mode 100644 lib/util.c
 create mode 100644 lib/util.h
 create mode 100644 powerpc/Makefile
 create mode 100644 powerpc/Makefile.common
 create mode 100644 powerpc/Makefile.ppc64
 create mode 100644 powerpc/boot_rom.bin
 create mode 100644 powerpc/cstart64.S
 create mode 100644 powerpc/flat.lds
 create mode 100644 powerpc/reloc64.c
 create mode 100644 powerpc/rom/.gitignore
 create mode 100644 powerpc/rom/Makefile
 create mode 100644 powerpc/rom/header.img
 create mode 100644 powerpc/rom/rom.ffs
 create mode 100644 powerpc/rom/stage1.S
 create mode 100755 powerpc/run
 create mode 100644 powerpc/selftest.c
 create mode 100644 powerpc/unittests.cfg
 rename {config => scripts}/asm-offsets.mak (100%)
 create mode 100644 x86/Makefile
 rename config/config-x86-common.mak => x86/Makefile.common (100%)
 rename config/config-i386.mak => x86/Makefile.i386 (91%)
 rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)

-- 
2.4.3


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-08 18:53 ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

It's been a loooong time since I posted v1 of this series, but thanks
to Thomas' poking, and even volunteering to help move v2 along, I've
finally picked it back up.

v2:
  Besides rebasing on latest master, v2 addresses all of David's comments
    - assembler cleanup
    - jump into the RTAS blob we get from DT, instead of reproducing it
    - don't store the RTAS root node, always hunt it down

  v2 didn't address debug-exit, and we still need a solution for that.
  Plugging chr-testdev into an spapr vty is probably what we should
  investigate first (as was suggested by Alex Graf under the v1 review).
  For this v2 I just kept the hack from v1, but simplified it and
  explicitly call it out as the hack that it is.

Additional known issues:
  Latest F22 cross-compiler (gcc5 based) doesn't generate working
  code with this series. I didn't try to debug. The 4.9 based compiler
  I initially used on v1 works, so I reverted to that one.

Testing:
  I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
  try to get a machine to test with real hardware (and KVM) unless
  someone (hi Thomas :-) beats me to it.

Standard cover-letter summary:
  This series brings basic setup; starts a test's C entry point, main(),
  and printf, exit, and malloc work. Three more series should follow this
  one which must bring; vector support, mmu support, and smp support, at
  which point I believe the framework could just evolve with the creation
  of unit tests.

Patches also available here
https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2


Andrew Jones (14):
  lib: asm-generic: add missing casts
  lib: share arm-selftest utility functions
  config: no need to mix arch makefiles
  powerpc/ppc64: start skeleton framework
  powerpc/pp64: ppc-ify makefiles and linker script
  powerpc/ppc64: add boot rom source
  powerpc/ppc64: add bootloader to bounce into memory
  powerpc/ppc64: add HV putchar
  powerpc/ppc64: adapt arm's setup
  powerpc/ppc64: relocate linker VMAs
  powerpc/ppc64: add run script and unittests.cfg
  mkstandalone: add support for powerpc
  powerpc/ppc64: add RTAS support
  powerpc/ppc64: HACK: make a fake debug-exit

 Makefile                                           |   2 +-
 README                                             |   3 +-
 arm/Makefile                                       |   1 +
 config/config-arm.mak => arm/Makefile.arm          |   2 +-
 config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
 .../config-arm-common.mak => arm/Makefile.common   |   3 +-
 arm/selftest.c                                     |  45 +++-----
 configure                                          |   6 ++
 lib/asm-generic/io.h                               |  12 +--
 lib/libcflat.h                                     |  11 +-
 lib/powerpc/.gitignore                             |   1 +
 lib/powerpc/asm/rtas.h                             |  26 +++++
 lib/powerpc/asm/setup.h                            |  27 +++++
 lib/powerpc/io.c                                   |  37 +++++++
 lib/powerpc/mmu.c                                  |   0
 lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
 lib/powerpc/setup.c                                |  91 ++++++++++++++++
 lib/powerpc/smp.c                                  |   0
 lib/ppc64/.gitignore                               |   1 +
 lib/ppc64/asm-offsets.c                            |  12 +++
 lib/ppc64/asm/asm-offsets.h                        |   1 +
 lib/ppc64/asm/io.h                                 |   5 +
 lib/ppc64/asm/page.h                               |   1 +
 lib/ppc64/asm/rtas.h                               |   1 +
 lib/ppc64/asm/setup.h                              |   1 +
 lib/ppc64/asm/spinlock.h                           |  11 ++
 lib/ppc64/processor.c                              |   0
 lib/ppc64/spinlock.c                               |  11 ++
 lib/report.c                                       |  16 +++
 lib/util.c                                         |  18 ++++
 lib/util.h                                         |  23 ++++
 powerpc/Makefile                                   |   1 +
 powerpc/Makefile.common                            |  65 +++++++++++
 powerpc/Makefile.ppc64                             |  21 ++++
 powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
 powerpc/cstart64.S                                 |  86 +++++++++++++++
 powerpc/flat.lds                                   |  44 ++++++++
 powerpc/reloc64.c                                  |  55 ++++++++++
 powerpc/rom/.gitignore                             |   1 +
 powerpc/rom/Makefile                               |  36 +++++++
 powerpc/rom/header.img                             |   1 +
 powerpc/rom/rom.ffs                                |   4 +
 powerpc/rom/stage1.S                               |   5 +
 powerpc/run                                        |  60 +++++++++++
 powerpc/selftest.c                                 |  65 +++++++++++
 powerpc/unittests.cfg                              |  30 ++++++
 {config => scripts}/asm-offsets.mak                |   0
 scripts/mkstandalone.sh                            |   5 +
 x86/Makefile                                       |   1 +
 .../config-x86-common.mak => x86/Makefile.common   |   0
 config/config-i386.mak => x86/Makefile.i386        |   2 +-
 config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
 52 files changed, 924 insertions(+), 50 deletions(-)
 create mode 100644 arm/Makefile
 rename config/config-arm.mak => arm/Makefile.arm (90%)
 rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
 rename config/config-arm-common.mak => arm/Makefile.common (96%)
 create mode 100644 lib/powerpc/.gitignore
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/powerpc/io.c
 create mode 100644 lib/powerpc/mmu.c
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/powerpc/setup.c
 create mode 100644 lib/powerpc/smp.c
 create mode 100644 lib/ppc64/.gitignore
 create mode 100644 lib/ppc64/asm-offsets.c
 create mode 100644 lib/ppc64/asm/asm-offsets.h
 create mode 100644 lib/ppc64/asm/io.h
 create mode 100644 lib/ppc64/asm/page.h
 create mode 100644 lib/ppc64/asm/rtas.h
 create mode 100644 lib/ppc64/asm/setup.h
 create mode 100644 lib/ppc64/asm/spinlock.h
 create mode 100644 lib/ppc64/processor.c
 create mode 100644 lib/ppc64/spinlock.c
 create mode 100644 lib/util.c
 create mode 100644 lib/util.h
 create mode 100644 powerpc/Makefile
 create mode 100644 powerpc/Makefile.common
 create mode 100644 powerpc/Makefile.ppc64
 create mode 100644 powerpc/boot_rom.bin
 create mode 100644 powerpc/cstart64.S
 create mode 100644 powerpc/flat.lds
 create mode 100644 powerpc/reloc64.c
 create mode 100644 powerpc/rom/.gitignore
 create mode 100644 powerpc/rom/Makefile
 create mode 100644 powerpc/rom/header.img
 create mode 100644 powerpc/rom/rom.ffs
 create mode 100644 powerpc/rom/stage1.S
 create mode 100755 powerpc/run
 create mode 100644 powerpc/selftest.c
 create mode 100644 powerpc/unittests.cfg
 rename {config => scripts}/asm-offsets.mak (100%)
 create mode 100644 x86/Makefile
 rename config/config-x86-common.mak => x86/Makefile.common (100%)
 rename config/config-i386.mak => x86/Makefile.i386 (91%)
 rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)

-- 
2.4.3


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/asm-generic/io.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index a9939d3a5921f..abd245676e97a 100644
--- a/lib/asm-generic/io.h
+++ b/lib/asm-generic/io.h
@@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x)
 #endif
 
 #define le16_to_cpu(x) \
-	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
+	({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
 #define cpu_to_le16 le16_to_cpu
 
 #define le32_to_cpu(x) \
-	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
+	({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
 #define cpu_to_le32 le32_to_cpu
 
 #define le64_to_cpu(x) \
-	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
+	({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
 #define cpu_to_le64 le64_to_cpu
 
 #define be16_to_cpu(x) \
-	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
+	({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
 #define cpu_to_be16 be16_to_cpu
 
 #define be32_to_cpu(x) \
-	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
+	({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
 #define cpu_to_be32 be32_to_cpu
 
 #define be64_to_cpu(x) \
-	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
+	({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
 #define cpu_to_be64 be64_to_cpu
 
 #ifndef rmb
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/asm-generic/io.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index a9939d3a5921f..abd245676e97a 100644
--- a/lib/asm-generic/io.h
+++ b/lib/asm-generic/io.h
@@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x)
 #endif
 
 #define le16_to_cpu(x) \
-	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
+	({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
 #define cpu_to_le16 le16_to_cpu
 
 #define le32_to_cpu(x) \
-	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
+	({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
 #define cpu_to_le32 le32_to_cpu
 
 #define le64_to_cpu(x) \
-	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
+	({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
 #define cpu_to_le64 le64_to_cpu
 
 #define be16_to_cpu(x) \
-	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
+	({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
 #define cpu_to_be16 be16_to_cpu
 
 #define be32_to_cpu(x) \
-	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
+	({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
 #define cpu_to_be32 be32_to_cpu
 
 #define be64_to_cpu(x) \
-	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
+	({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
 #define cpu_to_be64 be64_to_cpu
 
 #ifndef rmb
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 02/14] lib: share arm-selftest utility functions
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

arm-selftest has a couple utility functions that could be useful
to other unit tests, even other architectures. So move them out.
split_var moves to lib/util, where we can add other random
utilities over time. assert_args inspires report_abort, which
allows us to report a message, using the current prefix, that
we're aborting (outputs ABORT vs. PASS/FAIL). This is useful
for cases when unit tests can't complete due to missing
dependencies of some sort, such as missing/invalid inputs from
the user.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 arm/selftest.c               | 45 ++++++++++++++------------------------------
 config/config-arm-common.mak |  1 +
 lib/libcflat.h               | 11 ++++++-----
 lib/report.c                 | 16 ++++++++++++++++
 lib/util.c                   | 18 ++++++++++++++++++
 lib/util.h                   | 23 ++++++++++++++++++++++
 6 files changed, 78 insertions(+), 36 deletions(-)
 create mode 100644 lib/util.c
 create mode 100644 lib/util.h

diff --git a/arm/selftest.c b/arm/selftest.c
index aad7eecd529ad..8a68f8bf25167 100644
--- a/arm/selftest.c
+++ b/arm/selftest.c
@@ -6,6 +6,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
+#include <util.h>
 #include <alloc.h>
 #include <devicetree.h>
 #include <asm/setup.h>
@@ -18,43 +19,21 @@
 #include <asm/cpumask.h>
 #include <asm/barrier.h>
 
-static void assert_args(int num_args, int needed_args)
-{
-	if (num_args < needed_args) {
-		printf("selftest: not enough arguments\n");
-		abort();
-	}
-}
-
-static char *split_var(char *s, long *val)
-{
-	char *p;
-
-	p = strchr(s, '=');
-	if (!p)
-		return NULL;
-
-	*val = atol(p+1);
-	*p = '\0';
-
-	return s;
-}
-
 static void check_setup(int argc, char **argv)
 {
-	int nr_tests = 0, i;
-	char *var;
+	int nr_tests = 0, len, i;
 	long val;
 
 	for (i = 0; i < argc; ++i) {
 
-		var = split_var(argv[i], &val);
-		if (!var)
+		len = parse_keyval(argv[i], &val);
+		if (len == -1)
 			continue;
 
-		report_prefix_push(var);
+		argv[i][len] = '\0';
+		report_prefix_push(argv[i]);
 
-		if (strcmp(var, "mem") == 0) {
+		if (strcmp(argv[i], "mem") == 0) {
 
 			phys_addr_t memsize = PHYS_END - PHYS_OFFSET;
 			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
@@ -63,7 +42,7 @@ static void check_setup(int argc, char **argv)
 							memsize/1024/1024);
 			++nr_tests;
 
-		} else if (strcmp(var, "smp") == 0) {
+		} else if (strcmp(argv[i], "smp") == 0) {
 
 			report("nr_cpus = %d", nr_cpus == (int)val, nr_cpus);
 			++nr_tests;
@@ -72,7 +51,8 @@ static void check_setup(int argc, char **argv)
 		report_prefix_pop();
 	}
 
-	assert_args(nr_tests, 2);
+	if (nr_tests < 2)
+		report_abort("missing input");
 }
 
 static struct pt_regs expected_regs;
@@ -343,7 +323,10 @@ static void cpu_report(void)
 int main(int argc, char **argv)
 {
 	report_prefix_push("selftest");
-	assert_args(argc, 1);
+
+	if (argc < 1)
+		report_abort("no test specified");
+
 	report_prefix_push(argv[0]);
 
 	if (strcmp(argv[0], "setup") == 0) {
diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
index 698555d6a676f..bd153cf6ea5ba 100644
--- a/config/config-arm-common.mak
+++ b/config/config-arm-common.mak
@@ -27,6 +27,7 @@ CFLAGS += -I lib -I lib/libfdt
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include config/asm-offsets.mak
 
+cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/virtio.o
diff --git a/lib/libcflat.h b/lib/libcflat.h
index 9747ccdbc9f1d..8411f6c5d92e3 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -57,11 +57,12 @@ extern int snprintf(char *buf, int size, const char *fmt, ...);
 extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
 extern long atol(const char *ptr);
 
-void report_prefix_push(const char *prefix);
-void report_prefix_pop(void);
-void report(const char *msg_fmt, bool pass, ...);
-void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
-int report_summary(void);
+extern void report_prefix_push(const char *prefix);
+extern void report_prefix_pop(void);
+extern void report(const char *msg_fmt, bool pass, ...);
+extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
+extern void report_abort(const char *msg_fmt, ...);
+extern int report_summary(void);
 
 #define ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
 
diff --git a/lib/report.c b/lib/report.c
index 35e664108a921..62916c4ac3c8a 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -96,3 +96,19 @@ int report_summary(void)
 
 	spin_unlock(&lock);
 }
+
+void report_abort(const char *msg_fmt, ...)
+{
+	va_list va;
+	char buf[2000];
+
+	puts("ABORT: ");
+	puts(prefixes);
+	va_start(va, msg_fmt);
+	vsnprintf(buf, sizeof(buf), msg_fmt, va);
+	va_end(va);
+	puts(buf);
+	puts("\n");
+	report_summary();
+	abort();
+}
diff --git a/lib/util.c b/lib/util.c
new file mode 100644
index 0000000000000..69b18100c9722
--- /dev/null
+++ b/lib/util.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+int parse_keyval(char *s, long *val)
+{
+	char *p;
+
+	p = strchr(s, '=');
+	if (!p)
+		return -1;
+
+	*val = atol(p+1);
+	return p - s;
+}
diff --git a/lib/util.h b/lib/util.h
new file mode 100644
index 0000000000000..5b07626175bab
--- /dev/null
+++ b/lib/util.h
@@ -0,0 +1,23 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+/*
+ * Collection of utility functions to share between unit tests.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+/*
+ * parse_keyval extracts the integer from a string formatted as
+ * string=integer. This is useful for passing expected values in
+ * to the unit test on the command line, i.e. it helps parse QEMU
+ * command lines that include something like -append var1=1 var2=2
+ * @s is the input string, likely a command line parameter, and
+ * @val is a pointer to where the integer will be stored.
+ *
+ * Returns the offset of the '=', or -1 if no keyval pair is found.
+ */
+extern int parse_keyval(char *s, long *val);
+
+#endif
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 02/14] lib: share arm-selftest utility functions
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

arm-selftest has a couple utility functions that could be useful
to other unit tests, even other architectures. So move them out.
split_var moves to lib/util, where we can add other random
utilities over time. assert_args inspires report_abort, which
allows us to report a message, using the current prefix, that
we're aborting (outputs ABORT vs. PASS/FAIL). This is useful
for cases when unit tests can't complete due to missing
dependencies of some sort, such as missing/invalid inputs from
the user.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 arm/selftest.c               | 45 ++++++++++++++------------------------------
 config/config-arm-common.mak |  1 +
 lib/libcflat.h               | 11 ++++++-----
 lib/report.c                 | 16 ++++++++++++++++
 lib/util.c                   | 18 ++++++++++++++++++
 lib/util.h                   | 23 ++++++++++++++++++++++
 6 files changed, 78 insertions(+), 36 deletions(-)
 create mode 100644 lib/util.c
 create mode 100644 lib/util.h

diff --git a/arm/selftest.c b/arm/selftest.c
index aad7eecd529ad..8a68f8bf25167 100644
--- a/arm/selftest.c
+++ b/arm/selftest.c
@@ -6,6 +6,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
+#include <util.h>
 #include <alloc.h>
 #include <devicetree.h>
 #include <asm/setup.h>
@@ -18,43 +19,21 @@
 #include <asm/cpumask.h>
 #include <asm/barrier.h>
 
-static void assert_args(int num_args, int needed_args)
-{
-	if (num_args < needed_args) {
-		printf("selftest: not enough arguments\n");
-		abort();
-	}
-}
-
-static char *split_var(char *s, long *val)
-{
-	char *p;
-
-	p = strchr(s, '=');
-	if (!p)
-		return NULL;
-
-	*val = atol(p+1);
-	*p = '\0';
-
-	return s;
-}
-
 static void check_setup(int argc, char **argv)
 {
-	int nr_tests = 0, i;
-	char *var;
+	int nr_tests = 0, len, i;
 	long val;
 
 	for (i = 0; i < argc; ++i) {
 
-		var = split_var(argv[i], &val);
-		if (!var)
+		len = parse_keyval(argv[i], &val);
+		if (len = -1)
 			continue;
 
-		report_prefix_push(var);
+		argv[i][len] = '\0';
+		report_prefix_push(argv[i]);
 
-		if (strcmp(var, "mem") = 0) {
+		if (strcmp(argv[i], "mem") = 0) {
 
 			phys_addr_t memsize = PHYS_END - PHYS_OFFSET;
 			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
@@ -63,7 +42,7 @@ static void check_setup(int argc, char **argv)
 							memsize/1024/1024);
 			++nr_tests;
 
-		} else if (strcmp(var, "smp") = 0) {
+		} else if (strcmp(argv[i], "smp") = 0) {
 
 			report("nr_cpus = %d", nr_cpus = (int)val, nr_cpus);
 			++nr_tests;
@@ -72,7 +51,8 @@ static void check_setup(int argc, char **argv)
 		report_prefix_pop();
 	}
 
-	assert_args(nr_tests, 2);
+	if (nr_tests < 2)
+		report_abort("missing input");
 }
 
 static struct pt_regs expected_regs;
@@ -343,7 +323,10 @@ static void cpu_report(void)
 int main(int argc, char **argv)
 {
 	report_prefix_push("selftest");
-	assert_args(argc, 1);
+
+	if (argc < 1)
+		report_abort("no test specified");
+
 	report_prefix_push(argv[0]);
 
 	if (strcmp(argv[0], "setup") = 0) {
diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
index 698555d6a676f..bd153cf6ea5ba 100644
--- a/config/config-arm-common.mak
+++ b/config/config-arm-common.mak
@@ -27,6 +27,7 @@ CFLAGS += -I lib -I lib/libfdt
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include config/asm-offsets.mak
 
+cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/virtio.o
diff --git a/lib/libcflat.h b/lib/libcflat.h
index 9747ccdbc9f1d..8411f6c5d92e3 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -57,11 +57,12 @@ extern int snprintf(char *buf, int size, const char *fmt, ...);
 extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
 extern long atol(const char *ptr);
 
-void report_prefix_push(const char *prefix);
-void report_prefix_pop(void);
-void report(const char *msg_fmt, bool pass, ...);
-void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
-int report_summary(void);
+extern void report_prefix_push(const char *prefix);
+extern void report_prefix_pop(void);
+extern void report(const char *msg_fmt, bool pass, ...);
+extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
+extern void report_abort(const char *msg_fmt, ...);
+extern int report_summary(void);
 
 #define ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
 
diff --git a/lib/report.c b/lib/report.c
index 35e664108a921..62916c4ac3c8a 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -96,3 +96,19 @@ int report_summary(void)
 
 	spin_unlock(&lock);
 }
+
+void report_abort(const char *msg_fmt, ...)
+{
+	va_list va;
+	char buf[2000];
+
+	puts("ABORT: ");
+	puts(prefixes);
+	va_start(va, msg_fmt);
+	vsnprintf(buf, sizeof(buf), msg_fmt, va);
+	va_end(va);
+	puts(buf);
+	puts("\n");
+	report_summary();
+	abort();
+}
diff --git a/lib/util.c b/lib/util.c
new file mode 100644
index 0000000000000..69b18100c9722
--- /dev/null
+++ b/lib/util.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+int parse_keyval(char *s, long *val)
+{
+	char *p;
+
+	p = strchr(s, '=');
+	if (!p)
+		return -1;
+
+	*val = atol(p+1);
+	return p - s;
+}
diff --git a/lib/util.h b/lib/util.h
new file mode 100644
index 0000000000000..5b07626175bab
--- /dev/null
+++ b/lib/util.h
@@ -0,0 +1,23 @@
+#ifndef _UTIL_H_
+#define _UTIL_H_
+/*
+ * Collection of utility functions to share between unit tests.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+/*
+ * parse_keyval extracts the integer from a string formatted as
+ * string=integer. This is useful for passing expected values in
+ * to the unit test on the command line, i.e. it helps parse QEMU
+ * command lines that include something like -append var1=1 var2=2
+ * @s is the input string, likely a command line parameter, and
+ * @val is a pointer to where the integer will be stored.
+ *
+ * Returns the offset of the '=', or -1 if no keyval pair is found.
+ */
+extern int parse_keyval(char *s, long *val);
+
+#endif
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 03/14] config: no need to mix arch makefiles
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Move the config/config-*.mak files to their own directories and
rename to Makefile.* README is also updated to reflect the change,
as well as to remove an optimistic reference to a non-existent
docs directory.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 Makefile                                            | 2 +-
 README                                              | 3 +--
 arm/Makefile                                        | 1 +
 config/config-arm.mak => arm/Makefile.arm           | 2 +-
 config/config-arm64.mak => arm/Makefile.arm64       | 2 +-
 config/config-arm-common.mak => arm/Makefile.common | 2 +-
 {config => scripts}/asm-offsets.mak                 | 0
 x86/Makefile                                        | 1 +
 config/config-x86-common.mak => x86/Makefile.common | 0
 config/config-i386.mak => x86/Makefile.i386         | 2 +-
 config/config-x86_64.mak => x86/Makefile.x86_64     | 2 +-
 11 files changed, 9 insertions(+), 8 deletions(-)
 create mode 100644 arm/Makefile
 rename config/config-arm.mak => arm/Makefile.arm (90%)
 rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
 rename config/config-arm-common.mak => arm/Makefile.common (98%)
 rename {config => scripts}/asm-offsets.mak (100%)
 create mode 100644 x86/Makefile
 rename config/config-x86-common.mak => x86/Makefile.common (100%)
 rename config/config-i386.mak => x86/Makefile.i386 (91%)
 rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)

diff --git a/Makefile b/Makefile
index 0be2b6670daf6..eef2188d07a62 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
 LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
 
 #include architecure specific make rules
-include config/config-$(ARCH).mak
+include $(TEST_DIR)/Makefile
 
 # cc-option
 # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
diff --git a/README b/README
index 457bd797362cf..f8f196d90bf10 100644
--- a/README
+++ b/README
@@ -34,8 +34,7 @@ each as a standalone test.
 
 Directory structure:
 .:		configure script, top-level Makefile, and run_tests.sh
-./config:	collection of architecture dependent makefiles
-./docs:		documentation files
+./scripts:	helper scripts for building and running tests
 ./lib:		general architecture neutral services for the tests
 ./lib/<ARCH>:	architecture dependent services for the tests
 ./<ARCH>:	the sources of the tests and the created objects/images
diff --git a/arm/Makefile b/arm/Makefile
new file mode 100644
index 0000000000000..369a38b2d1703
--- /dev/null
+++ b/arm/Makefile
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
diff --git a/config/config-arm.mak b/arm/Makefile.arm
similarity index 90%
rename from config/config-arm.mak
rename to arm/Makefile.arm
index ae6c2e7134883..946422872532d 100644
--- a/config/config-arm.mak
+++ b/arm/Makefile.arm
@@ -18,6 +18,6 @@ cflatobjs += lib/arm/processor.o
 # arm specific tests
 tests =
 
-include config/config-arm-common.mak
+include $(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
diff --git a/config/config-arm64.mak b/arm/Makefile.arm64
similarity index 89%
rename from config/config-arm64.mak
rename to arm/Makefile.arm64
index d61b703c8140e..0b0761c729c7c 100644
--- a/config/config-arm64.mak
+++ b/arm/Makefile.arm64
@@ -14,7 +14,7 @@ cflatobjs += lib/arm64/spinlock.o
 # arm64 specific tests
 tests =
 
-include config/config-arm-common.mak
+include $(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
 	$(RM) lib/arm64/.*.d
diff --git a/config/config-arm-common.mak b/arm/Makefile.common
similarity index 98%
rename from config/config-arm-common.mak
rename to arm/Makefile.common
index bd153cf6ea5ba..dd3a0ca327d06 100644
--- a/config/config-arm-common.mak
+++ b/arm/Makefile.common
@@ -25,7 +25,7 @@ CFLAGS += -O2
 CFLAGS += -I lib -I lib/libfdt
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
-include config/asm-offsets.mak
+include scripts/asm-offsets.mak
 
 cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
diff --git a/config/asm-offsets.mak b/scripts/asm-offsets.mak
similarity index 100%
rename from config/asm-offsets.mak
rename to scripts/asm-offsets.mak
diff --git a/x86/Makefile b/x86/Makefile
new file mode 100644
index 0000000000000..369a38b2d1703
--- /dev/null
+++ b/x86/Makefile
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
diff --git a/config/config-x86-common.mak b/x86/Makefile.common
similarity index 100%
rename from config/config-x86-common.mak
rename to x86/Makefile.common
diff --git a/config/config-i386.mak b/x86/Makefile.i386
similarity index 91%
rename from config/config-i386.mak
rename to x86/Makefile.i386
index e353387551585..8a4c45c457476 100644
--- a/config/config-i386.mak
+++ b/x86/Makefile.i386
@@ -8,7 +8,7 @@ cflatobjs += lib/x86/setjmp32.o
 tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \
 	$(TEST_DIR)/cmpxchg8b.flat
 
-include config/config-x86-common.mak
+include $(TEST_DIR)/Makefile.common
 
 $(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o
 $(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o
diff --git a/config/config-x86_64.mak b/x86/Makefile.x86_64
similarity index 93%
rename from config/config-x86_64.mak
rename to x86/Makefile.x86_64
index d190be82e0cf2..6b7ccfba550b6 100644
--- a/config/config-x86_64.mak
+++ b/x86/Makefile.x86_64
@@ -15,4 +15,4 @@ tests += $(TEST_DIR)/svm.flat
 tests += $(TEST_DIR)/vmx.flat
 tests += $(TEST_DIR)/tscdeadline_latency.flat
 
-include config/config-x86-common.mak
+include $(TEST_DIR)/Makefile.common
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 03/14] config: no need to mix arch makefiles
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Move the config/config-*.mak files to their own directories and
rename to Makefile.* README is also updated to reflect the change,
as well as to remove an optimistic reference to a non-existent
docs directory.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 Makefile                                            | 2 +-
 README                                              | 3 +--
 arm/Makefile                                        | 1 +
 config/config-arm.mak => arm/Makefile.arm           | 2 +-
 config/config-arm64.mak => arm/Makefile.arm64       | 2 +-
 config/config-arm-common.mak => arm/Makefile.common | 2 +-
 {config => scripts}/asm-offsets.mak                 | 0
 x86/Makefile                                        | 1 +
 config/config-x86-common.mak => x86/Makefile.common | 0
 config/config-i386.mak => x86/Makefile.i386         | 2 +-
 config/config-x86_64.mak => x86/Makefile.x86_64     | 2 +-
 11 files changed, 9 insertions(+), 8 deletions(-)
 create mode 100644 arm/Makefile
 rename config/config-arm.mak => arm/Makefile.arm (90%)
 rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
 rename config/config-arm-common.mak => arm/Makefile.common (98%)
 rename {config => scripts}/asm-offsets.mak (100%)
 create mode 100644 x86/Makefile
 rename config/config-x86-common.mak => x86/Makefile.common (100%)
 rename config/config-i386.mak => x86/Makefile.i386 (91%)
 rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)

diff --git a/Makefile b/Makefile
index 0be2b6670daf6..eef2188d07a62 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
 LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
 
 #include architecure specific make rules
-include config/config-$(ARCH).mak
+include $(TEST_DIR)/Makefile
 
 # cc-option
 # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
diff --git a/README b/README
index 457bd797362cf..f8f196d90bf10 100644
--- a/README
+++ b/README
@@ -34,8 +34,7 @@ each as a standalone test.
 
 Directory structure:
 .:		configure script, top-level Makefile, and run_tests.sh
-./config:	collection of architecture dependent makefiles
-./docs:		documentation files
+./scripts:	helper scripts for building and running tests
 ./lib:		general architecture neutral services for the tests
 ./lib/<ARCH>:	architecture dependent services for the tests
 ./<ARCH>:	the sources of the tests and the created objects/images
diff --git a/arm/Makefile b/arm/Makefile
new file mode 100644
index 0000000000000..369a38b2d1703
--- /dev/null
+++ b/arm/Makefile
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
diff --git a/config/config-arm.mak b/arm/Makefile.arm
similarity index 90%
rename from config/config-arm.mak
rename to arm/Makefile.arm
index ae6c2e7134883..946422872532d 100644
--- a/config/config-arm.mak
+++ b/arm/Makefile.arm
@@ -18,6 +18,6 @@ cflatobjs += lib/arm/processor.o
 # arm specific tests
 tests  
-include config/config-arm-common.mak
+include $(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
diff --git a/config/config-arm64.mak b/arm/Makefile.arm64
similarity index 89%
rename from config/config-arm64.mak
rename to arm/Makefile.arm64
index d61b703c8140e..0b0761c729c7c 100644
--- a/config/config-arm64.mak
+++ b/arm/Makefile.arm64
@@ -14,7 +14,7 @@ cflatobjs += lib/arm64/spinlock.o
 # arm64 specific tests
 tests  
-include config/config-arm-common.mak
+include $(TEST_DIR)/Makefile.common
 
 arch_clean: arm_clean
 	$(RM) lib/arm64/.*.d
diff --git a/config/config-arm-common.mak b/arm/Makefile.common
similarity index 98%
rename from config/config-arm-common.mak
rename to arm/Makefile.common
index bd153cf6ea5ba..dd3a0ca327d06 100644
--- a/config/config-arm-common.mak
+++ b/arm/Makefile.common
@@ -25,7 +25,7 @@ CFLAGS += -O2
 CFLAGS += -I lib -I lib/libfdt
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
-include config/asm-offsets.mak
+include scripts/asm-offsets.mak
 
 cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
diff --git a/config/asm-offsets.mak b/scripts/asm-offsets.mak
similarity index 100%
rename from config/asm-offsets.mak
rename to scripts/asm-offsets.mak
diff --git a/x86/Makefile b/x86/Makefile
new file mode 100644
index 0000000000000..369a38b2d1703
--- /dev/null
+++ b/x86/Makefile
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
diff --git a/config/config-x86-common.mak b/x86/Makefile.common
similarity index 100%
rename from config/config-x86-common.mak
rename to x86/Makefile.common
diff --git a/config/config-i386.mak b/x86/Makefile.i386
similarity index 91%
rename from config/config-i386.mak
rename to x86/Makefile.i386
index e353387551585..8a4c45c457476 100644
--- a/config/config-i386.mak
+++ b/x86/Makefile.i386
@@ -8,7 +8,7 @@ cflatobjs += lib/x86/setjmp32.o
 tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \
 	$(TEST_DIR)/cmpxchg8b.flat
 
-include config/config-x86-common.mak
+include $(TEST_DIR)/Makefile.common
 
 $(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o
 $(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o
diff --git a/config/config-x86_64.mak b/x86/Makefile.x86_64
similarity index 93%
rename from config/config-x86_64.mak
rename to x86/Makefile.x86_64
index d190be82e0cf2..6b7ccfba550b6 100644
--- a/config/config-x86_64.mak
+++ b/x86/Makefile.x86_64
@@ -15,4 +15,4 @@ tests += $(TEST_DIR)/svm.flat
 tests += $(TEST_DIR)/vmx.flat
 tests += $(TEST_DIR)/tscdeadline_latency.flat
 
-include config/config-x86-common.mak
+include $(TEST_DIR)/Makefile.common
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 04/14] powerpc/ppc64: start skeleton framework
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Use the arm/arm64 framework as a template to start a skeleton
for powerpc/ppc64. Copy the arm makefiles and linker script
verbatim. We'll modify them for powerpc with the next patch,
making it clear what needs to be changed.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure                   |  2 ++
 lib/powerpc/.gitignore      |  1 +
 lib/powerpc/io.c            | 20 +++++++++++++
 lib/powerpc/mmu.c           |  0
 lib/powerpc/setup.c         |  0
 lib/powerpc/smp.c           |  0
 lib/ppc64/.gitignore        |  1 +
 lib/ppc64/asm-offsets.c     | 12 ++++++++
 lib/ppc64/asm/asm-offsets.h |  1 +
 lib/ppc64/asm/io.h          |  5 ++++
 lib/ppc64/asm/page.h        |  1 +
 lib/ppc64/asm/spinlock.h    | 11 +++++++
 lib/ppc64/processor.c       |  0
 lib/ppc64/spinlock.c        | 11 +++++++
 powerpc/Makefile            |  1 +
 powerpc/Makefile.common     | 73 +++++++++++++++++++++++++++++++++++++++++++++
 powerpc/Makefile.ppc64      | 20 +++++++++++++
 powerpc/cstart64.S          | 19 ++++++++++++
 powerpc/flat.lds            | 27 +++++++++++++++++
 powerpc/selftest.c          |  7 +++++
 20 files changed, 212 insertions(+)
 create mode 100644 lib/powerpc/.gitignore
 create mode 100644 lib/powerpc/io.c
 create mode 100644 lib/powerpc/mmu.c
 create mode 100644 lib/powerpc/setup.c
 create mode 100644 lib/powerpc/smp.c
 create mode 100644 lib/ppc64/.gitignore
 create mode 100644 lib/ppc64/asm-offsets.c
 create mode 100644 lib/ppc64/asm/asm-offsets.h
 create mode 100644 lib/ppc64/asm/io.h
 create mode 100644 lib/ppc64/asm/page.h
 create mode 100644 lib/ppc64/asm/spinlock.h
 create mode 100644 lib/ppc64/processor.c
 create mode 100644 lib/ppc64/spinlock.c
 create mode 100644 powerpc/Makefile
 create mode 100644 powerpc/Makefile.common
 create mode 100644 powerpc/Makefile.ppc64
 create mode 100644 powerpc/cstart64.S
 create mode 100644 powerpc/flat.lds
 create mode 100644 powerpc/selftest.c

diff --git a/configure b/configure
index 078b70ce096a6..b367224093369 100755
--- a/configure
+++ b/configure
@@ -80,6 +80,8 @@ if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
     testdir=x86
 elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
     testdir=arm
+elif [ "$arch" = "ppc64" ]; then
+    testdir=powerpc
 else
     testdir=$arch
 fi
diff --git a/lib/powerpc/.gitignore b/lib/powerpc/.gitignore
new file mode 100644
index 0000000000000..84872bf197c67
--- /dev/null
+++ b/lib/powerpc/.gitignore
@@ -0,0 +1 @@
+asm-offsets.[hs]
diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
new file mode 100644
index 0000000000000..0af45742fc900
--- /dev/null
+++ b/lib/powerpc/io.c
@@ -0,0 +1,20 @@
+/*
+ * Each architecture must implement puts() and exit().
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+void io_init(void)
+{
+}
+
+void puts(const char *s __unused)
+{
+}
+
+void exit(int code __unused)
+{
+}
diff --git a/lib/powerpc/mmu.c b/lib/powerpc/mmu.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/powerpc/smp.c b/lib/powerpc/smp.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/ppc64/.gitignore b/lib/ppc64/.gitignore
new file mode 100644
index 0000000000000..84872bf197c67
--- /dev/null
+++ b/lib/ppc64/.gitignore
@@ -0,0 +1 @@
+asm-offsets.[hs]
diff --git a/lib/ppc64/asm-offsets.c b/lib/ppc64/asm-offsets.c
new file mode 100644
index 0000000000000..2d38a716976f2
--- /dev/null
+++ b/lib/ppc64/asm-offsets.c
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <kbuild.h>
+
+int main(void)
+{
+	return 0;
+}
diff --git a/lib/ppc64/asm/asm-offsets.h b/lib/ppc64/asm/asm-offsets.h
new file mode 100644
index 0000000000000..d370ee36a182b
--- /dev/null
+++ b/lib/ppc64/asm/asm-offsets.h
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
new file mode 100644
index 0000000000000..c0801d4762ba6
--- /dev/null
+++ b/lib/ppc64/asm/io.h
@@ -0,0 +1,5 @@
+#ifndef _ASMPPC64_IO_H_
+#define _ASMPPC64_IO_H_
+#define __cpu_is_be() (1)
+#include <asm-generic/io.h>
+#endif
diff --git a/lib/ppc64/asm/page.h b/lib/ppc64/asm/page.h
new file mode 100644
index 0000000000000..1a8b62711f288
--- /dev/null
+++ b/lib/ppc64/asm/page.h
@@ -0,0 +1 @@
+#include <asm-generic/page.h>
diff --git a/lib/ppc64/asm/spinlock.h b/lib/ppc64/asm/spinlock.h
new file mode 100644
index 0000000000000..002cdb194b1db
--- /dev/null
+++ b/lib/ppc64/asm/spinlock.h
@@ -0,0 +1,11 @@
+#ifndef _ASMPPC64_SPINLOCK_H_
+#define _ASMPPC64_SPINLOCK_H_
+
+struct spinlock {
+	int v;
+};
+
+extern void spin_lock(struct spinlock *lock);
+extern void spin_unlock(struct spinlock *lock);
+
+#endif /* _ASMPPC64_SPINLOCK_H_ */
diff --git a/lib/ppc64/processor.c b/lib/ppc64/processor.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/ppc64/spinlock.c b/lib/ppc64/spinlock.c
new file mode 100644
index 0000000000000..522f8d047c970
--- /dev/null
+++ b/lib/ppc64/spinlock.c
@@ -0,0 +1,11 @@
+#include <asm/spinlock.h>
+
+void spin_lock(struct spinlock *lock)
+{
+        lock->v = 1;
+}
+
+void spin_unlock(struct spinlock *lock)
+{
+        lock->v = 0;
+}
diff --git a/powerpc/Makefile b/powerpc/Makefile
new file mode 100644
index 0000000000000..369a38b2d1703
--- /dev/null
+++ b/powerpc/Makefile
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
new file mode 100644
index 0000000000000..dd3a0ca327d06
--- /dev/null
+++ b/powerpc/Makefile.common
@@ -0,0 +1,73 @@
+#
+# arm common makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+
+ifeq ($(LOADADDR),)
+	# qemu mach-virt default load address
+	LOADADDR = 0x40000000
+endif
+
+tests-common = \
+	$(TEST_DIR)/selftest.flat \
+	$(TEST_DIR)/spinlock-test.flat
+
+all: test_cases
+
+##################################################################
+phys_base = $(LOADADDR)
+
+CFLAGS += -std=gnu99
+CFLAGS += -ffreestanding
+CFLAGS += -Wextra
+CFLAGS += -O2
+CFLAGS += -I lib -I lib/libfdt
+
+asm-offsets = lib/$(ARCH)/asm-offsets.h
+include scripts/asm-offsets.mak
+
+cflatobjs += lib/util.o
+cflatobjs += lib/alloc.o
+cflatobjs += lib/devicetree.o
+cflatobjs += lib/virtio.o
+cflatobjs += lib/virtio-mmio.o
+cflatobjs += lib/chr-testdev.o
+cflatobjs += lib/arm/io.o
+cflatobjs += lib/arm/setup.o
+cflatobjs += lib/arm/mmu.o
+cflatobjs += lib/arm/bitops.o
+cflatobjs += lib/arm/psci.o
+cflatobjs += lib/arm/smp.o
+
+libeabi = lib/arm/libeabi.a
+eabiobjs = lib/arm/eabi_compat.o
+
+libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
+start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
+
+FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
+%.elf: LDFLAGS = $(CFLAGS) -nostdlib
+%.elf: %.o $(FLATLIBS) arm/flat.lds
+	$(CC) $(LDFLAGS) -o $@ \
+		-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
+		$(filter %.o, $^) $(FLATLIBS)
+
+%.flat: %.elf
+	$(OBJCOPY) -O binary $^ $@
+
+$(libeabi): $(eabiobjs)
+	$(AR) rcs $@ $^
+
+arm_clean: libfdt_clean asm_offsets_clean
+	$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
+	      $(TEST_DIR)/.*.d lib/arm/.*.d
+
+##################################################################
+
+generated_files = $(asm-offsets)
+
+test_cases: $(generated_files) $(tests-common) $(tests)
+
+$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
+$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
new file mode 100644
index 0000000000000..0b0761c729c7c
--- /dev/null
+++ b/powerpc/Makefile.ppc64
@@ -0,0 +1,20 @@
+#
+# arm64 makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+bits = 64
+ldarch = elf64-littleaarch64
+kernel_offset = 0x80000
+
+cstart.o = $(TEST_DIR)/cstart64.o
+cflatobjs += lib/arm64/processor.o
+cflatobjs += lib/arm64/spinlock.o
+
+# arm64 specific tests
+tests =
+
+include $(TEST_DIR)/Makefile.common
+
+arch_clean: arm_clean
+	$(RM) lib/arm64/.*.d
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
new file mode 100644
index 0000000000000..4692f2d9d057e
--- /dev/null
+++ b/powerpc/cstart64.S
@@ -0,0 +1,19 @@
+/*
+ * Entry point and assembler functions for ppc64 tests.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+.section .init
+
+.globl start
+start:
+	b	halt
+
+.text
+
+.globl halt
+halt:
+1:	b	1b
diff --git a/powerpc/flat.lds b/powerpc/flat.lds
new file mode 100644
index 0000000000000..efdf5d7109ffb
--- /dev/null
+++ b/powerpc/flat.lds
@@ -0,0 +1,27 @@
+
+SECTIONS
+{
+    .text : { *(.init) *(.text) *(.text.*) }
+    . = ALIGN(64K);
+    etext = .;
+    .data : {
+        *(.data)
+    }
+    . = ALIGN(16);
+    .rodata : { *(.rodata) }
+    . = ALIGN(16);
+    .bss : { *(.bss) }
+    . = ALIGN(64K);
+    edata = .;
+    . += 64K;
+    . = ALIGN(64K);
+    /*
+     * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE
+     * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm
+     * sp must always be strictly less than the true stacktop
+     */
+    stackptr = . - 16;
+    stacktop = .;
+}
+
+ENTRY(start)
diff --git a/powerpc/selftest.c b/powerpc/selftest.c
new file mode 100644
index 0000000000000..2f2a5215dd55c
--- /dev/null
+++ b/powerpc/selftest.c
@@ -0,0 +1,7 @@
+#include <libcflat.h>
+
+int main(void)
+{
+	printf("hello world\n");
+	return 0;
+}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 04/14] powerpc/ppc64: start skeleton framework
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Use the arm/arm64 framework as a template to start a skeleton
for powerpc/ppc64. Copy the arm makefiles and linker script
verbatim. We'll modify them for powerpc with the next patch,
making it clear what needs to be changed.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure                   |  2 ++
 lib/powerpc/.gitignore      |  1 +
 lib/powerpc/io.c            | 20 +++++++++++++
 lib/powerpc/mmu.c           |  0
 lib/powerpc/setup.c         |  0
 lib/powerpc/smp.c           |  0
 lib/ppc64/.gitignore        |  1 +
 lib/ppc64/asm-offsets.c     | 12 ++++++++
 lib/ppc64/asm/asm-offsets.h |  1 +
 lib/ppc64/asm/io.h          |  5 ++++
 lib/ppc64/asm/page.h        |  1 +
 lib/ppc64/asm/spinlock.h    | 11 +++++++
 lib/ppc64/processor.c       |  0
 lib/ppc64/spinlock.c        | 11 +++++++
 powerpc/Makefile            |  1 +
 powerpc/Makefile.common     | 73 +++++++++++++++++++++++++++++++++++++++++++++
 powerpc/Makefile.ppc64      | 20 +++++++++++++
 powerpc/cstart64.S          | 19 ++++++++++++
 powerpc/flat.lds            | 27 +++++++++++++++++
 powerpc/selftest.c          |  7 +++++
 20 files changed, 212 insertions(+)
 create mode 100644 lib/powerpc/.gitignore
 create mode 100644 lib/powerpc/io.c
 create mode 100644 lib/powerpc/mmu.c
 create mode 100644 lib/powerpc/setup.c
 create mode 100644 lib/powerpc/smp.c
 create mode 100644 lib/ppc64/.gitignore
 create mode 100644 lib/ppc64/asm-offsets.c
 create mode 100644 lib/ppc64/asm/asm-offsets.h
 create mode 100644 lib/ppc64/asm/io.h
 create mode 100644 lib/ppc64/asm/page.h
 create mode 100644 lib/ppc64/asm/spinlock.h
 create mode 100644 lib/ppc64/processor.c
 create mode 100644 lib/ppc64/spinlock.c
 create mode 100644 powerpc/Makefile
 create mode 100644 powerpc/Makefile.common
 create mode 100644 powerpc/Makefile.ppc64
 create mode 100644 powerpc/cstart64.S
 create mode 100644 powerpc/flat.lds
 create mode 100644 powerpc/selftest.c

diff --git a/configure b/configure
index 078b70ce096a6..b367224093369 100755
--- a/configure
+++ b/configure
@@ -80,6 +80,8 @@ if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
     testdir=x86
 elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
     testdir=arm
+elif [ "$arch" = "ppc64" ]; then
+    testdir=powerpc
 else
     testdir=$arch
 fi
diff --git a/lib/powerpc/.gitignore b/lib/powerpc/.gitignore
new file mode 100644
index 0000000000000..84872bf197c67
--- /dev/null
+++ b/lib/powerpc/.gitignore
@@ -0,0 +1 @@
+asm-offsets.[hs]
diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
new file mode 100644
index 0000000000000..0af45742fc900
--- /dev/null
+++ b/lib/powerpc/io.c
@@ -0,0 +1,20 @@
+/*
+ * Each architecture must implement puts() and exit().
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+void io_init(void)
+{
+}
+
+void puts(const char *s __unused)
+{
+}
+
+void exit(int code __unused)
+{
+}
diff --git a/lib/powerpc/mmu.c b/lib/powerpc/mmu.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/powerpc/smp.c b/lib/powerpc/smp.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/ppc64/.gitignore b/lib/ppc64/.gitignore
new file mode 100644
index 0000000000000..84872bf197c67
--- /dev/null
+++ b/lib/ppc64/.gitignore
@@ -0,0 +1 @@
+asm-offsets.[hs]
diff --git a/lib/ppc64/asm-offsets.c b/lib/ppc64/asm-offsets.c
new file mode 100644
index 0000000000000..2d38a716976f2
--- /dev/null
+++ b/lib/ppc64/asm-offsets.c
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <kbuild.h>
+
+int main(void)
+{
+	return 0;
+}
diff --git a/lib/ppc64/asm/asm-offsets.h b/lib/ppc64/asm/asm-offsets.h
new file mode 100644
index 0000000000000..d370ee36a182b
--- /dev/null
+++ b/lib/ppc64/asm/asm-offsets.h
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
new file mode 100644
index 0000000000000..c0801d4762ba6
--- /dev/null
+++ b/lib/ppc64/asm/io.h
@@ -0,0 +1,5 @@
+#ifndef _ASMPPC64_IO_H_
+#define _ASMPPC64_IO_H_
+#define __cpu_is_be() (1)
+#include <asm-generic/io.h>
+#endif
diff --git a/lib/ppc64/asm/page.h b/lib/ppc64/asm/page.h
new file mode 100644
index 0000000000000..1a8b62711f288
--- /dev/null
+++ b/lib/ppc64/asm/page.h
@@ -0,0 +1 @@
+#include <asm-generic/page.h>
diff --git a/lib/ppc64/asm/spinlock.h b/lib/ppc64/asm/spinlock.h
new file mode 100644
index 0000000000000..002cdb194b1db
--- /dev/null
+++ b/lib/ppc64/asm/spinlock.h
@@ -0,0 +1,11 @@
+#ifndef _ASMPPC64_SPINLOCK_H_
+#define _ASMPPC64_SPINLOCK_H_
+
+struct spinlock {
+	int v;
+};
+
+extern void spin_lock(struct spinlock *lock);
+extern void spin_unlock(struct spinlock *lock);
+
+#endif /* _ASMPPC64_SPINLOCK_H_ */
diff --git a/lib/ppc64/processor.c b/lib/ppc64/processor.c
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/lib/ppc64/spinlock.c b/lib/ppc64/spinlock.c
new file mode 100644
index 0000000000000..522f8d047c970
--- /dev/null
+++ b/lib/ppc64/spinlock.c
@@ -0,0 +1,11 @@
+#include <asm/spinlock.h>
+
+void spin_lock(struct spinlock *lock)
+{
+        lock->v = 1;
+}
+
+void spin_unlock(struct spinlock *lock)
+{
+        lock->v = 0;
+}
diff --git a/powerpc/Makefile b/powerpc/Makefile
new file mode 100644
index 0000000000000..369a38b2d1703
--- /dev/null
+++ b/powerpc/Makefile
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
new file mode 100644
index 0000000000000..dd3a0ca327d06
--- /dev/null
+++ b/powerpc/Makefile.common
@@ -0,0 +1,73 @@
+#
+# arm common makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+
+ifeq ($(LOADADDR),)
+	# qemu mach-virt default load address
+	LOADADDR = 0x40000000
+endif
+
+tests-common = \
+	$(TEST_DIR)/selftest.flat \
+	$(TEST_DIR)/spinlock-test.flat
+
+all: test_cases
+
+##################################################################
+phys_base = $(LOADADDR)
+
+CFLAGS += -std=gnu99
+CFLAGS += -ffreestanding
+CFLAGS += -Wextra
+CFLAGS += -O2
+CFLAGS += -I lib -I lib/libfdt
+
+asm-offsets = lib/$(ARCH)/asm-offsets.h
+include scripts/asm-offsets.mak
+
+cflatobjs += lib/util.o
+cflatobjs += lib/alloc.o
+cflatobjs += lib/devicetree.o
+cflatobjs += lib/virtio.o
+cflatobjs += lib/virtio-mmio.o
+cflatobjs += lib/chr-testdev.o
+cflatobjs += lib/arm/io.o
+cflatobjs += lib/arm/setup.o
+cflatobjs += lib/arm/mmu.o
+cflatobjs += lib/arm/bitops.o
+cflatobjs += lib/arm/psci.o
+cflatobjs += lib/arm/smp.o
+
+libeabi = lib/arm/libeabi.a
+eabiobjs = lib/arm/eabi_compat.o
+
+libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
+start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
+
+FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
+%.elf: LDFLAGS = $(CFLAGS) -nostdlib
+%.elf: %.o $(FLATLIBS) arm/flat.lds
+	$(CC) $(LDFLAGS) -o $@ \
+		-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
+		$(filter %.o, $^) $(FLATLIBS)
+
+%.flat: %.elf
+	$(OBJCOPY) -O binary $^ $@
+
+$(libeabi): $(eabiobjs)
+	$(AR) rcs $@ $^
+
+arm_clean: libfdt_clean asm_offsets_clean
+	$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
+	      $(TEST_DIR)/.*.d lib/arm/.*.d
+
+##################################################################
+
+generated_files = $(asm-offsets)
+
+test_cases: $(generated_files) $(tests-common) $(tests)
+
+$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
+$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
new file mode 100644
index 0000000000000..0b0761c729c7c
--- /dev/null
+++ b/powerpc/Makefile.ppc64
@@ -0,0 +1,20 @@
+#
+# arm64 makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+bits = 64
+ldarch = elf64-littleaarch64
+kernel_offset = 0x80000
+
+cstart.o = $(TEST_DIR)/cstart64.o
+cflatobjs += lib/arm64/processor.o
+cflatobjs += lib/arm64/spinlock.o
+
+# arm64 specific tests
+tests +
+include $(TEST_DIR)/Makefile.common
+
+arch_clean: arm_clean
+	$(RM) lib/arm64/.*.d
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
new file mode 100644
index 0000000000000..4692f2d9d057e
--- /dev/null
+++ b/powerpc/cstart64.S
@@ -0,0 +1,19 @@
+/*
+ * Entry point and assembler functions for ppc64 tests.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+.section .init
+
+.globl start
+start:
+	b	halt
+
+.text
+
+.globl halt
+halt:
+1:	b	1b
diff --git a/powerpc/flat.lds b/powerpc/flat.lds
new file mode 100644
index 0000000000000..efdf5d7109ffb
--- /dev/null
+++ b/powerpc/flat.lds
@@ -0,0 +1,27 @@
+
+SECTIONS
+{
+    .text : { *(.init) *(.text) *(.text.*) }
+    . = ALIGN(64K);
+    etext = .;
+    .data : {
+        *(.data)
+    }
+    . = ALIGN(16);
+    .rodata : { *(.rodata) }
+    . = ALIGN(16);
+    .bss : { *(.bss) }
+    . = ALIGN(64K);
+    edata = .;
+    . += 64K;
+    . = ALIGN(64K);
+    /*
+     * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE
+     * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm
+     * sp must always be strictly less than the true stacktop
+     */
+    stackptr = . - 16;
+    stacktop = .;
+}
+
+ENTRY(start)
diff --git a/powerpc/selftest.c b/powerpc/selftest.c
new file mode 100644
index 0000000000000..2f2a5215dd55c
--- /dev/null
+++ b/powerpc/selftest.c
@@ -0,0 +1,7 @@
+#include <libcflat.h>
+
+int main(void)
+{
+	printf("hello world\n");
+	return 0;
+}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 05/14] powerpc/pp64: ppc-ify makefiles and linker script
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/Makefile.common | 43 +++++++++++++------------------------------
 powerpc/Makefile.ppc64  | 16 ++++++++--------
 powerpc/flat.lds        | 14 ++++++++++----
 3 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index dd3a0ca327d06..cc1a521f1a269 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -1,17 +1,15 @@
 #
-# arm common makefile
+# powerpc common makefile
 #
 # Authors: Andrew Jones <drjones@redhat.com>
 #
 
 ifeq ($(LOADADDR),)
-	# qemu mach-virt default load address
-	LOADADDR = 0x40000000
+	LOADADDR = 0x0
 endif
 
 tests-common = \
-	$(TEST_DIR)/selftest.flat \
-	$(TEST_DIR)/spinlock-test.flat
+	$(TEST_DIR)/selftest.elf
 
 all: test_cases
 
@@ -30,38 +28,24 @@ include scripts/asm-offsets.mak
 cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
-cflatobjs += lib/virtio.o
-cflatobjs += lib/virtio-mmio.o
-cflatobjs += lib/chr-testdev.o
-cflatobjs += lib/arm/io.o
-cflatobjs += lib/arm/setup.o
-cflatobjs += lib/arm/mmu.o
-cflatobjs += lib/arm/bitops.o
-cflatobjs += lib/arm/psci.o
-cflatobjs += lib/arm/smp.o
-
-libeabi = lib/arm/libeabi.a
-eabiobjs = lib/arm/eabi_compat.o
+cflatobjs += lib/powerpc/io.o
+cflatobjs += lib/powerpc/setup.o
+cflatobjs += lib/powerpc/mmu.o
+cflatobjs += lib/powerpc/smp.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
 
-FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
+FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc)
 %.elf: LDFLAGS = $(CFLAGS) -nostdlib
-%.elf: %.o $(FLATLIBS) arm/flat.lds
+%.elf: %.o $(FLATLIBS) powerpc/flat.lds
 	$(CC) $(LDFLAGS) -o $@ \
-		-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
+		-Wl,-T,powerpc/flat.lds,--build-id=none,-Ttext=$(start_addr) \
 		$(filter %.o, $^) $(FLATLIBS)
 
-%.flat: %.elf
-	$(OBJCOPY) -O binary $^ $@
-
-$(libeabi): $(eabiobjs)
-	$(AR) rcs $@ $^
-
-arm_clean: libfdt_clean asm_offsets_clean
-	$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
-	      $(TEST_DIR)/.*.d lib/arm/.*.d
+powerpc_clean: libfdt_clean asm_offsets_clean
+	$(RM) $(TEST_DIR)/*.{o,elf} \
+	      $(TEST_DIR)/.*.d lib/powerpc/.*.d
 
 ##################################################################
 
@@ -70,4 +54,3 @@ generated_files = $(asm-offsets)
 test_cases: $(generated_files) $(tests-common) $(tests)
 
 $(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
-$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 0b0761c729c7c..e9aa9f560204a 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -1,20 +1,20 @@
 #
-# arm64 makefile
+# ppc64 makefile
 #
 # Authors: Andrew Jones <drjones@redhat.com>
 #
 bits = 64
-ldarch = elf64-littleaarch64
-kernel_offset = 0x80000
+ldarch = elf64-powerpc
+kernel_offset = 0x0
 
 cstart.o = $(TEST_DIR)/cstart64.o
-cflatobjs += lib/arm64/processor.o
-cflatobjs += lib/arm64/spinlock.o
+cflatobjs += lib/ppc64/processor.o
+cflatobjs += lib/ppc64/spinlock.o
 
-# arm64 specific tests
+# ppc64 specific tests
 tests =
 
 include $(TEST_DIR)/Makefile.common
 
-arch_clean: arm_clean
-	$(RM) lib/arm64/.*.d
+arch_clean: powerpc_clean
+	$(RM) lib/ppc64/.*.d
diff --git a/powerpc/flat.lds b/powerpc/flat.lds
index efdf5d7109ffb..bd075efb2c51b 100644
--- a/powerpc/flat.lds
+++ b/powerpc/flat.lds
@@ -4,6 +4,8 @@ SECTIONS
     .text : { *(.init) *(.text) *(.text.*) }
     . = ALIGN(64K);
     etext = .;
+    .opd : { *(.opd) }
+    . = ALIGN(16);
     .data : {
         *(.data)
     }
@@ -11,16 +13,20 @@ SECTIONS
     .rodata : { *(.rodata) }
     . = ALIGN(16);
     .bss : { *(.bss) }
+    . = ALIGN(16);
+    /*
+     * tocptr is tocbase + 32K, allowing toc offsets to be +-32K
+     */
+    tocptr = . + 32K;
+    .got : { *(.toc) *(.got) }
     . = ALIGN(64K);
     edata = .;
     . += 64K;
     . = ALIGN(64K);
     /*
-     * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE
-     * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm
-     * sp must always be strictly less than the true stacktop
+     * stackptr set with initial stack frame (64 bytes) preallocated
      */
-    stackptr = . - 16;
+    stackptr = . - 64;
     stacktop = .;
 }
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 05/14] powerpc/pp64: ppc-ify makefiles and linker script
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/Makefile.common | 43 +++++++++++++------------------------------
 powerpc/Makefile.ppc64  | 16 ++++++++--------
 powerpc/flat.lds        | 14 ++++++++++----
 3 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index dd3a0ca327d06..cc1a521f1a269 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -1,17 +1,15 @@
 #
-# arm common makefile
+# powerpc common makefile
 #
 # Authors: Andrew Jones <drjones@redhat.com>
 #
 
 ifeq ($(LOADADDR),)
-	# qemu mach-virt default load address
-	LOADADDR = 0x40000000
+	LOADADDR = 0x0
 endif
 
 tests-common = \
-	$(TEST_DIR)/selftest.flat \
-	$(TEST_DIR)/spinlock-test.flat
+	$(TEST_DIR)/selftest.elf
 
 all: test_cases
 
@@ -30,38 +28,24 @@ include scripts/asm-offsets.mak
 cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
-cflatobjs += lib/virtio.o
-cflatobjs += lib/virtio-mmio.o
-cflatobjs += lib/chr-testdev.o
-cflatobjs += lib/arm/io.o
-cflatobjs += lib/arm/setup.o
-cflatobjs += lib/arm/mmu.o
-cflatobjs += lib/arm/bitops.o
-cflatobjs += lib/arm/psci.o
-cflatobjs += lib/arm/smp.o
-
-libeabi = lib/arm/libeabi.a
-eabiobjs = lib/arm/eabi_compat.o
+cflatobjs += lib/powerpc/io.o
+cflatobjs += lib/powerpc/setup.o
+cflatobjs += lib/powerpc/mmu.o
+cflatobjs += lib/powerpc/smp.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
 
-FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
+FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc)
 %.elf: LDFLAGS = $(CFLAGS) -nostdlib
-%.elf: %.o $(FLATLIBS) arm/flat.lds
+%.elf: %.o $(FLATLIBS) powerpc/flat.lds
 	$(CC) $(LDFLAGS) -o $@ \
-		-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
+		-Wl,-T,powerpc/flat.lds,--build-id=none,-Ttext=$(start_addr) \
 		$(filter %.o, $^) $(FLATLIBS)
 
-%.flat: %.elf
-	$(OBJCOPY) -O binary $^ $@
-
-$(libeabi): $(eabiobjs)
-	$(AR) rcs $@ $^
-
-arm_clean: libfdt_clean asm_offsets_clean
-	$(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \
-	      $(TEST_DIR)/.*.d lib/arm/.*.d
+powerpc_clean: libfdt_clean asm_offsets_clean
+	$(RM) $(TEST_DIR)/*.{o,elf} \
+	      $(TEST_DIR)/.*.d lib/powerpc/.*.d
 
 ##################################################################
 
@@ -70,4 +54,3 @@ generated_files = $(asm-offsets)
 test_cases: $(generated_files) $(tests-common) $(tests)
 
 $(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
-$(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 0b0761c729c7c..e9aa9f560204a 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -1,20 +1,20 @@
 #
-# arm64 makefile
+# ppc64 makefile
 #
 # Authors: Andrew Jones <drjones@redhat.com>
 #
 bits = 64
-ldarch = elf64-littleaarch64
-kernel_offset = 0x80000
+ldarch = elf64-powerpc
+kernel_offset = 0x0
 
 cstart.o = $(TEST_DIR)/cstart64.o
-cflatobjs += lib/arm64/processor.o
-cflatobjs += lib/arm64/spinlock.o
+cflatobjs += lib/ppc64/processor.o
+cflatobjs += lib/ppc64/spinlock.o
 
-# arm64 specific tests
+# ppc64 specific tests
 tests  
 include $(TEST_DIR)/Makefile.common
 
-arch_clean: arm_clean
-	$(RM) lib/arm64/.*.d
+arch_clean: powerpc_clean
+	$(RM) lib/ppc64/.*.d
diff --git a/powerpc/flat.lds b/powerpc/flat.lds
index efdf5d7109ffb..bd075efb2c51b 100644
--- a/powerpc/flat.lds
+++ b/powerpc/flat.lds
@@ -4,6 +4,8 @@ SECTIONS
     .text : { *(.init) *(.text) *(.text.*) }
     . = ALIGN(64K);
     etext = .;
+    .opd : { *(.opd) }
+    . = ALIGN(16);
     .data : {
         *(.data)
     }
@@ -11,16 +13,20 @@ SECTIONS
     .rodata : { *(.rodata) }
     . = ALIGN(16);
     .bss : { *(.bss) }
+    . = ALIGN(16);
+    /*
+     * tocptr is tocbase + 32K, allowing toc offsets to be +-32K
+     */
+    tocptr = . + 32K;
+    .got : { *(.toc) *(.got) }
     . = ALIGN(64K);
     edata = .;
     . += 64K;
     . = ALIGN(64K);
     /*
-     * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE
-     * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm
-     * sp must always be strictly less than the true stacktop
+     * stackptr set with initial stack frame (64 bytes) preallocated
      */
-    stackptr = . - 16;
+    stackptr = . - 64;
     stacktop = .;
 }
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Make a one line replacement for SLOF. This bootloader just
jumps to 0x400000, because we know the kernel will be there.
This commit allows rebuilding of the bootloader, as long
as the SLOF build_romfs tool is present, but since it would be
a pain to require that tool for ever build, we'll just commit
the binary rom image too with the next commit.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/rom/.gitignore |  1 +
 powerpc/rom/Makefile   | 36 ++++++++++++++++++++++++++++++++++++
 powerpc/rom/header.img |  1 +
 powerpc/rom/rom.ffs    |  4 ++++
 powerpc/rom/stage1.S   |  5 +++++
 5 files changed, 47 insertions(+)
 create mode 100644 powerpc/rom/.gitignore
 create mode 100644 powerpc/rom/Makefile
 create mode 100644 powerpc/rom/header.img
 create mode 100644 powerpc/rom/rom.ffs
 create mode 100644 powerpc/rom/stage1.S

diff --git a/powerpc/rom/.gitignore b/powerpc/rom/.gitignore
new file mode 100644
index 0000000000000..a8a0dcec44720
--- /dev/null
+++ b/powerpc/rom/.gitignore
@@ -0,0 +1 @@
+*.bin
diff --git a/powerpc/rom/Makefile b/powerpc/rom/Makefile
new file mode 100644
index 0000000000000..03b8bf7e0b5d2
--- /dev/null
+++ b/powerpc/rom/Makefile
@@ -0,0 +1,36 @@
+#
+# powerpc boot_rom makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+
+# Use SLOF's build_romfs tool (git://git.qemu-project.org/SLOF.git)
+BUILD_ROMFS ?= build_romfs
+
+ifeq ($(wildcard ../../config.mak),)
+$(error run ./configure first. See ./configure -h)
+endif
+
+include ../../config.mak
+
+.PHONY: clean distclean
+
+all: boot_rom.bin
+
+boot_rom.bin: stage1.bin
+	$(BUILD_ROMFS) rom.ffs boot_rom.bin
+
+stage1.bin: stage1.elf
+	$(OBJCOPY) -O binary $^ $@
+
+stage1.elf: stage1.o
+	$(LD) -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
+
+stage1.o: stage1.S
+	$(CC) -c -o $@ $<
+
+clean:
+	$(RM) stage1.{o,elf,bin}
+
+distclean: clean
+	$(RM) boot_rom.bin
diff --git a/powerpc/rom/header.img b/powerpc/rom/header.img
new file mode 100644
index 0000000000000..794129c95eec5
--- /dev/null
+++ b/powerpc/rom/header.img
@@ -0,0 +1 @@
+Key.Polynome....XXXXXXXX..Mask..XXXXXXXX.Polynome.Length....XXXX.Header.and.File.lengthXXXXXXXX... und weiter im Text!
diff --git a/powerpc/rom/rom.ffs b/powerpc/rom/rom.ffs
new file mode 100644
index 0000000000000..b7851c00c462b
--- /dev/null
+++ b/powerpc/rom/rom.ffs
@@ -0,0 +1,4 @@
+# FFile-Name	Real Filename			Flags			ROM-Offset i/a
+#--------------|-------------------------------|-----------------------|--------------
+header		header.img			0			0
+stage1		stage1.bin			1			0x100
diff --git a/powerpc/rom/stage1.S b/powerpc/rom/stage1.S
new file mode 100644
index 0000000000000..ae2c08ddce3c1
--- /dev/null
+++ b/powerpc/rom/stage1.S
@@ -0,0 +1,5 @@
+#define SPAPR_KERNEL_LOAD_ADDR 0x400000
+.text
+.globl start
+start:
+	b	SPAPR_KERNEL_LOAD_ADDR - 0x100
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Make a one line replacement for SLOF. This bootloader just
jumps to 0x400000, because we know the kernel will be there.
This commit allows rebuilding of the bootloader, as long
as the SLOF build_romfs tool is present, but since it would be
a pain to require that tool for ever build, we'll just commit
the binary rom image too with the next commit.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/rom/.gitignore |  1 +
 powerpc/rom/Makefile   | 36 ++++++++++++++++++++++++++++++++++++
 powerpc/rom/header.img |  1 +
 powerpc/rom/rom.ffs    |  4 ++++
 powerpc/rom/stage1.S   |  5 +++++
 5 files changed, 47 insertions(+)
 create mode 100644 powerpc/rom/.gitignore
 create mode 100644 powerpc/rom/Makefile
 create mode 100644 powerpc/rom/header.img
 create mode 100644 powerpc/rom/rom.ffs
 create mode 100644 powerpc/rom/stage1.S

diff --git a/powerpc/rom/.gitignore b/powerpc/rom/.gitignore
new file mode 100644
index 0000000000000..a8a0dcec44720
--- /dev/null
+++ b/powerpc/rom/.gitignore
@@ -0,0 +1 @@
+*.bin
diff --git a/powerpc/rom/Makefile b/powerpc/rom/Makefile
new file mode 100644
index 0000000000000..03b8bf7e0b5d2
--- /dev/null
+++ b/powerpc/rom/Makefile
@@ -0,0 +1,36 @@
+#
+# powerpc boot_rom makefile
+#
+# Authors: Andrew Jones <drjones@redhat.com>
+#
+
+# Use SLOF's build_romfs tool (git://git.qemu-project.org/SLOF.git)
+BUILD_ROMFS ?= build_romfs
+
+ifeq ($(wildcard ../../config.mak),)
+$(error run ./configure first. See ./configure -h)
+endif
+
+include ../../config.mak
+
+.PHONY: clean distclean
+
+all: boot_rom.bin
+
+boot_rom.bin: stage1.bin
+	$(BUILD_ROMFS) rom.ffs boot_rom.bin
+
+stage1.bin: stage1.elf
+	$(OBJCOPY) -O binary $^ $@
+
+stage1.elf: stage1.o
+	$(LD) -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
+
+stage1.o: stage1.S
+	$(CC) -c -o $@ $<
+
+clean:
+	$(RM) stage1.{o,elf,bin}
+
+distclean: clean
+	$(RM) boot_rom.bin
diff --git a/powerpc/rom/header.img b/powerpc/rom/header.img
new file mode 100644
index 0000000000000..794129c95eec5
--- /dev/null
+++ b/powerpc/rom/header.img
@@ -0,0 +1 @@
+Key.Polynome....XXXXXXXX..Mask..XXXXXXXX.Polynome.Length....XXXX.Header.and.File.lengthXXXXXXXX... und weiter im Text!
diff --git a/powerpc/rom/rom.ffs b/powerpc/rom/rom.ffs
new file mode 100644
index 0000000000000..b7851c00c462b
--- /dev/null
+++ b/powerpc/rom/rom.ffs
@@ -0,0 +1,4 @@
+# FFile-Name	Real Filename			Flags			ROM-Offset i/a
+#--------------|-------------------------------|-----------------------|--------------
+header		header.img			0			0
+stage1		stage1.bin			1			0x100
diff --git a/powerpc/rom/stage1.S b/powerpc/rom/stage1.S
new file mode 100644
index 0000000000000..ae2c08ddce3c1
--- /dev/null
+++ b/powerpc/rom/stage1.S
@@ -0,0 +1,5 @@
+#define SPAPR_KERNEL_LOAD_ADDR 0x400000
+.text
+.globl start
+start:
+	b	SPAPR_KERNEL_LOAD_ADDR - 0x100
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 07/14] powerpc/ppc64: add bootloader to bounce into memory
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Committing the binary, since there's little point in rebuilding,
and it requires SLOF's build_romfs tool, which is not part of
this source repository.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/boot_rom.bin | Bin 0 -> 280 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 powerpc/boot_rom.bin

diff --git a/powerpc/boot_rom.bin b/powerpc/boot_rom.bin
new file mode 100644
index 0000000000000000000000000000000000000000..606e1204047afb21e1a90469d7e708496e596e7e
GIT binary patch
literal 280
zcmZQz0D~J4ilGBa!zhi6)Wnq3A_j)s#PrN$LnC8|1fxVsQC5ClYB5Y5Lt$!esR5ja
zjiDgQE-vZ}lQD!bfON3u)_MP-07;mdOctnNj8IymxFj(>73c^L`~P4eWcwelS1bkq
DUsxnq

literal 0
HcmV?d00001

-- 
2.4.3


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 07/14] powerpc/ppc64: add bootloader to bounce into memory
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Committing the binary, since there's little point in rebuilding,
and it requires SLOF's build_romfs tool, which is not part of
this source repository.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/boot_rom.bin | Bin 0 -> 280 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 powerpc/boot_rom.bin

diff --git a/powerpc/boot_rom.bin b/powerpc/boot_rom.bin
new file mode 100644
index 0000000000000000000000000000000000000000..606e1204047afb21e1a90469d7e708496e596e7e
GIT binary patch
literal 280
zcmZQz0D~J4ilGBa!zhi6)Wnq3A_j)s#PrN$LnC8|1fxVsQC5ClYB5Y5Lt$!esR5ja
zjiDgQE-vZ}lQD!bfON3u)_MP-07;mdOctnNj8IymxFj(>73c^L`~P4eWcwelS1bkq
DUsxnq

literal 0
HcmV?d00001

-- 
2.4.3


^ permalink raw reply	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Add the hvcall for putchar and use it in puts. That, along with a
couple more lines in start to prepare for C code, and a branch to
main(), gets us "hello world". Run with

qemu-system-ppc64 -M pseries            \
        -bios powerpc/boot_rom.bin      \
        -display none -serial stdio     \
        -kernel powerpc/selftest.elf

(We're still not relocating yet, that comes in a later patch. Thus,
 testing hello-world at this point requires a hacked QEMU and linking
 the unit test at QEMU's kernel load address.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/io.c        | 15 +++++++++++++--
 powerpc/Makefile.common |  1 +
 powerpc/cstart64.S      | 26 ++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index 0af45742fc900..5e1fa8dd96ab6 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -6,15 +6,26 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
+#include <asm/spinlock.h>
+
+extern void halt(int code);
+extern void putchar(int c);
+
+static struct spinlock uart_lock;
 
 void io_init(void)
 {
 }
 
-void puts(const char *s __unused)
+void puts(const char *s)
 {
+	spin_lock(&uart_lock);
+	while (*s)
+		putchar(*s++);
+	spin_unlock(&uart_lock);
 }
 
-void exit(int code __unused)
+void exit(int code)
 {
+	halt(code);
 }
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index cc1a521f1a269..89ad7a1907ac9 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -21,6 +21,7 @@ CFLAGS += -ffreestanding
 CFLAGS += -Wextra
 CFLAGS += -O2
 CFLAGS += -I lib -I lib/libfdt
+CFLAGS += -Wa,-mregnames
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include scripts/asm-offsets.mak
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index 4692f2d9d057e..466ec800313b3 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -6,14 +6,40 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 
+#define H_PUT_TERM_CHAR		0x58
+
+#define LOAD_REG_IMMEDIATE(reg,expr)		\
+	lis	reg,(expr)@highest;		\
+	ori	reg,reg,(expr)@higher;		\
+	rldicr	reg,reg,32,31;			\
+	oris	reg,reg,(expr)@h;		\
+	ori	reg,reg,(expr)@l;
+
+#define LOAD_REG_ADDR(reg,name)			\
+	ld	reg,name@got(r2)
+
 .section .init
 
 .globl start
 start:
+	LOAD_REG_IMMEDIATE(r1, stackptr)
+	LOAD_REG_IMMEDIATE(r2, tocptr)
+	bl	main
+	bl	exit
 	b	halt
 
 .text
+.align 3
 
 .globl halt
 halt:
 1:	b	1b
+
+.globl putchar
+putchar:
+	sldi	r6, r3, 56
+	li	r3, H_PUT_TERM_CHAR
+	li	r4, 0	/* vty-reg 0 means to use the default vty */
+	li	r5, 1	/* sending just 1 byte */
+	sc	1
+	blr
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Add the hvcall for putchar and use it in puts. That, along with a
couple more lines in start to prepare for C code, and a branch to
main(), gets us "hello world". Run with

qemu-system-ppc64 -M pseries            \
        -bios powerpc/boot_rom.bin      \
        -display none -serial stdio     \
        -kernel powerpc/selftest.elf

(We're still not relocating yet, that comes in a later patch. Thus,
 testing hello-world at this point requires a hacked QEMU and linking
 the unit test at QEMU's kernel load address.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/io.c        | 15 +++++++++++++--
 powerpc/Makefile.common |  1 +
 powerpc/cstart64.S      | 26 ++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index 0af45742fc900..5e1fa8dd96ab6 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -6,15 +6,26 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
+#include <asm/spinlock.h>
+
+extern void halt(int code);
+extern void putchar(int c);
+
+static struct spinlock uart_lock;
 
 void io_init(void)
 {
 }
 
-void puts(const char *s __unused)
+void puts(const char *s)
 {
+	spin_lock(&uart_lock);
+	while (*s)
+		putchar(*s++);
+	spin_unlock(&uart_lock);
 }
 
-void exit(int code __unused)
+void exit(int code)
 {
+	halt(code);
 }
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index cc1a521f1a269..89ad7a1907ac9 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -21,6 +21,7 @@ CFLAGS += -ffreestanding
 CFLAGS += -Wextra
 CFLAGS += -O2
 CFLAGS += -I lib -I lib/libfdt
+CFLAGS += -Wa,-mregnames
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include scripts/asm-offsets.mak
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index 4692f2d9d057e..466ec800313b3 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -6,14 +6,40 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 
+#define H_PUT_TERM_CHAR		0x58
+
+#define LOAD_REG_IMMEDIATE(reg,expr)		\
+	lis	reg,(expr)@highest;		\
+	ori	reg,reg,(expr)@higher;		\
+	rldicr	reg,reg,32,31;			\
+	oris	reg,reg,(expr)@h;		\
+	ori	reg,reg,(expr)@l;
+
+#define LOAD_REG_ADDR(reg,name)			\
+	ld	reg,name@got(r2)
+
 .section .init
 
 .globl start
 start:
+	LOAD_REG_IMMEDIATE(r1, stackptr)
+	LOAD_REG_IMMEDIATE(r2, tocptr)
+	bl	main
+	bl	exit
 	b	halt
 
 .text
+.align 3
 
 .globl halt
 halt:
 1:	b	1b
+
+.globl putchar
+putchar:
+	sldi	r6, r3, 56
+	li	r3, H_PUT_TERM_CHAR
+	li	r4, 0	/* vty-reg 0 means to use the default vty */
+	li	r5, 1	/* sending just 1 byte */
+	sc	1
+	blr
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Copy arm's setup code (also DT based) over to powerpc, adapting
it a bit. Also bring over arm's setup selftest, giving powerpc
its first test.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/asm/setup.h | 27 +++++++++++++++
 lib/powerpc/setup.c     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/setup.h   |  1 +
 powerpc/cstart64.S      |  9 +++++
 powerpc/selftest.c      | 64 ++++++++++++++++++++++++++++++++--
 5 files changed, 189 insertions(+), 3 deletions(-)
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/ppc64/asm/setup.h

diff --git a/lib/powerpc/asm/setup.h b/lib/powerpc/asm/setup.h
new file mode 100644
index 0000000000000..b9c1c270a2225
--- /dev/null
+++ b/lib/powerpc/asm/setup.h
@@ -0,0 +1,27 @@
+#ifndef _ASMPOWERPC_SETUP_H_
+#define _ASMPOWERPC_SETUP_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+#define NR_CPUS			8	/* arbitrarily set for now */
+extern u32 cpus[NR_CPUS];
+extern int nr_cpus;
+
+extern phys_addr_t __physical_start, __physical_end;
+
+#define PHYSICAL_START		(__physical_start)
+#define PHYSICAL_END		(__physical_end)
+
+#ifdef __powerpc64__
+#define L1_CACHE_SHIFT		7
+#else
+#define L1_CACHE_SHIFT		5
+#endif
+#define L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
+#define SMP_CACHE_BYTES		L1_CACHE_BYTES
+
+#endif /* _ASMPOWERPC_SETUP_H_ */
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index e69de29bb2d1d..a87e0f7642eb0 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -0,0 +1,91 @@
+/*
+ * Initialize machine setup information and I/O.
+ *
+ * After running setup() unit tests may query how many cpus they have
+ * (nr_cpus), how much memory they have (PHYSICAL_END - PHYSICAL_START),
+ * may use dynamic memory allocation (malloc, etc.), printf, and exit.
+ * Finally, argc and argv are also ready to be passed to main().
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <libfdt/libfdt.h>
+#include <devicetree.h>
+#include <alloc.h>
+#include <asm/setup.h>
+#include <asm/page.h>
+
+extern unsigned long stacktop;
+extern void io_init(void);
+extern void setup_args(const char *args);
+
+u32 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (~0U) };
+int nr_cpus;
+
+phys_addr_t __physical_start, __physical_end;
+
+static void cpu_set(int fdtnode __unused, u32 regval, void *info __unused)
+{
+	int cpu = nr_cpus++;
+	assert(cpu < NR_CPUS);
+	cpus[cpu] = regval;
+}
+
+static void cpu_init(void)
+{
+	int ret;
+
+	nr_cpus = 0;
+	ret = dt_for_each_cpu_node(cpu_set, NULL);
+	assert(ret == 0);
+}
+
+static void mem_init(phys_addr_t freemem_start)
+{
+	/* we only expect one membank to be defined in the DT */
+	struct dt_pbus_reg regs[1];
+	phys_addr_t mem_start, mem_end;
+	int ret;
+
+	ret = dt_get_memory_params(regs, 1);
+	assert(ret != 0);
+
+	mem_start = regs[0].addr;
+	mem_end = mem_start + regs[0].size;
+
+//	assert(!(mem_start & ~PHYS_MASK) && !((mem_end-1) & ~PHYS_MASK));
+	assert(freemem_start >= mem_start && freemem_start < mem_end);
+
+	__physical_start = mem_start;	/* PHYSICAL_START */
+	__physical_end = mem_end;	/* PHYSICAL_END */
+
+	phys_alloc_init(freemem_start, mem_end - freemem_start);
+	phys_alloc_set_minimum_alignment(SMP_CACHE_BYTES);
+}
+
+void setup(const void *fdt)
+{
+	const char *bootargs;
+	u32 fdt_size;
+	int ret;
+
+	/*
+	 * Move the fdt to just above the stack. The free memory
+	 * then starts just after the fdt.
+	 */
+	fdt_size = fdt_totalsize(fdt);
+	ret = fdt_move(fdt, &stacktop, fdt_size);
+	assert(ret == 0);
+	ret = dt_init(&stacktop);
+	assert(ret == 0);
+
+	mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size));
+	io_init();
+	cpu_init();
+
+	ret = dt_get_bootargs(&bootargs);
+	assert(ret == 0);
+	setup_args(bootargs);
+}
diff --git a/lib/ppc64/asm/setup.h b/lib/ppc64/asm/setup.h
new file mode 100644
index 0000000000000..20192985928a4
--- /dev/null
+++ b/lib/ppc64/asm/setup.h
@@ -0,0 +1 @@
+#include "../../powerpc/asm/setup.h"
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index 466ec800313b3..ce942f93bef05 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -20,10 +20,19 @@
 
 .section .init
 
+/*
+ * start is the entry point. r3 points to the DTB
+ */
 .globl start
 start:
 	LOAD_REG_IMMEDIATE(r1, stackptr)
 	LOAD_REG_IMMEDIATE(r2, tocptr)
+	bl	setup
+
+	/* run the test */
+	LOAD_REG_IMMEDIATE(r5, __argc)
+	LOAD_REG_IMMEDIATE(r4, __argv)
+	lwz	r3, 0(r5)
 	bl	main
 	bl	exit
 	b	halt
diff --git a/powerpc/selftest.c b/powerpc/selftest.c
index 2f2a5215dd55c..3dd7ce9945307 100644
--- a/powerpc/selftest.c
+++ b/powerpc/selftest.c
@@ -1,7 +1,65 @@
+/*
+ * Test the framework itself. These tests confirm that setup works.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
 #include <libcflat.h>
+#include <util.h>
+#include <alloc.h>		/* phys_addr_t */
+#include <asm/setup.h>
 
-int main(void)
+static void check_setup(int argc, char **argv)
 {
-	printf("hello world\n");
-	return 0;
+	int nr_tests = 0, len, i;
+	long val;
+
+	for (i = 0; i < argc; ++i) {
+
+		len = parse_keyval(argv[i], &val);
+		if (len == -1)
+			continue;
+
+		argv[i][len] = '\0';
+		report_prefix_push(argv[i]);
+
+		if (strcmp(argv[i], "mem") == 0) {
+
+			phys_addr_t memsize = PHYSICAL_END - PHYSICAL_START;
+			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
+
+			report("size = %d MB", memsize == expected,
+							memsize/1024/1024);
+			++nr_tests;
+
+		} else if (strcmp(argv[i], "smp") == 0) {
+
+			report("nr_cpus = %d", nr_cpus == (int)val, nr_cpus);
+			++nr_tests;
+		}
+
+		report_prefix_pop();
+	}
+
+	if (nr_tests < 2)
+		report_abort("missing input");
+}
+
+int main(int argc, char **argv)
+{
+	report_prefix_push("selftest");
+
+	if (argc < 1)
+		report_abort("no test specified");
+
+	report_prefix_push(argv[0]);
+
+	if (strcmp(argv[0], "setup") == 0) {
+
+		check_setup(argc-1, &argv[1]);
+
+	}
+
+	return report_summary();
 }
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Copy arm's setup code (also DT based) over to powerpc, adapting
it a bit. Also bring over arm's setup selftest, giving powerpc
its first test.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/asm/setup.h | 27 +++++++++++++++
 lib/powerpc/setup.c     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/setup.h   |  1 +
 powerpc/cstart64.S      |  9 +++++
 powerpc/selftest.c      | 64 ++++++++++++++++++++++++++++++++--
 5 files changed, 189 insertions(+), 3 deletions(-)
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/ppc64/asm/setup.h

diff --git a/lib/powerpc/asm/setup.h b/lib/powerpc/asm/setup.h
new file mode 100644
index 0000000000000..b9c1c270a2225
--- /dev/null
+++ b/lib/powerpc/asm/setup.h
@@ -0,0 +1,27 @@
+#ifndef _ASMPOWERPC_SETUP_H_
+#define _ASMPOWERPC_SETUP_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+#define NR_CPUS			8	/* arbitrarily set for now */
+extern u32 cpus[NR_CPUS];
+extern int nr_cpus;
+
+extern phys_addr_t __physical_start, __physical_end;
+
+#define PHYSICAL_START		(__physical_start)
+#define PHYSICAL_END		(__physical_end)
+
+#ifdef __powerpc64__
+#define L1_CACHE_SHIFT		7
+#else
+#define L1_CACHE_SHIFT		5
+#endif
+#define L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
+#define SMP_CACHE_BYTES		L1_CACHE_BYTES
+
+#endif /* _ASMPOWERPC_SETUP_H_ */
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index e69de29bb2d1d..a87e0f7642eb0 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -0,0 +1,91 @@
+/*
+ * Initialize machine setup information and I/O.
+ *
+ * After running setup() unit tests may query how many cpus they have
+ * (nr_cpus), how much memory they have (PHYSICAL_END - PHYSICAL_START),
+ * may use dynamic memory allocation (malloc, etc.), printf, and exit.
+ * Finally, argc and argv are also ready to be passed to main().
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <libfdt/libfdt.h>
+#include <devicetree.h>
+#include <alloc.h>
+#include <asm/setup.h>
+#include <asm/page.h>
+
+extern unsigned long stacktop;
+extern void io_init(void);
+extern void setup_args(const char *args);
+
+u32 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (~0U) };
+int nr_cpus;
+
+phys_addr_t __physical_start, __physical_end;
+
+static void cpu_set(int fdtnode __unused, u32 regval, void *info __unused)
+{
+	int cpu = nr_cpus++;
+	assert(cpu < NR_CPUS);
+	cpus[cpu] = regval;
+}
+
+static void cpu_init(void)
+{
+	int ret;
+
+	nr_cpus = 0;
+	ret = dt_for_each_cpu_node(cpu_set, NULL);
+	assert(ret = 0);
+}
+
+static void mem_init(phys_addr_t freemem_start)
+{
+	/* we only expect one membank to be defined in the DT */
+	struct dt_pbus_reg regs[1];
+	phys_addr_t mem_start, mem_end;
+	int ret;
+
+	ret = dt_get_memory_params(regs, 1);
+	assert(ret != 0);
+
+	mem_start = regs[0].addr;
+	mem_end = mem_start + regs[0].size;
+
+//	assert(!(mem_start & ~PHYS_MASK) && !((mem_end-1) & ~PHYS_MASK));
+	assert(freemem_start >= mem_start && freemem_start < mem_end);
+
+	__physical_start = mem_start;	/* PHYSICAL_START */
+	__physical_end = mem_end;	/* PHYSICAL_END */
+
+	phys_alloc_init(freemem_start, mem_end - freemem_start);
+	phys_alloc_set_minimum_alignment(SMP_CACHE_BYTES);
+}
+
+void setup(const void *fdt)
+{
+	const char *bootargs;
+	u32 fdt_size;
+	int ret;
+
+	/*
+	 * Move the fdt to just above the stack. The free memory
+	 * then starts just after the fdt.
+	 */
+	fdt_size = fdt_totalsize(fdt);
+	ret = fdt_move(fdt, &stacktop, fdt_size);
+	assert(ret = 0);
+	ret = dt_init(&stacktop);
+	assert(ret = 0);
+
+	mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size));
+	io_init();
+	cpu_init();
+
+	ret = dt_get_bootargs(&bootargs);
+	assert(ret = 0);
+	setup_args(bootargs);
+}
diff --git a/lib/ppc64/asm/setup.h b/lib/ppc64/asm/setup.h
new file mode 100644
index 0000000000000..20192985928a4
--- /dev/null
+++ b/lib/ppc64/asm/setup.h
@@ -0,0 +1 @@
+#include "../../powerpc/asm/setup.h"
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index 466ec800313b3..ce942f93bef05 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -20,10 +20,19 @@
 
 .section .init
 
+/*
+ * start is the entry point. r3 points to the DTB
+ */
 .globl start
 start:
 	LOAD_REG_IMMEDIATE(r1, stackptr)
 	LOAD_REG_IMMEDIATE(r2, tocptr)
+	bl	setup
+
+	/* run the test */
+	LOAD_REG_IMMEDIATE(r5, __argc)
+	LOAD_REG_IMMEDIATE(r4, __argv)
+	lwz	r3, 0(r5)
 	bl	main
 	bl	exit
 	b	halt
diff --git a/powerpc/selftest.c b/powerpc/selftest.c
index 2f2a5215dd55c..3dd7ce9945307 100644
--- a/powerpc/selftest.c
+++ b/powerpc/selftest.c
@@ -1,7 +1,65 @@
+/*
+ * Test the framework itself. These tests confirm that setup works.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
 #include <libcflat.h>
+#include <util.h>
+#include <alloc.h>		/* phys_addr_t */
+#include <asm/setup.h>
 
-int main(void)
+static void check_setup(int argc, char **argv)
 {
-	printf("hello world\n");
-	return 0;
+	int nr_tests = 0, len, i;
+	long val;
+
+	for (i = 0; i < argc; ++i) {
+
+		len = parse_keyval(argv[i], &val);
+		if (len = -1)
+			continue;
+
+		argv[i][len] = '\0';
+		report_prefix_push(argv[i]);
+
+		if (strcmp(argv[i], "mem") = 0) {
+
+			phys_addr_t memsize = PHYSICAL_END - PHYSICAL_START;
+			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
+
+			report("size = %d MB", memsize = expected,
+							memsize/1024/1024);
+			++nr_tests;
+
+		} else if (strcmp(argv[i], "smp") = 0) {
+
+			report("nr_cpus = %d", nr_cpus = (int)val, nr_cpus);
+			++nr_tests;
+		}
+
+		report_prefix_pop();
+	}
+
+	if (nr_tests < 2)
+		report_abort("missing input");
+}
+
+int main(int argc, char **argv)
+{
+	report_prefix_push("selftest");
+
+	if (argc < 1)
+		report_abort("no test specified");
+
+	report_prefix_push(argv[0]);
+
+	if (strcmp(argv[0], "setup") = 0) {
+
+		check_setup(argc-1, &argv[1]);
+
+	}
+
+	return report_summary();
 }
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 10/14] powerpc/ppc64: relocate linker VMAs
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

QEMU loads the unit test, but due to the way it translates the
unit test's linker VMA to the LMA, we can't just link such that
VMA == LMA. Thus, we link with VMA == 0x0, and then deal with
relocation.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure               |  2 ++
 powerpc/Makefile.common | 11 ++++++++--
 powerpc/Makefile.ppc64  |  1 +
 powerpc/cstart64.S      | 40 +++++++++++++++++++++++++++++++----
 powerpc/flat.lds        | 13 +++++++++++-
 powerpc/reloc64.c       | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 115 insertions(+), 7 deletions(-)
 create mode 100644 powerpc/reloc64.c

diff --git a/configure b/configure
index b367224093369..b2ad199da7873 100755
--- a/configure
+++ b/configure
@@ -5,6 +5,7 @@ kerneldir=/lib/modules/$(uname -r)/build
 cc=gcc
 ld=ld
 objcopy=objcopy
+objdump=objdump
 ar=ar
 arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'`
 host=$arch
@@ -132,6 +133,7 @@ PROCESSOR=$processor
 CC=$cross_prefix$cc
 LD=$cross_prefix$ld
 OBJCOPY=$cross_prefix$objcopy
+OBJDUMP=$cross_prefix$objdump
 AR=$cross_prefix$ar
 API=$api
 TEST_DIR=$testdir
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index 89ad7a1907ac9..074f5672356b1 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -22,6 +22,7 @@ CFLAGS += -Wextra
 CFLAGS += -O2
 CFLAGS += -I lib -I lib/libfdt
 CFLAGS += -Wa,-mregnames
+CFLAGS += -fpie
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include scripts/asm-offsets.mak
@@ -38,11 +39,17 @@ libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
 
 FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc)
-%.elf: LDFLAGS = $(CFLAGS) -nostdlib
+%.elf: LDFLAGS = $(CFLAGS) -nostdlib -pie
 %.elf: %.o $(FLATLIBS) powerpc/flat.lds
 	$(CC) $(LDFLAGS) -o $@ \
 		-Wl,-T,powerpc/flat.lds,--build-id=none,-Ttext=$(start_addr) \
 		$(filter %.o, $^) $(FLATLIBS)
+	@echo -n Checking $@ for unsupported reloc types...
+	@if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then	\
+		false;							\
+	else								\
+		echo " looks good.";					\
+	fi
 
 powerpc_clean: libfdt_clean asm_offsets_clean
 	$(RM) $(TEST_DIR)/*.{o,elf} \
@@ -54,4 +61,4 @@ generated_files = $(asm-offsets)
 
 test_cases: $(generated_files) $(tests-common) $(tests)
 
-$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
+$(TEST_DIR)/selftest.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/selftest.o
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index e9aa9f560204a..a1e2696c8d4f0 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -8,6 +8,7 @@ ldarch = elf64-powerpc
 kernel_offset = 0x0
 
 cstart.o = $(TEST_DIR)/cstart64.o
+reloc.o  = $(TEST_DIR)/reloc64.o
 cflatobjs += lib/ppc64/processor.o
 cflatobjs += lib/ppc64/spinlock.o
 
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index ce942f93bef05..97376fb025760 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -25,18 +25,50 @@
  */
 .globl start
 start:
-	LOAD_REG_IMMEDIATE(r1, stackptr)
-	LOAD_REG_IMMEDIATE(r2, tocptr)
+	/*
+	 * We were loaded at QEMU's kernel load address, but we're not
+	 * allowed to link there due to how QEMU deals with linker VMAs,
+	 * so we just linked at zero. This means the first thing to do is
+	 * to find our stack and toc, and then do a relocate.
+	 */
+	bl	0f
+0:	mflr	r31
+	subi	r31, r31, 0b - start    /* QEMU's kernel load address */
+	ld	r1, (p_stack - start)(r31)
+	ld	r2, (p_toc - start)(r31)
+	add	r1, r1, r31
+	add	r2, r2, r31
+
+	/* save DTB pointer */
+	std	r3, 56(r1)
+
+	/*
+	 * Call relocate. relocate is C code, but careful to not use
+	 * any global references, as they may use absolute addresses,
+	 * which are, obviously, not yet relocated.
+	 */
+	mr	r3, r31
+	ld	r4, (p_dyn - start)(r31)
+	add	r4, r4, r31
+	bl	relocate
+
+	/* complete setup */
+	ld	r3, 56(r1)
 	bl	setup
 
 	/* run the test */
-	LOAD_REG_IMMEDIATE(r5, __argc)
-	LOAD_REG_IMMEDIATE(r4, __argv)
+	LOAD_REG_ADDR(r5, __argc)
+	LOAD_REG_ADDR(r4, __argv)
 	lwz	r3, 0(r5)
 	bl	main
 	bl	exit
 	b	halt
 
+.align 3
+p_stack:	.llong  stackptr
+p_toc:		.llong  tocptr
+p_dyn:		.llong  dynamic_start
+
 .text
 .align 3
 
diff --git a/powerpc/flat.lds b/powerpc/flat.lds
index bd075efb2c51b..8a573d27346de 100644
--- a/powerpc/flat.lds
+++ b/powerpc/flat.lds
@@ -6,11 +6,22 @@ SECTIONS
     etext = .;
     .opd : { *(.opd) }
     . = ALIGN(16);
+    .dynamic : {
+        dynamic_start = .;
+        *(.dynamic)
+    }
+    .dynsym : {
+        dynsym_start = .;
+        *(.dynsym)
+    }
+    .rela.dyn : { *(.rela*) }
+    . = ALIGN(16);
     .data : {
         *(.data)
+        *(.data.rel*)
     }
     . = ALIGN(16);
-    .rodata : { *(.rodata) }
+    .rodata : { *(.rodata) *(.rodata.*) }
     . = ALIGN(16);
     .bss : { *(.bss) }
     . = ALIGN(16);
diff --git a/powerpc/reloc64.c b/powerpc/reloc64.c
new file mode 100644
index 0000000000000..d919372bf9288
--- /dev/null
+++ b/powerpc/reloc64.c
@@ -0,0 +1,55 @@
+/*
+ * relocate R_PPC_RELATIVE RELA entries. Normally this is done in
+ * assembly code to avoid the risk of using absolute addresses before
+ * they're relocated. We use C, but cautiously (no global references).
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#define DT_NULL		0
+#define DT_RELA 	7
+#define DT_RELACOUNT	0x6ffffff9
+#define R_PPC_RELATIVE	22
+
+struct elf64_dyn {
+	signed long long tag;
+	unsigned long long val;
+};
+
+#define RELA_GET_TYPE(rela_ptr) ((rela_ptr)->info & 0xffffffff)
+struct elf64_rela {
+	unsigned long long offset;
+	unsigned long long info;
+	signed long long addend;
+};
+
+void relocate(unsigned long load_addr, struct elf64_dyn *dyn_table)
+{
+	unsigned long long rela_addr = 0, rela_count = 0, *addr;
+	struct elf64_dyn *d = dyn_table;
+	struct elf64_rela *r;
+
+	while (d && d->tag != DT_NULL) {
+		if (d->tag == DT_RELA)
+			rela_addr = d->val;
+		else if (d->tag == DT_RELACOUNT)
+			rela_count = d->val;
+		if (rela_addr && rela_count)
+			break;
+		++d;
+	}
+
+	if (!rela_addr || !rela_count)
+		return;
+
+	r = (void *)(rela_addr + load_addr);
+
+	while (rela_count--) {
+		if (RELA_GET_TYPE(r) == R_PPC_RELATIVE) {
+			addr = (void *)(r->offset + load_addr);
+			*addr = r->addend + load_addr;
+		}
+		++r;
+	}
+}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 10/14] powerpc/ppc64: relocate linker VMAs
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

QEMU loads the unit test, but due to the way it translates the
unit test's linker VMA to the LMA, we can't just link such that
VMA = LMA. Thus, we link with VMA = 0x0, and then deal with
relocation.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure               |  2 ++
 powerpc/Makefile.common | 11 ++++++++--
 powerpc/Makefile.ppc64  |  1 +
 powerpc/cstart64.S      | 40 +++++++++++++++++++++++++++++++----
 powerpc/flat.lds        | 13 +++++++++++-
 powerpc/reloc64.c       | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 115 insertions(+), 7 deletions(-)
 create mode 100644 powerpc/reloc64.c

diff --git a/configure b/configure
index b367224093369..b2ad199da7873 100755
--- a/configure
+++ b/configure
@@ -5,6 +5,7 @@ kerneldir=/lib/modules/$(uname -r)/build
 cc=gcc
 ld=ld
 objcopy=objcopy
+objdump=objdump
 ar=ar
 arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'`
 host=$arch
@@ -132,6 +133,7 @@ PROCESSOR=$processor
 CC=$cross_prefix$cc
 LD=$cross_prefix$ld
 OBJCOPY=$cross_prefix$objcopy
+OBJDUMP=$cross_prefix$objdump
 AR=$cross_prefix$ar
 API=$api
 TEST_DIR=$testdir
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index 89ad7a1907ac9..074f5672356b1 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -22,6 +22,7 @@ CFLAGS += -Wextra
 CFLAGS += -O2
 CFLAGS += -I lib -I lib/libfdt
 CFLAGS += -Wa,-mregnames
+CFLAGS += -fpie
 
 asm-offsets = lib/$(ARCH)/asm-offsets.h
 include scripts/asm-offsets.mak
@@ -38,11 +39,17 @@ libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
 
 FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc)
-%.elf: LDFLAGS = $(CFLAGS) -nostdlib
+%.elf: LDFLAGS = $(CFLAGS) -nostdlib -pie
 %.elf: %.o $(FLATLIBS) powerpc/flat.lds
 	$(CC) $(LDFLAGS) -o $@ \
 		-Wl,-T,powerpc/flat.lds,--build-id=none,-Ttext=$(start_addr) \
 		$(filter %.o, $^) $(FLATLIBS)
+	@echo -n Checking $@ for unsupported reloc types...
+	@if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then	\
+		false;							\
+	else								\
+		echo " looks good.";					\
+	fi
 
 powerpc_clean: libfdt_clean asm_offsets_clean
 	$(RM) $(TEST_DIR)/*.{o,elf} \
@@ -54,4 +61,4 @@ generated_files = $(asm-offsets)
 
 test_cases: $(generated_files) $(tests-common) $(tests)
 
-$(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
+$(TEST_DIR)/selftest.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/selftest.o
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index e9aa9f560204a..a1e2696c8d4f0 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -8,6 +8,7 @@ ldarch = elf64-powerpc
 kernel_offset = 0x0
 
 cstart.o = $(TEST_DIR)/cstart64.o
+reloc.o  = $(TEST_DIR)/reloc64.o
 cflatobjs += lib/ppc64/processor.o
 cflatobjs += lib/ppc64/spinlock.o
 
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index ce942f93bef05..97376fb025760 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -25,18 +25,50 @@
  */
 .globl start
 start:
-	LOAD_REG_IMMEDIATE(r1, stackptr)
-	LOAD_REG_IMMEDIATE(r2, tocptr)
+	/*
+	 * We were loaded at QEMU's kernel load address, but we're not
+	 * allowed to link there due to how QEMU deals with linker VMAs,
+	 * so we just linked at zero. This means the first thing to do is
+	 * to find our stack and toc, and then do a relocate.
+	 */
+	bl	0f
+0:	mflr	r31
+	subi	r31, r31, 0b - start    /* QEMU's kernel load address */
+	ld	r1, (p_stack - start)(r31)
+	ld	r2, (p_toc - start)(r31)
+	add	r1, r1, r31
+	add	r2, r2, r31
+
+	/* save DTB pointer */
+	std	r3, 56(r1)
+
+	/*
+	 * Call relocate. relocate is C code, but careful to not use
+	 * any global references, as they may use absolute addresses,
+	 * which are, obviously, not yet relocated.
+	 */
+	mr	r3, r31
+	ld	r4, (p_dyn - start)(r31)
+	add	r4, r4, r31
+	bl	relocate
+
+	/* complete setup */
+	ld	r3, 56(r1)
 	bl	setup
 
 	/* run the test */
-	LOAD_REG_IMMEDIATE(r5, __argc)
-	LOAD_REG_IMMEDIATE(r4, __argv)
+	LOAD_REG_ADDR(r5, __argc)
+	LOAD_REG_ADDR(r4, __argv)
 	lwz	r3, 0(r5)
 	bl	main
 	bl	exit
 	b	halt
 
+.align 3
+p_stack:	.llong  stackptr
+p_toc:		.llong  tocptr
+p_dyn:		.llong  dynamic_start
+
 .text
 .align 3
 
diff --git a/powerpc/flat.lds b/powerpc/flat.lds
index bd075efb2c51b..8a573d27346de 100644
--- a/powerpc/flat.lds
+++ b/powerpc/flat.lds
@@ -6,11 +6,22 @@ SECTIONS
     etext = .;
     .opd : { *(.opd) }
     . = ALIGN(16);
+    .dynamic : {
+        dynamic_start = .;
+        *(.dynamic)
+    }
+    .dynsym : {
+        dynsym_start = .;
+        *(.dynsym)
+    }
+    .rela.dyn : { *(.rela*) }
+    . = ALIGN(16);
     .data : {
         *(.data)
+        *(.data.rel*)
     }
     . = ALIGN(16);
-    .rodata : { *(.rodata) }
+    .rodata : { *(.rodata) *(.rodata.*) }
     . = ALIGN(16);
     .bss : { *(.bss) }
     . = ALIGN(16);
diff --git a/powerpc/reloc64.c b/powerpc/reloc64.c
new file mode 100644
index 0000000000000..d919372bf9288
--- /dev/null
+++ b/powerpc/reloc64.c
@@ -0,0 +1,55 @@
+/*
+ * relocate R_PPC_RELATIVE RELA entries. Normally this is done in
+ * assembly code to avoid the risk of using absolute addresses before
+ * they're relocated. We use C, but cautiously (no global references).
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#define DT_NULL		0
+#define DT_RELA 	7
+#define DT_RELACOUNT	0x6ffffff9
+#define R_PPC_RELATIVE	22
+
+struct elf64_dyn {
+	signed long long tag;
+	unsigned long long val;
+};
+
+#define RELA_GET_TYPE(rela_ptr) ((rela_ptr)->info & 0xffffffff)
+struct elf64_rela {
+	unsigned long long offset;
+	unsigned long long info;
+	signed long long addend;
+};
+
+void relocate(unsigned long load_addr, struct elf64_dyn *dyn_table)
+{
+	unsigned long long rela_addr = 0, rela_count = 0, *addr;
+	struct elf64_dyn *d = dyn_table;
+	struct elf64_rela *r;
+
+	while (d && d->tag != DT_NULL) {
+		if (d->tag = DT_RELA)
+			rela_addr = d->val;
+		else if (d->tag = DT_RELACOUNT)
+			rela_count = d->val;
+		if (rela_addr && rela_count)
+			break;
+		++d;
+	}
+
+	if (!rela_addr || !rela_count)
+		return;
+
+	r = (void *)(rela_addr + load_addr);
+
+	while (rela_count--) {
+		if (RELA_GET_TYPE(r) = R_PPC_RELATIVE) {
+			addr = (void *)(r->offset + load_addr);
+			*addr = r->addend + load_addr;
+		}
+		++r;
+	}
+}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 11/14] powerpc/ppc64: add run script and unittests.cfg
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Now that we have all the pieces, pull them together into a
run script (adapted from arm's). To run a test do './powerpc-run
powerpc/test.elf'. To run all tests in unittests.cfg do
'./run_tests.sh'

(We can now run simple unit tests, but they don't quit on their
 own yet. Use ^C to quit them.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/run           | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc/unittests.cfg | 30 +++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100755 powerpc/run
 create mode 100644 powerpc/unittests.cfg

diff --git a/powerpc/run b/powerpc/run
new file mode 100755
index 0000000000000..b317c6c0dc62e
--- /dev/null
+++ b/powerpc/run
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+if [ -z "$STANDALONE" ]; then
+	if [ ! -f config.mak ]; then
+		echo "run ./configure && make first. See ./configure -h"
+		exit 2
+	fi
+	source config.mak
+fi
+
+if [ -c /dev/kvm ]; then
+	if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then
+		kvm_available=yes
+	fi
+fi
+
+if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
+	echo "skip $TESTNAME (kvm only)"
+	exit 2
+fi
+
+if [ -z "$ACCEL" ]; then
+	if [ "$kvm_available" = "yes" ]; then
+		ACCEL="kvm"
+	else
+		ACCEL="tcg"
+	fi
+fi
+
+qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+qpath=$(which $qemu 2>/dev/null)
+
+if [ -z "$qpath" ]; then
+	echo $qemu not found.
+	exit 2
+fi
+
+if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
+	echo "$qpath doesn't support pSeries ('-machine pseries'). Exiting."
+	exit 2
+fi
+
+boot_rom='powerpc/boot_rom.bin'
+if [ -f powerpc/rom/boot_rom.bin ]; then
+	boot_rom='powerpc/rom/boot_rom.bin'
+fi
+
+M='-machine pseries'
+M+=",accel=$ACCEL"
+command="$qemu $M -bios $boot_rom"
+command+=" -display none -serial stdio -kernel"
+echo $command "$@"
+
+$command "$@"
+ret=$?
+echo Return value from qemu: $ret
+exit $ret
diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
new file mode 100644
index 0000000000000..60f9be80e8abf
--- /dev/null
+++ b/powerpc/unittests.cfg
@@ -0,0 +1,30 @@
+##############################################################################
+# unittest configuration
+#
+# [unittest_name]
+# file = <name>.flat		# Name of the flat file to be used.
+# smp  = <num>			# Number of processors the VM will use
+#				# during this test. Use $MAX_SMP to use
+#				# the maximum the host supports. Defaults
+#				# to one.
+# extra_params = -append <params...>	# Additional parameters used.
+# arch = ppc64				# Select one if the test case is
+#					# specific to only one.
+# groups = <group_name1> <group_name2> ...	# Used to identify test cases
+#						# with run_tests -g ...
+# accel = kvm|tcg		# Optionally specify if test must run with
+#				# kvm or tcg. If not specified, then kvm will
+#				# be used when available.
+# timeout = <duration>		# Optionally specify a timeout.
+##############################################################################
+
+#
+# Test that the configured number of processors (smp = <num>), and
+# that the configured amount of memory (-m <MB>) are correctly setup
+# by the framework.
+#
+[selftest-setup]
+file = selftest.elf
+smp = 2
+extra_params = -m 256 -append 'setup smp=2 mem=256'
+groups = selftest
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 11/14] powerpc/ppc64: add run script and unittests.cfg
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Now that we have all the pieces, pull them together into a
run script (adapted from arm's). To run a test do './powerpc-run
powerpc/test.elf'. To run all tests in unittests.cfg do
'./run_tests.sh'

(We can now run simple unit tests, but they don't quit on their
 own yet. Use ^C to quit them.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 powerpc/run           | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc/unittests.cfg | 30 +++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100755 powerpc/run
 create mode 100644 powerpc/unittests.cfg

diff --git a/powerpc/run b/powerpc/run
new file mode 100755
index 0000000000000..b317c6c0dc62e
--- /dev/null
+++ b/powerpc/run
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+if [ -z "$STANDALONE" ]; then
+	if [ ! -f config.mak ]; then
+		echo "run ./configure && make first. See ./configure -h"
+		exit 2
+	fi
+	source config.mak
+fi
+
+if [ -c /dev/kvm ]; then
+	if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then
+		kvm_available=yes
+	fi
+fi
+
+if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
+	echo "skip $TESTNAME (kvm only)"
+	exit 2
+fi
+
+if [ -z "$ACCEL" ]; then
+	if [ "$kvm_available" = "yes" ]; then
+		ACCEL="kvm"
+	else
+		ACCEL="tcg"
+	fi
+fi
+
+qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+qpath=$(which $qemu 2>/dev/null)
+
+if [ -z "$qpath" ]; then
+	echo $qemu not found.
+	exit 2
+fi
+
+if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
+	echo "$qpath doesn't support pSeries ('-machine pseries'). Exiting."
+	exit 2
+fi
+
+boot_rom='powerpc/boot_rom.bin'
+if [ -f powerpc/rom/boot_rom.bin ]; then
+	boot_rom='powerpc/rom/boot_rom.bin'
+fi
+
+M='-machine pseries'
+M+=",accel=$ACCEL"
+command="$qemu $M -bios $boot_rom"
+command+=" -display none -serial stdio -kernel"
+echo $command "$@"
+
+$command "$@"
+ret=$?
+echo Return value from qemu: $ret
+exit $ret
diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
new file mode 100644
index 0000000000000..60f9be80e8abf
--- /dev/null
+++ b/powerpc/unittests.cfg
@@ -0,0 +1,30 @@
+##############################################################################
+# unittest configuration
+#
+# [unittest_name]
+# file = <name>.flat		# Name of the flat file to be used.
+# smp  = <num>			# Number of processors the VM will use
+#				# during this test. Use $MAX_SMP to use
+#				# the maximum the host supports. Defaults
+#				# to one.
+# extra_params = -append <params...>	# Additional parameters used.
+# arch = ppc64				# Select one if the test case is
+#					# specific to only one.
+# groups = <group_name1> <group_name2> ...	# Used to identify test cases
+#						# with run_tests -g ...
+# accel = kvm|tcg		# Optionally specify if test must run with
+#				# kvm or tcg. If not specified, then kvm will
+#				# be used when available.
+# timeout = <duration>		# Optionally specify a timeout.
+##############################################################################
+
+#
+# Test that the configured number of processors (smp = <num>), and
+# that the configured amount of memory (-m <MB>) are correctly setup
+# by the framework.
+#
+[selftest-setup]
+file = selftest.elf
+smp = 2
+extra_params = -m 256 -append 'setup smp=2 mem%6'
+groups = selftest
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 12/14] mkstandalone: add support for powerpc
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

PowerPC needs firmware.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure               | 2 ++
 powerpc/run             | 4 ++--
 scripts/mkstandalone.sh | 5 +++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b2ad199da7873..7d5702e28d627 100755
--- a/configure
+++ b/configure
@@ -83,6 +83,7 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
     testdir=arm
 elif [ "$arch" = "ppc64" ]; then
     testdir=powerpc
+    firmware="$testdir/boot_rom.bin"
 else
     testdir=$arch
 fi
@@ -137,4 +138,5 @@ OBJDUMP=$cross_prefix$objdump
 AR=$cross_prefix$ar
 API=$api
 TEST_DIR=$testdir
+FIRMWARE=$firmware
 EOF
diff --git a/powerpc/run b/powerpc/run
index b317c6c0dc62e..4509429f9712b 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -40,8 +40,8 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
 	exit 2
 fi
 
-boot_rom='powerpc/boot_rom.bin'
-if [ -f powerpc/rom/boot_rom.bin ]; then
+boot_rom=$FIRMWARE
+if [ -z "$STANDALONE" ] && [ -f powerpc/rom/boot_rom.bin ]; then
 	boot_rom='powerpc/rom/boot_rom.bin'
 fi
 
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index b0f1e7c098afb..1788a8ef4e92a 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -51,6 +51,11 @@ generate_test ()
 		return 1
 	fi
 
+	if [ "$FIRMWARE" ]; then
+		temp_file firmware "$FIRMWARE"
+		echo 'export FIRMWARE=$firmware'
+	fi
+
 	echo "trap 'rm -f \$cleanup' EXIT"
 
 	temp_file bin "$kernel"
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 12/14] mkstandalone: add support for powerpc
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

PowerPC needs firmware.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure               | 2 ++
 powerpc/run             | 4 ++--
 scripts/mkstandalone.sh | 5 +++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b2ad199da7873..7d5702e28d627 100755
--- a/configure
+++ b/configure
@@ -83,6 +83,7 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
     testdir=arm
 elif [ "$arch" = "ppc64" ]; then
     testdir=powerpc
+    firmware="$testdir/boot_rom.bin"
 else
     testdir=$arch
 fi
@@ -137,4 +138,5 @@ OBJDUMP=$cross_prefix$objdump
 AR=$cross_prefix$ar
 API=$api
 TEST_DIR=$testdir
+FIRMWARE=$firmware
 EOF
diff --git a/powerpc/run b/powerpc/run
index b317c6c0dc62e..4509429f9712b 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -40,8 +40,8 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
 	exit 2
 fi
 
-boot_rom='powerpc/boot_rom.bin'
-if [ -f powerpc/rom/boot_rom.bin ]; then
+boot_rom=$FIRMWARE
+if [ -z "$STANDALONE" ] && [ -f powerpc/rom/boot_rom.bin ]; then
 	boot_rom='powerpc/rom/boot_rom.bin'
 fi
 
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index b0f1e7c098afb..1788a8ef4e92a 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -51,6 +51,11 @@ generate_test ()
 		return 1
 	fi
 
+	if [ "$FIRMWARE" ]; then
+		temp_file firmware "$FIRMWARE"
+		echo 'export FIRMWARE=$firmware'
+	fi
+
 	echo "trap 'rm -f \$cleanup' EXIT"
 
 	temp_file bin "$kernel"
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 13/14] powerpc/ppc64: add RTAS support
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Add enough RTAS support to start adding RTAS commands. Just add
power-off for now.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/asm/rtas.h  |  26 +++++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 120 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 150 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h

diff --git a/lib/powerpc/asm/rtas.h b/lib/powerpc/asm/rtas.h
new file mode 100644
index 0000000000000..522225bcb6de3
--- /dev/null
+++ b/lib/powerpc/asm/rtas.h
@@ -0,0 +1,26 @@
+#ifndef _ASMPOWERPC_RTAS_H_
+#define _ASMPOWERPC_RTAS_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+#define RTAS_UNKNOWN_SERVICE	(-1)
+
+struct rtas_args {
+	u32 token;
+	u32 nargs;
+	u32 nret;
+	u32 args[16];
+	u32 *rets;
+};
+
+extern void rtas_init(void);
+extern int rtas_token(const char *service);
+extern int rtas_call(int token, int nargs, int nret, int *outputs, ...);
+
+extern void rtas_power_off(void);
+
+#endif /* _ASMPOWERPC_RTAS_H_ */
diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index 5e1fa8dd96ab6..e57a28c583eb0 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -7,6 +7,7 @@
  */
 #include <libcflat.h>
 #include <asm/spinlock.h>
+#include <asm/rtas.h>
 
 extern void halt(int code);
 extern void putchar(int c);
@@ -15,6 +16,7 @@ static struct spinlock uart_lock;
 
 void io_init(void)
 {
+	rtas_init();
 }
 
 void puts(const char *s)
diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
new file mode 100644
index 0000000000000..7fcd667513087
--- /dev/null
+++ b/lib/powerpc/rtas.c
@@ -0,0 +1,120 @@
+/*
+ * powerpc RTAS
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <libfdt/libfdt.h>
+#include <devicetree.h>
+#include <asm/spinlock.h>
+#include <asm/io.h>
+#include <asm/rtas.h>
+
+#if defined(__powerpc64__)
+struct func_ptr {
+	unsigned long ptr;
+	unsigned long toc;
+};
+static struct func_ptr rtas_entry_funcptr;
+#endif
+typedef void (*rtas_entry_t)(unsigned long);
+static rtas_entry_t enter_rtas;
+static struct rtas_args rtas_args;
+static struct spinlock lock;
+
+static int rtas_node(void)
+{
+	int node = fdt_path_offset(dt_fdt(), "/rtas");
+
+	if (node < 0) {
+		printf("%s: /rtas: %s\n", __func__, fdt_strerror(node));
+		abort();
+	}
+
+	return node;
+}
+
+void rtas_init(void)
+{
+	const struct fdt_property *prop;
+	unsigned long entry;
+	u32 *data;
+	int len;
+
+	if (!dt_available()) {
+		printf("%s: No device tree!\n", __func__);
+		abort();
+	}
+
+	prop = fdt_get_property(dt_fdt(), rtas_node(),
+				"linux,rtas-entry", &len);
+	if (!prop) {
+		printf("%s: /rtas/linux,rtas-entry: %s\n",
+				__func__, fdt_strerror(len));
+		abort();
+	}
+
+	data = (u32 *)prop->data;
+	entry = (unsigned long)fdt32_to_cpu(*data);
+
+#if defined(__powerpc64__)
+	rtas_entry_funcptr.ptr = entry;
+	enter_rtas = (rtas_entry_t)&rtas_entry_funcptr;
+#else
+	enter_rtas = (rtas_entry_t)entry;
+#endif
+}
+
+int rtas_token(const char *service)
+{
+	const struct fdt_property *prop;
+	u32 *token;
+
+	prop = fdt_get_property(dt_fdt(), rtas_node(), service, NULL);
+	if (prop) {
+		token = (u32 *)prop->data;
+		return fdt32_to_cpu(*token);
+	}
+	return RTAS_UNKNOWN_SERVICE;
+}
+
+int rtas_call(int token, int nargs, int nret, int *outputs, ...)
+{
+	va_list list;
+	int ret, i;
+
+	spin_lock(&lock);
+
+	rtas_args.token = cpu_to_be32(token);
+	rtas_args.nargs = cpu_to_be32(nargs);
+	rtas_args.nret = cpu_to_be32(nret);
+	rtas_args.rets = &rtas_args.args[nargs];
+
+	va_start(list, outputs);
+	for (i = 0; i < nargs; ++i)
+		rtas_args.args[i] = cpu_to_be32(va_arg(list, u32));
+	va_end(list);
+
+	for (i = 0; i < nret; ++i)
+		rtas_args.rets[i] = 0;
+
+	enter_rtas(__pa(&rtas_args));
+
+	if (nret > 1 && outputs != NULL)
+		for (i = 0; i < nret - 1; ++i)
+			outputs[i] = be32_to_cpu(rtas_args.rets[i + 1]);
+
+	ret = nret > 0 ? be32_to_cpu(rtas_args.rets[0]) : 0;
+
+	spin_unlock(&lock);
+	return ret;
+}
+
+void rtas_power_off(void)
+{
+	printf("RTAS power-off returned %d\n",
+		rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
+	assert(0);
+}
diff --git a/lib/ppc64/asm/rtas.h b/lib/ppc64/asm/rtas.h
new file mode 100644
index 0000000000000..fe77f635cd860
--- /dev/null
+++ b/lib/ppc64/asm/rtas.h
@@ -0,0 +1 @@
+#include "../../powerpc/asm/rtas.h"
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index 074f5672356b1..27b2bcad74865 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -34,6 +34,7 @@ cflatobjs += lib/powerpc/io.o
 cflatobjs += lib/powerpc/setup.o
 cflatobjs += lib/powerpc/mmu.o
 cflatobjs += lib/powerpc/smp.o
+cflatobjs += lib/powerpc/rtas.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 13/14] powerpc/ppc64: add RTAS support
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

Add enough RTAS support to start adding RTAS commands. Just add
power-off for now.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/asm/rtas.h  |  26 +++++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 120 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 150 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h

diff --git a/lib/powerpc/asm/rtas.h b/lib/powerpc/asm/rtas.h
new file mode 100644
index 0000000000000..522225bcb6de3
--- /dev/null
+++ b/lib/powerpc/asm/rtas.h
@@ -0,0 +1,26 @@
+#ifndef _ASMPOWERPC_RTAS_H_
+#define _ASMPOWERPC_RTAS_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+
+#define RTAS_UNKNOWN_SERVICE	(-1)
+
+struct rtas_args {
+	u32 token;
+	u32 nargs;
+	u32 nret;
+	u32 args[16];
+	u32 *rets;
+};
+
+extern void rtas_init(void);
+extern int rtas_token(const char *service);
+extern int rtas_call(int token, int nargs, int nret, int *outputs, ...);
+
+extern void rtas_power_off(void);
+
+#endif /* _ASMPOWERPC_RTAS_H_ */
diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index 5e1fa8dd96ab6..e57a28c583eb0 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -7,6 +7,7 @@
  */
 #include <libcflat.h>
 #include <asm/spinlock.h>
+#include <asm/rtas.h>
 
 extern void halt(int code);
 extern void putchar(int c);
@@ -15,6 +16,7 @@ static struct spinlock uart_lock;
 
 void io_init(void)
 {
+	rtas_init();
 }
 
 void puts(const char *s)
diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
new file mode 100644
index 0000000000000..7fcd667513087
--- /dev/null
+++ b/lib/powerpc/rtas.c
@@ -0,0 +1,120 @@
+/*
+ * powerpc RTAS
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <libfdt/libfdt.h>
+#include <devicetree.h>
+#include <asm/spinlock.h>
+#include <asm/io.h>
+#include <asm/rtas.h>
+
+#if defined(__powerpc64__)
+struct func_ptr {
+	unsigned long ptr;
+	unsigned long toc;
+};
+static struct func_ptr rtas_entry_funcptr;
+#endif
+typedef void (*rtas_entry_t)(unsigned long);
+static rtas_entry_t enter_rtas;
+static struct rtas_args rtas_args;
+static struct spinlock lock;
+
+static int rtas_node(void)
+{
+	int node = fdt_path_offset(dt_fdt(), "/rtas");
+
+	if (node < 0) {
+		printf("%s: /rtas: %s\n", __func__, fdt_strerror(node));
+		abort();
+	}
+
+	return node;
+}
+
+void rtas_init(void)
+{
+	const struct fdt_property *prop;
+	unsigned long entry;
+	u32 *data;
+	int len;
+
+	if (!dt_available()) {
+		printf("%s: No device tree!\n", __func__);
+		abort();
+	}
+
+	prop = fdt_get_property(dt_fdt(), rtas_node(),
+				"linux,rtas-entry", &len);
+	if (!prop) {
+		printf("%s: /rtas/linux,rtas-entry: %s\n",
+				__func__, fdt_strerror(len));
+		abort();
+	}
+
+	data = (u32 *)prop->data;
+	entry = (unsigned long)fdt32_to_cpu(*data);
+
+#if defined(__powerpc64__)
+	rtas_entry_funcptr.ptr = entry;
+	enter_rtas = (rtas_entry_t)&rtas_entry_funcptr;
+#else
+	enter_rtas = (rtas_entry_t)entry;
+#endif
+}
+
+int rtas_token(const char *service)
+{
+	const struct fdt_property *prop;
+	u32 *token;
+
+	prop = fdt_get_property(dt_fdt(), rtas_node(), service, NULL);
+	if (prop) {
+		token = (u32 *)prop->data;
+		return fdt32_to_cpu(*token);
+	}
+	return RTAS_UNKNOWN_SERVICE;
+}
+
+int rtas_call(int token, int nargs, int nret, int *outputs, ...)
+{
+	va_list list;
+	int ret, i;
+
+	spin_lock(&lock);
+
+	rtas_args.token = cpu_to_be32(token);
+	rtas_args.nargs = cpu_to_be32(nargs);
+	rtas_args.nret = cpu_to_be32(nret);
+	rtas_args.rets = &rtas_args.args[nargs];
+
+	va_start(list, outputs);
+	for (i = 0; i < nargs; ++i)
+		rtas_args.args[i] = cpu_to_be32(va_arg(list, u32));
+	va_end(list);
+
+	for (i = 0; i < nret; ++i)
+		rtas_args.rets[i] = 0;
+
+	enter_rtas(__pa(&rtas_args));
+
+	if (nret > 1 && outputs != NULL)
+		for (i = 0; i < nret - 1; ++i)
+			outputs[i] = be32_to_cpu(rtas_args.rets[i + 1]);
+
+	ret = nret > 0 ? be32_to_cpu(rtas_args.rets[0]) : 0;
+
+	spin_unlock(&lock);
+	return ret;
+}
+
+void rtas_power_off(void)
+{
+	printf("RTAS power-off returned %d\n",
+		rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
+	assert(0);
+}
diff --git a/lib/ppc64/asm/rtas.h b/lib/ppc64/asm/rtas.h
new file mode 100644
index 0000000000000..fe77f635cd860
--- /dev/null
+++ b/lib/ppc64/asm/rtas.h
@@ -0,0 +1 @@
+#include "../../powerpc/asm/rtas.h"
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index 074f5672356b1..27b2bcad74865 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -34,6 +34,7 @@ cflatobjs += lib/powerpc/io.o
 cflatobjs += lib/powerpc/setup.o
 cflatobjs += lib/powerpc/mmu.o
 cflatobjs += lib/powerpc/smp.o
+cflatobjs += lib/powerpc/rtas.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-08 18:53   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

We should use a QEMU debug-exit device like chr-testdev, but for
now we just fake things by outputting the exit code (which we
parse later) and quitting with RTAS (which always exits with zero).

(When we've got a real debug-exit working, then this patch can
 be reverted.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/io.c | 4 ++++
 powerpc/run      | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index e57a28c583eb0..276eb4c0ebd41 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -29,5 +29,9 @@ void puts(const char *s)
 
 void exit(int code)
 {
+// FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit()
+//        Maybe by plugging chr-testdev into a spapr-vty.
+	printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
+	rtas_power_off();
 	halt(code);
 }
diff --git a/powerpc/run b/powerpc/run
index 4509429f9712b..7247e167e2ac6 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -51,7 +51,10 @@ command="$qemu $M -bios $boot_rom"
 command+=" -display none -serial stdio -kernel"
 echo $command "$@"
 
-$command "$@"
-ret=$?
+#FIXME: rtas-poweroff always exits with zero, so we have to parse
+#       the true exit code from the output.
+lines=$($command "$@")
+echo "$lines"
+ret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/')
 echo Return value from qemu: $ret
 exit $ret
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit
@ 2016-02-08 18:53   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-08 18:53 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

We should use a QEMU debug-exit device like chr-testdev, but for
now we just fake things by outputting the exit code (which we
parse later) and quitting with RTAS (which always exits with zero).

(When we've got a real debug-exit working, then this patch can
 be reverted.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/powerpc/io.c | 4 ++++
 powerpc/run      | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index e57a28c583eb0..276eb4c0ebd41 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -29,5 +29,9 @@ void puts(const char *s)
 
 void exit(int code)
 {
+// FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit()
+//        Maybe by plugging chr-testdev into a spapr-vty.
+	printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
+	rtas_power_off();
 	halt(code);
 }
diff --git a/powerpc/run b/powerpc/run
index 4509429f9712b..7247e167e2ac6 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -51,7 +51,10 @@ command="$qemu $M -bios $boot_rom"
 command+=" -display none -serial stdio -kernel"
 echo $command "$@"
 
-$command "$@"
-ret=$?
+#FIXME: rtas-poweroff always exits with zero, so we have to parse
+#       the true exit code from the output.
+lines=$($command "$@")
+echo "$lines"
+ret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/')
 echo Return value from qemu: $ret
 exit $ret
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-09 17:49   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-09 17:49 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

On Mon, Feb 08, 2016 at 07:53:00PM +0100, Andrew Jones wrote:
> It's been a loooong time since I posted v1 of this series, but thanks
> to Thomas' poking, and even volunteering to help move v2 along, I've
> finally picked it back up.
> 
> v2:
>   Besides rebasing on latest master, v2 addresses all of David's comments
>     - assembler cleanup
>     - jump into the RTAS blob we get from DT, instead of reproducing it
>     - don't store the RTAS root node, always hunt it down
> 
>   v2 didn't address debug-exit, and we still need a solution for that.
>   Plugging chr-testdev into an spapr vty is probably what we should
>   investigate first (as was suggested by Alex Graf under the v1 review).
>   For this v2 I just kept the hack from v1, but simplified it and
>   explicitly call it out as the hack that it is.
> 
> Additional known issues:
>   Latest F22 cross-compiler (gcc5 based) doesn't generate working
>   code with this series. I didn't try to debug. The 4.9 based compiler
>   I initially used on v1 works, so I reverted to that one.

OK, I couldn't resist debugging this one. It appears recent toolchains
require the TOC to be 256 byte aligned (see [*]). The patch to this
series is a simple change to flat.lds, which I'll send as a follow-up
to patch 05/14.

[*] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5e95235

> 
> Testing:
>   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
>   try to get a machine to test with real hardware (and KVM) unless
>   someone (hi Thomas :-) beats me to it.
> 
> Standard cover-letter summary:
>   This series brings basic setup; starts a test's C entry point, main(),
>   and printf, exit, and malloc work. Three more series should follow this
>   one which must bring; vector support, mmu support, and smp support, at
>   which point I believe the framework could just evolve with the creation
>   of unit tests.
> 
> Patches also available here
> https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2

I'll rebase this branch with the fix included too.

> 
> 
> Andrew Jones (14):
>   lib: asm-generic: add missing casts
>   lib: share arm-selftest utility functions
>   config: no need to mix arch makefiles
>   powerpc/ppc64: start skeleton framework
>   powerpc/pp64: ppc-ify makefiles and linker script
>   powerpc/ppc64: add boot rom source
>   powerpc/ppc64: add bootloader to bounce into memory
>   powerpc/ppc64: add HV putchar
>   powerpc/ppc64: adapt arm's setup
>   powerpc/ppc64: relocate linker VMAs
>   powerpc/ppc64: add run script and unittests.cfg
>   mkstandalone: add support for powerpc
>   powerpc/ppc64: add RTAS support
>   powerpc/ppc64: HACK: make a fake debug-exit
> 
>  Makefile                                           |   2 +-
>  README                                             |   3 +-
>  arm/Makefile                                       |   1 +
>  config/config-arm.mak => arm/Makefile.arm          |   2 +-
>  config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
>  .../config-arm-common.mak => arm/Makefile.common   |   3 +-
>  arm/selftest.c                                     |  45 +++-----
>  configure                                          |   6 ++
>  lib/asm-generic/io.h                               |  12 +--
>  lib/libcflat.h                                     |  11 +-
>  lib/powerpc/.gitignore                             |   1 +
>  lib/powerpc/asm/rtas.h                             |  26 +++++
>  lib/powerpc/asm/setup.h                            |  27 +++++
>  lib/powerpc/io.c                                   |  37 +++++++
>  lib/powerpc/mmu.c                                  |   0
>  lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
>  lib/powerpc/setup.c                                |  91 ++++++++++++++++
>  lib/powerpc/smp.c                                  |   0
>  lib/ppc64/.gitignore                               |   1 +
>  lib/ppc64/asm-offsets.c                            |  12 +++
>  lib/ppc64/asm/asm-offsets.h                        |   1 +
>  lib/ppc64/asm/io.h                                 |   5 +
>  lib/ppc64/asm/page.h                               |   1 +
>  lib/ppc64/asm/rtas.h                               |   1 +
>  lib/ppc64/asm/setup.h                              |   1 +
>  lib/ppc64/asm/spinlock.h                           |  11 ++
>  lib/ppc64/processor.c                              |   0
>  lib/ppc64/spinlock.c                               |  11 ++
>  lib/report.c                                       |  16 +++
>  lib/util.c                                         |  18 ++++
>  lib/util.h                                         |  23 ++++
>  powerpc/Makefile                                   |   1 +
>  powerpc/Makefile.common                            |  65 +++++++++++
>  powerpc/Makefile.ppc64                             |  21 ++++
>  powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
>  powerpc/cstart64.S                                 |  86 +++++++++++++++
>  powerpc/flat.lds                                   |  44 ++++++++
>  powerpc/reloc64.c                                  |  55 ++++++++++
>  powerpc/rom/.gitignore                             |   1 +
>  powerpc/rom/Makefile                               |  36 +++++++
>  powerpc/rom/header.img                             |   1 +
>  powerpc/rom/rom.ffs                                |   4 +
>  powerpc/rom/stage1.S                               |   5 +
>  powerpc/run                                        |  60 +++++++++++
>  powerpc/selftest.c                                 |  65 +++++++++++
>  powerpc/unittests.cfg                              |  30 ++++++
>  {config => scripts}/asm-offsets.mak                |   0
>  scripts/mkstandalone.sh                            |   5 +
>  x86/Makefile                                       |   1 +
>  .../config-x86-common.mak => x86/Makefile.common   |   0
>  config/config-i386.mak => x86/Makefile.i386        |   2 +-
>  config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
>  52 files changed, 924 insertions(+), 50 deletions(-)
>  create mode 100644 arm/Makefile
>  rename config/config-arm.mak => arm/Makefile.arm (90%)
>  rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
>  rename config/config-arm-common.mak => arm/Makefile.common (96%)
>  create mode 100644 lib/powerpc/.gitignore
>  create mode 100644 lib/powerpc/asm/rtas.h
>  create mode 100644 lib/powerpc/asm/setup.h
>  create mode 100644 lib/powerpc/io.c
>  create mode 100644 lib/powerpc/mmu.c
>  create mode 100644 lib/powerpc/rtas.c
>  create mode 100644 lib/powerpc/setup.c
>  create mode 100644 lib/powerpc/smp.c
>  create mode 100644 lib/ppc64/.gitignore
>  create mode 100644 lib/ppc64/asm-offsets.c
>  create mode 100644 lib/ppc64/asm/asm-offsets.h
>  create mode 100644 lib/ppc64/asm/io.h
>  create mode 100644 lib/ppc64/asm/page.h
>  create mode 100644 lib/ppc64/asm/rtas.h
>  create mode 100644 lib/ppc64/asm/setup.h
>  create mode 100644 lib/ppc64/asm/spinlock.h
>  create mode 100644 lib/ppc64/processor.c
>  create mode 100644 lib/ppc64/spinlock.c
>  create mode 100644 lib/util.c
>  create mode 100644 lib/util.h
>  create mode 100644 powerpc/Makefile
>  create mode 100644 powerpc/Makefile.common
>  create mode 100644 powerpc/Makefile.ppc64
>  create mode 100644 powerpc/boot_rom.bin
>  create mode 100644 powerpc/cstart64.S
>  create mode 100644 powerpc/flat.lds
>  create mode 100644 powerpc/reloc64.c
>  create mode 100644 powerpc/rom/.gitignore
>  create mode 100644 powerpc/rom/Makefile
>  create mode 100644 powerpc/rom/header.img
>  create mode 100644 powerpc/rom/rom.ffs
>  create mode 100644 powerpc/rom/stage1.S
>  create mode 100755 powerpc/run
>  create mode 100644 powerpc/selftest.c
>  create mode 100644 powerpc/unittests.cfg
>  rename {config => scripts}/asm-offsets.mak (100%)
>  create mode 100644 x86/Makefile
>  rename config/config-x86-common.mak => x86/Makefile.common (100%)
>  rename config/config-i386.mak => x86/Makefile.i386 (91%)
>  rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)
> 
> -- 
> 2.4.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-09 17:49   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-09 17:49 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

On Mon, Feb 08, 2016 at 07:53:00PM +0100, Andrew Jones wrote:
> It's been a loooong time since I posted v1 of this series, but thanks
> to Thomas' poking, and even volunteering to help move v2 along, I've
> finally picked it back up.
> 
> v2:
>   Besides rebasing on latest master, v2 addresses all of David's comments
>     - assembler cleanup
>     - jump into the RTAS blob we get from DT, instead of reproducing it
>     - don't store the RTAS root node, always hunt it down
> 
>   v2 didn't address debug-exit, and we still need a solution for that.
>   Plugging chr-testdev into an spapr vty is probably what we should
>   investigate first (as was suggested by Alex Graf under the v1 review).
>   For this v2 I just kept the hack from v1, but simplified it and
>   explicitly call it out as the hack that it is.
> 
> Additional known issues:
>   Latest F22 cross-compiler (gcc5 based) doesn't generate working
>   code with this series. I didn't try to debug. The 4.9 based compiler
>   I initially used on v1 works, so I reverted to that one.

OK, I couldn't resist debugging this one. It appears recent toolchains
require the TOC to be 256 byte aligned (see [*]). The patch to this
series is a simple change to flat.lds, which I'll send as a follow-up
to patch 05/14.

[*] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id^95235

> 
> Testing:
>   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
>   try to get a machine to test with real hardware (and KVM) unless
>   someone (hi Thomas :-) beats me to it.
> 
> Standard cover-letter summary:
>   This series brings basic setup; starts a test's C entry point, main(),
>   and printf, exit, and malloc work. Three more series should follow this
>   one which must bring; vector support, mmu support, and smp support, at
>   which point I believe the framework could just evolve with the creation
>   of unit tests.
> 
> Patches also available here
> https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2

I'll rebase this branch with the fix included too.

> 
> 
> Andrew Jones (14):
>   lib: asm-generic: add missing casts
>   lib: share arm-selftest utility functions
>   config: no need to mix arch makefiles
>   powerpc/ppc64: start skeleton framework
>   powerpc/pp64: ppc-ify makefiles and linker script
>   powerpc/ppc64: add boot rom source
>   powerpc/ppc64: add bootloader to bounce into memory
>   powerpc/ppc64: add HV putchar
>   powerpc/ppc64: adapt arm's setup
>   powerpc/ppc64: relocate linker VMAs
>   powerpc/ppc64: add run script and unittests.cfg
>   mkstandalone: add support for powerpc
>   powerpc/ppc64: add RTAS support
>   powerpc/ppc64: HACK: make a fake debug-exit
> 
>  Makefile                                           |   2 +-
>  README                                             |   3 +-
>  arm/Makefile                                       |   1 +
>  config/config-arm.mak => arm/Makefile.arm          |   2 +-
>  config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
>  .../config-arm-common.mak => arm/Makefile.common   |   3 +-
>  arm/selftest.c                                     |  45 +++-----
>  configure                                          |   6 ++
>  lib/asm-generic/io.h                               |  12 +--
>  lib/libcflat.h                                     |  11 +-
>  lib/powerpc/.gitignore                             |   1 +
>  lib/powerpc/asm/rtas.h                             |  26 +++++
>  lib/powerpc/asm/setup.h                            |  27 +++++
>  lib/powerpc/io.c                                   |  37 +++++++
>  lib/powerpc/mmu.c                                  |   0
>  lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
>  lib/powerpc/setup.c                                |  91 ++++++++++++++++
>  lib/powerpc/smp.c                                  |   0
>  lib/ppc64/.gitignore                               |   1 +
>  lib/ppc64/asm-offsets.c                            |  12 +++
>  lib/ppc64/asm/asm-offsets.h                        |   1 +
>  lib/ppc64/asm/io.h                                 |   5 +
>  lib/ppc64/asm/page.h                               |   1 +
>  lib/ppc64/asm/rtas.h                               |   1 +
>  lib/ppc64/asm/setup.h                              |   1 +
>  lib/ppc64/asm/spinlock.h                           |  11 ++
>  lib/ppc64/processor.c                              |   0
>  lib/ppc64/spinlock.c                               |  11 ++
>  lib/report.c                                       |  16 +++
>  lib/util.c                                         |  18 ++++
>  lib/util.h                                         |  23 ++++
>  powerpc/Makefile                                   |   1 +
>  powerpc/Makefile.common                            |  65 +++++++++++
>  powerpc/Makefile.ppc64                             |  21 ++++
>  powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
>  powerpc/cstart64.S                                 |  86 +++++++++++++++
>  powerpc/flat.lds                                   |  44 ++++++++
>  powerpc/reloc64.c                                  |  55 ++++++++++
>  powerpc/rom/.gitignore                             |   1 +
>  powerpc/rom/Makefile                               |  36 +++++++
>  powerpc/rom/header.img                             |   1 +
>  powerpc/rom/rom.ffs                                |   4 +
>  powerpc/rom/stage1.S                               |   5 +
>  powerpc/run                                        |  60 +++++++++++
>  powerpc/selftest.c                                 |  65 +++++++++++
>  powerpc/unittests.cfg                              |  30 ++++++
>  {config => scripts}/asm-offsets.mak                |   0
>  scripts/mkstandalone.sh                            |   5 +
>  x86/Makefile                                       |   1 +
>  .../config-x86-common.mak => x86/Makefile.common   |   0
>  config/config-i386.mak => x86/Makefile.i386        |   2 +-
>  config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
>  52 files changed, 924 insertions(+), 50 deletions(-)
>  create mode 100644 arm/Makefile
>  rename config/config-arm.mak => arm/Makefile.arm (90%)
>  rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
>  rename config/config-arm-common.mak => arm/Makefile.common (96%)
>  create mode 100644 lib/powerpc/.gitignore
>  create mode 100644 lib/powerpc/asm/rtas.h
>  create mode 100644 lib/powerpc/asm/setup.h
>  create mode 100644 lib/powerpc/io.c
>  create mode 100644 lib/powerpc/mmu.c
>  create mode 100644 lib/powerpc/rtas.c
>  create mode 100644 lib/powerpc/setup.c
>  create mode 100644 lib/powerpc/smp.c
>  create mode 100644 lib/ppc64/.gitignore
>  create mode 100644 lib/ppc64/asm-offsets.c
>  create mode 100644 lib/ppc64/asm/asm-offsets.h
>  create mode 100644 lib/ppc64/asm/io.h
>  create mode 100644 lib/ppc64/asm/page.h
>  create mode 100644 lib/ppc64/asm/rtas.h
>  create mode 100644 lib/ppc64/asm/setup.h
>  create mode 100644 lib/ppc64/asm/spinlock.h
>  create mode 100644 lib/ppc64/processor.c
>  create mode 100644 lib/ppc64/spinlock.c
>  create mode 100644 lib/util.c
>  create mode 100644 lib/util.h
>  create mode 100644 powerpc/Makefile
>  create mode 100644 powerpc/Makefile.common
>  create mode 100644 powerpc/Makefile.ppc64
>  create mode 100644 powerpc/boot_rom.bin
>  create mode 100644 powerpc/cstart64.S
>  create mode 100644 powerpc/flat.lds
>  create mode 100644 powerpc/reloc64.c
>  create mode 100644 powerpc/rom/.gitignore
>  create mode 100644 powerpc/rom/Makefile
>  create mode 100644 powerpc/rom/header.img
>  create mode 100644 powerpc/rom/rom.ffs
>  create mode 100644 powerpc/rom/stage1.S
>  create mode 100755 powerpc/run
>  create mode 100644 powerpc/selftest.c
>  create mode 100644 powerpc/unittests.cfg
>  rename {config => scripts}/asm-offsets.mak (100%)
>  create mode 100644 x86/Makefile
>  rename config/config-x86-common.mak => x86/Makefile.common (100%)
>  rename config/config-i386.mak => x86/Makefile.i386 (91%)
>  rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)
> 
> -- 
> 2.4.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH] align toc to 256 bytes
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-09 17:54     ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-09 17:54 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

---
 powerpc/flat.lds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/powerpc/flat.lds b/powerpc/flat.lds
index 8a573d27346de..53221e8b4211c 100644
--- a/powerpc/flat.lds
+++ b/powerpc/flat.lds
@@ -24,7 +24,7 @@ SECTIONS
     .rodata : { *(.rodata) *(.rodata.*) }
     . = ALIGN(16);
     .bss : { *(.bss) }
-    . = ALIGN(16);
+    . = ALIGN(256);
     /*
      * tocptr is tocbase + 32K, allowing toc offsets to be +-32K
      */
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* [kvm-unit-tests PATCH] align toc to 256 bytes
@ 2016-02-09 17:54     ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-09 17:54 UTC (permalink / raw)
  To: kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier, pbonzini

---
 powerpc/flat.lds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/powerpc/flat.lds b/powerpc/flat.lds
index 8a573d27346de..53221e8b4211c 100644
--- a/powerpc/flat.lds
+++ b/powerpc/flat.lds
@@ -24,7 +24,7 @@ SECTIONS
     .rodata : { *(.rodata) *(.rodata.*) }
     . = ALIGN(16);
     .bss : { *(.bss) }
-    . = ALIGN(16);
+    . = ALIGN(256);
     /*
      * tocptr is tocbase + 32K, allowing toc offsets to be +-32K
      */
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-10 14:27   ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2016-02-10 14:27 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier



On 08/02/2016 19:53, Andrew Jones wrote:
> It's been a loooong time since I posted v1 of this series, but thanks
> to Thomas' poking, and even volunteering to help move v2 along, I've
> finally picked it back up.
> 
> v2:
>   Besides rebasing on latest master, v2 addresses all of David's comments
>     - assembler cleanup
>     - jump into the RTAS blob we get from DT, instead of reproducing it
>     - don't store the RTAS root node, always hunt it down
> 
>   v2 didn't address debug-exit, and we still need a solution for that.
>   Plugging chr-testdev into an spapr vty is probably what we should
>   investigate first (as was suggested by Alex Graf under the v1 review).
>   For this v2 I just kept the hack from v1, but simplified it and
>   explicitly call it out as the hack that it is.
> 
> Additional known issues:
>   Latest F22 cross-compiler (gcc5 based) doesn't generate working
>   code with this series. I didn't try to debug. The 4.9 based compiler
>   I initially used on v1 works, so I reverted to that one.
> 
> Testing:
>   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
>   try to get a machine to test with real hardware (and KVM) unless
>   someone (hi Thomas :-) beats me to it.
> 
> Standard cover-letter summary:
>   This series brings basic setup; starts a test's C entry point, main(),
>   and printf, exit, and malloc work. Three more series should follow this
>   one which must bring; vector support, mmu support, and smp support, at
>   which point I believe the framework could just evolve with the creation
>   of unit tests.
> 
> Patches also available here
> https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2

The only request is to not include zero-size files; just leave them out
and add them as necessary.

Otherwise it's nice. :)

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-10 14:27   ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2016-02-10 14:27 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, lvivier



On 08/02/2016 19:53, Andrew Jones wrote:
> It's been a loooong time since I posted v1 of this series, but thanks
> to Thomas' poking, and even volunteering to help move v2 along, I've
> finally picked it back up.
> 
> v2:
>   Besides rebasing on latest master, v2 addresses all of David's comments
>     - assembler cleanup
>     - jump into the RTAS blob we get from DT, instead of reproducing it
>     - don't store the RTAS root node, always hunt it down
> 
>   v2 didn't address debug-exit, and we still need a solution for that.
>   Plugging chr-testdev into an spapr vty is probably what we should
>   investigate first (as was suggested by Alex Graf under the v1 review).
>   For this v2 I just kept the hack from v1, but simplified it and
>   explicitly call it out as the hack that it is.
> 
> Additional known issues:
>   Latest F22 cross-compiler (gcc5 based) doesn't generate working
>   code with this series. I didn't try to debug. The 4.9 based compiler
>   I initially used on v1 works, so I reverted to that one.
> 
> Testing:
>   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
>   try to get a machine to test with real hardware (and KVM) unless
>   someone (hi Thomas :-) beats me to it.
> 
> Standard cover-letter summary:
>   This series brings basic setup; starts a test's C entry point, main(),
>   and printf, exit, and malloc work. Three more series should follow this
>   one which must bring; vector support, mmu support, and smp support, at
>   which point I believe the framework could just evolve with the creation
>   of unit tests.
> 
> Patches also available here
> https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2

The only request is to not include zero-size files; just leave them out
and add them as necessary.

Otherwise it's nice. :)

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-10 14:27   ` Paolo Bonzini
@ 2016-02-11 11:56     ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-11 11:56 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, lvivier

On Wed, Feb 10, 2016 at 03:27:09PM +0100, Paolo Bonzini wrote:
> 
> 
> On 08/02/2016 19:53, Andrew Jones wrote:
> > It's been a loooong time since I posted v1 of this series, but thanks
> > to Thomas' poking, and even volunteering to help move v2 along, I've
> > finally picked it back up.
> > 
> > v2:
> >   Besides rebasing on latest master, v2 addresses all of David's comments
> >     - assembler cleanup
> >     - jump into the RTAS blob we get from DT, instead of reproducing it
> >     - don't store the RTAS root node, always hunt it down
> > 
> >   v2 didn't address debug-exit, and we still need a solution for that.
> >   Plugging chr-testdev into an spapr vty is probably what we should
> >   investigate first (as was suggested by Alex Graf under the v1 review).
> >   For this v2 I just kept the hack from v1, but simplified it and
> >   explicitly call it out as the hack that it is.
> > 
> > Additional known issues:
> >   Latest F22 cross-compiler (gcc5 based) doesn't generate working
> >   code with this series. I didn't try to debug. The 4.9 based compiler
> >   I initially used on v1 works, so I reverted to that one.
> > 
> > Testing:
> >   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
> >   try to get a machine to test with real hardware (and KVM) unless
> >   someone (hi Thomas :-) beats me to it.
> > 
> > Standard cover-letter summary:
> >   This series brings basic setup; starts a test's C entry point, main(),
> >   and printf, exit, and malloc work. Three more series should follow this
> >   one which must bring; vector support, mmu support, and smp support, at
> >   which point I believe the framework could just evolve with the creation
> >   of unit tests.
> > 
> > Patches also available here
> > https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2
> 
> The only request is to not include zero-size files; just leave them out
> and add them as necessary.

Yeah, upon reflection of that idea, it was dumb. I'll not do that.

> 
> Otherwise it's nice. :)

Thanks!

So, how should we proceed? I propose to
 1) Wait for some more reviews (some r-b's would be nice to add)
 2) I'll remove the zero-size files and fix anything else brought up,
    then post a v3.
Then
 3) Q: Should we wait until the debug-exit hack has been replaced with
       something better? Or could we commit it as a starter (I believe
       it may already even be a useful framework for hypercall testing.
       Something Thomas wants to use it for now.)

drew

> 
> Paolo
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 11:56     ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-11 11:56 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, lvivier

On Wed, Feb 10, 2016 at 03:27:09PM +0100, Paolo Bonzini wrote:
> 
> 
> On 08/02/2016 19:53, Andrew Jones wrote:
> > It's been a loooong time since I posted v1 of this series, but thanks
> > to Thomas' poking, and even volunteering to help move v2 along, I've
> > finally picked it back up.
> > 
> > v2:
> >   Besides rebasing on latest master, v2 addresses all of David's comments
> >     - assembler cleanup
> >     - jump into the RTAS blob we get from DT, instead of reproducing it
> >     - don't store the RTAS root node, always hunt it down
> > 
> >   v2 didn't address debug-exit, and we still need a solution for that.
> >   Plugging chr-testdev into an spapr vty is probably what we should
> >   investigate first (as was suggested by Alex Graf under the v1 review).
> >   For this v2 I just kept the hack from v1, but simplified it and
> >   explicitly call it out as the hack that it is.
> > 
> > Additional known issues:
> >   Latest F22 cross-compiler (gcc5 based) doesn't generate working
> >   code with this series. I didn't try to debug. The 4.9 based compiler
> >   I initially used on v1 works, so I reverted to that one.
> > 
> > Testing:
> >   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
> >   try to get a machine to test with real hardware (and KVM) unless
> >   someone (hi Thomas :-) beats me to it.
> > 
> > Standard cover-letter summary:
> >   This series brings basic setup; starts a test's C entry point, main(),
> >   and printf, exit, and malloc work. Three more series should follow this
> >   one which must bring; vector support, mmu support, and smp support, at
> >   which point I believe the framework could just evolve with the creation
> >   of unit tests.
> > 
> > Patches also available here
> > https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2
> 
> The only request is to not include zero-size files; just leave them out
> and add them as necessary.

Yeah, upon reflection of that idea, it was dumb. I'll not do that.

> 
> Otherwise it's nice. :)

Thanks!

So, how should we proceed? I propose to
 1) Wait for some more reviews (some r-b's would be nice to add)
 2) I'll remove the zero-size files and fix anything else brought up,
    then post a v3.
Then
 3) Q: Should we wait until the debug-exit hack has been replaced with
       something better? Or could we commit it as a starter (I believe
       it may already even be a useful framework for hypercall testing.
       Something Thomas wants to use it for now.)

drew

> 
> Paolo
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-11 11:56     ` Andrew Jones
@ 2016-02-11 12:36       ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2016-02-11 12:36 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, lvivier



On 11/02/2016 12:56, Andrew Jones wrote:
> 
> So, how should we proceed? I propose to
>  1) Wait for some more reviews (some r-b's would be nice to add)
>  2) I'll remove the zero-size files and fix anything else brought up,
>     then post a v3.
> Then
>  3) Q: Should we wait until the debug-exit hack has been replaced with
>        something better? Or could we commit it as a starter (I believe
>        it may already even be a useful framework for hypercall testing.

Yes, I think we want it for now.  Remove the "HACK" even; as long as
it's a PPC-only thing it's fine.

Paolo

>        Something Thomas wants to use it for now.)

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 12:36       ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2016-02-11 12:36 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, lvivier



On 11/02/2016 12:56, Andrew Jones wrote:
> 
> So, how should we proceed? I propose to
>  1) Wait for some more reviews (some r-b's would be nice to add)
>  2) I'll remove the zero-size files and fix anything else brought up,
>     then post a v3.
> Then
>  3) Q: Should we wait until the debug-exit hack has been replaced with
>        something better? Or could we commit it as a starter (I believe
>        it may already even be a useful framework for hypercall testing.

Yes, I think we want it for now.  Remove the "HACK" even; as long as
it's a PPC-only thing it's fine.

Paolo

>        Something Thomas wants to use it for now.)

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-08 18:53 ` Andrew Jones
@ 2016-02-11 13:36   ` Laurent Vivier
  -1 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-11 13:36 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, pbonzini

Hi,

On 08/02/2016 19:53, Andrew Jones wrote:
> It's been a loooong time since I posted v1 of this series, but thanks
> to Thomas' poking, and even volunteering to help move v2 along, I've
> finally picked it back up.
> 
> v2:
>   Besides rebasing on latest master, v2 addresses all of David's comments
>     - assembler cleanup
>     - jump into the RTAS blob we get from DT, instead of reproducing it
>     - don't store the RTAS root node, always hunt it down
> 
>   v2 didn't address debug-exit, and we still need a solution for that.
>   Plugging chr-testdev into an spapr vty is probably what we should
>   investigate first (as was suggested by Alex Graf under the v1 review).
>   For this v2 I just kept the hack from v1, but simplified it and
>   explicitly call it out as the hack that it is.
> 
> Additional known issues:
>   Latest F22 cross-compiler (gcc5 based) doesn't generate working
>   code with this series. I didn't try to debug. The 4.9 based compiler
>   I initially used on v1 works, so I reverted to that one.
> 
> Testing:
>   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
>   try to get a machine to test with real hardware (and KVM) unless
>   someone (hi Thomas :-) beats me to it.

I've tested the series from the branch initial-drop-v2:

- On RHEL 7.2 ppc64 (ppc64le is not supported ?), POWER8 + kvm_hv.
  I have (sometime) an error:

./powerpc/run: line 60: exit: too many arguments
PASS selftest-setup


Which is in fact:

/usr/libexec/qemu-kvm -machine pseries,accel=kvm -bios
powerpc/boot_rom.bin -display none -serial stdio -kernel
powerpc/selftest.elf -smp 2 -m 256 -append setup smp=2 mem=256
PASS: selftest: setup: smp: nr_cpus = 2
PASS: selftest: setup: mem: size = 256 MB

SUMMARY: 2 tests, 0 unexpected failures

EXIT: STATUS=1
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS=12
Return value from qemu: 1 127 127 127 127 127 127 127 127 127 127 127 12
./powerpc/run: line 60: exit: too many arguments


- On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:

lib/powerpc/setup.c:60: assert failed
 59         assert(freemem_start >= mem_start && freemem_start < mem_end);

The values I have are:
freemem_start 434000 mem_start 8000000 mem_end 10000000

> 
> Standard cover-letter summary:
>   This series brings basic setup; starts a test's C entry point, main(),
>   and printf, exit, and malloc work. Three more series should follow this
>   one which must bring; vector support, mmu support, and smp support, at
>   which point I believe the framework could just evolve with the creation
>   of unit tests.
> 
> Patches also available here
> https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2
> 
> 
> Andrew Jones (14):
>   lib: asm-generic: add missing casts
>   lib: share arm-selftest utility functions
>   config: no need to mix arch makefiles
>   powerpc/ppc64: start skeleton framework
>   powerpc/pp64: ppc-ify makefiles and linker script
>   powerpc/ppc64: add boot rom source
>   powerpc/ppc64: add bootloader to bounce into memory
>   powerpc/ppc64: add HV putchar
>   powerpc/ppc64: adapt arm's setup
>   powerpc/ppc64: relocate linker VMAs
>   powerpc/ppc64: add run script and unittests.cfg
>   mkstandalone: add support for powerpc
>   powerpc/ppc64: add RTAS support
>   powerpc/ppc64: HACK: make a fake debug-exit
> 
>  Makefile                                           |   2 +-
>  README                                             |   3 +-
>  arm/Makefile                                       |   1 +
>  config/config-arm.mak => arm/Makefile.arm          |   2 +-
>  config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
>  .../config-arm-common.mak => arm/Makefile.common   |   3 +-
>  arm/selftest.c                                     |  45 +++-----
>  configure                                          |   6 ++
>  lib/asm-generic/io.h                               |  12 +--
>  lib/libcflat.h                                     |  11 +-
>  lib/powerpc/.gitignore                             |   1 +
>  lib/powerpc/asm/rtas.h                             |  26 +++++
>  lib/powerpc/asm/setup.h                            |  27 +++++
>  lib/powerpc/io.c                                   |  37 +++++++
>  lib/powerpc/mmu.c                                  |   0
>  lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
>  lib/powerpc/setup.c                                |  91 ++++++++++++++++
>  lib/powerpc/smp.c                                  |   0
>  lib/ppc64/.gitignore                               |   1 +
>  lib/ppc64/asm-offsets.c                            |  12 +++
>  lib/ppc64/asm/asm-offsets.h                        |   1 +
>  lib/ppc64/asm/io.h                                 |   5 +
>  lib/ppc64/asm/page.h                               |   1 +
>  lib/ppc64/asm/rtas.h                               |   1 +
>  lib/ppc64/asm/setup.h                              |   1 +
>  lib/ppc64/asm/spinlock.h                           |  11 ++
>  lib/ppc64/processor.c                              |   0
>  lib/ppc64/spinlock.c                               |  11 ++
>  lib/report.c                                       |  16 +++
>  lib/util.c                                         |  18 ++++
>  lib/util.h                                         |  23 ++++
>  powerpc/Makefile                                   |   1 +
>  powerpc/Makefile.common                            |  65 +++++++++++
>  powerpc/Makefile.ppc64                             |  21 ++++
>  powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
>  powerpc/cstart64.S                                 |  86 +++++++++++++++
>  powerpc/flat.lds                                   |  44 ++++++++
>  powerpc/reloc64.c                                  |  55 ++++++++++
>  powerpc/rom/.gitignore                             |   1 +
>  powerpc/rom/Makefile                               |  36 +++++++
>  powerpc/rom/header.img                             |   1 +
>  powerpc/rom/rom.ffs                                |   4 +
>  powerpc/rom/stage1.S                               |   5 +
>  powerpc/run                                        |  60 +++++++++++
>  powerpc/selftest.c                                 |  65 +++++++++++
>  powerpc/unittests.cfg                              |  30 ++++++
>  {config => scripts}/asm-offsets.mak                |   0
>  scripts/mkstandalone.sh                            |   5 +
>  x86/Makefile                                       |   1 +
>  .../config-x86-common.mak => x86/Makefile.common   |   0
>  config/config-i386.mak => x86/Makefile.i386        |   2 +-
>  config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
>  52 files changed, 924 insertions(+), 50 deletions(-)
>  create mode 100644 arm/Makefile
>  rename config/config-arm.mak => arm/Makefile.arm (90%)
>  rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
>  rename config/config-arm-common.mak => arm/Makefile.common (96%)
>  create mode 100644 lib/powerpc/.gitignore
>  create mode 100644 lib/powerpc/asm/rtas.h
>  create mode 100644 lib/powerpc/asm/setup.h
>  create mode 100644 lib/powerpc/io.c
>  create mode 100644 lib/powerpc/mmu.c
>  create mode 100644 lib/powerpc/rtas.c
>  create mode 100644 lib/powerpc/setup.c
>  create mode 100644 lib/powerpc/smp.c
>  create mode 100644 lib/ppc64/.gitignore
>  create mode 100644 lib/ppc64/asm-offsets.c
>  create mode 100644 lib/ppc64/asm/asm-offsets.h
>  create mode 100644 lib/ppc64/asm/io.h
>  create mode 100644 lib/ppc64/asm/page.h
>  create mode 100644 lib/ppc64/asm/rtas.h
>  create mode 100644 lib/ppc64/asm/setup.h
>  create mode 100644 lib/ppc64/asm/spinlock.h
>  create mode 100644 lib/ppc64/processor.c
>  create mode 100644 lib/ppc64/spinlock.c
>  create mode 100644 lib/util.c
>  create mode 100644 lib/util.h
>  create mode 100644 powerpc/Makefile
>  create mode 100644 powerpc/Makefile.common
>  create mode 100644 powerpc/Makefile.ppc64
>  create mode 100644 powerpc/boot_rom.bin
>  create mode 100644 powerpc/cstart64.S
>  create mode 100644 powerpc/flat.lds
>  create mode 100644 powerpc/reloc64.c
>  create mode 100644 powerpc/rom/.gitignore
>  create mode 100644 powerpc/rom/Makefile
>  create mode 100644 powerpc/rom/header.img
>  create mode 100644 powerpc/rom/rom.ffs
>  create mode 100644 powerpc/rom/stage1.S
>  create mode 100755 powerpc/run
>  create mode 100644 powerpc/selftest.c
>  create mode 100644 powerpc/unittests.cfg
>  rename {config => scripts}/asm-offsets.mak (100%)
>  create mode 100644 x86/Makefile
>  rename config/config-x86-common.mak => x86/Makefile.common (100%)
>  rename config/config-i386.mak => x86/Makefile.i386 (91%)
>  rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 13:36   ` Laurent Vivier
  0 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-11 13:36 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: thuth, dgibson, david, agraf, pbonzini

Hi,

On 08/02/2016 19:53, Andrew Jones wrote:
> It's been a loooong time since I posted v1 of this series, but thanks
> to Thomas' poking, and even volunteering to help move v2 along, I've
> finally picked it back up.
> 
> v2:
>   Besides rebasing on latest master, v2 addresses all of David's comments
>     - assembler cleanup
>     - jump into the RTAS blob we get from DT, instead of reproducing it
>     - don't store the RTAS root node, always hunt it down
> 
>   v2 didn't address debug-exit, and we still need a solution for that.
>   Plugging chr-testdev into an spapr vty is probably what we should
>   investigate first (as was suggested by Alex Graf under the v1 review).
>   For this v2 I just kept the hack from v1, but simplified it and
>   explicitly call it out as the hack that it is.
> 
> Additional known issues:
>   Latest F22 cross-compiler (gcc5 based) doesn't generate working
>   code with this series. I didn't try to debug. The 4.9 based compiler
>   I initially used on v1 works, so I reverted to that one.
> 
> Testing:
>   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
>   try to get a machine to test with real hardware (and KVM) unless
>   someone (hi Thomas :-) beats me to it.

I've tested the series from the branch initial-drop-v2:

- On RHEL 7.2 ppc64 (ppc64le is not supported ?), POWER8 + kvm_hv.
  I have (sometime) an error:

./powerpc/run: line 60: exit: too many arguments
PASS selftest-setup


Which is in fact:

/usr/libexec/qemu-kvm -machine pseries,accel=kvm -bios
powerpc/boot_rom.bin -display none -serial stdio -kernel
powerpc/selftest.elf -smp 2 -m 256 -append setup smp=2 mem%6
PASS: selftest: setup: smp: nr_cpus = 2
PASS: selftest: setup: mem: size = 256 MB

SUMMARY: 2 tests, 0 unexpected failures

EXIT: STATUS=1
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x127
RTAS power-off returned 0
lib/powerpc/rtas.c:119: assert failed

EXIT: STATUS\x12
Return value from qemu: 1 127 127 127 127 127 127 127 127 127 127 127 12
./powerpc/run: line 60: exit: too many arguments


- On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:

lib/powerpc/setup.c:60: assert failed
 59         assert(freemem_start >= mem_start && freemem_start < mem_end);

The values I have are:
freemem_start 434000 mem_start 8000000 mem_end 10000000

> 
> Standard cover-letter summary:
>   This series brings basic setup; starts a test's C entry point, main(),
>   and printf, exit, and malloc work. Three more series should follow this
>   one which must bring; vector support, mmu support, and smp support, at
>   which point I believe the framework could just evolve with the creation
>   of unit tests.
> 
> Patches also available here
> https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2
> 
> 
> Andrew Jones (14):
>   lib: asm-generic: add missing casts
>   lib: share arm-selftest utility functions
>   config: no need to mix arch makefiles
>   powerpc/ppc64: start skeleton framework
>   powerpc/pp64: ppc-ify makefiles and linker script
>   powerpc/ppc64: add boot rom source
>   powerpc/ppc64: add bootloader to bounce into memory
>   powerpc/ppc64: add HV putchar
>   powerpc/ppc64: adapt arm's setup
>   powerpc/ppc64: relocate linker VMAs
>   powerpc/ppc64: add run script and unittests.cfg
>   mkstandalone: add support for powerpc
>   powerpc/ppc64: add RTAS support
>   powerpc/ppc64: HACK: make a fake debug-exit
> 
>  Makefile                                           |   2 +-
>  README                                             |   3 +-
>  arm/Makefile                                       |   1 +
>  config/config-arm.mak => arm/Makefile.arm          |   2 +-
>  config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
>  .../config-arm-common.mak => arm/Makefile.common   |   3 +-
>  arm/selftest.c                                     |  45 +++-----
>  configure                                          |   6 ++
>  lib/asm-generic/io.h                               |  12 +--
>  lib/libcflat.h                                     |  11 +-
>  lib/powerpc/.gitignore                             |   1 +
>  lib/powerpc/asm/rtas.h                             |  26 +++++
>  lib/powerpc/asm/setup.h                            |  27 +++++
>  lib/powerpc/io.c                                   |  37 +++++++
>  lib/powerpc/mmu.c                                  |   0
>  lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
>  lib/powerpc/setup.c                                |  91 ++++++++++++++++
>  lib/powerpc/smp.c                                  |   0
>  lib/ppc64/.gitignore                               |   1 +
>  lib/ppc64/asm-offsets.c                            |  12 +++
>  lib/ppc64/asm/asm-offsets.h                        |   1 +
>  lib/ppc64/asm/io.h                                 |   5 +
>  lib/ppc64/asm/page.h                               |   1 +
>  lib/ppc64/asm/rtas.h                               |   1 +
>  lib/ppc64/asm/setup.h                              |   1 +
>  lib/ppc64/asm/spinlock.h                           |  11 ++
>  lib/ppc64/processor.c                              |   0
>  lib/ppc64/spinlock.c                               |  11 ++
>  lib/report.c                                       |  16 +++
>  lib/util.c                                         |  18 ++++
>  lib/util.h                                         |  23 ++++
>  powerpc/Makefile                                   |   1 +
>  powerpc/Makefile.common                            |  65 +++++++++++
>  powerpc/Makefile.ppc64                             |  21 ++++
>  powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
>  powerpc/cstart64.S                                 |  86 +++++++++++++++
>  powerpc/flat.lds                                   |  44 ++++++++
>  powerpc/reloc64.c                                  |  55 ++++++++++
>  powerpc/rom/.gitignore                             |   1 +
>  powerpc/rom/Makefile                               |  36 +++++++
>  powerpc/rom/header.img                             |   1 +
>  powerpc/rom/rom.ffs                                |   4 +
>  powerpc/rom/stage1.S                               |   5 +
>  powerpc/run                                        |  60 +++++++++++
>  powerpc/selftest.c                                 |  65 +++++++++++
>  powerpc/unittests.cfg                              |  30 ++++++
>  {config => scripts}/asm-offsets.mak                |   0
>  scripts/mkstandalone.sh                            |   5 +
>  x86/Makefile                                       |   1 +
>  .../config-x86-common.mak => x86/Makefile.common   |   0
>  config/config-i386.mak => x86/Makefile.i386        |   2 +-
>  config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
>  52 files changed, 924 insertions(+), 50 deletions(-)
>  create mode 100644 arm/Makefile
>  rename config/config-arm.mak => arm/Makefile.arm (90%)
>  rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
>  rename config/config-arm-common.mak => arm/Makefile.common (96%)
>  create mode 100644 lib/powerpc/.gitignore
>  create mode 100644 lib/powerpc/asm/rtas.h
>  create mode 100644 lib/powerpc/asm/setup.h
>  create mode 100644 lib/powerpc/io.c
>  create mode 100644 lib/powerpc/mmu.c
>  create mode 100644 lib/powerpc/rtas.c
>  create mode 100644 lib/powerpc/setup.c
>  create mode 100644 lib/powerpc/smp.c
>  create mode 100644 lib/ppc64/.gitignore
>  create mode 100644 lib/ppc64/asm-offsets.c
>  create mode 100644 lib/ppc64/asm/asm-offsets.h
>  create mode 100644 lib/ppc64/asm/io.h
>  create mode 100644 lib/ppc64/asm/page.h
>  create mode 100644 lib/ppc64/asm/rtas.h
>  create mode 100644 lib/ppc64/asm/setup.h
>  create mode 100644 lib/ppc64/asm/spinlock.h
>  create mode 100644 lib/ppc64/processor.c
>  create mode 100644 lib/ppc64/spinlock.c
>  create mode 100644 lib/util.c
>  create mode 100644 lib/util.h
>  create mode 100644 powerpc/Makefile
>  create mode 100644 powerpc/Makefile.common
>  create mode 100644 powerpc/Makefile.ppc64
>  create mode 100644 powerpc/boot_rom.bin
>  create mode 100644 powerpc/cstart64.S
>  create mode 100644 powerpc/flat.lds
>  create mode 100644 powerpc/reloc64.c
>  create mode 100644 powerpc/rom/.gitignore
>  create mode 100644 powerpc/rom/Makefile
>  create mode 100644 powerpc/rom/header.img
>  create mode 100644 powerpc/rom/rom.ffs
>  create mode 100644 powerpc/rom/stage1.S
>  create mode 100755 powerpc/run
>  create mode 100644 powerpc/selftest.c
>  create mode 100644 powerpc/unittests.cfg
>  rename {config => scripts}/asm-offsets.mak (100%)
>  create mode 100644 x86/Makefile
>  rename config/config-x86-common.mak => x86/Makefile.common (100%)
>  rename config/config-i386.mak => x86/Makefile.i386 (91%)
>  rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)
> 

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-11 13:36   ` Laurent Vivier
@ 2016-02-11 15:29     ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-11 15:29 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> Hi,
> 
> On 08/02/2016 19:53, Andrew Jones wrote:
> > It's been a loooong time since I posted v1 of this series, but thanks
> > to Thomas' poking, and even volunteering to help move v2 along, I've
> > finally picked it back up.
> > 
> > v2:
> >   Besides rebasing on latest master, v2 addresses all of David's comments
> >     - assembler cleanup
> >     - jump into the RTAS blob we get from DT, instead of reproducing it
> >     - don't store the RTAS root node, always hunt it down
> > 
> >   v2 didn't address debug-exit, and we still need a solution for that.
> >   Plugging chr-testdev into an spapr vty is probably what we should
> >   investigate first (as was suggested by Alex Graf under the v1 review).
> >   For this v2 I just kept the hack from v1, but simplified it and
> >   explicitly call it out as the hack that it is.
> > 
> > Additional known issues:
> >   Latest F22 cross-compiler (gcc5 based) doesn't generate working
> >   code with this series. I didn't try to debug. The 4.9 based compiler
> >   I initially used on v1 works, so I reverted to that one.
> > 
> > Testing:
> >   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
> >   try to get a machine to test with real hardware (and KVM) unless
> >   someone (hi Thomas :-) beats me to it.
> 
> I've tested the series from the branch initial-drop-v2:

Thanks for the testing!

> 
> - On RHEL 7.2 ppc64 (ppc64le is not supported ?), POWER8 + kvm_hv.

Right, only ppc64 for now. ppc64le is definitely a planned target though.

>   I have (sometime) an error:
> 
> ./powerpc/run: line 60: exit: too many arguments
> PASS selftest-setup
> 
> 
> Which is in fact:
> 
> /usr/libexec/qemu-kvm -machine pseries,accel=kvm -bios
> powerpc/boot_rom.bin -display none -serial stdio -kernel
> powerpc/selftest.elf -smp 2 -m 256 -append setup smp=2 mem=256
> PASS: selftest: setup: smp: nr_cpus = 2
> PASS: selftest: setup: mem: size = 256 MB
> 
> SUMMARY: 2 tests, 0 unexpected failures
> 
> EXIT: STATUS=1
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS=12
> Return value from qemu: 1 127 127 127 127 127 127 127 127 127 127 127 12
> ./powerpc/run: line 60: exit: too many arguments

So rtas-poweroff is returning, but only sometimes. Weird. I should
change that assert(), which results in an exit, which results in a
poweroff, to just a printf, followed by a halt. That would clean up
this looping.

> 
> 
> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> 
> lib/powerpc/setup.c:60: assert failed
>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> 
> The values I have are:
> freemem_start 434000 mem_start 8000000 mem_end 10000000

That's interesting. I might know what the problem is though. If
the spapr machine divides memory up into multiple regions in some
kvm use cases, then I'll need to look at all of regions to either a)
choose the one I want to use, or b) map them all for use. On that
machine, can you run

$ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
$ dtc -I dtb -O dts dtb | less

and then check if there are multiple memory regions?

Thanks,
drew

> 
> > 
> > Standard cover-letter summary:
> >   This series brings basic setup; starts a test's C entry point, main(),
> >   and printf, exit, and malloc work. Three more series should follow this
> >   one which must bring; vector support, mmu support, and smp support, at
> >   which point I believe the framework could just evolve with the creation
> >   of unit tests.
> > 
> > Patches also available here
> > https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2
> > 
> > 
> > Andrew Jones (14):
> >   lib: asm-generic: add missing casts
> >   lib: share arm-selftest utility functions
> >   config: no need to mix arch makefiles
> >   powerpc/ppc64: start skeleton framework
> >   powerpc/pp64: ppc-ify makefiles and linker script
> >   powerpc/ppc64: add boot rom source
> >   powerpc/ppc64: add bootloader to bounce into memory
> >   powerpc/ppc64: add HV putchar
> >   powerpc/ppc64: adapt arm's setup
> >   powerpc/ppc64: relocate linker VMAs
> >   powerpc/ppc64: add run script and unittests.cfg
> >   mkstandalone: add support for powerpc
> >   powerpc/ppc64: add RTAS support
> >   powerpc/ppc64: HACK: make a fake debug-exit
> > 
> >  Makefile                                           |   2 +-
> >  README                                             |   3 +-
> >  arm/Makefile                                       |   1 +
> >  config/config-arm.mak => arm/Makefile.arm          |   2 +-
> >  config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
> >  .../config-arm-common.mak => arm/Makefile.common   |   3 +-
> >  arm/selftest.c                                     |  45 +++-----
> >  configure                                          |   6 ++
> >  lib/asm-generic/io.h                               |  12 +--
> >  lib/libcflat.h                                     |  11 +-
> >  lib/powerpc/.gitignore                             |   1 +
> >  lib/powerpc/asm/rtas.h                             |  26 +++++
> >  lib/powerpc/asm/setup.h                            |  27 +++++
> >  lib/powerpc/io.c                                   |  37 +++++++
> >  lib/powerpc/mmu.c                                  |   0
> >  lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
> >  lib/powerpc/setup.c                                |  91 ++++++++++++++++
> >  lib/powerpc/smp.c                                  |   0
> >  lib/ppc64/.gitignore                               |   1 +
> >  lib/ppc64/asm-offsets.c                            |  12 +++
> >  lib/ppc64/asm/asm-offsets.h                        |   1 +
> >  lib/ppc64/asm/io.h                                 |   5 +
> >  lib/ppc64/asm/page.h                               |   1 +
> >  lib/ppc64/asm/rtas.h                               |   1 +
> >  lib/ppc64/asm/setup.h                              |   1 +
> >  lib/ppc64/asm/spinlock.h                           |  11 ++
> >  lib/ppc64/processor.c                              |   0
> >  lib/ppc64/spinlock.c                               |  11 ++
> >  lib/report.c                                       |  16 +++
> >  lib/util.c                                         |  18 ++++
> >  lib/util.h                                         |  23 ++++
> >  powerpc/Makefile                                   |   1 +
> >  powerpc/Makefile.common                            |  65 +++++++++++
> >  powerpc/Makefile.ppc64                             |  21 ++++
> >  powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
> >  powerpc/cstart64.S                                 |  86 +++++++++++++++
> >  powerpc/flat.lds                                   |  44 ++++++++
> >  powerpc/reloc64.c                                  |  55 ++++++++++
> >  powerpc/rom/.gitignore                             |   1 +
> >  powerpc/rom/Makefile                               |  36 +++++++
> >  powerpc/rom/header.img                             |   1 +
> >  powerpc/rom/rom.ffs                                |   4 +
> >  powerpc/rom/stage1.S                               |   5 +
> >  powerpc/run                                        |  60 +++++++++++
> >  powerpc/selftest.c                                 |  65 +++++++++++
> >  powerpc/unittests.cfg                              |  30 ++++++
> >  {config => scripts}/asm-offsets.mak                |   0
> >  scripts/mkstandalone.sh                            |   5 +
> >  x86/Makefile                                       |   1 +
> >  .../config-x86-common.mak => x86/Makefile.common   |   0
> >  config/config-i386.mak => x86/Makefile.i386        |   2 +-
> >  config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
> >  52 files changed, 924 insertions(+), 50 deletions(-)
> >  create mode 100644 arm/Makefile
> >  rename config/config-arm.mak => arm/Makefile.arm (90%)
> >  rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
> >  rename config/config-arm-common.mak => arm/Makefile.common (96%)
> >  create mode 100644 lib/powerpc/.gitignore
> >  create mode 100644 lib/powerpc/asm/rtas.h
> >  create mode 100644 lib/powerpc/asm/setup.h
> >  create mode 100644 lib/powerpc/io.c
> >  create mode 100644 lib/powerpc/mmu.c
> >  create mode 100644 lib/powerpc/rtas.c
> >  create mode 100644 lib/powerpc/setup.c
> >  create mode 100644 lib/powerpc/smp.c
> >  create mode 100644 lib/ppc64/.gitignore
> >  create mode 100644 lib/ppc64/asm-offsets.c
> >  create mode 100644 lib/ppc64/asm/asm-offsets.h
> >  create mode 100644 lib/ppc64/asm/io.h
> >  create mode 100644 lib/ppc64/asm/page.h
> >  create mode 100644 lib/ppc64/asm/rtas.h
> >  create mode 100644 lib/ppc64/asm/setup.h
> >  create mode 100644 lib/ppc64/asm/spinlock.h
> >  create mode 100644 lib/ppc64/processor.c
> >  create mode 100644 lib/ppc64/spinlock.c
> >  create mode 100644 lib/util.c
> >  create mode 100644 lib/util.h
> >  create mode 100644 powerpc/Makefile
> >  create mode 100644 powerpc/Makefile.common
> >  create mode 100644 powerpc/Makefile.ppc64
> >  create mode 100644 powerpc/boot_rom.bin
> >  create mode 100644 powerpc/cstart64.S
> >  create mode 100644 powerpc/flat.lds
> >  create mode 100644 powerpc/reloc64.c
> >  create mode 100644 powerpc/rom/.gitignore
> >  create mode 100644 powerpc/rom/Makefile
> >  create mode 100644 powerpc/rom/header.img
> >  create mode 100644 powerpc/rom/rom.ffs
> >  create mode 100644 powerpc/rom/stage1.S
> >  create mode 100755 powerpc/run
> >  create mode 100644 powerpc/selftest.c
> >  create mode 100644 powerpc/unittests.cfg
> >  rename {config => scripts}/asm-offsets.mak (100%)
> >  create mode 100644 x86/Makefile
> >  rename config/config-x86-common.mak => x86/Makefile.common (100%)
> >  rename config/config-i386.mak => x86/Makefile.i386 (91%)
> >  rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 15:29     ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-11 15:29 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> Hi,
> 
> On 08/02/2016 19:53, Andrew Jones wrote:
> > It's been a loooong time since I posted v1 of this series, but thanks
> > to Thomas' poking, and even volunteering to help move v2 along, I've
> > finally picked it back up.
> > 
> > v2:
> >   Besides rebasing on latest master, v2 addresses all of David's comments
> >     - assembler cleanup
> >     - jump into the RTAS blob we get from DT, instead of reproducing it
> >     - don't store the RTAS root node, always hunt it down
> > 
> >   v2 didn't address debug-exit, and we still need a solution for that.
> >   Plugging chr-testdev into an spapr vty is probably what we should
> >   investigate first (as was suggested by Alex Graf under the v1 review).
> >   For this v2 I just kept the hack from v1, but simplified it and
> >   explicitly call it out as the hack that it is.
> > 
> > Additional known issues:
> >   Latest F22 cross-compiler (gcc5 based) doesn't generate working
> >   code with this series. I didn't try to debug. The 4.9 based compiler
> >   I initially used on v1 works, so I reverted to that one.
> > 
> > Testing:
> >   I only tested with qemu-system-ppc64 (latest) on x86_64 so far. I'll
> >   try to get a machine to test with real hardware (and KVM) unless
> >   someone (hi Thomas :-) beats me to it.
> 
> I've tested the series from the branch initial-drop-v2:

Thanks for the testing!

> 
> - On RHEL 7.2 ppc64 (ppc64le is not supported ?), POWER8 + kvm_hv.

Right, only ppc64 for now. ppc64le is definitely a planned target though.

>   I have (sometime) an error:
> 
> ./powerpc/run: line 60: exit: too many arguments
> PASS selftest-setup
> 
> 
> Which is in fact:
> 
> /usr/libexec/qemu-kvm -machine pseries,accel=kvm -bios
> powerpc/boot_rom.bin -display none -serial stdio -kernel
> powerpc/selftest.elf -smp 2 -m 256 -append setup smp=2 mem%6
> PASS: selftest: setup: smp: nr_cpus = 2
> PASS: selftest: setup: mem: size = 256 MB
> 
> SUMMARY: 2 tests, 0 unexpected failures
> 
> EXIT: STATUS=1
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x127
> RTAS power-off returned 0
> lib/powerpc/rtas.c:119: assert failed
> 
> EXIT: STATUS\x12
> Return value from qemu: 1 127 127 127 127 127 127 127 127 127 127 127 12
> ./powerpc/run: line 60: exit: too many arguments

So rtas-poweroff is returning, but only sometimes. Weird. I should
change that assert(), which results in an exit, which results in a
poweroff, to just a printf, followed by a halt. That would clean up
this looping.

> 
> 
> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> 
> lib/powerpc/setup.c:60: assert failed
>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> 
> The values I have are:
> freemem_start 434000 mem_start 8000000 mem_end 10000000

That's interesting. I might know what the problem is though. If
the spapr machine divides memory up into multiple regions in some
kvm use cases, then I'll need to look at all of regions to either a)
choose the one I want to use, or b) map them all for use. On that
machine, can you run

$ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
$ dtc -I dtb -O dts dtb | less

and then check if there are multiple memory regions?

Thanks,
drew

> 
> > 
> > Standard cover-letter summary:
> >   This series brings basic setup; starts a test's C entry point, main(),
> >   and printf, exit, and malloc work. Three more series should follow this
> >   one which must bring; vector support, mmu support, and smp support, at
> >   which point I believe the framework could just evolve with the creation
> >   of unit tests.
> > 
> > Patches also available here
> > https://github.com/rhdrjones/kvm-unit-tests/commits/ppc64/initial-drop-v2
> > 
> > 
> > Andrew Jones (14):
> >   lib: asm-generic: add missing casts
> >   lib: share arm-selftest utility functions
> >   config: no need to mix arch makefiles
> >   powerpc/ppc64: start skeleton framework
> >   powerpc/pp64: ppc-ify makefiles and linker script
> >   powerpc/ppc64: add boot rom source
> >   powerpc/ppc64: add bootloader to bounce into memory
> >   powerpc/ppc64: add HV putchar
> >   powerpc/ppc64: adapt arm's setup
> >   powerpc/ppc64: relocate linker VMAs
> >   powerpc/ppc64: add run script and unittests.cfg
> >   mkstandalone: add support for powerpc
> >   powerpc/ppc64: add RTAS support
> >   powerpc/ppc64: HACK: make a fake debug-exit
> > 
> >  Makefile                                           |   2 +-
> >  README                                             |   3 +-
> >  arm/Makefile                                       |   1 +
> >  config/config-arm.mak => arm/Makefile.arm          |   2 +-
> >  config/config-arm64.mak => arm/Makefile.arm64      |   2 +-
> >  .../config-arm-common.mak => arm/Makefile.common   |   3 +-
> >  arm/selftest.c                                     |  45 +++-----
> >  configure                                          |   6 ++
> >  lib/asm-generic/io.h                               |  12 +--
> >  lib/libcflat.h                                     |  11 +-
> >  lib/powerpc/.gitignore                             |   1 +
> >  lib/powerpc/asm/rtas.h                             |  26 +++++
> >  lib/powerpc/asm/setup.h                            |  27 +++++
> >  lib/powerpc/io.c                                   |  37 +++++++
> >  lib/powerpc/mmu.c                                  |   0
> >  lib/powerpc/rtas.c                                 | 120 +++++++++++++++++++++
> >  lib/powerpc/setup.c                                |  91 ++++++++++++++++
> >  lib/powerpc/smp.c                                  |   0
> >  lib/ppc64/.gitignore                               |   1 +
> >  lib/ppc64/asm-offsets.c                            |  12 +++
> >  lib/ppc64/asm/asm-offsets.h                        |   1 +
> >  lib/ppc64/asm/io.h                                 |   5 +
> >  lib/ppc64/asm/page.h                               |   1 +
> >  lib/ppc64/asm/rtas.h                               |   1 +
> >  lib/ppc64/asm/setup.h                              |   1 +
> >  lib/ppc64/asm/spinlock.h                           |  11 ++
> >  lib/ppc64/processor.c                              |   0
> >  lib/ppc64/spinlock.c                               |  11 ++
> >  lib/report.c                                       |  16 +++
> >  lib/util.c                                         |  18 ++++
> >  lib/util.h                                         |  23 ++++
> >  powerpc/Makefile                                   |   1 +
> >  powerpc/Makefile.common                            |  65 +++++++++++
> >  powerpc/Makefile.ppc64                             |  21 ++++
> >  powerpc/boot_rom.bin                               | Bin 0 -> 280 bytes
> >  powerpc/cstart64.S                                 |  86 +++++++++++++++
> >  powerpc/flat.lds                                   |  44 ++++++++
> >  powerpc/reloc64.c                                  |  55 ++++++++++
> >  powerpc/rom/.gitignore                             |   1 +
> >  powerpc/rom/Makefile                               |  36 +++++++
> >  powerpc/rom/header.img                             |   1 +
> >  powerpc/rom/rom.ffs                                |   4 +
> >  powerpc/rom/stage1.S                               |   5 +
> >  powerpc/run                                        |  60 +++++++++++
> >  powerpc/selftest.c                                 |  65 +++++++++++
> >  powerpc/unittests.cfg                              |  30 ++++++
> >  {config => scripts}/asm-offsets.mak                |   0
> >  scripts/mkstandalone.sh                            |   5 +
> >  x86/Makefile                                       |   1 +
> >  .../config-x86-common.mak => x86/Makefile.common   |   0
> >  config/config-i386.mak => x86/Makefile.i386        |   2 +-
> >  config/config-x86_64.mak => x86/Makefile.x86_64    |   2 +-
> >  52 files changed, 924 insertions(+), 50 deletions(-)
> >  create mode 100644 arm/Makefile
> >  rename config/config-arm.mak => arm/Makefile.arm (90%)
> >  rename config/config-arm64.mak => arm/Makefile.arm64 (89%)
> >  rename config/config-arm-common.mak => arm/Makefile.common (96%)
> >  create mode 100644 lib/powerpc/.gitignore
> >  create mode 100644 lib/powerpc/asm/rtas.h
> >  create mode 100644 lib/powerpc/asm/setup.h
> >  create mode 100644 lib/powerpc/io.c
> >  create mode 100644 lib/powerpc/mmu.c
> >  create mode 100644 lib/powerpc/rtas.c
> >  create mode 100644 lib/powerpc/setup.c
> >  create mode 100644 lib/powerpc/smp.c
> >  create mode 100644 lib/ppc64/.gitignore
> >  create mode 100644 lib/ppc64/asm-offsets.c
> >  create mode 100644 lib/ppc64/asm/asm-offsets.h
> >  create mode 100644 lib/ppc64/asm/io.h
> >  create mode 100644 lib/ppc64/asm/page.h
> >  create mode 100644 lib/ppc64/asm/rtas.h
> >  create mode 100644 lib/ppc64/asm/setup.h
> >  create mode 100644 lib/ppc64/asm/spinlock.h
> >  create mode 100644 lib/ppc64/processor.c
> >  create mode 100644 lib/ppc64/spinlock.c
> >  create mode 100644 lib/util.c
> >  create mode 100644 lib/util.h
> >  create mode 100644 powerpc/Makefile
> >  create mode 100644 powerpc/Makefile.common
> >  create mode 100644 powerpc/Makefile.ppc64
> >  create mode 100644 powerpc/boot_rom.bin
> >  create mode 100644 powerpc/cstart64.S
> >  create mode 100644 powerpc/flat.lds
> >  create mode 100644 powerpc/reloc64.c
> >  create mode 100644 powerpc/rom/.gitignore
> >  create mode 100644 powerpc/rom/Makefile
> >  create mode 100644 powerpc/rom/header.img
> >  create mode 100644 powerpc/rom/rom.ffs
> >  create mode 100644 powerpc/rom/stage1.S
> >  create mode 100755 powerpc/run
> >  create mode 100644 powerpc/selftest.c
> >  create mode 100644 powerpc/unittests.cfg
> >  rename {config => scripts}/asm-offsets.mak (100%)
> >  create mode 100644 x86/Makefile
> >  rename config/config-x86-common.mak => x86/Makefile.common (100%)
> >  rename config/config-i386.mak => x86/Makefile.i386 (91%)
> >  rename config/config-x86_64.mak => x86/Makefile.x86_64 (93%)
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-11 15:29     ` Andrew Jones
@ 2016-02-11 16:44       ` Laurent Vivier
  -1 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-11 16:44 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini



On 11/02/2016 16:29, Andrew Jones wrote:
> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:

>>
>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
>>
>> lib/powerpc/setup.c:60: assert failed
>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
>>
>> The values I have are:
>> freemem_start 434000 mem_start 8000000 mem_end 10000000
> 
> That's interesting. I might know what the problem is though. If
> the spapr machine divides memory up into multiple regions in some
> kvm use cases, then I'll need to look at all of regions to either a)
> choose the one I want to use, or b) map them all for use. On that
> machine, can you run
> 
> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> $ dtc -I dtb -O dts dtb | less
> 
> and then check if there are multiple memory regions?

No output... fc23 has qemu-2.4.1, so this commit is missing:
ad440b4 spapr: add dumpdtb support

So I've recompiled master (PPC970MP is not as fast as POWER8...), and:

        memory@0000000010000000 {
                ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
                reg = <0x0 0x10000000 0x0 0x10000000>;
                device_type = "memory";
        };

        memory@0000000008000000 {
                ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
                reg = <0x0 0x8000000 0x0 0x8000000>;
                device_type = "memory";
        };

        memory@0000000000000000 {
                ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
                reg = <0x0 0x0 0x0 0x8000000>;
                device_type = "memory";
        };

But master doesn't have the "assert()", it hangs, and in kernel logs:

[  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
[  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)

Laurent

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 16:44       ` Laurent Vivier
  0 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-11 16:44 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini



On 11/02/2016 16:29, Andrew Jones wrote:
> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:

>>
>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
>>
>> lib/powerpc/setup.c:60: assert failed
>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
>>
>> The values I have are:
>> freemem_start 434000 mem_start 8000000 mem_end 10000000
> 
> That's interesting. I might know what the problem is though. If
> the spapr machine divides memory up into multiple regions in some
> kvm use cases, then I'll need to look at all of regions to either a)
> choose the one I want to use, or b) map them all for use. On that
> machine, can you run
> 
> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> $ dtc -I dtb -O dts dtb | less
> 
> and then check if there are multiple memory regions?

No output... fc23 has qemu-2.4.1, so this commit is missing:
ad440b4 spapr: add dumpdtb support

So I've recompiled master (PPC970MP is not as fast as POWER8...), and:

        memory@0000000010000000 {
                ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
                reg = <0x0 0x10000000 0x0 0x10000000>;
                device_type = "memory";
        };

        memory@0000000008000000 {
                ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
                reg = <0x0 0x8000000 0x0 0x8000000>;
                device_type = "memory";
        };

        memory@0000000000000000 {
                ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
                reg = <0x0 0x0 0x0 0x8000000>;
                device_type = "memory";
        };

But master doesn't have the "assert()", it hangs, and in kernel logs:

[  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
[  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)

Laurent

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-11 16:44       ` Laurent Vivier
@ 2016-02-11 17:22         ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-11 17:22 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
> 
> 
> On 11/02/2016 16:29, Andrew Jones wrote:
> > On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> 
> >>
> >> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> >>
> >> lib/powerpc/setup.c:60: assert failed
> >>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> >>
> >> The values I have are:
> >> freemem_start 434000 mem_start 8000000 mem_end 10000000
> > 
> > That's interesting. I might know what the problem is though. If
> > the spapr machine divides memory up into multiple regions in some
> > kvm use cases, then I'll need to look at all of regions to either a)
> > choose the one I want to use, or b) map them all for use. On that
> > machine, can you run
> > 
> > $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> > $ dtc -I dtb -O dts dtb | less
> > 
> > and then check if there are multiple memory regions?
> 
> No output... fc23 has qemu-2.4.1, so this commit is missing:
> ad440b4 spapr: add dumpdtb support
> 
> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
> 
>         memory@0000000010000000 {
>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>                 reg = <0x0 0x10000000 0x0 0x10000000>;
>                 device_type = "memory";
>         };
> 
>         memory@0000000008000000 {
>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>                 reg = <0x0 0x8000000 0x0 0x8000000>;
>                 device_type = "memory";
>         };
> 
>         memory@0000000000000000 {
>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>                 reg = <0x0 0x0 0x0 0x8000000>;
>                 device_type = "memory";
>         };

OK, I can fix memory region mapping for v3 pretty easily.

> 
> But master doesn't have the "assert()", it hangs, and in kernel logs:
> 
> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)

That 700 is what I got when I tried compiling with gcc-5.2, before
changing the toc alignment. I guess that just means "we've gone off
in the weeds." Unfortunately I don't have any idea why this time,
assuming we've got the toc patched kvm-unit-tests. Does everything
run except the rtas-poweroff command? If you comment the call to it
out of exit(), and then just use ^C to quit, does it seem happy?

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 17:22         ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-11 17:22 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
> 
> 
> On 11/02/2016 16:29, Andrew Jones wrote:
> > On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> 
> >>
> >> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> >>
> >> lib/powerpc/setup.c:60: assert failed
> >>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> >>
> >> The values I have are:
> >> freemem_start 434000 mem_start 8000000 mem_end 10000000
> > 
> > That's interesting. I might know what the problem is though. If
> > the spapr machine divides memory up into multiple regions in some
> > kvm use cases, then I'll need to look at all of regions to either a)
> > choose the one I want to use, or b) map them all for use. On that
> > machine, can you run
> > 
> > $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> > $ dtc -I dtb -O dts dtb | less
> > 
> > and then check if there are multiple memory regions?
> 
> No output... fc23 has qemu-2.4.1, so this commit is missing:
> ad440b4 spapr: add dumpdtb support
> 
> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
> 
>         memory@0000000010000000 {
>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>                 reg = <0x0 0x10000000 0x0 0x10000000>;
>                 device_type = "memory";
>         };
> 
>         memory@0000000008000000 {
>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>                 reg = <0x0 0x8000000 0x0 0x8000000>;
>                 device_type = "memory";
>         };
> 
>         memory@0000000000000000 {
>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>                 reg = <0x0 0x0 0x0 0x8000000>;
>                 device_type = "memory";
>         };

OK, I can fix memory region mapping for v3 pretty easily.

> 
> But master doesn't have the "assert()", it hangs, and in kernel logs:
> 
> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)

That 700 is what I got when I tried compiling with gcc-5.2, before
changing the toc alignment. I guess that just means "we've gone off
in the weeds." Unfortunately I don't have any idea why this time,
assuming we've got the toc patched kvm-unit-tests. Does everything
run except the rtas-poweroff command? If you comment the call to it
out of exit(), and then just use ^C to quit, does it seem happy?

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-11 17:22         ` Andrew Jones
@ 2016-02-11 17:47           ` Laurent Vivier
  -1 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-11 17:47 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini



On 11/02/2016 18:22, Andrew Jones wrote:
> On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
>>
>>
>> On 11/02/2016 16:29, Andrew Jones wrote:
>>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
>>
>>>>
>>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
>>>>
>>>> lib/powerpc/setup.c:60: assert failed
>>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
>>>>
>>>> The values I have are:
>>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
>>>
>>> That's interesting. I might know what the problem is though. If
>>> the spapr machine divides memory up into multiple regions in some
>>> kvm use cases, then I'll need to look at all of regions to either a)
>>> choose the one I want to use, or b) map them all for use. On that
>>> machine, can you run
>>>
>>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
>>> $ dtc -I dtb -O dts dtb | less
>>>
>>> and then check if there are multiple memory regions?
>>
>> No output... fc23 has qemu-2.4.1, so this commit is missing:
>> ad440b4 spapr: add dumpdtb support
>>
>> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
>>
>>         memory@0000000010000000 {
>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>                 reg = <0x0 0x10000000 0x0 0x10000000>;
>>                 device_type = "memory";
>>         };
>>
>>         memory@0000000008000000 {
>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>                 reg = <0x0 0x8000000 0x0 0x8000000>;
>>                 device_type = "memory";
>>         };
>>
>>         memory@0000000000000000 {
>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>                 reg = <0x0 0x0 0x0 0x8000000>;
>>                 device_type = "memory";
>>         };
> 
> OK, I can fix memory region mapping for v3 pretty easily.
> 
>>
>> But master doesn't have the "assert()", it hangs, and in kernel logs:
>>
>> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
>> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
> 
> That 700 is what I got when I tried compiling with gcc-5.2, before
> changing the toc alignment. I guess that just means "we've gone off
> in the weeds." Unfortunately I don't have any idea why this time,
> assuming we've got the toc patched kvm-unit-tests. Does everything
> run except the rtas-poweroff command? If you comment the call to it
> out of exit(), and then just use ^C to quit, does it seem happy?

Yes, it seems happy: nothing is displayed in terminal nor in the kernel
logs.

Laurent

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-11 17:47           ` Laurent Vivier
  0 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-11 17:47 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini



On 11/02/2016 18:22, Andrew Jones wrote:
> On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
>>
>>
>> On 11/02/2016 16:29, Andrew Jones wrote:
>>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
>>
>>>>
>>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
>>>>
>>>> lib/powerpc/setup.c:60: assert failed
>>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
>>>>
>>>> The values I have are:
>>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
>>>
>>> That's interesting. I might know what the problem is though. If
>>> the spapr machine divides memory up into multiple regions in some
>>> kvm use cases, then I'll need to look at all of regions to either a)
>>> choose the one I want to use, or b) map them all for use. On that
>>> machine, can you run
>>>
>>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
>>> $ dtc -I dtb -O dts dtb | less
>>>
>>> and then check if there are multiple memory regions?
>>
>> No output... fc23 has qemu-2.4.1, so this commit is missing:
>> ad440b4 spapr: add dumpdtb support
>>
>> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
>>
>>         memory@0000000010000000 {
>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>                 reg = <0x0 0x10000000 0x0 0x10000000>;
>>                 device_type = "memory";
>>         };
>>
>>         memory@0000000008000000 {
>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>                 reg = <0x0 0x8000000 0x0 0x8000000>;
>>                 device_type = "memory";
>>         };
>>
>>         memory@0000000000000000 {
>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>                 reg = <0x0 0x0 0x0 0x8000000>;
>>                 device_type = "memory";
>>         };
> 
> OK, I can fix memory region mapping for v3 pretty easily.
> 
>>
>> But master doesn't have the "assert()", it hangs, and in kernel logs:
>>
>> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
>> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
> 
> That 700 is what I got when I tried compiling with gcc-5.2, before
> changing the toc alignment. I guess that just means "we've gone off
> in the weeds." Unfortunately I don't have any idea why this time,
> assuming we've got the toc patched kvm-unit-tests. Does everything
> run except the rtas-poweroff command? If you comment the call to it
> out of exit(), and then just use ^C to quit, does it seem happy?

Yes, it seems happy: nothing is displayed in terminal nor in the kernel
logs.

Laurent

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12  6:27     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12  6:27 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Make a one line replacement for SLOF. This bootloader just
> jumps to 0x400000, because we know the kernel will be there.
> This commit allows rebuilding of the bootloader, as long
> as the SLOF build_romfs tool is present, but since it would be
> a pain to require that tool for ever build, we'll just commit
> the binary rom image too with the next commit.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>

I haven't tested it yet, but I think this should also be doable without
the build_romfs tool? Since QEMU does not care about the header that
this tool creates, it should not matter whether there is some valid data
in the first 256 or simply zeros. So simply linking with
"-Wl,--oformat,binary -Ttext=0x100" or so should do the job, also?

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source
@ 2016-02-12  6:27     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12  6:27 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Make a one line replacement for SLOF. This bootloader just
> jumps to 0x400000, because we know the kernel will be there.
> This commit allows rebuilding of the bootloader, as long
> as the SLOF build_romfs tool is present, but since it would be
> a pain to require that tool for ever build, we'll just commit
> the binary rom image too with the next commit.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>

I haven't tested it yet, but I think this should also be doable without
the build_romfs tool? Since QEMU does not care about the header that
this tool creates, it should not matter whether there is some valid data
in the first 256 or simply zeros. So simply linking with
"-Wl,--oformat,binary -Ttext=0x100" or so should do the job, also?

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-11 17:47           ` Laurent Vivier
@ 2016-02-12 10:06             ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 10:06 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Thu, Feb 11, 2016 at 06:47:22PM +0100, Laurent Vivier wrote:
> 
> 
> On 11/02/2016 18:22, Andrew Jones wrote:
> > On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
> >>
> >>
> >> On 11/02/2016 16:29, Andrew Jones wrote:
> >>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> >>
> >>>>
> >>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> >>>>
> >>>> lib/powerpc/setup.c:60: assert failed
> >>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> >>>>
> >>>> The values I have are:
> >>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
> >>>
> >>> That's interesting. I might know what the problem is though. If
> >>> the spapr machine divides memory up into multiple regions in some
> >>> kvm use cases, then I'll need to look at all of regions to either a)
> >>> choose the one I want to use, or b) map them all for use. On that
> >>> machine, can you run
> >>>
> >>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> >>> $ dtc -I dtb -O dts dtb | less
> >>>
> >>> and then check if there are multiple memory regions?
> >>
> >> No output... fc23 has qemu-2.4.1, so this commit is missing:
> >> ad440b4 spapr: add dumpdtb support
> >>
> >> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
> >>
> >>         memory@0000000010000000 {
> >>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>                 reg = <0x0 0x10000000 0x0 0x10000000>;
> >>                 device_type = "memory";
> >>         };
> >>
> >>         memory@0000000008000000 {
> >>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>                 reg = <0x0 0x8000000 0x0 0x8000000>;
> >>                 device_type = "memory";
> >>         };
> >>
> >>         memory@0000000000000000 {
> >>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>                 reg = <0x0 0x0 0x0 0x8000000>;
> >>                 device_type = "memory";
> >>         };
> > 
> > OK, I can fix memory region mapping for v3 pretty easily.
> > 
> >>
> >> But master doesn't have the "assert()", it hangs, and in kernel logs:
> >>
> >> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
> >> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
> > 
> > That 700 is what I got when I tried compiling with gcc-5.2, before
> > changing the toc alignment. I guess that just means "we've gone off
> > in the weeds." Unfortunately I don't have any idea why this time,
> > assuming we've got the toc patched kvm-unit-tests. Does everything
> > run except the rtas-poweroff command? If you comment the call to it
> > out of exit(), and then just use ^C to quit, does it seem happy?
> 
> Yes, it seems happy: nothing is displayed in terminal nor in the kernel
> logs.

Thanks for the extra test. Just to be clear though, do you mean no
errors are logged, but we still get the expected printf output? Or
was nothing at all output (in which case we're badly broken)?

If it's the former, then I guess I screwed up the rtas call somehow,
most likely by the way I tried to prepare the rtas entry function
pointer for jumping into the blob provided in the DT.

drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-12 10:06             ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 10:06 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Thu, Feb 11, 2016 at 06:47:22PM +0100, Laurent Vivier wrote:
> 
> 
> On 11/02/2016 18:22, Andrew Jones wrote:
> > On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
> >>
> >>
> >> On 11/02/2016 16:29, Andrew Jones wrote:
> >>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> >>
> >>>>
> >>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> >>>>
> >>>> lib/powerpc/setup.c:60: assert failed
> >>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> >>>>
> >>>> The values I have are:
> >>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
> >>>
> >>> That's interesting. I might know what the problem is though. If
> >>> the spapr machine divides memory up into multiple regions in some
> >>> kvm use cases, then I'll need to look at all of regions to either a)
> >>> choose the one I want to use, or b) map them all for use. On that
> >>> machine, can you run
> >>>
> >>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> >>> $ dtc -I dtb -O dts dtb | less
> >>>
> >>> and then check if there are multiple memory regions?
> >>
> >> No output... fc23 has qemu-2.4.1, so this commit is missing:
> >> ad440b4 spapr: add dumpdtb support
> >>
> >> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
> >>
> >>         memory@0000000010000000 {
> >>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>                 reg = <0x0 0x10000000 0x0 0x10000000>;
> >>                 device_type = "memory";
> >>         };
> >>
> >>         memory@0000000008000000 {
> >>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>                 reg = <0x0 0x8000000 0x0 0x8000000>;
> >>                 device_type = "memory";
> >>         };
> >>
> >>         memory@0000000000000000 {
> >>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>                 reg = <0x0 0x0 0x0 0x8000000>;
> >>                 device_type = "memory";
> >>         };
> > 
> > OK, I can fix memory region mapping for v3 pretty easily.
> > 
> >>
> >> But master doesn't have the "assert()", it hangs, and in kernel logs:
> >>
> >> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
> >> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
> > 
> > That 700 is what I got when I tried compiling with gcc-5.2, before
> > changing the toc alignment. I guess that just means "we've gone off
> > in the weeds." Unfortunately I don't have any idea why this time,
> > assuming we've got the toc patched kvm-unit-tests. Does everything
> > run except the rtas-poweroff command? If you comment the call to it
> > out of exit(), and then just use ^C to quit, does it seem happy?
> 
> Yes, it seems happy: nothing is displayed in terminal nor in the kernel
> logs.

Thanks for the extra test. Just to be clear though, do you mean no
errors are logged, but we still get the expected printf output? Or
was nothing at all output (in which case we're badly broken)?

If it's the former, then I guess I screwed up the rtas call somehow,
most likely by the way I tried to prepare the rtas entry function
pointer for jumping into the blob provided in the DT.

drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source
  2016-02-12  6:27     ` Thomas Huth
@ 2016-02-12 10:07       ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 10:07 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, kvm-ppc, dgibson, david, agraf, lvivier, pbonzini

On Fri, Feb 12, 2016 at 07:27:32AM +0100, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
> > Make a one line replacement for SLOF. This bootloader just
> > jumps to 0x400000, because we know the kernel will be there.
> > This commit allows rebuilding of the bootloader, as long
> > as the SLOF build_romfs tool is present, but since it would be
> > a pain to require that tool for ever build, we'll just commit
> > the binary rom image too with the next commit.
> > 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> 
> I haven't tested it yet, but I think this should also be doable without
> the build_romfs tool? Since QEMU does not care about the header that
> this tool creates, it should not matter whether there is some valid data
> in the first 256 or simply zeros. So simply linking with
> "-Wl,--oformat,binary -Ttext=0x100" or so should do the job, also?

That would be much nicer indeed! I can try it when preparing v3.

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source
@ 2016-02-12 10:07       ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 10:07 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, kvm-ppc, dgibson, david, agraf, lvivier, pbonzini

On Fri, Feb 12, 2016 at 07:27:32AM +0100, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
> > Make a one line replacement for SLOF. This bootloader just
> > jumps to 0x400000, because we know the kernel will be there.
> > This commit allows rebuilding of the bootloader, as long
> > as the SLOF build_romfs tool is present, but since it would be
> > a pain to require that tool for ever build, we'll just commit
> > the binary rom image too with the next commit.
> > 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> 
> I haven't tested it yet, but I think this should also be doable without
> the build_romfs tool? Since QEMU does not care about the header that
> this tool creates, it should not matter whether there is some valid data
> in the first 256 or simply zeros. So simply linking with
> "-Wl,--oformat,binary -Ttext=0x100" or so should do the job, also?

That would be much nicer indeed! I can try it when preparing v3.

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-12 10:06             ` Andrew Jones
@ 2016-02-12 10:31               ` Laurent Vivier
  -1 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-12 10:31 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini



On 12/02/2016 11:06, Andrew Jones wrote:
> On Thu, Feb 11, 2016 at 06:47:22PM +0100, Laurent Vivier wrote:
>>
>>
>> On 11/02/2016 18:22, Andrew Jones wrote:
>>> On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
>>>>
>>>>
>>>> On 11/02/2016 16:29, Andrew Jones wrote:
>>>>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
>>>>
>>>>>>
>>>>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
>>>>>>
>>>>>> lib/powerpc/setup.c:60: assert failed
>>>>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
>>>>>>
>>>>>> The values I have are:
>>>>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
>>>>>
>>>>> That's interesting. I might know what the problem is though. If
>>>>> the spapr machine divides memory up into multiple regions in some
>>>>> kvm use cases, then I'll need to look at all of regions to either a)
>>>>> choose the one I want to use, or b) map them all for use. On that
>>>>> machine, can you run
>>>>>
>>>>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
>>>>> $ dtc -I dtb -O dts dtb | less
>>>>>
>>>>> and then check if there are multiple memory regions?
>>>>
>>>> No output... fc23 has qemu-2.4.1, so this commit is missing:
>>>> ad440b4 spapr: add dumpdtb support
>>>>
>>>> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
>>>>
>>>>         memory@0000000010000000 {
>>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>>>                 reg = <0x0 0x10000000 0x0 0x10000000>;
>>>>                 device_type = "memory";
>>>>         };
>>>>
>>>>         memory@0000000008000000 {
>>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>>>                 reg = <0x0 0x8000000 0x0 0x8000000>;
>>>>                 device_type = "memory";
>>>>         };
>>>>
>>>>         memory@0000000000000000 {
>>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>>>                 reg = <0x0 0x0 0x0 0x8000000>;
>>>>                 device_type = "memory";
>>>>         };
>>>
>>> OK, I can fix memory region mapping for v3 pretty easily.
>>>
>>>>
>>>> But master doesn't have the "assert()", it hangs, and in kernel logs:
>>>>
>>>> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
>>>> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
>>>
>>> That 700 is what I got when I tried compiling with gcc-5.2, before
>>> changing the toc alignment. I guess that just means "we've gone off
>>> in the weeds." Unfortunately I don't have any idea why this time,
>>> assuming we've got the toc patched kvm-unit-tests. Does everything
>>> run except the rtas-poweroff command? If you comment the call to it
>>> out of exit(), and then just use ^C to quit, does it seem happy?
>>
>> Yes, it seems happy: nothing is displayed in terminal nor in the kernel
>> logs.
> 
> Thanks for the extra test. Just to be clear though, do you mean no
> errors are logged, but we still get the expected printf output? Or
> was nothing at all output (in which case we're badly broken)?
> 
> If it's the former, then I guess I screwed up the rtas call somehow,
> most likely by the way I tried to prepare the rtas entry function
> pointer for jumping into the blob provided in the DT.

I have nothing at all. It hangs.

The command I run is:
kvm-unit-tests]$ sudo  ./powerpc/run powerpc/selftest.elf -smp 2 -m 256
-append 'setup smp=2 mem=256'
qemu-system-ppc64 -machine pseries,accel=kvm -bios powerpc/boot_rom.bin
-display none -serial stdio -kernel powerpc/selftest.elf -smp 2 -m 256
-append setup smp=2 mem=256
^C
qemu: terminating on signal 2


The change I did:

--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -32,6 +32,6 @@ void exit(int code)
 // FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit()
 //        Maybe by plugging chr-testdev into a spapr-vty.
        printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
-       rtas_power_off();
+       //rtas_power_off();
        halt(code);
 }

Laurent

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-12 10:31               ` Laurent Vivier
  0 siblings, 0 replies; 84+ messages in thread
From: Laurent Vivier @ 2016-02-12 10:31 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini



On 12/02/2016 11:06, Andrew Jones wrote:
> On Thu, Feb 11, 2016 at 06:47:22PM +0100, Laurent Vivier wrote:
>>
>>
>> On 11/02/2016 18:22, Andrew Jones wrote:
>>> On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
>>>>
>>>>
>>>> On 11/02/2016 16:29, Andrew Jones wrote:
>>>>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
>>>>
>>>>>>
>>>>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
>>>>>>
>>>>>> lib/powerpc/setup.c:60: assert failed
>>>>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
>>>>>>
>>>>>> The values I have are:
>>>>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
>>>>>
>>>>> That's interesting. I might know what the problem is though. If
>>>>> the spapr machine divides memory up into multiple regions in some
>>>>> kvm use cases, then I'll need to look at all of regions to either a)
>>>>> choose the one I want to use, or b) map them all for use. On that
>>>>> machine, can you run
>>>>>
>>>>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
>>>>> $ dtc -I dtb -O dts dtb | less
>>>>>
>>>>> and then check if there are multiple memory regions?
>>>>
>>>> No output... fc23 has qemu-2.4.1, so this commit is missing:
>>>> ad440b4 spapr: add dumpdtb support
>>>>
>>>> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
>>>>
>>>>         memory@0000000010000000 {
>>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>>>                 reg = <0x0 0x10000000 0x0 0x10000000>;
>>>>                 device_type = "memory";
>>>>         };
>>>>
>>>>         memory@0000000008000000 {
>>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>>>                 reg = <0x0 0x8000000 0x0 0x8000000>;
>>>>                 device_type = "memory";
>>>>         };
>>>>
>>>>         memory@0000000000000000 {
>>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
>>>>                 reg = <0x0 0x0 0x0 0x8000000>;
>>>>                 device_type = "memory";
>>>>         };
>>>
>>> OK, I can fix memory region mapping for v3 pretty easily.
>>>
>>>>
>>>> But master doesn't have the "assert()", it hangs, and in kernel logs:
>>>>
>>>> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
>>>> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
>>>
>>> That 700 is what I got when I tried compiling with gcc-5.2, before
>>> changing the toc alignment. I guess that just means "we've gone off
>>> in the weeds." Unfortunately I don't have any idea why this time,
>>> assuming we've got the toc patched kvm-unit-tests. Does everything
>>> run except the rtas-poweroff command? If you comment the call to it
>>> out of exit(), and then just use ^C to quit, does it seem happy?
>>
>> Yes, it seems happy: nothing is displayed in terminal nor in the kernel
>> logs.
> 
> Thanks for the extra test. Just to be clear though, do you mean no
> errors are logged, but we still get the expected printf output? Or
> was nothing at all output (in which case we're badly broken)?
> 
> If it's the former, then I guess I screwed up the rtas call somehow,
> most likely by the way I tried to prepare the rtas entry function
> pointer for jumping into the blob provided in the DT.

I have nothing at all. It hangs.

The command I run is:
kvm-unit-tests]$ sudo  ./powerpc/run powerpc/selftest.elf -smp 2 -m 256
-append 'setup smp=2 mem%6'
qemu-system-ppc64 -machine pseries,accel=kvm -bios powerpc/boot_rom.bin
-display none -serial stdio -kernel powerpc/selftest.elf -smp 2 -m 256
-append setup smp=2 mem%6
^C
qemu: terminating on signal 2


The change I did:

--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -32,6 +32,6 @@ void exit(int code)
 // FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit()
 //        Maybe by plugging chr-testdev into a spapr-vty.
        printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
-       rtas_power_off();
+       //rtas_power_off();
        halt(code);
 }

Laurent

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-12 10:31               ` Laurent Vivier
@ 2016-02-12 10:57                 ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 10:57 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Fri, Feb 12, 2016 at 11:31:32AM +0100, Laurent Vivier wrote:
> 
> 
> On 12/02/2016 11:06, Andrew Jones wrote:
> > On Thu, Feb 11, 2016 at 06:47:22PM +0100, Laurent Vivier wrote:
> >>
> >>
> >> On 11/02/2016 18:22, Andrew Jones wrote:
> >>> On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
> >>>>
> >>>>
> >>>> On 11/02/2016 16:29, Andrew Jones wrote:
> >>>>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> >>>>
> >>>>>>
> >>>>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> >>>>>>
> >>>>>> lib/powerpc/setup.c:60: assert failed
> >>>>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> >>>>>>
> >>>>>> The values I have are:
> >>>>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
> >>>>>
> >>>>> That's interesting. I might know what the problem is though. If
> >>>>> the spapr machine divides memory up into multiple regions in some
> >>>>> kvm use cases, then I'll need to look at all of regions to either a)
> >>>>> choose the one I want to use, or b) map them all for use. On that
> >>>>> machine, can you run
> >>>>>
> >>>>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> >>>>> $ dtc -I dtb -O dts dtb | less
> >>>>>
> >>>>> and then check if there are multiple memory regions?
> >>>>
> >>>> No output... fc23 has qemu-2.4.1, so this commit is missing:
> >>>> ad440b4 spapr: add dumpdtb support
> >>>>
> >>>> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
> >>>>
> >>>>         memory@0000000010000000 {
> >>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>>>                 reg = <0x0 0x10000000 0x0 0x10000000>;
> >>>>                 device_type = "memory";
> >>>>         };
> >>>>
> >>>>         memory@0000000008000000 {
> >>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>>>                 reg = <0x0 0x8000000 0x0 0x8000000>;
> >>>>                 device_type = "memory";
> >>>>         };
> >>>>
> >>>>         memory@0000000000000000 {
> >>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>>>                 reg = <0x0 0x0 0x0 0x8000000>;
> >>>>                 device_type = "memory";
> >>>>         };
> >>>
> >>> OK, I can fix memory region mapping for v3 pretty easily.
> >>>
> >>>>
> >>>> But master doesn't have the "assert()", it hangs, and in kernel logs:
> >>>>
> >>>> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
> >>>> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
> >>>
> >>> That 700 is what I got when I tried compiling with gcc-5.2, before
> >>> changing the toc alignment. I guess that just means "we've gone off
> >>> in the weeds." Unfortunately I don't have any idea why this time,
> >>> assuming we've got the toc patched kvm-unit-tests. Does everything
> >>> run except the rtas-poweroff command? If you comment the call to it
> >>> out of exit(), and then just use ^C to quit, does it seem happy?
> >>
> >> Yes, it seems happy: nothing is displayed in terminal nor in the kernel
> >> logs.
> > 
> > Thanks for the extra test. Just to be clear though, do you mean no
> > errors are logged, but we still get the expected printf output? Or
> > was nothing at all output (in which case we're badly broken)?
> > 
> > If it's the former, then I guess I screwed up the rtas call somehow,
> > most likely by the way I tried to prepare the rtas entry function
> > pointer for jumping into the blob provided in the DT.
> 
> I have nothing at all. It hangs.

Damn. I'll need to get a machine where the problems reproduce to debug.

> 
> The command I run is:
> kvm-unit-tests]$ sudo  ./powerpc/run powerpc/selftest.elf -smp 2 -m 256
> -append 'setup smp=2 mem=256'
> qemu-system-ppc64 -machine pseries,accel=kvm -bios powerpc/boot_rom.bin
> -display none -serial stdio -kernel powerpc/selftest.elf -smp 2 -m 256
> -append setup smp=2 mem=256
> ^C
> qemu: terminating on signal 2
> 
> 
> The change I did:
> 
> --- a/lib/powerpc/io.c
> +++ b/lib/powerpc/io.c
> @@ -32,6 +32,6 @@ void exit(int code)
>  // FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit()
>  //        Maybe by plugging chr-testdev into a spapr-vty.
>         printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
> -       rtas_power_off();
> +       //rtas_power_off();
>         halt(code);
>  }

Yup, that's what I was hoping would make things "work", guess it doesn't.

Thanks for all the testing.

drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-12 10:57                 ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 10:57 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Fri, Feb 12, 2016 at 11:31:32AM +0100, Laurent Vivier wrote:
> 
> 
> On 12/02/2016 11:06, Andrew Jones wrote:
> > On Thu, Feb 11, 2016 at 06:47:22PM +0100, Laurent Vivier wrote:
> >>
> >>
> >> On 11/02/2016 18:22, Andrew Jones wrote:
> >>> On Thu, Feb 11, 2016 at 05:44:00PM +0100, Laurent Vivier wrote:
> >>>>
> >>>>
> >>>> On 11/02/2016 16:29, Andrew Jones wrote:
> >>>>> On Thu, Feb 11, 2016 at 02:36:57PM +0100, Laurent Vivier wrote:
> >>>>
> >>>>>>
> >>>>>> - On fedora 23 on PowerMac G5 (ppc64) kvm_pr, it doesn't work at all:
> >>>>>>
> >>>>>> lib/powerpc/setup.c:60: assert failed
> >>>>>>  59         assert(freemem_start >= mem_start && freemem_start < mem_end);
> >>>>>>
> >>>>>> The values I have are:
> >>>>>> freemem_start 434000 mem_start 8000000 mem_end 10000000
> >>>>>
> >>>>> That's interesting. I might know what the problem is though. If
> >>>>> the spapr machine divides memory up into multiple regions in some
> >>>>> kvm use cases, then I'll need to look at all of regions to either a)
> >>>>> choose the one I want to use, or b) map them all for use. On that
> >>>>> machine, can you run
> >>>>>
> >>>>> $ /usr/libexec/qemu-kvm -machine pseries,accel=kvm -machine dumpdtb=dtb
> >>>>> $ dtc -I dtb -O dts dtb | less
> >>>>>
> >>>>> and then check if there are multiple memory regions?
> >>>>
> >>>> No output... fc23 has qemu-2.4.1, so this commit is missing:
> >>>> ad440b4 spapr: add dumpdtb support
> >>>>
> >>>> So I've recompiled master (PPC970MP is not as fast as POWER8...), and:
> >>>>
> >>>>         memory@0000000010000000 {
> >>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>>>                 reg = <0x0 0x10000000 0x0 0x10000000>;
> >>>>                 device_type = "memory";
> >>>>         };
> >>>>
> >>>>         memory@0000000008000000 {
> >>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>>>                 reg = <0x0 0x8000000 0x0 0x8000000>;
> >>>>                 device_type = "memory";
> >>>>         };
> >>>>
> >>>>         memory@0000000000000000 {
> >>>>                 ibm,associativity = <0x4 0x0 0x0 0x0 0x0>;
> >>>>                 reg = <0x0 0x0 0x0 0x8000000>;
> >>>>                 device_type = "memory";
> >>>>         };
> >>>
> >>> OK, I can fix memory region mapping for v3 pretty easily.
> >>>
> >>>>
> >>>> But master doesn't have the "assert()", it hangs, and in kernel logs:
> >>>>
> >>>> [  438.503410] kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
> >>>> [  438.503412] Couldn't emulate instruction 0x00000000 (op 0 xop 0)
> >>>
> >>> That 700 is what I got when I tried compiling with gcc-5.2, before
> >>> changing the toc alignment. I guess that just means "we've gone off
> >>> in the weeds." Unfortunately I don't have any idea why this time,
> >>> assuming we've got the toc patched kvm-unit-tests. Does everything
> >>> run except the rtas-poweroff command? If you comment the call to it
> >>> out of exit(), and then just use ^C to quit, does it seem happy?
> >>
> >> Yes, it seems happy: nothing is displayed in terminal nor in the kernel
> >> logs.
> > 
> > Thanks for the extra test. Just to be clear though, do you mean no
> > errors are logged, but we still get the expected printf output? Or
> > was nothing at all output (in which case we're badly broken)?
> > 
> > If it's the former, then I guess I screwed up the rtas call somehow,
> > most likely by the way I tried to prepare the rtas entry function
> > pointer for jumping into the blob provided in the DT.
> 
> I have nothing at all. It hangs.

Damn. I'll need to get a machine where the problems reproduce to debug.

> 
> The command I run is:
> kvm-unit-tests]$ sudo  ./powerpc/run powerpc/selftest.elf -smp 2 -m 256
> -append 'setup smp=2 mem%6'
> qemu-system-ppc64 -machine pseries,accel=kvm -bios powerpc/boot_rom.bin
> -display none -serial stdio -kernel powerpc/selftest.elf -smp 2 -m 256
> -append setup smp=2 mem%6
> ^C
> qemu: terminating on signal 2
> 
> 
> The change I did:
> 
> --- a/lib/powerpc/io.c
> +++ b/lib/powerpc/io.c
> @@ -32,6 +32,6 @@ void exit(int code)
>  // FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit()
>  //        Maybe by plugging chr-testdev into a spapr-vty.
>         printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
> -       rtas_power_off();
> +       //rtas_power_off();
>         halt(code);
>  }

Yup, that's what I was hoping would make things "work", guess it doesn't.

Thanks for all the testing.

drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12 11:50     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 11:50 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Copy arm's setup code (also DT based) over to powerpc, adapting
> it a bit. Also bring over arm's setup selftest, giving powerpc
> its first test.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/powerpc/asm/setup.h | 27 +++++++++++++++
>  lib/powerpc/setup.c     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/ppc64/asm/setup.h   |  1 +
>  powerpc/cstart64.S      |  9 +++++
>  powerpc/selftest.c      | 64 ++++++++++++++++++++++++++++++++--
>  5 files changed, 189 insertions(+), 3 deletions(-)
>  create mode 100644 lib/powerpc/asm/setup.h
>  create mode 100644 lib/ppc64/asm/setup.h
...
> diff --git a/powerpc/selftest.c b/powerpc/selftest.c
> index 2f2a5215dd55c..3dd7ce9945307 100644
> --- a/powerpc/selftest.c
> +++ b/powerpc/selftest.c
> @@ -1,7 +1,65 @@
> +/*
> + * Test the framework itself. These tests confirm that setup works.
> + *
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
>  #include <libcflat.h>
> +#include <util.h>
> +#include <alloc.h>		/* phys_addr_t */
> +#include <asm/setup.h>
>  
> -int main(void)
> +static void check_setup(int argc, char **argv)
>  {
> -	printf("hello world\n");
> -	return 0;
> +	int nr_tests = 0, len, i;
> +	long val;
> +
> +	for (i = 0; i < argc; ++i) {
> +
> +		len = parse_keyval(argv[i], &val);
> +		if (len == -1)
> +			continue;
> +
> +		argv[i][len] = '\0';
> +		report_prefix_push(argv[i]);
> +
> +		if (strcmp(argv[i], "mem") == 0) {
> +
> +			phys_addr_t memsize = PHYSICAL_END - PHYSICAL_START;
> +			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
> +
> +			report("size = %d MB", memsize == expected,
> +							memsize/1024/1024);
> +			++nr_tests;
> +
> +		} else if (strcmp(argv[i], "smp") == 0) {
> +
> +			report("nr_cpus = %d", nr_cpus == (int)val, nr_cpus);
> +			++nr_tests;

Could you maybe add a check for nr_cpus <= NR_CPUS somewhere and print a
friendly warning message if it the amount of CPUs exceeds NR_CPUS?
Otherwise you only get a very cryptic assert() message if you
accidentially specify too many CPUs ... (it just happened to me, and it
took a while till I understood what was wrong).

> +		}
> +
> +		report_prefix_pop();
> +	}
> +
> +	if (nr_tests < 2)
> +		report_abort("missing input");
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	report_prefix_push("selftest");
> +
> +	if (argc < 1)
> +		report_abort("no test specified");
> +
> +	report_prefix_push(argv[0]);
> +
> +	if (strcmp(argv[0], "setup") == 0) {
> +
> +		check_setup(argc-1, &argv[1]);
> +
> +	}
> +
> +	return report_summary();
>  }
> 

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup
@ 2016-02-12 11:50     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 11:50 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Copy arm's setup code (also DT based) over to powerpc, adapting
> it a bit. Also bring over arm's setup selftest, giving powerpc
> its first test.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/powerpc/asm/setup.h | 27 +++++++++++++++
>  lib/powerpc/setup.c     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/ppc64/asm/setup.h   |  1 +
>  powerpc/cstart64.S      |  9 +++++
>  powerpc/selftest.c      | 64 ++++++++++++++++++++++++++++++++--
>  5 files changed, 189 insertions(+), 3 deletions(-)
>  create mode 100644 lib/powerpc/asm/setup.h
>  create mode 100644 lib/ppc64/asm/setup.h
...
> diff --git a/powerpc/selftest.c b/powerpc/selftest.c
> index 2f2a5215dd55c..3dd7ce9945307 100644
> --- a/powerpc/selftest.c
> +++ b/powerpc/selftest.c
> @@ -1,7 +1,65 @@
> +/*
> + * Test the framework itself. These tests confirm that setup works.
> + *
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
>  #include <libcflat.h>
> +#include <util.h>
> +#include <alloc.h>		/* phys_addr_t */
> +#include <asm/setup.h>
>  
> -int main(void)
> +static void check_setup(int argc, char **argv)
>  {
> -	printf("hello world\n");
> -	return 0;
> +	int nr_tests = 0, len, i;
> +	long val;
> +
> +	for (i = 0; i < argc; ++i) {
> +
> +		len = parse_keyval(argv[i], &val);
> +		if (len = -1)
> +			continue;
> +
> +		argv[i][len] = '\0';
> +		report_prefix_push(argv[i]);
> +
> +		if (strcmp(argv[i], "mem") = 0) {
> +
> +			phys_addr_t memsize = PHYSICAL_END - PHYSICAL_START;
> +			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
> +
> +			report("size = %d MB", memsize = expected,
> +							memsize/1024/1024);
> +			++nr_tests;
> +
> +		} else if (strcmp(argv[i], "smp") = 0) {
> +
> +			report("nr_cpus = %d", nr_cpus = (int)val, nr_cpus);
> +			++nr_tests;

Could you maybe add a check for nr_cpus <= NR_CPUS somewhere and print a
friendly warning message if it the amount of CPUs exceeds NR_CPUS?
Otherwise you only get a very cryptic assert() message if you
accidentially specify too many CPUs ... (it just happened to me, and it
took a while till I understood what was wrong).

> +		}
> +
> +		report_prefix_pop();
> +	}
> +
> +	if (nr_tests < 2)
> +		report_abort("missing input");
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	report_prefix_push("selftest");
> +
> +	if (argc < 1)
> +		report_abort("no test specified");
> +
> +	report_prefix_push(argv[0]);
> +
> +	if (strcmp(argv[0], "setup") = 0) {
> +
> +		check_setup(argc-1, &argv[1]);
> +
> +	}
> +
> +	return report_summary();
>  }
> 

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12 12:05     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 12:05 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/asm-generic/io.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> index a9939d3a5921f..abd245676e97a 100644
> --- a/lib/asm-generic/io.h
> +++ b/lib/asm-generic/io.h
> @@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x)
>  #endif
>  
>  #define le16_to_cpu(x) \
> -	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
> +	({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
>  #define cpu_to_le16 le16_to_cpu
>  
>  #define le32_to_cpu(x) \
> -	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
> +	({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
>  #define cpu_to_le32 le32_to_cpu
>  
>  #define le64_to_cpu(x) \
> -	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
> +	({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
>  #define cpu_to_le64 le64_to_cpu
>  
>  #define be16_to_cpu(x) \
> -	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
> +	({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
>  #define cpu_to_be16 be16_to_cpu
>  
>  #define be32_to_cpu(x) \
> -	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
> +	({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
>  #define cpu_to_be32 be32_to_cpu
>  
>  #define be64_to_cpu(x) \
> -	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
> +	({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
>  #define cpu_to_be64 be64_to_cpu

The typecasts for the __bswapXX() macros certainly do not hurt here, but
I think you also do not need them - typecasting should be done
automatically through __bswapXX(), shouldn't it?
So IMHO it should be enough to typecase the values after the colons.

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts
@ 2016-02-12 12:05     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 12:05 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/asm-generic/io.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> index a9939d3a5921f..abd245676e97a 100644
> --- a/lib/asm-generic/io.h
> +++ b/lib/asm-generic/io.h
> @@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x)
>  #endif
>  
>  #define le16_to_cpu(x) \
> -	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
> +	({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
>  #define cpu_to_le16 le16_to_cpu
>  
>  #define le32_to_cpu(x) \
> -	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
> +	({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
>  #define cpu_to_le32 le32_to_cpu
>  
>  #define le64_to_cpu(x) \
> -	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
> +	({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
>  #define cpu_to_le64 le64_to_cpu
>  
>  #define be16_to_cpu(x) \
> -	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
> +	({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
>  #define cpu_to_be16 be16_to_cpu
>  
>  #define be32_to_cpu(x) \
> -	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
> +	({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
>  #define cpu_to_be32 be32_to_cpu
>  
>  #define be64_to_cpu(x) \
> -	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
> +	({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
>  #define cpu_to_be64 be64_to_cpu

The typecasts for the __bswapXX() macros certainly do not hurt here, but
I think you also do not need them - typecasting should be done
automatically through __bswapXX(), shouldn't it?
So IMHO it should be enough to typecase the values after the colons.

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 02/14] lib: share arm-selftest utility functions
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12 12:40     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 12:40 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> arm-selftest has a couple utility functions that could be useful
> to other unit tests, even other architectures. So move them out.
> split_var moves to lib/util, where we can add other random
> utilities over time. assert_args inspires report_abort, which
> allows us to report a message, using the current prefix, that
> we're aborting (outputs ABORT vs. PASS/FAIL). This is useful
> for cases when unit tests can't complete due to missing
> dependencies of some sort, such as missing/invalid inputs from
> the user.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  arm/selftest.c               | 45 ++++++++++++++------------------------------
>  config/config-arm-common.mak |  1 +
>  lib/libcflat.h               | 11 ++++++-----
>  lib/report.c                 | 16 ++++++++++++++++
>  lib/util.c                   | 18 ++++++++++++++++++
>  lib/util.h                   | 23 ++++++++++++++++++++++
>  6 files changed, 78 insertions(+), 36 deletions(-)
>  create mode 100644 lib/util.c
>  create mode 100644 lib/util.h
> 
> diff --git a/arm/selftest.c b/arm/selftest.c
> index aad7eecd529ad..8a68f8bf25167 100644
> --- a/arm/selftest.c
> +++ b/arm/selftest.c
> @@ -6,6 +6,7 @@
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
>  #include <libcflat.h>
> +#include <util.h>
>  #include <alloc.h>
>  #include <devicetree.h>
>  #include <asm/setup.h>
> @@ -18,43 +19,21 @@
>  #include <asm/cpumask.h>
>  #include <asm/barrier.h>
>  
> -static void assert_args(int num_args, int needed_args)
> -{
> -	if (num_args < needed_args) {
> -		printf("selftest: not enough arguments\n");
> -		abort();
> -	}
> -}
> -
> -static char *split_var(char *s, long *val)
> -{
> -	char *p;
> -
> -	p = strchr(s, '=');
> -	if (!p)
> -		return NULL;
> -
> -	*val = atol(p+1);
> -	*p = '\0';
> -
> -	return s;
> -}
> -
>  static void check_setup(int argc, char **argv)
>  {
> -	int nr_tests = 0, i;
> -	char *var;
> +	int nr_tests = 0, len, i;
>  	long val;
>  
>  	for (i = 0; i < argc; ++i) {
>  
> -		var = split_var(argv[i], &val);
> -		if (!var)
> +		len = parse_keyval(argv[i], &val);
> +		if (len == -1)
>  			continue;
>  
> -		report_prefix_push(var);
> +		argv[i][len] = '\0';
> +		report_prefix_push(argv[i]);
>  
> -		if (strcmp(var, "mem") == 0) {
> +		if (strcmp(argv[i], "mem") == 0) {
>  
>  			phys_addr_t memsize = PHYS_END - PHYS_OFFSET;
>  			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
> @@ -63,7 +42,7 @@ static void check_setup(int argc, char **argv)
>  							memsize/1024/1024);
>  			++nr_tests;
>  
> -		} else if (strcmp(var, "smp") == 0) {
> +		} else if (strcmp(argv[i], "smp") == 0) {
>  
>  			report("nr_cpus = %d", nr_cpus == (int)val, nr_cpus);
>  			++nr_tests;
> @@ -72,7 +51,8 @@ static void check_setup(int argc, char **argv)
>  		report_prefix_pop();
>  	}
>  
> -	assert_args(nr_tests, 2);
> +	if (nr_tests < 2)
> +		report_abort("missing input");
>  }
>  
>  static struct pt_regs expected_regs;
> @@ -343,7 +323,10 @@ static void cpu_report(void)
>  int main(int argc, char **argv)
>  {
>  	report_prefix_push("selftest");
> -	assert_args(argc, 1);
> +
> +	if (argc < 1)
> +		report_abort("no test specified");
> +
>  	report_prefix_push(argv[0]);
>  
>  	if (strcmp(argv[0], "setup") == 0) {
> diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
> index 698555d6a676f..bd153cf6ea5ba 100644
> --- a/config/config-arm-common.mak
> +++ b/config/config-arm-common.mak
> @@ -27,6 +27,7 @@ CFLAGS += -I lib -I lib/libfdt
>  asm-offsets = lib/$(ARCH)/asm-offsets.h
>  include config/asm-offsets.mak
>  
> +cflatobjs += lib/util.o
>  cflatobjs += lib/alloc.o
>  cflatobjs += lib/devicetree.o
>  cflatobjs += lib/virtio.o
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index 9747ccdbc9f1d..8411f6c5d92e3 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -57,11 +57,12 @@ extern int snprintf(char *buf, int size, const char *fmt, ...);
>  extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
>  extern long atol(const char *ptr);
>  
> -void report_prefix_push(const char *prefix);
> -void report_prefix_pop(void);
> -void report(const char *msg_fmt, bool pass, ...);
> -void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
> -int report_summary(void);
> +extern void report_prefix_push(const char *prefix);
> +extern void report_prefix_pop(void);
> +extern void report(const char *msg_fmt, bool pass, ...);
> +extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
> +extern void report_abort(const char *msg_fmt, ...);
> +extern int report_summary(void);
>  
>  #define ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
>  
> diff --git a/lib/report.c b/lib/report.c
> index 35e664108a921..62916c4ac3c8a 100644
> --- a/lib/report.c
> +++ b/lib/report.c
> @@ -96,3 +96,19 @@ int report_summary(void)
>  
>  	spin_unlock(&lock);
>  }
> +
> +void report_abort(const char *msg_fmt, ...)
> +{
> +	va_list va;
> +	char buf[2000];
> +
> +	puts("ABORT: ");
> +	puts(prefixes);
> +	va_start(va, msg_fmt);
> +	vsnprintf(buf, sizeof(buf), msg_fmt, va);
> +	va_end(va);
> +	puts(buf);
> +	puts("\n");
> +	report_summary();
> +	abort();
> +}
> diff --git a/lib/util.c b/lib/util.c
> new file mode 100644
> index 0000000000000..69b18100c9722
> --- /dev/null
> +++ b/lib/util.c
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
> +#include <libcflat.h>
> +
> +int parse_keyval(char *s, long *val)
> +{
> +	char *p;
> +
> +	p = strchr(s, '=');
> +	if (!p)
> +		return -1;
> +
> +	*val = atol(p+1);
> +	return p - s;
> +}
> diff --git a/lib/util.h b/lib/util.h
> new file mode 100644
> index 0000000000000..5b07626175bab
> --- /dev/null
> +++ b/lib/util.h
> @@ -0,0 +1,23 @@
> +#ifndef _UTIL_H_
> +#define _UTIL_H_
> +/*
> + * Collection of utility functions to share between unit tests.
> + *
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
> +
> +/*
> + * parse_keyval extracts the integer from a string formatted as
> + * string=integer. This is useful for passing expected values in
> + * to the unit test on the command line, i.e. it helps parse QEMU
> + * command lines that include something like -append var1=1 var2=2
> + * @s is the input string, likely a command line parameter, and
> + * @val is a pointer to where the integer will be stored.
> + *
> + * Returns the offset of the '=', or -1 if no keyval pair is found.
> + */
> +extern int parse_keyval(char *s, long *val);
> +
> +#endif

Looks fine to me.

Reviewed-by: Thomas Huth <thuth@redhat.com>


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 02/14] lib: share arm-selftest utility functions
@ 2016-02-12 12:40     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 12:40 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> arm-selftest has a couple utility functions that could be useful
> to other unit tests, even other architectures. So move them out.
> split_var moves to lib/util, where we can add other random
> utilities over time. assert_args inspires report_abort, which
> allows us to report a message, using the current prefix, that
> we're aborting (outputs ABORT vs. PASS/FAIL). This is useful
> for cases when unit tests can't complete due to missing
> dependencies of some sort, such as missing/invalid inputs from
> the user.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  arm/selftest.c               | 45 ++++++++++++++------------------------------
>  config/config-arm-common.mak |  1 +
>  lib/libcflat.h               | 11 ++++++-----
>  lib/report.c                 | 16 ++++++++++++++++
>  lib/util.c                   | 18 ++++++++++++++++++
>  lib/util.h                   | 23 ++++++++++++++++++++++
>  6 files changed, 78 insertions(+), 36 deletions(-)
>  create mode 100644 lib/util.c
>  create mode 100644 lib/util.h
> 
> diff --git a/arm/selftest.c b/arm/selftest.c
> index aad7eecd529ad..8a68f8bf25167 100644
> --- a/arm/selftest.c
> +++ b/arm/selftest.c
> @@ -6,6 +6,7 @@
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
>  #include <libcflat.h>
> +#include <util.h>
>  #include <alloc.h>
>  #include <devicetree.h>
>  #include <asm/setup.h>
> @@ -18,43 +19,21 @@
>  #include <asm/cpumask.h>
>  #include <asm/barrier.h>
>  
> -static void assert_args(int num_args, int needed_args)
> -{
> -	if (num_args < needed_args) {
> -		printf("selftest: not enough arguments\n");
> -		abort();
> -	}
> -}
> -
> -static char *split_var(char *s, long *val)
> -{
> -	char *p;
> -
> -	p = strchr(s, '=');
> -	if (!p)
> -		return NULL;
> -
> -	*val = atol(p+1);
> -	*p = '\0';
> -
> -	return s;
> -}
> -
>  static void check_setup(int argc, char **argv)
>  {
> -	int nr_tests = 0, i;
> -	char *var;
> +	int nr_tests = 0, len, i;
>  	long val;
>  
>  	for (i = 0; i < argc; ++i) {
>  
> -		var = split_var(argv[i], &val);
> -		if (!var)
> +		len = parse_keyval(argv[i], &val);
> +		if (len = -1)
>  			continue;
>  
> -		report_prefix_push(var);
> +		argv[i][len] = '\0';
> +		report_prefix_push(argv[i]);
>  
> -		if (strcmp(var, "mem") = 0) {
> +		if (strcmp(argv[i], "mem") = 0) {
>  
>  			phys_addr_t memsize = PHYS_END - PHYS_OFFSET;
>  			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
> @@ -63,7 +42,7 @@ static void check_setup(int argc, char **argv)
>  							memsize/1024/1024);
>  			++nr_tests;
>  
> -		} else if (strcmp(var, "smp") = 0) {
> +		} else if (strcmp(argv[i], "smp") = 0) {
>  
>  			report("nr_cpus = %d", nr_cpus = (int)val, nr_cpus);
>  			++nr_tests;
> @@ -72,7 +51,8 @@ static void check_setup(int argc, char **argv)
>  		report_prefix_pop();
>  	}
>  
> -	assert_args(nr_tests, 2);
> +	if (nr_tests < 2)
> +		report_abort("missing input");
>  }
>  
>  static struct pt_regs expected_regs;
> @@ -343,7 +323,10 @@ static void cpu_report(void)
>  int main(int argc, char **argv)
>  {
>  	report_prefix_push("selftest");
> -	assert_args(argc, 1);
> +
> +	if (argc < 1)
> +		report_abort("no test specified");
> +
>  	report_prefix_push(argv[0]);
>  
>  	if (strcmp(argv[0], "setup") = 0) {
> diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
> index 698555d6a676f..bd153cf6ea5ba 100644
> --- a/config/config-arm-common.mak
> +++ b/config/config-arm-common.mak
> @@ -27,6 +27,7 @@ CFLAGS += -I lib -I lib/libfdt
>  asm-offsets = lib/$(ARCH)/asm-offsets.h
>  include config/asm-offsets.mak
>  
> +cflatobjs += lib/util.o
>  cflatobjs += lib/alloc.o
>  cflatobjs += lib/devicetree.o
>  cflatobjs += lib/virtio.o
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index 9747ccdbc9f1d..8411f6c5d92e3 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -57,11 +57,12 @@ extern int snprintf(char *buf, int size, const char *fmt, ...);
>  extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
>  extern long atol(const char *ptr);
>  
> -void report_prefix_push(const char *prefix);
> -void report_prefix_pop(void);
> -void report(const char *msg_fmt, bool pass, ...);
> -void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
> -int report_summary(void);
> +extern void report_prefix_push(const char *prefix);
> +extern void report_prefix_pop(void);
> +extern void report(const char *msg_fmt, bool pass, ...);
> +extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...);
> +extern void report_abort(const char *msg_fmt, ...);
> +extern int report_summary(void);
>  
>  #define ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
>  
> diff --git a/lib/report.c b/lib/report.c
> index 35e664108a921..62916c4ac3c8a 100644
> --- a/lib/report.c
> +++ b/lib/report.c
> @@ -96,3 +96,19 @@ int report_summary(void)
>  
>  	spin_unlock(&lock);
>  }
> +
> +void report_abort(const char *msg_fmt, ...)
> +{
> +	va_list va;
> +	char buf[2000];
> +
> +	puts("ABORT: ");
> +	puts(prefixes);
> +	va_start(va, msg_fmt);
> +	vsnprintf(buf, sizeof(buf), msg_fmt, va);
> +	va_end(va);
> +	puts(buf);
> +	puts("\n");
> +	report_summary();
> +	abort();
> +}
> diff --git a/lib/util.c b/lib/util.c
> new file mode 100644
> index 0000000000000..69b18100c9722
> --- /dev/null
> +++ b/lib/util.c
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
> +#include <libcflat.h>
> +
> +int parse_keyval(char *s, long *val)
> +{
> +	char *p;
> +
> +	p = strchr(s, '=');
> +	if (!p)
> +		return -1;
> +
> +	*val = atol(p+1);
> +	return p - s;
> +}
> diff --git a/lib/util.h b/lib/util.h
> new file mode 100644
> index 0000000000000..5b07626175bab
> --- /dev/null
> +++ b/lib/util.h
> @@ -0,0 +1,23 @@
> +#ifndef _UTIL_H_
> +#define _UTIL_H_
> +/*
> + * Collection of utility functions to share between unit tests.
> + *
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
> +
> +/*
> + * parse_keyval extracts the integer from a string formatted as
> + * string=integer. This is useful for passing expected values in
> + * to the unit test on the command line, i.e. it helps parse QEMU
> + * command lines that include something like -append var1=1 var2=2
> + * @s is the input string, likely a command line parameter, and
> + * @val is a pointer to where the integer will be stored.
> + *
> + * Returns the offset of the '=', or -1 if no keyval pair is found.
> + */
> +extern int parse_keyval(char *s, long *val);
> +
> +#endif

Looks fine to me.

Reviewed-by: Thomas Huth <thuth@redhat.com>


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-12 10:57                 ` Andrew Jones
@ 2016-02-12 13:44                   ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 13:44 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Fri, Feb 12, 2016 at 11:57:51AM +0100, Andrew Jones wrote:
> On Fri, Feb 12, 2016 at 11:31:32AM +0100, Laurent Vivier wrote:
> > I have nothing at all. It hangs.
> 
> Damn. I'll need to get a machine where the problems reproduce to debug.

I got a machine, an lpar, so using kvm_pr. I immediately hit a problem.
Hung, no output. I was hitting the assert you found earlier, due to
assuming a single memory region. The lack of output and rtas-poweroff were
due to 'sc 1' being broken on this machine. I can fix that by patching
like SLOF does, see [*]. Although I'm not 100% sure how I want to approach
it yet.

There are enough things to fix now that I should probably spin another
version before you bother retesting on the PowerMac. I'll pull something
together soon.

Thanks,
drew

[*] http://git.qemu-project.org/?p=SLOF.git;a=patch;h=dd53579ae82bed0654dd3e4b3052ef2cac58b5f4

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-12 13:44                   ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 13:44 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, david, agraf, pbonzini

On Fri, Feb 12, 2016 at 11:57:51AM +0100, Andrew Jones wrote:
> On Fri, Feb 12, 2016 at 11:31:32AM +0100, Laurent Vivier wrote:
> > I have nothing at all. It hangs.
> 
> Damn. I'll need to get a machine where the problems reproduce to debug.

I got a machine, an lpar, so using kvm_pr. I immediately hit a problem.
Hung, no output. I was hitting the assert you found earlier, due to
assuming a single memory region. The lack of output and rtas-poweroff were
due to 'sc 1' being broken on this machine. I can fix that by patching
like SLOF does, see [*]. Although I'm not 100% sure how I want to approach
it yet.

There are enough things to fix now that I should probably spin another
version before you bother retesting on the PowerMac. I'll pull something
together soon.

Thanks,
drew

[*] http://git.qemu-project.org/?p=SLOF.git;a=patch;h›53579ae82bed0654dd3e4b3052ef2cac58b5f4
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts
  2016-02-12 12:05     ` Thomas Huth
@ 2016-02-12 13:58       ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 13:58 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, kvm-ppc, dgibson, david, agraf, lvivier, pbonzini

On Fri, Feb 12, 2016 at 01:05:26PM +0100, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> >  lib/asm-generic/io.h | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> > index a9939d3a5921f..abd245676e97a 100644
> > --- a/lib/asm-generic/io.h
> > +++ b/lib/asm-generic/io.h
> > @@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x)
> >  #endif
> >  
> >  #define le16_to_cpu(x) \
> > -	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
> > +	({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
> >  #define cpu_to_le16 le16_to_cpu
> >  
> >  #define le32_to_cpu(x) \
> > -	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
> > +	({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
> >  #define cpu_to_le32 le32_to_cpu
> >  
> >  #define le64_to_cpu(x) \
> > -	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
> > +	({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
> >  #define cpu_to_le64 le64_to_cpu
> >  
> >  #define be16_to_cpu(x) \
> > -	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
> > +	({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
> >  #define cpu_to_be16 be16_to_cpu
> >  
> >  #define be32_to_cpu(x) \
> > -	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
> > +	({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
> >  #define cpu_to_be32 be32_to_cpu
> >  
> >  #define be64_to_cpu(x) \
> > -	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
> > +	({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
> >  #define cpu_to_be64 be64_to_cpu
> 
> The typecasts for the __bswapXX() macros certainly do not hurt here, but
> I think you also do not need them - typecasting should be done

Agreed, those are pointless and ugly. I'll remove them.

> automatically through __bswapXX(), shouldn't it?
> So IMHO it should be enough to typecase the values after the colons.

Yup, I'll change for v3.

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts
@ 2016-02-12 13:58       ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 13:58 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, kvm-ppc, dgibson, david, agraf, lvivier, pbonzini

On Fri, Feb 12, 2016 at 01:05:26PM +0100, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> >  lib/asm-generic/io.h | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> > index a9939d3a5921f..abd245676e97a 100644
> > --- a/lib/asm-generic/io.h
> > +++ b/lib/asm-generic/io.h
> > @@ -104,27 +104,27 @@ static inline u64 __bswap64(u64 x)
> >  #endif
> >  
> >  #define le16_to_cpu(x) \
> > -	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
> > +	({ u16 __r = __cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
> >  #define cpu_to_le16 le16_to_cpu
> >  
> >  #define le32_to_cpu(x) \
> > -	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
> > +	({ u32 __r = __cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
> >  #define cpu_to_le32 le32_to_cpu
> >  
> >  #define le64_to_cpu(x) \
> > -	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
> > +	({ u64 __r = __cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
> >  #define cpu_to_le64 le64_to_cpu
> >  
> >  #define be16_to_cpu(x) \
> > -	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
> > +	({ u16 __r = !__cpu_is_be() ? __bswap16((u16)x) : ((u16)x); __r; })
> >  #define cpu_to_be16 be16_to_cpu
> >  
> >  #define be32_to_cpu(x) \
> > -	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
> > +	({ u32 __r = !__cpu_is_be() ? __bswap32((u32)x) : ((u32)x); __r; })
> >  #define cpu_to_be32 be32_to_cpu
> >  
> >  #define be64_to_cpu(x) \
> > -	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
> > +	({ u64 __r = !__cpu_is_be() ? __bswap64((u64)x) : ((u64)x); __r; })
> >  #define cpu_to_be64 be64_to_cpu
> 
> The typecasts for the __bswapXX() macros certainly do not hurt here, but
> I think you also do not need them - typecasting should be done

Agreed, those are pointless and ugly. I'll remove them.

> automatically through __bswapXX(), shouldn't it?
> So IMHO it should be enough to typecase the values after the colons.

Yup, I'll change for v3.

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup
  2016-02-12 11:50     ` Thomas Huth
@ 2016-02-12 13:59       ` Andrew Jones
  -1 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 13:59 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, kvm-ppc, dgibson, david, agraf, lvivier, pbonzini

On Fri, Feb 12, 2016 at 12:50:12PM +0100, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
> > Copy arm's setup code (also DT based) over to powerpc, adapting
> > it a bit. Also bring over arm's setup selftest, giving powerpc
> > its first test.
> > 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> >  lib/powerpc/asm/setup.h | 27 +++++++++++++++
> >  lib/powerpc/setup.c     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  lib/ppc64/asm/setup.h   |  1 +
> >  powerpc/cstart64.S      |  9 +++++
> >  powerpc/selftest.c      | 64 ++++++++++++++++++++++++++++++++--
> >  5 files changed, 189 insertions(+), 3 deletions(-)
> >  create mode 100644 lib/powerpc/asm/setup.h
> >  create mode 100644 lib/ppc64/asm/setup.h
> ...
> > diff --git a/powerpc/selftest.c b/powerpc/selftest.c
> > index 2f2a5215dd55c..3dd7ce9945307 100644
> > --- a/powerpc/selftest.c
> > +++ b/powerpc/selftest.c
> > @@ -1,7 +1,65 @@
> > +/*
> > + * Test the framework itself. These tests confirm that setup works.
> > + *
> > + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> > + *
> > + * This work is licensed under the terms of the GNU LGPL, version 2.
> > + */
> >  #include <libcflat.h>
> > +#include <util.h>
> > +#include <alloc.h>		/* phys_addr_t */
> > +#include <asm/setup.h>
> >  
> > -int main(void)
> > +static void check_setup(int argc, char **argv)
> >  {
> > -	printf("hello world\n");
> > -	return 0;
> > +	int nr_tests = 0, len, i;
> > +	long val;
> > +
> > +	for (i = 0; i < argc; ++i) {
> > +
> > +		len = parse_keyval(argv[i], &val);
> > +		if (len == -1)
> > +			continue;
> > +
> > +		argv[i][len] = '\0';
> > +		report_prefix_push(argv[i]);
> > +
> > +		if (strcmp(argv[i], "mem") == 0) {
> > +
> > +			phys_addr_t memsize = PHYSICAL_END - PHYSICAL_START;
> > +			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
> > +
> > +			report("size = %d MB", memsize == expected,
> > +							memsize/1024/1024);
> > +			++nr_tests;
> > +
> > +		} else if (strcmp(argv[i], "smp") == 0) {
> > +
> > +			report("nr_cpus = %d", nr_cpus == (int)val, nr_cpus);
> > +			++nr_tests;
> 
> Could you maybe add a check for nr_cpus <= NR_CPUS somewhere and print a
> friendly warning message if it the amount of CPUs exceeds NR_CPUS?
> Otherwise you only get a very cryptic assert() message if you
> accidentially specify too many CPUs ... (it just happened to me, and it
> took a while till I understood what was wrong).

Will do.

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup
@ 2016-02-12 13:59       ` Andrew Jones
  0 siblings, 0 replies; 84+ messages in thread
From: Andrew Jones @ 2016-02-12 13:59 UTC (permalink / raw)
  To: Thomas Huth; +Cc: kvm, kvm-ppc, dgibson, david, agraf, lvivier, pbonzini

On Fri, Feb 12, 2016 at 12:50:12PM +0100, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
> > Copy arm's setup code (also DT based) over to powerpc, adapting
> > it a bit. Also bring over arm's setup selftest, giving powerpc
> > its first test.
> > 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> >  lib/powerpc/asm/setup.h | 27 +++++++++++++++
> >  lib/powerpc/setup.c     | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  lib/ppc64/asm/setup.h   |  1 +
> >  powerpc/cstart64.S      |  9 +++++
> >  powerpc/selftest.c      | 64 ++++++++++++++++++++++++++++++++--
> >  5 files changed, 189 insertions(+), 3 deletions(-)
> >  create mode 100644 lib/powerpc/asm/setup.h
> >  create mode 100644 lib/ppc64/asm/setup.h
> ...
> > diff --git a/powerpc/selftest.c b/powerpc/selftest.c
> > index 2f2a5215dd55c..3dd7ce9945307 100644
> > --- a/powerpc/selftest.c
> > +++ b/powerpc/selftest.c
> > @@ -1,7 +1,65 @@
> > +/*
> > + * Test the framework itself. These tests confirm that setup works.
> > + *
> > + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> > + *
> > + * This work is licensed under the terms of the GNU LGPL, version 2.
> > + */
> >  #include <libcflat.h>
> > +#include <util.h>
> > +#include <alloc.h>		/* phys_addr_t */
> > +#include <asm/setup.h>
> >  
> > -int main(void)
> > +static void check_setup(int argc, char **argv)
> >  {
> > -	printf("hello world\n");
> > -	return 0;
> > +	int nr_tests = 0, len, i;
> > +	long val;
> > +
> > +	for (i = 0; i < argc; ++i) {
> > +
> > +		len = parse_keyval(argv[i], &val);
> > +		if (len = -1)
> > +			continue;
> > +
> > +		argv[i][len] = '\0';
> > +		report_prefix_push(argv[i]);
> > +
> > +		if (strcmp(argv[i], "mem") = 0) {
> > +
> > +			phys_addr_t memsize = PHYSICAL_END - PHYSICAL_START;
> > +			phys_addr_t expected = ((phys_addr_t)val)*1024*1024;
> > +
> > +			report("size = %d MB", memsize = expected,
> > +							memsize/1024/1024);
> > +			++nr_tests;
> > +
> > +		} else if (strcmp(argv[i], "smp") = 0) {
> > +
> > +			report("nr_cpus = %d", nr_cpus = (int)val, nr_cpus);
> > +			++nr_tests;
> 
> Could you maybe add a check for nr_cpus <= NR_CPUS somewhere and print a
> friendly warning message if it the amount of CPUs exceeds NR_CPUS?
> Otherwise you only get a very cryptic assert() message if you
> accidentially specify too many CPUs ... (it just happened to me, and it
> took a while till I understood what was wrong).

Will do.

Thanks,
drew

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12 17:08     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 17:08 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Add the hvcall for putchar and use it in puts. That, along with a
> couple more lines in start to prepare for C code, and a branch to
> main(), gets us "hello world". Run with
> 
> qemu-system-ppc64 -M pseries            \
>         -bios powerpc/boot_rom.bin      \
>         -display none -serial stdio     \
>         -kernel powerpc/selftest.elf
> 
> (We're still not relocating yet, that comes in a later patch. Thus,
>  testing hello-world at this point requires a hacked QEMU and linking
>  the unit test at QEMU's kernel load address.)

Is that comment still valid? I thought that's what the boot_rom.bin was
good for?

Apart from that, this patch looks fine to me.

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar
@ 2016-02-12 17:08     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 17:08 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Add the hvcall for putchar and use it in puts. That, along with a
> couple more lines in start to prepare for C code, and a branch to
> main(), gets us "hello world". Run with
> 
> qemu-system-ppc64 -M pseries            \
>         -bios powerpc/boot_rom.bin      \
>         -display none -serial stdio     \
>         -kernel powerpc/selftest.elf
> 
> (We're still not relocating yet, that comes in a later patch. Thus,
>  testing hello-world at this point requires a hacked QEMU and linking
>  the unit test at QEMU's kernel load address.)

Is that comment still valid? I thought that's what the boot_rom.bin was
good for?

Apart from that, this patch looks fine to me.

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar
  2016-02-12 17:08     ` Thomas Huth
@ 2016-02-12 17:45       ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 17:45 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 12.02.2016 18:08, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
>> Add the hvcall for putchar and use it in puts. That, along with a
>> couple more lines in start to prepare for C code, and a branch to
>> main(), gets us "hello world". Run with
>>
>> qemu-system-ppc64 -M pseries            \
>>         -bios powerpc/boot_rom.bin      \
>>         -display none -serial stdio     \
>>         -kernel powerpc/selftest.elf
>>
>> (We're still not relocating yet, that comes in a later patch. Thus,
>>  testing hello-world at this point requires a hacked QEMU and linking
>>  the unit test at QEMU's kernel load address.)
> 
> Is that comment still valid? I thought that's what the boot_rom.bin was
> good for?

Never mind, after reading patch 10/14, it's now clear to me what you
mean here.

 Thomas



^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar
@ 2016-02-12 17:45       ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 17:45 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 12.02.2016 18:08, Thomas Huth wrote:
> On 08.02.2016 19:53, Andrew Jones wrote:
>> Add the hvcall for putchar and use it in puts. That, along with a
>> couple more lines in start to prepare for C code, and a branch to
>> main(), gets us "hello world". Run with
>>
>> qemu-system-ppc64 -M pseries            \
>>         -bios powerpc/boot_rom.bin      \
>>         -display none -serial stdio     \
>>         -kernel powerpc/selftest.elf
>>
>> (We're still not relocating yet, that comes in a later patch. Thus,
>>  testing hello-world at this point requires a hacked QEMU and linking
>>  the unit test at QEMU's kernel load address.)
> 
> Is that comment still valid? I thought that's what the boot_rom.bin was
> good for?

Never mind, after reading patch 10/14, it's now clear to me what you
mean here.

 Thomas



^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 13/14] powerpc/ppc64: add RTAS support
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12 17:51     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 17:51 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Add enough RTAS support to start adding RTAS commands. Just add
> power-off for now.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/powerpc/asm/rtas.h  |  26 +++++++++++
>  lib/powerpc/io.c        |   2 +
>  lib/powerpc/rtas.c      | 120 ++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/ppc64/asm/rtas.h    |   1 +
>  powerpc/Makefile.common |   1 +
>  5 files changed, 150 insertions(+)
>  create mode 100644 lib/powerpc/asm/rtas.h
>  create mode 100644 lib/powerpc/rtas.c
>  create mode 100644 lib/ppc64/asm/rtas.h
...
> diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
> new file mode 100644
> index 0000000000000..7fcd667513087
> --- /dev/null
> +++ b/lib/powerpc/rtas.c
> @@ -0,0 +1,120 @@
> +/*
> + * powerpc RTAS
> + *
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
> +#include <libcflat.h>
> +#include <libfdt/libfdt.h>
> +#include <devicetree.h>
> +#include <asm/spinlock.h>
> +#include <asm/io.h>
> +#include <asm/rtas.h>
> +
> +#if defined(__powerpc64__)
> +struct func_ptr {
> +	unsigned long ptr;
> +	unsigned long toc;

Theoretically, there should be a third value "env" or so here (see
<http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES>),
but for C-code it likely does not matter.

> +};
> +static struct func_ptr rtas_entry_funcptr;
> +#endif
> +typedef void (*rtas_entry_t)(unsigned long);
> +static rtas_entry_t enter_rtas;
> +static struct rtas_args rtas_args;
> +static struct spinlock lock;
> +
> +static int rtas_node(void)
> +{
> +	int node = fdt_path_offset(dt_fdt(), "/rtas");
> +
> +	if (node < 0) {
> +		printf("%s: /rtas: %s\n", __func__, fdt_strerror(node));
> +		abort();
> +	}
> +
> +	return node;
> +}
> +
> +void rtas_init(void)
> +{
> +	const struct fdt_property *prop;
> +	unsigned long entry;
> +	u32 *data;
> +	int len;
> +
> +	if (!dt_available()) {
> +		printf("%s: No device tree!\n", __func__);
> +		abort();
> +	}
> +
> +	prop = fdt_get_property(dt_fdt(), rtas_node(),
> +				"linux,rtas-entry", &len);
> +	if (!prop) {
> +		printf("%s: /rtas/linux,rtas-entry: %s\n",
> +				__func__, fdt_strerror(len));
> +		abort();
> +	}
> +
> +	data = (u32 *)prop->data;
> +	entry = (unsigned long)fdt32_to_cpu(*data);
> +
> +#if defined(__powerpc64__)
> +	rtas_entry_funcptr.ptr = entry;
> +	enter_rtas = (rtas_entry_t)&rtas_entry_funcptr;
> +#else
> +	enter_rtas = (rtas_entry_t)entry;
> +#endif
> +}
> +
> +int rtas_token(const char *service)
> +{
> +	const struct fdt_property *prop;
> +	u32 *token;
> +
> +	prop = fdt_get_property(dt_fdt(), rtas_node(), service, NULL);
> +	if (prop) {
> +		token = (u32 *)prop->data;
> +		return fdt32_to_cpu(*token);
> +	}
> +	return RTAS_UNKNOWN_SERVICE;
> +}
> +
> +int rtas_call(int token, int nargs, int nret, int *outputs, ...)
> +{
> +	va_list list;
> +	int ret, i;
> +
> +	spin_lock(&lock);
> +
> +	rtas_args.token = cpu_to_be32(token);
> +	rtas_args.nargs = cpu_to_be32(nargs);
> +	rtas_args.nret = cpu_to_be32(nret);
> +	rtas_args.rets = &rtas_args.args[nargs];
> +
> +	va_start(list, outputs);
> +	for (i = 0; i < nargs; ++i)
> +		rtas_args.args[i] = cpu_to_be32(va_arg(list, u32));
> +	va_end(list);
> +
> +	for (i = 0; i < nret; ++i)
> +		rtas_args.rets[i] = 0;
> +
> +	enter_rtas(__pa(&rtas_args));
> +
> +	if (nret > 1 && outputs != NULL)
> +		for (i = 0; i < nret - 1; ++i)
> +			outputs[i] = be32_to_cpu(rtas_args.rets[i + 1]);
> +
> +	ret = nret > 0 ? be32_to_cpu(rtas_args.rets[0]) : 0;
> +
> +	spin_unlock(&lock);
> +	return ret;
> +}
> +
> +void rtas_power_off(void)
> +{
> +	printf("RTAS power-off returned %d\n",
> +		rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
> +	assert(0);
> +}

As discussed in IRC already, that assert() can cause an endless loop...
but apart from that, the patch looks fine to me.

 Thomas



^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 13/14] powerpc/ppc64: add RTAS support
@ 2016-02-12 17:51     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 17:51 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> Add enough RTAS support to start adding RTAS commands. Just add
> power-off for now.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/powerpc/asm/rtas.h  |  26 +++++++++++
>  lib/powerpc/io.c        |   2 +
>  lib/powerpc/rtas.c      | 120 ++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/ppc64/asm/rtas.h    |   1 +
>  powerpc/Makefile.common |   1 +
>  5 files changed, 150 insertions(+)
>  create mode 100644 lib/powerpc/asm/rtas.h
>  create mode 100644 lib/powerpc/rtas.c
>  create mode 100644 lib/ppc64/asm/rtas.h
...
> diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
> new file mode 100644
> index 0000000000000..7fcd667513087
> --- /dev/null
> +++ b/lib/powerpc/rtas.c
> @@ -0,0 +1,120 @@
> +/*
> + * powerpc RTAS
> + *
> + * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.
> + */
> +#include <libcflat.h>
> +#include <libfdt/libfdt.h>
> +#include <devicetree.h>
> +#include <asm/spinlock.h>
> +#include <asm/io.h>
> +#include <asm/rtas.h>
> +
> +#if defined(__powerpc64__)
> +struct func_ptr {
> +	unsigned long ptr;
> +	unsigned long toc;

Theoretically, there should be a third value "env" or so here (see
<http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES>),
but for C-code it likely does not matter.

> +};
> +static struct func_ptr rtas_entry_funcptr;
> +#endif
> +typedef void (*rtas_entry_t)(unsigned long);
> +static rtas_entry_t enter_rtas;
> +static struct rtas_args rtas_args;
> +static struct spinlock lock;
> +
> +static int rtas_node(void)
> +{
> +	int node = fdt_path_offset(dt_fdt(), "/rtas");
> +
> +	if (node < 0) {
> +		printf("%s: /rtas: %s\n", __func__, fdt_strerror(node));
> +		abort();
> +	}
> +
> +	return node;
> +}
> +
> +void rtas_init(void)
> +{
> +	const struct fdt_property *prop;
> +	unsigned long entry;
> +	u32 *data;
> +	int len;
> +
> +	if (!dt_available()) {
> +		printf("%s: No device tree!\n", __func__);
> +		abort();
> +	}
> +
> +	prop = fdt_get_property(dt_fdt(), rtas_node(),
> +				"linux,rtas-entry", &len);
> +	if (!prop) {
> +		printf("%s: /rtas/linux,rtas-entry: %s\n",
> +				__func__, fdt_strerror(len));
> +		abort();
> +	}
> +
> +	data = (u32 *)prop->data;
> +	entry = (unsigned long)fdt32_to_cpu(*data);
> +
> +#if defined(__powerpc64__)
> +	rtas_entry_funcptr.ptr = entry;
> +	enter_rtas = (rtas_entry_t)&rtas_entry_funcptr;
> +#else
> +	enter_rtas = (rtas_entry_t)entry;
> +#endif
> +}
> +
> +int rtas_token(const char *service)
> +{
> +	const struct fdt_property *prop;
> +	u32 *token;
> +
> +	prop = fdt_get_property(dt_fdt(), rtas_node(), service, NULL);
> +	if (prop) {
> +		token = (u32 *)prop->data;
> +		return fdt32_to_cpu(*token);
> +	}
> +	return RTAS_UNKNOWN_SERVICE;
> +}
> +
> +int rtas_call(int token, int nargs, int nret, int *outputs, ...)
> +{
> +	va_list list;
> +	int ret, i;
> +
> +	spin_lock(&lock);
> +
> +	rtas_args.token = cpu_to_be32(token);
> +	rtas_args.nargs = cpu_to_be32(nargs);
> +	rtas_args.nret = cpu_to_be32(nret);
> +	rtas_args.rets = &rtas_args.args[nargs];
> +
> +	va_start(list, outputs);
> +	for (i = 0; i < nargs; ++i)
> +		rtas_args.args[i] = cpu_to_be32(va_arg(list, u32));
> +	va_end(list);
> +
> +	for (i = 0; i < nret; ++i)
> +		rtas_args.rets[i] = 0;
> +
> +	enter_rtas(__pa(&rtas_args));
> +
> +	if (nret > 1 && outputs != NULL)
> +		for (i = 0; i < nret - 1; ++i)
> +			outputs[i] = be32_to_cpu(rtas_args.rets[i + 1]);
> +
> +	ret = nret > 0 ? be32_to_cpu(rtas_args.rets[0]) : 0;
> +
> +	spin_unlock(&lock);
> +	return ret;
> +}
> +
> +void rtas_power_off(void)
> +{
> +	printf("RTAS power-off returned %d\n",
> +		rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
> +	assert(0);
> +}

As discussed in IRC already, that assert() can cause an endless loop...
but apart from that, the patch looks fine to me.

 Thomas



^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit
  2016-02-08 18:53   ` Andrew Jones
@ 2016-02-12 18:07     ` Thomas Huth
  -1 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 18:07 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> We should use a QEMU debug-exit device like chr-testdev, but for
> now we just fake things by outputting the exit code (which we
> parse later) and quitting with RTAS (which always exits with zero).
> 
> (When we've got a real debug-exit working, then this patch can
>  be reverted.)
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/powerpc/io.c | 4 ++++
>  powerpc/run      | 7 +++++--
>  2 files changed, 9 insertions(+), 2 deletions(-)

Patch looks fine to me as an initial solution (and I'd also suggest to
remove the "HACK" in the title, as Paolo already said).

For a future improvement: Not sure, but there is a "ibm,os-term" RTAS
call which "[...] is provided for the OS to indicate to the platform
that it has terminated normal operation. A string of information is
passed to the platform", according to LoPAPR chapter 7.3.9.1. Maybe that
could be used to implement the debug-exit functionality? QEMU seems to
already send a GUEST_PANIC_ACTION_PAUSE event in this case, but the
parameter string is not taken into account yet...

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit
@ 2016-02-12 18:07     ` Thomas Huth
  0 siblings, 0 replies; 84+ messages in thread
From: Thomas Huth @ 2016-02-12 18:07 UTC (permalink / raw)
  To: Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier, pbonzini

On 08.02.2016 19:53, Andrew Jones wrote:
> We should use a QEMU debug-exit device like chr-testdev, but for
> now we just fake things by outputting the exit code (which we
> parse later) and quitting with RTAS (which always exits with zero).
> 
> (When we've got a real debug-exit working, then this patch can
>  be reverted.)
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  lib/powerpc/io.c | 4 ++++
>  powerpc/run      | 7 +++++--
>  2 files changed, 9 insertions(+), 2 deletions(-)

Patch looks fine to me as an initial solution (and I'd also suggest to
remove the "HACK" in the title, as Paolo already said).

For a future improvement: Not sure, but there is a "ibm,os-term" RTAS
call which "[...] is provided for the OS to indicate to the platform
that it has terminated normal operation. A string of information is
passed to the platform", according to LoPAPR chapter 7.3.9.1. Maybe that
could be used to implement the debug-exit functionality? QEMU seems to
already send a GUEST_PANIC_ACTION_PAUSE event in this case, but the
parameter string is not taken into account yet...

 Thomas


^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit
  2016-02-12 18:07     ` Thomas Huth
@ 2016-02-12 22:50       ` Paolo Bonzini
  -1 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2016-02-12 22:50 UTC (permalink / raw)
  To: Thomas Huth, Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier



On 12/02/2016 19:07, Thomas Huth wrote:
> For a future improvement: Not sure, but there is a "ibm,os-term" RTAS
> call which "[...] is provided for the OS to indicate to the platform
> that it has terminated normal operation. A string of information is
> passed to the platform", according to LoPAPR chapter 7.3.9.1. Maybe that
> could be used to implement the debug-exit functionality? QEMU seems to
> already send a GUEST_PANIC_ACTION_PAUSE event in this case, but the
> parameter string is not taken into account yet...

It also doesn't actually pause, unlike qemu_system_guest_panicked().  It
probably should use a different GUEST_PANIC_ACTION (e.g. "report") for
the event.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit
@ 2016-02-12 22:50       ` Paolo Bonzini
  0 siblings, 0 replies; 84+ messages in thread
From: Paolo Bonzini @ 2016-02-12 22:50 UTC (permalink / raw)
  To: Thomas Huth, Andrew Jones, kvm, kvm-ppc; +Cc: dgibson, david, agraf, lvivier



On 12/02/2016 19:07, Thomas Huth wrote:
> For a future improvement: Not sure, but there is a "ibm,os-term" RTAS
> call which "[...] is provided for the OS to indicate to the platform
> that it has terminated normal operation. A string of information is
> passed to the platform", according to LoPAPR chapter 7.3.9.1. Maybe that
> could be used to implement the debug-exit functionality? QEMU seems to
> already send a GUEST_PANIC_ACTION_PAUSE event in this case, but the
> parameter string is not taken into account yet...

It also doesn't actually pause, unlike qemu_system_guest_panicked().  It
probably should use a different GUEST_PANIC_ACTION (e.g. "report") for
the event.

Paolo

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
  2016-02-12 13:44                   ` Andrew Jones
@ 2016-02-14 22:43                     ` David Gibson
  -1 siblings, 0 replies; 84+ messages in thread
From: David Gibson @ 2016-02-14 22:43 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Laurent Vivier, kvm, kvm-ppc, thuth, dgibson, agraf, pbonzini

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]

On Fri, Feb 12, 2016 at 02:44:20PM +0100, Andrew Jones wrote:
> On Fri, Feb 12, 2016 at 11:57:51AM +0100, Andrew Jones wrote:
> > On Fri, Feb 12, 2016 at 11:31:32AM +0100, Laurent Vivier wrote:
> > > I have nothing at all. It hangs.
> > 
> > Damn. I'll need to get a machine where the problems reproduce to debug.
> 
> I got a machine, an lpar, so using kvm_pr. I immediately hit a problem.
> Hung, no output. I was hitting the assert you found earlier, due to
> assuming a single memory region. The lack of output and rtas-poweroff were
> due to 'sc 1' being broken on this machine. I can fix that by patching
> like SLOF does, see [*]. Although I'm not 100% sure how I want to approach
> it yet.

I'm guessing your test machine was a PowerVM LPAR rather than a KVM
LPAR.  If you can find a KVM LPAR (IBM host or RHEV host, doesn't
matter) things should work better.  KVM includes a hack for this
situation:  an sc 1 coming from guest usermode is redirected to the
guest kernel, instead of immediately returning H_PRIVILEGE, which
allows the L0 guest / L1 host's kvm_pr to handle it.

> There are enough things to fix now that I should probably spin another
> version before you bother retesting on the PowerMac. I'll pull something
> together soon.
> 
> Thanks,
> drew
> 
> [*] http://git.qemu-project.org/?p=SLOF.git;a=patch;h=dd53579ae82bed0654dd3e4b3052ef2cac58b5f4
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 84+ messages in thread

* Re: [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop
@ 2016-02-14 22:43                     ` David Gibson
  0 siblings, 0 replies; 84+ messages in thread
From: David Gibson @ 2016-02-14 22:43 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Laurent Vivier, kvm, kvm-ppc, thuth, dgibson, agraf, pbonzini

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]

On Fri, Feb 12, 2016 at 02:44:20PM +0100, Andrew Jones wrote:
> On Fri, Feb 12, 2016 at 11:57:51AM +0100, Andrew Jones wrote:
> > On Fri, Feb 12, 2016 at 11:31:32AM +0100, Laurent Vivier wrote:
> > > I have nothing at all. It hangs.
> > 
> > Damn. I'll need to get a machine where the problems reproduce to debug.
> 
> I got a machine, an lpar, so using kvm_pr. I immediately hit a problem.
> Hung, no output. I was hitting the assert you found earlier, due to
> assuming a single memory region. The lack of output and rtas-poweroff were
> due to 'sc 1' being broken on this machine. I can fix that by patching
> like SLOF does, see [*]. Although I'm not 100% sure how I want to approach
> it yet.

I'm guessing your test machine was a PowerVM LPAR rather than a KVM
LPAR.  If you can find a KVM LPAR (IBM host or RHEV host, doesn't
matter) things should work better.  KVM includes a hack for this
situation:  an sc 1 coming from guest usermode is redirected to the
guest kernel, instead of immediately returning H_PRIVILEGE, which
allows the L0 guest / L1 host's kvm_pr to handle it.

> There are enough things to fix now that I should probably spin another
> version before you bother retesting on the PowerMac. I'll pull something
> together soon.
> 
> Thanks,
> drew
> 
> [*] http://git.qemu-project.org/?p=SLOF.git;a=patch;h=dd53579ae82bed0654dd3e4b3052ef2cac58b5f4
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 84+ messages in thread

end of thread, other threads:[~2016-02-15  0:04 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 18:53 [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop Andrew Jones
2016-02-08 18:53 ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 01/14] lib: asm-generic: add missing casts Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12 12:05   ` Thomas Huth
2016-02-12 12:05     ` Thomas Huth
2016-02-12 13:58     ` Andrew Jones
2016-02-12 13:58       ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 02/14] lib: share arm-selftest utility functions Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12 12:40   ` Thomas Huth
2016-02-12 12:40     ` Thomas Huth
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 03/14] config: no need to mix arch makefiles Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 04/14] powerpc/ppc64: start skeleton framework Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 05/14] powerpc/pp64: ppc-ify makefiles and linker script Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-09 17:54   ` [kvm-unit-tests PATCH] align toc to 256 bytes Andrew Jones
2016-02-09 17:54     ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 06/14] powerpc/ppc64: add boot rom source Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12  6:27   ` Thomas Huth
2016-02-12  6:27     ` Thomas Huth
2016-02-12 10:07     ` Andrew Jones
2016-02-12 10:07       ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 07/14] powerpc/ppc64: add bootloader to bounce into memory Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 08/14] powerpc/ppc64: add HV putchar Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12 17:08   ` Thomas Huth
2016-02-12 17:08     ` Thomas Huth
2016-02-12 17:45     ` Thomas Huth
2016-02-12 17:45       ` Thomas Huth
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 09/14] powerpc/ppc64: adapt arm's setup Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12 11:50   ` Thomas Huth
2016-02-12 11:50     ` Thomas Huth
2016-02-12 13:59     ` Andrew Jones
2016-02-12 13:59       ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 10/14] powerpc/ppc64: relocate linker VMAs Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 11/14] powerpc/ppc64: add run script and unittests.cfg Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 12/14] mkstandalone: add support for powerpc Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 13/14] powerpc/ppc64: add RTAS support Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12 17:51   ` Thomas Huth
2016-02-12 17:51     ` Thomas Huth
2016-02-08 18:53 ` [kvm-unit-tests PATCH v2 14/14] powerpc/ppc64: HACK: make a fake debug-exit Andrew Jones
2016-02-08 18:53   ` Andrew Jones
2016-02-12 18:07   ` Thomas Huth
2016-02-12 18:07     ` Thomas Huth
2016-02-12 22:50     ` Paolo Bonzini
2016-02-12 22:50       ` Paolo Bonzini
2016-02-09 17:49 ` [kvm-unit-tests PATCH v2 00/14] ppc64: initial drop Andrew Jones
2016-02-09 17:49   ` Andrew Jones
2016-02-10 14:27 ` Paolo Bonzini
2016-02-10 14:27   ` Paolo Bonzini
2016-02-11 11:56   ` Andrew Jones
2016-02-11 11:56     ` Andrew Jones
2016-02-11 12:36     ` Paolo Bonzini
2016-02-11 12:36       ` Paolo Bonzini
2016-02-11 13:36 ` Laurent Vivier
2016-02-11 13:36   ` Laurent Vivier
2016-02-11 15:29   ` Andrew Jones
2016-02-11 15:29     ` Andrew Jones
2016-02-11 16:44     ` Laurent Vivier
2016-02-11 16:44       ` Laurent Vivier
2016-02-11 17:22       ` Andrew Jones
2016-02-11 17:22         ` Andrew Jones
2016-02-11 17:47         ` Laurent Vivier
2016-02-11 17:47           ` Laurent Vivier
2016-02-12 10:06           ` Andrew Jones
2016-02-12 10:06             ` Andrew Jones
2016-02-12 10:31             ` Laurent Vivier
2016-02-12 10:31               ` Laurent Vivier
2016-02-12 10:57               ` Andrew Jones
2016-02-12 10:57                 ` Andrew Jones
2016-02-12 13:44                 ` Andrew Jones
2016-02-12 13:44                   ` Andrew Jones
2016-02-14 22:43                   ` David Gibson
2016-02-14 22:43                     ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.