Skip to contentSkip to conversation

ppc64: initial drop

PATCH Superseded Andrew Jones 4 participants 40 messages Feb 13, 2016 – Feb 15, 2016

Subsystems (3)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover ppc64: initial drop

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.

Tested on TCG and a P8 kvm_pr machine. I'm looking forward to hearing more testing feedback from others. Maybe I should have added an RFT.

v3:
Paolo's comments:
- got rid of zero-sized files

Thomas' review comments:
- remove useless casts in needed cast adding patch
- got rid of build_romfs building (and committing a binary), just offset the rom binary by 256 bytes now
- added a better error message for a -smp N, N > NR_CPUS user error
- got rid of infinite loop with broken rtas-poweroff
- one r-b (wasn't sure the "looks good"'s counted, so didn't add more)

Laurent's testing led me to
- fix a problem on kvm_pr with broken sc1
- fix handling of memory regions, expect more than one
- and a fix to DT code so that works

Additionally:
- new patches
- cscope: ppc64 needs to look in lib/powerpc/asm too, and arm64 in lib/arm/asm
- handle memory regions better also for arm
- a misc trivial fix for arm...
- align toc to 256 bytes for later gcc

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

We still haven't addressed debug-exit. 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 now we keep the hack from v1, but simplified.

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

Andrew Jones (17):
arm/arm64: trivial: another assert fix
Makefile: cscope: also look in arch shared asm
lib: asm-generic: add missing casts
devicetree: fix dt_get_memory_params arm/arm64: setup improvements
lib: share arm-selftest utility functions
config: no need to mix arch makefiles powerpc/ppc64: start skeleton framework powerpc/ppc64: ppc-ify makefiles and linker script powerpc/ppc64: add a boot rom powerpc/ppc64: add hcall support and 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: make a fake debug-exit

 Makefile                                           |   8 +-
 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/arm/asm/setup.h                                |   9 ++
 lib/arm/io.c                                       |   3 +-
 lib/arm/setup.c                                    |  66 +++++++---
 lib/asm-generic/io.h                               |  12 +-
 lib/devicetree.c                                   |   8 +-
 lib/libcflat.h                                     |  11 +-
 lib/powerpc/.gitignore                             |   1 +
 lib/powerpc/asm/hcall.h                            |  43 +++++++
 lib/powerpc/asm/rtas.h                             |  26 ++++
 lib/powerpc/asm/setup.h                            |  36 ++++++
 lib/powerpc/hcall.c                                |  79 ++++++++++++
 lib/powerpc/io.c                                   |  37 ++++++
 lib/powerpc/rtas.c                                 | 139 +++++++++++++++++++++
 lib/powerpc/setup.c                                | 119 ++++++++++++++++++
 lib/ppc64/.gitignore                               |   1 +
 lib/ppc64/asm-offsets.c                            |  12 ++
 lib/ppc64/asm/asm-offsets.h                        |   1 +
 lib/ppc64/asm/hcall.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/spinlock.c                               |  11 ++
 lib/report.c                                       |  16 +++
 lib/util.c                                         |  18 +++
 lib/util.h                                         |  23 ++++
 powerpc/Makefile                                   |   1 +
 powerpc/Makefile.common                            |  71 +++++++++++
 powerpc/Makefile.ppc64                             |  20 +++
 powerpc/boot_rom.S                                 |   5 +
 powerpc/cstart64.S                                 |  83 ++++++++++++
 powerpc/flat.lds                                   |  44 +++++++
 powerpc/reloc64.c                                  |  55 ++++++++
 powerpc/run                                        |  55 ++++++++
 powerpc/selftest.c                                 |  64 ++++++++++
 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 +-
 51 files changed, 1124 insertions(+), 75 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/hcall.h
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/powerpc/hcall.c
 create mode 100644 lib/powerpc/io.c
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/powerpc/setup.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/hcall.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/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.S
 create mode 100644 powerpc/cstart64.S
 create mode 100644 powerpc/flat.lds
 create mode 100644 powerpc/reloc64.c
 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%)
Signature · 1 line
2.4.3
#1 lore raw

PATCH v3 1/17 arm/arm64: trivial: another assert fix

---
Unrelated to the powerpc initial drop, but found it while working on that, so just posting it now. Anyway, it's a trivial fix.

---
 lib/arm/io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/arm/io.c +2 -1
index a08d394e4aa1c..a111530f4802d 100644
@@ -50,7 +50,8 @@ static void uart0_init(void)
 		}
 
 	} else {
-		assert(dt_pbus_translate_node(ret, 0, &base) = 0);
+		ret = dt_pbus_translate_node(ret, 0, &base);
+		assert(ret = 0);
 	}
 
 	uart0_base = ioremap(base.addr, base.size);
Signature · 1 line
2.4.3
Reviewed-by on v3 1/17
#2 lore raw

Re: [kvm-unit-tests PATCH v3 01/17] arm/arm64: trivial: another assert fix

Quoted 1 line · Andrew Jones
Quoted 22 lines

---
Unrelated to the powerpc initial drop, but found it while working on that, so just posting it now. Anyway, it's a trivial fix.

---
 lib/arm/io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/arm/io.c +2 -1
index a08d394e4aa1c..a111530f4802d 100644
@@ -50,7 +50,8 @@ static void uart0_init(void)
 		}
 
 	} else {
-		assert(dt_pbus_translate_node(ret, 0, &base) == 0);
+		ret = dt_pbus_translate_node(ret, 0, &base);
+		assert(ret == 0);
 	}
 
 	uart0_base = ioremap(base.addr, base.size);
Signature · 4 lines
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
Reviewed-by on v3 1/17
#3 lore raw

Re: [kvm-unit-tests PATCH v3 01/17] arm/arm64: trivial: another assert fix

In reply to Andrew Jones
Quoted 14 lines · Andrew Jones

---
Unrelated to the powerpc initial drop, but found it while working on that, so just posting it now. Anyway, it's a trivial fix.

---
 lib/arm/io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/arm/io.c +0 -0
index a08d394e4aa1c..a111530f4802d 100644

lib/arm/io.c static void uart0_init(void) · line 57

Quoted 9 lines
lib/arm/io.c +2 -1
@@ -50,7 +50,8 @@ static void uart0_init(void)
 		}
 
 	} else {
-		assert(dt_pbus_translate_node(ret, 0, &base) = 0);
+		ret = dt_pbus_translate_node(ret, 0, &base);
+		assert(ret = 0);
 	}
 
 	uart0_base = ioremap(base.addr, base.size);
#4 lore raw

PATCH v3 2/17 Makefile: cscope: also look in arch shared asm

In reply to Andrew Jones

---
Not exactly related to the powerpc initial drop, but ppc64 will need it too.

---
 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Makefile +4 -2
index 0be2b6670daf6..fe5cc620d473b 100644
@@ -85,9 +85,11 @@ distclean: clean libfdt_clean
 	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
 	$(RM) -r tests
 
-cscope: common_dirs = lib lib/libfdt lib/linux lib/asm lib/asm-generic
+cscope: cscope_dirs = lib lib/libfdt lib/linux
+cscope: cscope_dirs += lib/$(ARCH)/asm lib/$(TEST_DIR)/asm lib/asm-generic
+cscope: cscope_dirs += $(TEST_DIR) lib/$(TEST_DIR) lib/$(ARCH)
 cscope:
 	$(RM) ./cscope.*
-	find -L $(TEST_DIR) lib/$(TEST_DIR) lib/$(ARCH) $(common_dirs) -maxdepth 1 \
+	find -L $(cscope_dirs) -maxdepth 1 \
 		-name '*.[chsS]' -print | sed 's,^\./,,' | sort -u > ./cscope.files
 	cscope -bk
Signature · 1 line
2.4.3
#5 lore raw

PATCH v3 3/17 lib: asm-generic: add missing casts

In reply to Andrew Jones
---
 lib/asm-generic/io.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
lib/asm-generic/io.h +6 -6
index a9939d3a5921f..931415a465b74 100644
@@ -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(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(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(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(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(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(x) : ((u64)x); __r; })
 #define cpu_to_be64 be64_to_cpu
 
 #ifndef rmb
Signature · 1 line
2.4.3
Reviewed-by on v3 3/17
#6 lore raw

Re: [kvm-unit-tests PATCH v3 03/17] lib: asm-generic: add missing casts

Quoted 1 line · Andrew Jones
Quoted 42 lines
---
 lib/asm-generic/io.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
lib/asm-generic/io.h +6 -6
index a9939d3a5921f..931415a465b74 100644
@@ -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(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(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(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(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(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(x) : ((u64)x); __r; })
 #define cpu_to_be64 be64_to_cpu
 
 #ifndef rmb
Signature · 4 lines
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
#7 lore raw

PATCH v3 4/17 devicetree: fix dt_get_memory_params

In reply to Andrew Jones

Index nr was overreaching with its indexing. It should only index the caller's regs array. We need a different index for the memory nodes' reg properties.

---
The next patch needs this fix.

---
 lib/devicetree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/devicetree.c +5 -3
index 36cb28610ff41..a5c7f7c69ddfd 100644
@@ -165,22 +165,24 @@ int dt_pbus_get_base_compatible(const char *compatible,
 int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs)
 {
 	const char *pn = "device_type", *pv = "memory";
-	int node, ret, pl = strlen(pv) + 1, nr = 0;
+	int node, ret, reg_idx, pl = strlen(pv) + 1, nr = 0;
 	struct dt_pbus_reg reg;
 
 	node = fdt_node_offset_by_prop_value(fdt, -1, pn, pv, pl);
 
 	while (node >= 0) {
 
+		reg_idx = 0;
+
 		while (nr < nr_regs) {
-			ret = dt_pbus_translate_node(node, nr, &reg);
+			ret = dt_pbus_translate_node(node, reg_idx, &reg);
 			if (ret = -FDT_ERR_NOTFOUND)
 				break;
 			if (ret < 0)
 				return ret;
 			regs[nr].addr = reg.addr;
 			regs[nr].size = reg.size;
-			++nr;
+			++nr, ++reg_idx;
 		}
 
 		node = fdt_node_offset_by_prop_value(fdt, node, pn, pv, pl);
Signature · 1 line
2.4.3
#8 lore raw

Re: [kvm-unit-tests PATCH v3 04/17] devicetree: fix dt_get_memory_params

Quoted 5 lines · Andrew Jones

Index nr was overreaching with its indexing. It should only index the caller's regs array. We need a different index for the memory nodes' reg properties.

I think I'm missing something, I don't see how reg_idx will ever take a different value from nr.

Quoted 39 lines

---
The next patch needs this fix.

---
 lib/devicetree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/devicetree.c +5 -3
index 36cb28610ff41..a5c7f7c69ddfd 100644
@@ -165,22 +165,24 @@ int dt_pbus_get_base_compatible(const char *compatible,
 int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs)
 {
 	const char *pn = "device_type", *pv = "memory";
-	int node, ret, pl = strlen(pv) + 1, nr = 0;
+	int node, ret, reg_idx, pl = strlen(pv) + 1, nr = 0;
 	struct dt_pbus_reg reg;
 
 	node = fdt_node_offset_by_prop_value(fdt, -1, pn, pv, pl);
 
 	while (node >= 0) {
 
+		reg_idx = 0;
+
 		while (nr < nr_regs) {
-			ret = dt_pbus_translate_node(node, nr, &reg);
+			ret = dt_pbus_translate_node(node, reg_idx, &reg);
 			if (ret == -FDT_ERR_NOTFOUND)
 				break;
 			if (ret < 0)
 				return ret;
 			regs[nr].addr = reg.addr;
 			regs[nr].size = reg.size;
-			++nr;
+			++nr, ++reg_idx;
 		}
 
 		node = fdt_node_offset_by_prop_value(fdt, node, pn, pv, pl);
Signature · 4 lines
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
Reviewed-by
#9 lore raw

Re: [kvm-unit-tests PATCH v3 04/17] devicetree: fix dt_get_memory_params

Quoted 9 lines · David Gibson
Quoted 5 lines · Andrew Jones

Index nr was overreaching with its indexing. It should only index the caller's regs array. We need a different index for the memory nodes' reg properties.

I think I'm missing something, I don't see how reg_idx will ever take a different value from nr.

There is one difference ...

Quoted 18 lines
Quoted 18 lines

---
The next patch needs this fix.

---
 lib/devicetree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/devicetree.c +1 -1
index 36cb28610ff41..a5c7f7c69ddfd 100644
@@ -165,22 +165,24 @@ int dt_pbus_get_base_compatible(const char *compatible,
 int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs)
 {
 	const char *pn = "device_type", *pv = "memory";
-	int node, ret, pl = strlen(pv) + 1, nr = 0;
+	int node, ret, reg_idx, pl = strlen(pv) + 1, nr = 0;
 	struct dt_pbus_reg reg;
 
Quoted 5 lines

lib/devicetree.c int dt_pbus_get_base_compatible(const char *compatible, · line 175

Quoted 5 lines
lib/devicetree.c +1 -0
 	node = fdt_node_offset_by_prop_value(fdt, -1, pn, pv, pl);
 
 	while (node >= 0) {
 
+		reg_idx = 0;

... here: reg_idx is reset to zero, but nr is not.

Quoted 13 lines
Quoted 13 lines
lib/devicetree.c +2 -2
 		while (nr < nr_regs) {
-			ret = dt_pbus_translate_node(node, nr, &reg);
+			ret = dt_pbus_translate_node(node, reg_idx, &reg);
 			if (ret == -FDT_ERR_NOTFOUND)
 				break;
 			if (ret < 0)
 				return ret;
 			regs[nr].addr = reg.addr;
 			regs[nr].size = reg.size;
-			++nr;
+			++nr, ++reg_idx;
 		}
 
Quoted 1 line

lib/devicetree.c int dt_pbus_get_base_compatible(const char *compatible, · line 188

Quoted 1 line
lib/devicetree.c +0 -0
 		node = fdt_node_offset_by_prop_value(fdt, node, pn, pv, pl);

Sounds reasonable to me.

#10 lore raw

PATCH v3 5/17 arm/arm64: setup improvements

In reply to Andrew Jones

Handle multiple memory regions being described in the DT. Also add a more informative error message for when a user does -smp N, N > NR_CPUS.

---
powerpc will adapt arm's setup to be used as it's own, and it needs these changes. There's no reason to only do them for power, so we do them in arm first, getting them ready to be adapted.

---
 lib/arm/asm/setup.h |  9 ++++++++
 lib/arm/setup.c     | 66 ++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 56 insertions(+), 19 deletions(-)
lib/arm/asm/setup.h +9 -0
index 02b668672fca4..cb8fdbd38dd5d 100644
@@ -6,6 +6,7 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
+#include <alloc.h>	/* phys_addr_t */
 #include <asm/page.h>
 #include <asm/pgtable-hwdef.h>
 
@@ -13,6 +14,14 @@
 extern u32 cpus[NR_CPUS];
 extern int nr_cpus;
 
+#define NR_MEM_REGIONS		8
+#define MR_F_PRIMARY		(1U << 0)
+struct mem_region {
+	phys_addr_t start;
+	phys_addr_t end;
+	unsigned int flags;
+};
+extern struct mem_region mem_regions[NR_MEM_REGIONS];
 extern phys_addr_t __phys_offset, __phys_end;
 
 #define PHYS_OFFSET		(__phys_offset)
lib/arm/setup.c +47 -19

83 lines not on this page · raw message

Signature · 1 line
2.4.3
#11 lore raw

PATCH v3 6/17 lib: share arm-selftest utility functions

In reply to Andrew Jones

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.

---
 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
arm/selftest.c +14 -31
index aad7eecd529ad..75dc91faab69a 100644
@@ -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)
+		report_abort("no test specified");
+
 	report_prefix_push(argv[0]);
 
 	if (strcmp(argv[0], "setup") = 0) {
config/config-arm-common.mak +1 -0
index 698555d6a676f..bd153cf6ea5ba 100644
@@ -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
lib/libcflat.h +6 -5
index 9747ccdbc9f1d..8411f6c5d92e3 100644
@@ -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]))
 
lib/report.c +16 -0
index 35e664108a921..62916c4ac3c8a 100644
@@ -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();
+}
lib/util.c new file +18 -0
new file mode 100644
index 0000000000000..69b18100c9722
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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;
+}
lib/util.h new file +23 -0
new file mode 100644
index 0000000000000..4c4b441322770
@@ -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 <[email protected]>
+ *
+ * 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 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
Signature · 1 line
2.4.3
#12 lore raw

PATCH v3 7/17 config: no need to mix arch makefiles

In reply to Andrew Jones

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.

---
 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%)
Makefile +1 -1
index fe5cc620d473b..ddba941858596 100644
@@ -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)
README +1 -2
index 457bd797362cf..f8f196d90bf10 100644
@@ -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
arm/Makefile new file +1 -0
new file mode 100644
index 0000000000000..369a38b2d1703
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
arm/Makefile.arm renamed from config/config-arm.mak +1 -1
similarity index 90%
rename from config/config-arm.mak
rename to arm/Makefile.arm
index ae6c2e7134883..946422872532d 100644
@@ -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
arm/Makefile.arm64 renamed from config/config-arm64.mak +1 -1
similarity index 89%
rename from config/config-arm64.mak
rename to arm/Makefile.arm64
index d61b703c8140e..0b0761c729c7c 100644
@@ -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
arm/Makefile.common renamed from config/config-arm-common.mak +1 -1
similarity index 98%
rename from config/config-arm-common.mak
rename to arm/Makefile.common
index bd153cf6ea5ba..dd3a0ca327d06 100644
@@ -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
scripts/asm-offsets.mak renamed from config/asm-offsets.mak +0 -0
similarity index 100%
rename from config/asm-offsets.mak
rename to scripts/asm-offsets.mak
x86/Makefile new file +1 -0
new file mode 100644
index 0000000000000..369a38b2d1703
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
x86/Makefile.common renamed from config/config-x86-common.mak +0 -0
similarity index 100%
rename from config/config-x86-common.mak
rename to x86/Makefile.common
x86/Makefile.i386 renamed from config/config-i386.mak +1 -1
similarity index 91%
rename from config/config-i386.mak
rename to x86/Makefile.i386
index e353387551585..8a4c45c457476 100644
@@ -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
x86/Makefile.x86_64 renamed from config/config-x86_64.mak +1 -1
similarity index 93%
rename from config/config-x86_64.mak
rename to x86/Makefile.x86_64
index d190be82e0cf2..6b7ccfba550b6 100644
@@ -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
Signature · 1 line
2.4.3
#13 lore raw

PATCH v3 8/17 powerpc/ppc64: start skeleton framework

In reply to Andrew Jones

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.

---
 configure                   |  2 ++
 lib/powerpc/.gitignore      |  1 +
 lib/powerpc/io.c            | 20 +++++++++++++
 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/spinlock.c        | 11 +++++++
 powerpc/Makefile            |  1 +
 powerpc/Makefile.common     | 73 +++++++++++++++++++++++++++++++++++++++++++++
 powerpc/Makefile.ppc64      | 20 +++++++++++++
 powerpc/cstart64.S          | 20 +++++++++++++
 powerpc/flat.lds            | 27 +++++++++++++++++
 powerpc/selftest.c          |  7 +++++
 16 files changed, 213 insertions(+)
 create mode 100644 lib/powerpc/.gitignore
 create mode 100644 lib/powerpc/io.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/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
configure +2 -0
index 078b70ce096a6..b367224093369 100755
@@ -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
lib/powerpc/.gitignore new file +1 -0
new file mode 100644
index 0000000000000..84872bf197c67
@@ -0,0 +1 @@
+asm-offsets.[hs]
lib/powerpc/io.c new file +20 -0
new file mode 100644
index 0000000000000..0af45742fc900
@@ -0,0 +1,20 @@
+/*
+ * Each architecture must implement puts() and exit().
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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)
+{
+}
lib/ppc64/.gitignore new file +1 -0
new file mode 100644
index 0000000000000..84872bf197c67
@@ -0,0 +1 @@
+asm-offsets.[hs]
lib/ppc64/asm-offsets.c new file +12 -0
new file mode 100644
index 0000000000000..2d38a716976f2
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <kbuild.h>
+
+int main(void)
+{
+	return 0;
+}
lib/ppc64/asm/asm-offsets.h new file +1 -0
new file mode 100644
index 0000000000000..d370ee36a182b
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
lib/ppc64/asm/io.h new file +5 -0
new file mode 100644
index 0000000000000..c0801d4762ba6
@@ -0,0 +1,5 @@
+#ifndef _ASMPPC64_IO_H_
+#define _ASMPPC64_IO_H_
+#define __cpu_is_be() (1)
+#include <asm-generic/io.h>
+#endif
lib/ppc64/asm/page.h new file +1 -0
new file mode 100644
index 0000000000000..1a8b62711f288
@@ -0,0 +1 @@
+#include <asm-generic/page.h>
lib/ppc64/asm/spinlock.h new file +11 -0
new file mode 100644
index 0000000000000..002cdb194b1db
@@ -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_ */
lib/ppc64/spinlock.c new file +11 -0
new file mode 100644
index 0000000000000..522f8d047c970
@@ -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;
+}
powerpc/Makefile new file +1 -0
new file mode 100644
index 0000000000000..369a38b2d1703
@@ -0,0 +1 @@
+include $(TEST_DIR)/Makefile.$(ARCH)
powerpc/Makefile.common new file +73 -0

73 lines not on this page · raw message

powerpc/Makefile.ppc64 new file +19 -0
new file mode 100644
index 0000000000000..0b0761c729c7c
@@ -0,0 +1,20 @@
+#
+# arm64 makefile
+#
+# Authors: Andrew Jones <[email protected]>
+#
+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
powerpc/cstart64.S new file +20 -0
new file mode 100644
index 0000000000000..f90828dee1c19
@@ -0,0 +1,20 @@
+/*
+ * Entry point and assembler functions for ppc64 tests.
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#define __ASSEMBLY__
+
+.section .init
+
+.globl start
+start:
+	b	halt
+
+.text
+
+.globl halt
+halt:
+1:	b	1b
powerpc/flat.lds new file +27 -0
new file mode 100644
index 0000000000000..efdf5d7109ffb
@@ -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)
powerpc/selftest.c new file +7 -0
new file mode 100644
index 0000000000000..2f2a5215dd55c
@@ -0,0 +1,7 @@
+#include <libcflat.h>
+
+int main(void)
+{
+	printf("hello world\n");
+	return 0;
+}
Signature · 1 line
2.4.3
Reviewed-by on v3 8/17
#14 lore raw

Re: [kvm-unit-tests PATCH v3 08/17] powerpc/ppc64: start skeleton framework

Quoted 31 lines · Andrew Jones

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.

---
 configure                   |  2 ++
 lib/powerpc/.gitignore      |  1 +
 lib/powerpc/io.c            | 20 +++++++++++++
 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/spinlock.c        | 11 +++++++
 powerpc/Makefile            |  1 +
 powerpc/Makefile.common     | 73 +++++++++++++++++++++++++++++++++++++++++++++
 powerpc/Makefile.ppc64      | 20 +++++++++++++
 powerpc/cstart64.S          | 20 +++++++++++++
 powerpc/flat.lds            | 27 +++++++++++++++++
 powerpc/selftest.c          |  7 +++++
 16 files changed, 213 insertions(+)
 create mode 100644 lib/powerpc/.gitignore
 create mode 100644 lib/powerpc/io.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
Quoted 8 lines
 create mode 100644 lib/ppc64/asm/spinlock.h
 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
#15 lore raw

PATCH v3 9/17 powerpc/ppc64: ppc-ify makefiles and linker script

In reply to Andrew Jones
---
 powerpc/Makefile.common | 40 ++++++++++------------------------------
 powerpc/Makefile.ppc64  | 15 +++++++--------
 powerpc/flat.lds        | 14 ++++++++++----
 3 files changed, 27 insertions(+), 42 deletions(-)
powerpc/Makefile.common +10 -30
index dd3a0ca327d06..13b828ab171d6 100644
@@ -1,17 +1,15 @@
 #
-# arm common makefile
+# powerpc common makefile
 #
 # Authors: Andrew Jones <[email protected]>
 #
 
 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,21 @@ 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
 
 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 +51,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
powerpc/Makefile.ppc64 +7 -8
index 0b0761c729c7c..95bf6772d65ed 100644
@@ -1,20 +1,19 @@
 #
-# arm64 makefile
+# ppc64 makefile
 #
 # Authors: Andrew Jones <[email protected]>
 #
 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/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
powerpc/flat.lds +10 -4
index efdf5d7109ffb..84087057c0ce2 100644
@@ -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(256);
+    /*
+     * 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 = .;
 }
 
Signature · 1 line
2.4.3
Reviewed-by on v3 9/17
#16 lore raw

Re: [kvm-unit-tests PATCH v3 09/17] powerpc/ppc64: ppc-ify makefiles and linker script

Quoted 6 lines · Andrew Jones
---
 powerpc/Makefile.common | 40 ++++++++++------------------------------
 powerpc/Makefile.ppc64  | 15 +++++++--------
 powerpc/flat.lds        | 14 ++++++++++----
 3 files changed, 27 insertions(+), 42 deletions(-)
#17 lore raw

PATCH v3 10/17 powerpc/ppc64: add a boot rom

In reply to Andrew Jones

Make a one line replacement for SLOF. This bootloader just jumps to 0x400000, because we know the kernel will be there.

---
 powerpc/Makefile.common | 11 +++++++++--
 powerpc/boot_rom.S      |  5 +++++
 2 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 powerpc/boot_rom.S
powerpc/Makefile.common +9 -2
index 13b828ab171d6..0c3eaba0d3aab 100644
@@ -11,7 +11,7 @@ endif
 tests-common = \
 	$(TEST_DIR)/selftest.elf
 
-all: test_cases
+all: $(TEST_DIR)/boot_rom.bin test_cases
 
 ##################################################################
 phys_base = $(LOADADDR)
@@ -40,8 +40,15 @@ FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc)
 		-Wl,-T,powerpc/flat.lds,--build-id=none,-Ttext=$(start_addr) \
 		$(filter %.o, $^) $(FLATLIBS)
 
+$(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
+	dd if=/dev/zero of=$@ bs%6 count=1
+	$(OBJCOPY) -O binary $^ >(cat - >>$@)
+
+$(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o
+	$(LD) -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
+
 powerpc_clean: libfdt_clean asm_offsets_clean
-	$(RM) $(TEST_DIR)/*.{o,elf} \
+	$(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/boot_rom.bin \
 	      $(TEST_DIR)/.*.d lib/powerpc/.*.d
 
 ##################################################################
powerpc/boot_rom.S new file +5 -0
new file mode 100644
index 0000000000000..ae2c08ddce3c1
@@ -0,0 +1,5 @@
+#define SPAPR_KERNEL_LOAD_ADDR 0x400000
+.text
+.globl start
+start:
+	b	SPAPR_KERNEL_LOAD_ADDR - 0x100
Signature · 1 line
2.4.3
Reviewed-by on v3 10/17
#18 lore raw

Re: [kvm-unit-tests PATCH v3 10/17] powerpc/ppc64: add a boot rom

Quoted 9 lines · Andrew Jones

Make a one line replacement for SLOF. This bootloader just jumps to 0x400000, because we know the kernel will be there.

---
 powerpc/Makefile.common | 11 +++++++++--
 powerpc/boot_rom.S      |  5 +++++
 2 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 powerpc/boot_rom.S
#19 lore raw

PATCH v3 11/17 powerpc/ppc64: add hcall support and putchar

In reply to Andrew Jones

Add broken sc1 detection and patching and an hcall for putchar, to use 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.)

---
 lib/powerpc/asm/hcall.h | 43 +++++++++++++++++++++++++++
 lib/powerpc/hcall.c     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/powerpc/io.c        | 15 ++++++++--
 lib/ppc64/asm/hcall.h   |  1 +
 powerpc/Makefile.common |  2 ++
 powerpc/cstart64.S      | 21 +++++++++++++
 6 files changed, 159 insertions(+), 2 deletions(-)
 create mode 100644 lib/powerpc/asm/hcall.h
 create mode 100644 lib/powerpc/hcall.c
 create mode 100644 lib/ppc64/asm/hcall.h
lib/powerpc/asm/hcall.h new file +43 -0
new file mode 100644
index 0000000000000..75eac456c49eb
@@ -0,0 +1,43 @@
+#ifndef _ASMPOWERPC_HCALL_H_
+#define _ASMPOWERPC_HCALL_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+#define SC1			0x44000022
+#define SC1_REPLACEMENT		0x7c000268
+
+#define H_SUCCESS		0
+#define H_HARDWARE		-1
+
+#define H_SET_DABR		0x28
+#define H_PUT_TERM_CHAR		0x58
+
+#ifndef __ASSEMBLY__
+#include <libcflat.h>
+
+/*
+ * hcall_have_broken_sc1 checks if we're on a host with a broken sc1.
+ * Returns true if we are.
+ */
+extern bool hcall_have_broken_sc1(void);
+
+/*
+ * hcall_patch_broken_sc1 patches hcall's sc1 instruction, if needed,
+ * allowing all hypercalls built on it to work.
+ */
+extern void hcall_patch_broken_sc1(void);
+
+/*
+ * hcall is the hypercall wrapper function. unittests may do what
+ * they like, but the framework should make all hypercalls through
+ * here to ensure they use a working sc1 instruction, and properly
+ * handle clobbered registers. @nr is the hypercall number.
+ */
+extern unsigned long
+hcall(unsigned long nr, unsigned long *in, unsigned long *out);
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _ASMPOWERPC_HCALL_H_ */
lib/powerpc/hcall.c new file +79 -0

79 lines not on this page · raw message

lib/powerpc/io.c +13 -2
index 0af45742fc900..5e1fa8dd96ab6 100644
@@ -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);
 }
lib/ppc64/asm/hcall.h new file +1 -0
new file mode 100644
index 0000000000000..daabaca510cd4
@@ -0,0 +1 @@
+#include "../../powerpc/asm/hcall.h"
powerpc/Makefile.common +2 -0
index 0c3eaba0d3aab..89610b525f0c1 100644
@@ -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
@@ -29,6 +30,7 @@ cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/powerpc/io.o
+cflatobjs += lib/powerpc/hcall.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
powerpc/cstart64.S +21 -0
index f90828dee1c19..623fd693b02d1 100644
@@ -7,13 +7,34 @@
  */
 #define __ASSEMBLY__
 
+#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	hcall_patch_broken_sc1
+	bl	main
+	bl	exit
 	b	halt
 
 .text
+.align 3
+
+.globl sc1
+sc1:
+	sc	1
+	blr
 
 .globl halt
 halt:
Signature · 1 line
2.4.3
#20 lore raw

Re: [kvm-unit-tests PATCH v3 11/17] powerpc/ppc64: add hcall support and putchar

Quoted 101 lines · Andrew Jones

Add broken sc1 detection and patching and an hcall for putchar, to use 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.)

---
 lib/powerpc/asm/hcall.h | 43 +++++++++++++++++++++++++++
 lib/powerpc/hcall.c     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/powerpc/io.c        | 15 ++++++++--
 lib/ppc64/asm/hcall.h   |  1 +
 powerpc/Makefile.common |  2 ++
 powerpc/cstart64.S      | 21 +++++++++++++
 6 files changed, 159 insertions(+), 2 deletions(-)
 create mode 100644 lib/powerpc/asm/hcall.h
 create mode 100644 lib/powerpc/hcall.c
 create mode 100644 lib/ppc64/asm/hcall.h
lib/powerpc/asm/hcall.h new file +43 -0
new file mode 100644
index 0000000000000..75eac456c49eb
@@ -0,0 +1,43 @@
+#ifndef _ASMPOWERPC_HCALL_H_
+#define _ASMPOWERPC_HCALL_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+#define SC1			0x44000022
+#define SC1_REPLACEMENT		0x7c000268
+
+#define H_SUCCESS		0
+#define H_HARDWARE		-1
+
+#define H_SET_DABR		0x28
+#define H_PUT_TERM_CHAR		0x58
+
+#ifndef __ASSEMBLY__
+#include <libcflat.h>
+
+/*
+ * hcall_have_broken_sc1 checks if we're on a host with a broken sc1.
+ * Returns true if we are.
+ */
+extern bool hcall_have_broken_sc1(void);
+
+/*
+ * hcall_patch_broken_sc1 patches hcall's sc1 instruction, if needed,
+ * allowing all hypercalls built on it to work.
+ */
+extern void hcall_patch_broken_sc1(void);
+
+/*
+ * hcall is the hypercall wrapper function. unittests may do what
+ * they like, but the framework should make all hypercalls through
+ * here to ensure they use a working sc1 instruction, and properly
+ * handle clobbered registers. @nr is the hypercall number.
+ */
+extern unsigned long
+hcall(unsigned long nr, unsigned long *in, unsigned long *out);
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _ASMPOWERPC_HCALL_H_ */
lib/powerpc/hcall.c new file +19 -0
new file mode 100644
index 0000000000000..4c42b18ef9901
@@ -0,0 +1,79 @@
+/*
+ * Hypercall helpers
+ *
+ * broken_sc1 probing/patching inspired by SLOF, see
+ *   SLOF:lib/libhvcall/brokensc1.c
+ *
+ * hcall() implementation inspired by Linux's epapr_hypercall, see
+ *   arch/powerpc/include/asm/epapr_hcalls.h
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <asm/hcall.h>
+
+static u32 sc1[];
+
+bool hcall_have_broken_sc1(void)

lib/powerpc/hcall.c line 29

Quoted 10 lines
lib/powerpc/hcall.c new file +10 -0
+{
+	register unsigned long r3 asm("r3") = H_SET_DABR;
+	register unsigned long r4 asm("r4") = 0;
+
+	asm volatile("sc 1"
+	: "=r" (r3)
+	: "r" (r3), "r" (r4)
+	: "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
+
+	return !(r3 == H_SUCCESS || r3 == (unsigned long)H_HARDWARE);

It might be safer to explicitly check for H_PRIVILEGE, which is what you'll get in the case of a broken sc 1 under nested virtualization. That way you won't get false positives if H_SET_DABR ever gets any new error codes it can return.

Quoted 149 lines
lib/powerpc/hcall.c new file +50 -0
+}
+
+void hcall_patch_broken_sc1(void)
+{
+	if (!hcall_have_broken_sc1())
+		return;
+	sc1[0] = SC1_REPLACEMENT;
+}
+
+unsigned long hcall(unsigned long nr, unsigned long *in, unsigned long *out)
+{
+	register unsigned long r3 asm("r3") = nr;
+	register unsigned long r4 asm("r4") = in[0];
+	register unsigned long r5 asm("r5") = in[1];
+	register unsigned long r6 asm("r6") = in[2];
+	register unsigned long r7 asm("r7") = in[3];
+	register unsigned long r8 asm("r8") = in[4];
+	register unsigned long r9 asm("r9") = in[5];
+	register unsigned long r10 asm("r10") = in[6];
+	register unsigned long r11 asm("r11") = in[7];
+
+	asm volatile("bl sc1"
+		: "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6), "=r"(r7),
+		  "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11)
+		: "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7),
+		  "r"(r8), "r"(r9), "r"(r10), "r"(r11)
+		: "r12", "memory", "lr");
+
+	out[0] = r4;
+	out[1] = r5;
+	out[2] = r6;
+	out[3] = r7;
+	out[4] = r8;
+	out[5] = r9;
+	out[6] = r10;
+	out[7] = r11;
+
+	return r3;
+}
+
+void putchar(int c)
+{
+	unsigned long in[8], out[8];
+
+	in[0] = 0; /* default vty */
+	in[1] = 1; /* just 1 byte */
+	in[2] = (unsigned long)c << 56;
+
+	hcall(H_PUT_TERM_CHAR, in, out);
+}
lib/powerpc/io.c +13 -2
index 0af45742fc900..5e1fa8dd96ab6 100644
@@ -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);
 }
lib/ppc64/asm/hcall.h new file +1 -0
new file mode 100644
index 0000000000000..daabaca510cd4
@@ -0,0 +1 @@
+#include "../../powerpc/asm/hcall.h"
powerpc/Makefile.common +2 -0
index 0c3eaba0d3aab..89610b525f0c1 100644
@@ -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
@@ -29,6 +30,7 @@ cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/powerpc/io.o
+cflatobjs += lib/powerpc/hcall.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
powerpc/cstart64.S +21 -0
index f90828dee1c19..623fd693b02d1 100644
@@ -7,13 +7,34 @@
  */
 #define __ASSEMBLY__
 
+#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	hcall_patch_broken_sc1
+	bl	main
+	bl	exit
 	b	halt
 
 .text
+.align 3
+
+.globl sc1
+sc1:
+	sc	1
+	blr
 
 .globl halt
 halt:
Signature · 4 lines
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
#21 lore raw

Re: [kvm-unit-tests PATCH v3 11/17] powerpc/ppc64: add hcall support and putchar

Quoted 109 lines · David Gibson
Quoted 108 lines · Andrew Jones

Add broken sc1 detection and patching and an hcall for putchar, to use 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.)

---
 lib/powerpc/asm/hcall.h | 43 +++++++++++++++++++++++++++
 lib/powerpc/hcall.c     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/powerpc/io.c        | 15 ++++++++--
 lib/ppc64/asm/hcall.h   |  1 +
 powerpc/Makefile.common |  2 ++
 powerpc/cstart64.S      | 21 +++++++++++++
 6 files changed, 159 insertions(+), 2 deletions(-)
 create mode 100644 lib/powerpc/asm/hcall.h
 create mode 100644 lib/powerpc/hcall.c
 create mode 100644 lib/ppc64/asm/hcall.h
lib/powerpc/asm/hcall.h new file +43 -0
new file mode 100644
index 0000000000000..75eac456c49eb
@@ -0,0 +1,43 @@
+#ifndef _ASMPOWERPC_HCALL_H_
+#define _ASMPOWERPC_HCALL_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+#define SC1			0x44000022
+#define SC1_REPLACEMENT		0x7c000268
+
+#define H_SUCCESS		0
+#define H_HARDWARE		-1
+
+#define H_SET_DABR		0x28
+#define H_PUT_TERM_CHAR		0x58
+
+#ifndef __ASSEMBLY__
+#include <libcflat.h>
+
+/*
+ * hcall_have_broken_sc1 checks if we're on a host with a broken sc1.
+ * Returns true if we are.
+ */
+extern bool hcall_have_broken_sc1(void);
+
+/*
+ * hcall_patch_broken_sc1 patches hcall's sc1 instruction, if needed,
+ * allowing all hypercalls built on it to work.
+ */
+extern void hcall_patch_broken_sc1(void);
+
+/*
+ * hcall is the hypercall wrapper function. unittests may do what
+ * they like, but the framework should make all hypercalls through
+ * here to ensure they use a working sc1 instruction, and properly
+ * handle clobbered registers. @nr is the hypercall number.
+ */
+extern unsigned long
+hcall(unsigned long nr, unsigned long *in, unsigned long *out);
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _ASMPOWERPC_HCALL_H_ */
lib/powerpc/hcall.c new file +26 -0
new file mode 100644
index 0000000000000..4c42b18ef9901
@@ -0,0 +1,79 @@
+/*
+ * Hypercall helpers
+ *
+ * broken_sc1 probing/patching inspired by SLOF, see
+ *   SLOF:lib/libhvcall/brokensc1.c
+ *
+ * hcall() implementation inspired by Linux's epapr_hypercall, see
+ *   arch/powerpc/include/asm/epapr_hcalls.h
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <asm/hcall.h>
+
+static u32 sc1[];
+
+bool hcall_have_broken_sc1(void)
+{
+	register unsigned long r3 asm("r3") = H_SET_DABR;
+	register unsigned long r4 asm("r4") = 0;
+
+	asm volatile("sc 1"
+	: "=r" (r3)
+	: "r" (r3), "r" (r4)
Quoted 8 lines

lib/powerpc/hcall.c

Quoted 3 lines
lib/powerpc/hcall.c new file +3 -0
+	: "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
+
+	return !(r3 == H_SUCCESS || r3 == (unsigned long)H_HARDWARE);

It might be safer to explicitly check for H_PRIVILEGE, which is what you'll get in the case of a broken sc 1 under nested virtualization. That way you won't get false positives if H_SET_DABR ever gets any new error codes it can return.

Right - actually, H_SET_DABR already might return H_RESERVED_DABR now if the host does not support the DABRX register.

Thomas

#22 lore raw

Re: [kvm-unit-tests PATCH v3 11/17] powerpc/ppc64: add hcall support and putchar

In reply to David Gibson
Quoted 17 lines · David Gibson

lib/powerpc/hcall.c line 29

Quoted 11 lines · Andrew Jones
lib/powerpc/hcall.c new file +11 -0
+bool hcall_have_broken_sc1(void)
+{
+	register unsigned long r3 asm("r3") = H_SET_DABR;
+	register unsigned long r4 asm("r4") = 0;
+
+	asm volatile("sc 1"
+	: "=r" (r3)
+	: "r" (r3), "r" (r4)
+	: "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
+
+	return !(r3 = H_SUCCESS || r3 = (unsigned long)H_HARDWARE);

It might be safer to explicitly check for H_PRIVILEGE, which is what you'll get in the case of a broken sc 1 under nested virtualization. That way you won't get false positives if H_SET_DABR ever gets any new error codes it can return.

Will do. Thanks. Should we consider a SLOF patch too? (As I stole this condition from there, see check_broken_sc1 in lib/libhvcall/brokensc1.c)

Thanks,
drew

#23 lore raw

Re: [kvm-unit-tests PATCH v3 11/17] powerpc/ppc64: add hcall support and putchar

Quoted 19 lines · Andrew Jones
Quoted 17 lines · David Gibson

lib/powerpc/hcall.c line 29

Quoted 11 lines · Andrew Jones
lib/powerpc/hcall.c new file +11 -0
+bool hcall_have_broken_sc1(void)
+{
+	register unsigned long r3 asm("r3") = H_SET_DABR;
+	register unsigned long r4 asm("r4") = 0;
+
+	asm volatile("sc 1"
+	: "=r" (r3)
+	: "r" (r3), "r" (r4)
+	: "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
+
+	return !(r3 = H_SUCCESS || r3 = (unsigned long)H_HARDWARE);

It might be safer to explicitly check for H_PRIVILEGE, which is what you'll get in the case of a broken sc 1 under nested virtualization. That way you won't get false positives if H_SET_DABR ever gets any new error codes it can return.

Quoted 2 lines

Will do. Thanks. Should we consider a SLOF patch too? (As I stole this condition from there, see check_broken_sc1 in lib/libhvcall/brokensc1.c)

Yes, I think it should be fixed there, too.

Thomas

#24 lore raw

PATCH v3 12/17 powerpc/ppc64: adapt arm's setup

In reply to Andrew Jones

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.

---
 lib/powerpc/asm/setup.h |  36 +++++++++++++++
 lib/powerpc/setup.c     | 119 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/setup.h   |   1 +
 powerpc/Makefile.common |   1 +
 powerpc/cstart64.S      |  16 +++++++
 powerpc/selftest.c      |  63 +++++++++++++++++++++++--
 6 files changed, 233 insertions(+), 3 deletions(-)
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/powerpc/setup.c
 create mode 100644 lib/ppc64/asm/setup.h
lib/powerpc/asm/setup.h new file +36 -0
new file mode 100644
index 0000000000000..0b9f04b4b7289
@@ -0,0 +1,36 @@
+#ifndef _ASMPOWERPC_SETUP_H_
+#define _ASMPOWERPC_SETUP_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <alloc.h>	/* phys_addr_t */
+
+#define NR_CPUS			8	/* arbitrarily set for now */
+extern u32 cpus[NR_CPUS];
+extern int nr_cpus;
+
+#define NR_MEM_REGIONS		8
+#define MR_F_PRIMARY		(1U << 0)
+struct mem_region {
+	phys_addr_t start;
+	phys_addr_t end;
+	unsigned int flags;
+};
+extern struct mem_region mem_regions[NR_MEM_REGIONS];
+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_ */
lib/powerpc/setup.c new file +119 -0

119 lines not on this page · raw message

lib/ppc64/asm/setup.h new file +1 -0
new file mode 100644
index 0000000000000..20192985928a4
@@ -0,0 +1 @@
+#include "../../powerpc/asm/setup.h"
powerpc/Makefile.common +1 -0
index 89610b525f0c1..de4d1ef3ac816 100644
@@ -31,6 +31,7 @@ cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/powerpc/io.o
 cflatobjs += lib/powerpc/hcall.o
+cflatobjs += lib/powerpc/setup.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
powerpc/cstart64.S +16 -0
index 623fd693b02d1..6d47eb59bb53e 100644
@@ -19,11 +19,27 @@
 
 .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)
+
+	/* save DTB pointer */
+	std	r3, 56(r1)
+
 	bl	hcall_patch_broken_sc1
+
+	/* complete setup */
+	ld	r3, 56(r1)
+	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
powerpc/selftest.c +60 -3

67 lines not on this page · raw message

Signature · 1 line
2.4.3
Reviewed-by on v3 12/17
#25 lore raw

Re: [kvm-unit-tests PATCH v3 12/17] powerpc/ppc64: adapt arm's setup

Quoted 5 lines · Andrew Jones

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.

Quoted 11 lines
---
 lib/powerpc/asm/setup.h |  36 +++++++++++++++
 lib/powerpc/setup.c     | 119 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/setup.h   |   1 +
 powerpc/Makefile.common |   1 +
 powerpc/cstart64.S      |  16 +++++++
 powerpc/selftest.c      |  63 +++++++++++++++++++++++--
 6 files changed, 233 insertions(+), 3 deletions(-)
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/powerpc/setup.c
 create mode 100644 lib/ppc64/asm/setup.h

Looks good to me.

#26 lore raw

PATCH v3 13/17 powerpc/ppc64: relocate linker VMAs

In reply to Andrew Jones

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.

---
 configure               |  2 ++
 powerpc/Makefile.common | 11 ++++++++--
 powerpc/Makefile.ppc64  |  1 +
 powerpc/cstart64.S      | 34 ++++++++++++++++++++++++++----
 powerpc/flat.lds        | 13 +++++++++++-
 powerpc/reloc64.c       | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 109 insertions(+), 7 deletions(-)
 create mode 100644 powerpc/reloc64.c
configure +2 -0
index b367224093369..b2ad199da7873 100755
@@ -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
powerpc/Makefile.common +9 -2
index de4d1ef3ac816..9654bce1752eb 100644
@@ -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
@@ -37,11 +38,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
 
 $(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
 	dd if=/dev/zero of=$@ bs%6 count=1
@@ -60,4 +67,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
powerpc/Makefile.ppc64 +1 -0
index 95bf6772d65ed..e965627991916 100644
@@ -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/spinlock.o
 
 # ppc64 specific tests
powerpc/cstart64.S +30 -4
index 6d47eb59bb53e..d1a5531eb1c44 100644
@@ -24,12 +24,33 @@
  */
 .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
+
 	bl	hcall_patch_broken_sc1
 
 	/* complete setup */
@@ -37,13 +58,18 @@ start:
 	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
 
powerpc/flat.lds +12 -1
index 84087057c0ce2..53221e8b4211c 100644
@@ -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(256);
powerpc/reloc64.c new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.4.3
#27 lore raw

PATCH v3 14/17 powerpc/ppc64: add run script and unittests.cfg

In reply to Andrew Jones

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.)

---
 powerpc/run           | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc/unittests.cfg | 30 +++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100755 powerpc/run
 create mode 100644 powerpc/unittests.cfg
powerpc/run new file +52 -0
new file mode 100755
index 0000000000000..47aecb7600832
@@ -0,0 +1,52 @@
+#!/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
+
+M='-machine pseries'
+M+=",accel=$ACCEL"
+command="$qemu $M -bios powerpc/boot_rom.bin"
+command+=" -display none -serial stdio -kernel"
+echo $command "$@"
+
+$command "$@"
+ret=$?
+echo Return value from qemu: $ret
+exit $ret
powerpc/unittests.cfg new file +30 -0
new file mode 100644
index 0000000000000..60f9be80e8abf
@@ -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
Signature · 1 line
2.4.3
Reviewed-by on v3 14/17
#28 lore raw

Re: [kvm-unit-tests PATCH v3 14/17] powerpc/ppc64: add run script and unittests.cfg

Quoted 8 lines · Andrew Jones

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.)

Quoted 7 lines
---
 powerpc/run           | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc/unittests.cfg | 30 +++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100755 powerpc/run
 create mode 100644 powerpc/unittests.cfg
#29 lore raw

PATCH v3 15/17 mkstandalone: add support for powerpc

In reply to Andrew Jones

PowerPC needs firmware.

---
 configure               | 2 ++
 powerpc/run             | 2 +-
 scripts/mkstandalone.sh | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)
configure +2 -0
index b2ad199da7873..7d5702e28d627 100755
@@ -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
powerpc/run +1 -1
index 47aecb7600832..c5108100fc5e0 100755
@@ -42,7 +42,7 @@ fi
 
 M='-machine pseries'
 M+=",accel=$ACCEL"
-command="$qemu $M -bios powerpc/boot_rom.bin"
+command="$qemu $M -bios $FIRMWARE"
 command+=" -display none -serial stdio -kernel"
 echo $command "$@"
 
scripts/mkstandalone.sh +5 -0
index b0f1e7c098afb..1788a8ef4e92a 100755
@@ -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"
Signature · 1 line
2.4.3
#30 lore raw

PATCH v3 16/17 powerpc/ppc64: add RTAS support

In reply to Andrew Jones

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

---
 lib/powerpc/asm/rtas.h  |  26 +++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 169 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h
lib/powerpc/asm/rtas.h new file +26 -0
new file mode 100644
index 0000000000000..522225bcb6de3
@@ -0,0 +1,26 @@
+#ifndef _ASMPOWERPC_RTAS_H_
+#define _ASMPOWERPC_RTAS_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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_ */
lib/powerpc/io.c +2 -0
index 5e1fa8dd96ab6..e57a28c583eb0 100644
@@ -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)
lib/powerpc/rtas.c new file +139 -0

139 lines not on this page · raw message

lib/ppc64/asm/rtas.h new file +1 -0
new file mode 100644
index 0000000000000..fe77f635cd860
@@ -0,0 +1 @@
+#include "../../powerpc/asm/rtas.h"
powerpc/Makefile.common +1 -0
index 9654bce1752eb..3a03ab6dfc3e9 100644
@@ -33,6 +33,7 @@ cflatobjs += lib/devicetree.o
 cflatobjs += lib/powerpc/io.o
 cflatobjs += lib/powerpc/hcall.o
 cflatobjs += lib/powerpc/setup.o
+cflatobjs += lib/powerpc/rtas.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
Signature · 1 line
2.4.3
#31 lore raw

Re: [kvm-unit-tests PATCH v3 16/17] powerpc/ppc64: add RTAS support

Quoted 140 lines · Andrew Jones

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

---
 lib/powerpc/asm/rtas.h  |  26 +++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 169 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h
lib/powerpc/asm/rtas.h new file +26 -0
new file mode 100644
index 0000000000000..522225bcb6de3
@@ -0,0 +1,26 @@
+#ifndef _ASMPOWERPC_RTAS_H_
+#define _ASMPOWERPC_RTAS_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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_ */
lib/powerpc/io.c +2 -0
index 5e1fa8dd96ab6..e57a28c583eb0 100644
@@ -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)
lib/powerpc/rtas.c new file +67 -0
new file mode 100644
index 0000000000000..b6ae7391181f9
@@ -0,0 +1,139 @@
+/*
+ * powerpc RTAS
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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/hcall.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;
+	int node = rtas_node(), len;
+	unsigned long entry;
+	u32 *data;
+
+	if (!dt_available()) {
+		printf("%s: No device tree!\n", __func__);
+		abort();
+	}
+
+	prop = fdt_get_property(dt_fdt(), 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 (hcall_have_broken_sc1()) {
+		u32 *insn = (u32 *)entry;
+		int size, i;
+
+		prop = fdt_get_property(dt_fdt(), node,

lib/powerpc/rtas.c line 77

Quoted 10 lines
lib/powerpc/rtas.c new file +10 -0
+					"rtas-size", &len);
+		if (!prop) {
+			printf("%s: /rtas/rtas-size: %s\n",
+					__func__, fdt_strerror(len));
+			abort();
+		}
+		data = (u32 *)prop->data;
+		size = (int)fdt32_to_cpu(*data);
+
+		for (i = 0; i < size; ++i, ++insn)

Darn. Looking over these patches doing a quick self review I see a bug. This i < size should be i < size/4. I've fixed the branch on github.

Quoted 88 lines
lib/powerpc/rtas.c new file +62 -0
+			if (*insn = SC1)
+				*insn = SC1_REPLACEMENT;
+	}
+
+#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)
+{
+	int ret = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1);
+	printf("RTAS power-off returned %d\n", ret);
+}
lib/ppc64/asm/rtas.h new file +1 -0
new file mode 100644
index 0000000000000..fe77f635cd860
@@ -0,0 +1 @@
+#include "../../powerpc/asm/rtas.h"
powerpc/Makefile.common +1 -0
index 9654bce1752eb..3a03ab6dfc3e9 100644
@@ -33,6 +33,7 @@ cflatobjs += lib/devicetree.o
 cflatobjs += lib/powerpc/io.o
 cflatobjs += lib/powerpc/hcall.o
 cflatobjs += lib/powerpc/setup.o
+cflatobjs += lib/powerpc/rtas.o
 
 libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name)
 start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
Signature · 6 lines
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#32 lore raw

Re: [kvm-unit-tests PATCH v3 16/17] powerpc/ppc64: add RTAS support

In reply to Andrew Jones
Quoted 14 lines · Andrew Jones

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

---
 lib/powerpc/asm/rtas.h  |  26 +++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 169 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h

...

Quoted 22 lines
lib/powerpc/rtas.c new file +16 -0
new file mode 100644
index 0000000000000..b6ae7391181f9
@@ -0,0 +1,139 @@
+/*
+ * powerpc RTAS
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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/hcall.h>
+#include <asm/io.h>
+#include <asm/rtas.h>
+
+#if defined(__powerpc64__)

lib/powerpc/rtas.c line 26

Quoted 10 lines
lib/powerpc/rtas.c new file +10 -0
+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;

I'd maybe name the lock variable "rtas_lock" instead (in case we ever use more locks in this file, it's then more obvious what this lock is about) ... but apart from that, and the bug in the sc1 loop that you already mentioned, the patch looks fine to me.

Thomas

#33 lore raw

Re: [kvm-unit-tests PATCH v3 16/17] powerpc/ppc64: add RTAS support

Quoted 44 lines · Thomas Huth
Quoted 14 lines · Andrew Jones

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

---
 lib/powerpc/asm/rtas.h  |  26 +++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 169 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h

...

Quoted 28 lines
lib/powerpc/rtas.c new file +22 -0
new file mode 100644
index 0000000000000..b6ae7391181f9
@@ -0,0 +1,139 @@
+/*
+ * powerpc RTAS
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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/hcall.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
Quoted 8 lines

lib/powerpc/rtas.c line 26

Quoted 4 lines
lib/powerpc/rtas.c new file +4 -0
+typedef void (*rtas_entry_t)(unsigned long);
+static rtas_entry_t enter_rtas;
+static struct rtas_args rtas_args;
+static struct spinlock lock;

I'd maybe name the lock variable "rtas_lock" instead (in case we ever use more locks in this file, it's then more obvious what this lock is about) ... but apart from that, and the bug in the sc1 loop that you

I'll rename lock, and v4 will have the size/4 fix.

Quoted 1 line

already mentioned, the patch looks fine to me.

Can I add your r-b?

Thanks,
drew

Reviewed-by
#34 lore raw

Re: [kvm-unit-tests PATCH v3 16/17] powerpc/ppc64: add RTAS support

Quoted 54 lines · Andrew Jones
Quoted 44 lines · Thomas Huth
Quoted 14 lines · Andrew Jones

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

---
 lib/powerpc/asm/rtas.h  |  26 +++++++++
 lib/powerpc/io.c        |   2 +
 lib/powerpc/rtas.c      | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ppc64/asm/rtas.h    |   1 +
 powerpc/Makefile.common |   1 +
 5 files changed, 169 insertions(+)
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/ppc64/asm/rtas.h

...

Quoted 28 lines
lib/powerpc/rtas.c new file +22 -0
new file mode 100644
index 0000000000000..b6ae7391181f9
@@ -0,0 +1,139 @@
+/*
+ * powerpc RTAS
+ *
+ * Copyright (C) 2016, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * 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/hcall.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
Quoted 8 lines

lib/powerpc/rtas.c line 26

Quoted 4 lines
lib/powerpc/rtas.c new file +4 -0
+typedef void (*rtas_entry_t)(unsigned long);
+static rtas_entry_t enter_rtas;
+static struct rtas_args rtas_args;
+static struct spinlock lock;

I'd maybe name the lock variable "rtas_lock" instead (in case we ever use more locks in this file, it's then more obvious what this lock is about) ... but apart from that, and the bug in the sc1 loop that you

Quoted 5 lines

I'll rename lock, and v4 will have the size/4 fix.

Quoted 1 line

already mentioned, the patch looks fine to me.

Can I add your r-b?

Yes, with the two changes:

#35 lore raw

PATCH v3 17/17 powerpc/ppc64: make a fake debug-exit

In reply to Andrew Jones

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.)

---
 lib/powerpc/io.c | 4 ++++
 powerpc/run      | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
lib/powerpc/io.c +4 -0
index e57a28c583eb0..ba90a08650b9d 100644
@@ -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);
 }
powerpc/run +5 -2
index c5108100fc5e0..45492a1cb8afc 100755
@@ -46,7 +46,10 @@ command="$qemu $M -bios $FIRMWARE"
 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
Signature · 1 line
2.4.3
Reviewed-by on v3 17/17
#36 lore raw

Re: [kvm-unit-tests PATCH v3 17/17] powerpc/ppc64: make a fake debug-exit

Quoted 4 lines · Andrew Jones

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).

Quoted 8 lines

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

---
 lib/powerpc/io.c | 4 ++++
 powerpc/run      | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
Tested-by on the v3 series
#37 lore raw
In reply to Andrew Jones
Quoted 150 lines · Andrew Jones

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.

Tested on TCG and a P8 kvm_pr machine. I'm looking forward to hearing more testing feedback from others. Maybe I should have added an RFT.

v3:
Paolo's comments:
- got rid of zero-sized files

Thomas' review comments:
- remove useless casts in needed cast adding patch
- got rid of build_romfs building (and committing a binary), just offset the rom binary by 256 bytes now
- added a better error message for a -smp N, N > NR_CPUS user error
- got rid of infinite loop with broken rtas-poweroff
- one r-b (wasn't sure the "looks good"'s counted, so didn't add more)

Laurent's testing led me to
- fix a problem on kvm_pr with broken sc1
- fix handling of memory regions, expect more than one
- and a fix to DT code so that works

Additionally:
- new patches
- cscope: ppc64 needs to look in lib/powerpc/asm too, and arm64 in lib/arm/asm
- handle memory regions better also for arm
- a misc trivial fix for arm...
- align toc to 256 bytes for later gcc

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

We still haven't addressed debug-exit. 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 now we keep the hack from v1, but simplified.

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

Andrew Jones (17):
arm/arm64: trivial: another assert fix
Makefile: cscope: also look in arch shared asm
lib: asm-generic: add missing casts
devicetree: fix dt_get_memory_params arm/arm64: setup improvements
lib: share arm-selftest utility functions
config: no need to mix arch makefiles powerpc/ppc64: start skeleton framework powerpc/ppc64: ppc-ify makefiles and linker script powerpc/ppc64: add a boot rom powerpc/ppc64: add hcall support and 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: make a fake debug-exit

 Makefile                                           |   8 +-
 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/arm/asm/setup.h                                |   9 ++
 lib/arm/io.c                                       |   3 +-
 lib/arm/setup.c                                    |  66 +++++++---
 lib/asm-generic/io.h                               |  12 +-
 lib/devicetree.c                                   |   8 +-
 lib/libcflat.h                                     |  11 +-
 lib/powerpc/.gitignore                             |   1 +
 lib/powerpc/asm/hcall.h                            |  43 +++++++
 lib/powerpc/asm/rtas.h                             |  26 ++++
 lib/powerpc/asm/setup.h                            |  36 ++++++
 lib/powerpc/hcall.c                                |  79 ++++++++++++
 lib/powerpc/io.c                                   |  37 ++++++
 lib/powerpc/rtas.c                                 | 139 +++++++++++++++++++++
 lib/powerpc/setup.c                                | 119 ++++++++++++++++++
 lib/ppc64/.gitignore                               |   1 +
 lib/ppc64/asm-offsets.c                            |  12 ++
 lib/ppc64/asm/asm-offsets.h                        |   1 +
 lib/ppc64/asm/hcall.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/spinlock.c                               |  11 ++
 lib/report.c                                       |  16 +++
 lib/util.c                                         |  18 +++
 lib/util.h                                         |  23 ++++
 powerpc/Makefile                                   |   1 +
 powerpc/Makefile.common                            |  71 +++++++++++
 powerpc/Makefile.ppc64                             |  20 +++
 powerpc/boot_rom.S                                 |   5 +
 powerpc/cstart64.S                                 |  83 ++++++++++++
 powerpc/flat.lds                                   |  44 +++++++
 powerpc/reloc64.c                                  |  55 ++++++++
 powerpc/run                                        |  55 ++++++++
 powerpc/selftest.c                                 |  64 ++++++++++
 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 +-
 51 files changed, 1124 insertions(+), 75 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/hcall.h
 create mode 100644 lib/powerpc/asm/rtas.h
 create mode 100644 lib/powerpc/asm/setup.h
 create mode 100644 lib/powerpc/hcall.c
 create mode 100644 lib/powerpc/io.c
 create mode 100644 lib/powerpc/rtas.c
 create mode 100644 lib/powerpc/setup.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/hcall.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/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.S
 create mode 100644 powerpc/cstart64.S
 create mode 100644 powerpc/flat.lds
 create mode 100644 powerpc/reloc64.c
Quoted 9 lines
 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%)

tested with kvm_pr and kvm_hv.

Just a note for the next release:

$ ./run_tests.sh
./run_tests.sh: line 51: test.log: Permission denied
scripts/runtime.bash: line 48: test.log: Permission denied
PASS selftest-setup

You should check current user can write into test.log.

Laurent

#38 lore raw
Quoted 4 lines · Laurent Vivier

tested with kvm_pr and kvm_hv.

Thanks for the testing! I'm glad it now works for you now. Just to confirm, the kvm_pr machine you tested on was the PowerMac G5 that you had trouble with before, right?

Quoted 9 lines

Just a note for the next release:

$ ./run_tests.sh
./run_tests.sh: line 51: test.log: Permission denied
scripts/runtime.bash: line 48: test.log: Permission denied
PASS selftest-setup

You should check current user can write into test.log.

Ah, I've never seen that. I guess you ran it once as root, and then later as a non-root user? I'll add a change to run_tests.sh that does a 'rm -f test.log' before the echo, but I'll submit that as a separate patch.

Thanks,
drew

#39 lore raw
Quoted 9 lines · Andrew Jones
Quoted 4 lines · Laurent Vivier

tested with kvm_pr and kvm_hv.

Thanks for the testing! I'm glad it now works for you now. Just to confirm, the kvm_pr machine you tested on was the PowerMac G5 that you had trouble with before, right?

Yes

Quoted 8 lines
Quoted 8 lines

Just a note for the next release:

$ ./run_tests.sh
./run_tests.sh: line 51: test.log: Permission denied
scripts/runtime.bash: line 48: test.log: Permission denied
PASS selftest-setup
Quoted 4 lines
Quoted 1 line

You should check current user can write into test.log.

Ah, I've never seen that. I guess you ran it once as root, and then later as a non-root user? I'll add a change to

Yes.

Quoted 2 lines

run_tests.sh that does a 'rm -f test.log' before the echo, but I'll submit that as a separate patch.

Thanks,
Laurent