Skip to contentSkip to conversation

Current MTTCG kvm-unit-test patches

RFC In review Alex Bennée 2 participants 23 messages Feb 26, 2016 – Apr 28, 2016 Library code

lore
Share & tools
lore
#0 lore raw

cover Current MTTCG kvm-unit-test patches

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

 arm/barrier-litmus-test.c    | 258 ++++++++++++++++++++++++++++++++++++
 arm/ipi-test.c               |  58 +++++++++
 arm/locking-test.c           | 302 +++++++++++++++++++++++++++++++++++++++++++
 arm/run                      |  11 +-
 arm/tcg-test-asm.S           | 170 ++++++++++++++++++++++++
 arm/tcg-test.c               | 248 +++++++++++++++++++++++++++++++++++
 arm/tlbflush-test.c          | 194 +++++++++++++++++++++++++++
 arm/unittests.cfg            | 170 ++++++++++++++++++++++++
 config/config-arm-common.mak |  16 ++-
 lib/arm/asm/barrier.h        |  63 ++++++++-
 lib/arm/asm/gic.h            | 122 +++++++++++++++++
 lib/arm/asm/processor.h      |  10 ++
 lib/arm/io.c                 |  31 +++++
 lib/arm64/asm/barrier.h      |  50 +++++++
 lib/arm64/asm/gic.h          |   1 +
 lib/arm64/asm/processor.h    |  10 ++
 lib/prng.c                   | 162 +++++++++++++++++++++++
 lib/prng.h                   |  82 ++++++++++++
 18 files changed, 1953 insertions(+), 5 deletions(-)
 create mode 100644 arm/barrier-litmus-test.c
 create mode 100644 arm/ipi-test.c
 create mode 100644 arm/locking-test.c
 create mode 100644 arm/tcg-test-asm.S
 create mode 100644 arm/tcg-test.c
 create mode 100644 arm/tlbflush-test.c
 create mode 100644 lib/arm/asm/gic.h
 create mode 100644 lib/arm64/asm/gic.h
 create mode 100644 lib/prng.c
 create mode 100644 lib/prng.h
Signature · 1 line
2.7.1
#1 lore raw

RFC 1/11 config/config-arm-common: build-up tests-common target

This is a source of needless conflicts when adding new tests and re-basing. Let's just build up the lists of tests by hand.

---
 config/config-arm-common.mak | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
config/config-arm-common.mak +2 -3
index 698555d..e037507 100644
@@ -9,9 +9,8 @@ ifeq ($(LOADADDR),)
 	LOADADDR = 0x40000000
 endif
 
-tests-common = \
-	$(TEST_DIR)/selftest.flat \
-	$(TEST_DIR)/spinlock-test.flat
+tests-common = $(TEST_DIR)/selftest.flat
+tests-common += $(TEST_DIR)/spinlock-test.flat
 
 all: test_cases
 
Signature · 1 line
2.7.1
#2 lore raw

Re: [Qemu-devel] [RFC 01/11] config/config-arm-common: build-up tests-common target

Quoted 28 lines · Alex Bennée

This is a source of needless conflicts when adding new tests and re-basing. Let's just build up the lists of tests by hand.

---
 config/config-arm-common.mak | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
config/config-arm-common.mak +2 -3
index 698555d..e037507 100644
@@ -9,9 +9,8 @@ ifeq ($(LOADADDR),)
 	LOADADDR = 0x40000000
 endif
 
-tests-common = \
-	$(TEST_DIR)/selftest.flat \
-	$(TEST_DIR)/spinlock-test.flat
+tests-common = $(TEST_DIR)/selftest.flat
+tests-common += $(TEST_DIR)/spinlock-test.flat
 
 all: test_cases
 
Signature · 1 line
2.7.1

I agree with this patch, but we could probably just squash it with the addition of the next test.

drew

#3 lore raw

Re: [Qemu-devel] [RFC 01/11] config/config-arm-common: build-up tests-common target

Quoted 25 lines · Andrew Jones
Quoted 24 lines · Alex Bennée

This is a source of needless conflicts when adding new tests and re-basing. Let's just build up the lists of tests by hand.

---
 config/config-arm-common.mak | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
config/config-arm-common.mak +2 -3
index 698555d..e037507 100644
@@ -9,9 +9,8 @@ ifeq ($(LOADADDR),)
 	LOADADDR = 0x40000000
 endif
 
-tests-common = \
-	$(TEST_DIR)/selftest.flat \
-	$(TEST_DIR)/spinlock-test.flat
+tests-common = $(TEST_DIR)/selftest.flat
+tests-common += $(TEST_DIR)/spinlock-test.flat
 
 all: test_cases
 
Quoted 7 lines
Quoted 4 lines

--
2.7.1

I agree with this patch, but we could probably just squash it with the addition of the next test.

It was originally but during yet-another-rebase I thought I'd just separate the patch so it wasn't dependant on what was merged next!

Quoted 2 lines

drew

--
Alex Bennée

#4 lore raw

RFC 2/11 arm/arm64: irq enable/disable

In reply to Alex Bennée

From: Andrew Jones <[email protected]>

---
 lib/arm/asm/processor.h   | 10 ++++++++++
 lib/arm64/asm/processor.h | 10 ++++++++++
 2 files changed, 20 insertions(+)
lib/arm/asm/processor.h +10 -0
index f25e7ee..a3a4e0b 100644
@@ -33,6 +33,16 @@ static inline unsigned long current_cpsr(void)
 
 #define current_mode() (current_cpsr() & MODE_MASK)
 
+static inline void local_irq_enable(void)
+{
+	asm volatile("cpsie i" : : : "memory", "cc");
+}
+
+static inline void local_irq_disable(void)
+{
+	asm volatile("cpsid i" : : : "memory", "cc");
+}
+
 static inline unsigned int get_mpidr(void)
 {
 	unsigned int mpidr;
lib/arm64/asm/processor.h +10 -0
index 84d5c7c..18fa2a2 100644
@@ -66,6 +66,16 @@ static inline unsigned long current_level(void)
 	return el & 0xc;
 }
 
+static inline void local_irq_enable(void)
+{
+	asm volatile("msr daifclr, #2" : : : "memory");
+}
+
+static inline void local_irq_disable(void)
+{
+	asm volatile("msr daifset, #2" : : : "memory");
+}
+
 #define DEFINE_GET_SYSREG32(reg)				\
 static inline unsigned int get_##reg(void)			\
 {								\
Signature · 1 line
2.7.1
#5 lore raw

RFC 3/11 arm/arm64: Add initial gic support

In reply to Alex Bennée

From: Andrew Jones <[email protected]>

Add some gic(v2) support. This just adds enough support for an IPI test. It's really just a starting point, and the general functions (inlines in gic.h) may need some changes as more support is added.

---
 lib/arm/asm/gic.h   | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/arm/io.c        |  31 +++++++++++++
 lib/arm64/asm/gic.h |   1 +
 3 files changed, 154 insertions(+)
 create mode 100644 lib/arm/asm/gic.h
 create mode 100644 lib/arm64/asm/gic.h
lib/arm/asm/gic.h new file +122 -0
new file mode 100644
index 0000000..6f27c91
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2015, Red Hat Inc, Andrew Jones <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ *
+ * All GIC* defines are lifted from include/linux/irqchip/arm-gic.h
+ */
+#ifndef _ASMARM_GIC_H_
+#define _ASMARM_GIC_H_
+
+#define GIC_CPU_CTRL			0x00
+#define GIC_CPU_PRIMASK			0x04
+#define GIC_CPU_BINPOINT		0x08
+#define GIC_CPU_INTACK			0x0c
+#define GIC_CPU_EOI			0x10
+#define GIC_CPU_RUNNINGPRI		0x14
+#define GIC_CPU_HIGHPRI			0x18
+#define GIC_CPU_ALIAS_BINPOINT		0x1c
+#define GIC_CPU_ACTIVEPRIO		0xd0
+#define GIC_CPU_IDENT			0xfc
+
+#define GICC_ENABLE			0x1
+#define GICC_INT_PRI_THRESHOLD		0xf0
+#define GICC_IAR_INT_ID_MASK		0x3ff
+#define GICC_INT_SPURIOUS		1023
+#define GICC_DIS_BYPASS_MASK		0x1e0
+
+#define GIC_DIST_CTRL			0x000
+#define GIC_DIST_CTR			0x004
+#define GIC_DIST_IGROUP			0x080
+#define GIC_DIST_ENABLE_SET		0x100
+#define GIC_DIST_ENABLE_CLEAR		0x180
+#define GIC_DIST_PENDING_SET		0x200
+#define GIC_DIST_PENDING_CLEAR		0x280
+#define GIC_DIST_ACTIVE_SET		0x300
+#define GIC_DIST_ACTIVE_CLEAR		0x380
+#define GIC_DIST_PRI			0x400
+#define GIC_DIST_TARGET			0x800
+#define GIC_DIST_CONFIG			0xc00
+#define GIC_DIST_SOFTINT		0xf00
+#define GIC_DIST_SGI_PENDING_CLEAR	0xf10
+#define GIC_DIST_SGI_PENDING_SET	0xf20
+
+#define GICD_ENABLE			0x1
+#define GICD_DISABLE			0x0
+#define GICD_INT_ACTLOW_LVLTRIG		0x0
+#define GICD_INT_EN_CLR_X32		0xffffffff
+#define GICD_INT_EN_SET_SGI		0x0000ffff
+#define GICD_INT_EN_CLR_PPI		0xffff0000
+#define GICD_INT_DEF_PRI		0xa0
+#define GICD_INT_DEF_PRI_X4		((GICD_INT_DEF_PRI << 24) |\
+					(GICD_INT_DEF_PRI << 16) |\
+					(GICD_INT_DEF_PRI << 8) |\
+					GICD_INT_DEF_PRI)
+
+#define GICH_HCR			0x0
+#define GICH_VTR			0x4
+#define GICH_VMCR			0x8
+#define GICH_MISR			0x10
+#define GICH_EISR0 			0x20
+#define GICH_EISR1 			0x24
+#define GICH_ELRSR0 			0x30
+#define GICH_ELRSR1 			0x34
+#define GICH_APR			0xf0
+#define GICH_LR0			0x100
+
+#define GICH_HCR_EN			(1 << 0)
+#define GICH_HCR_UIE			(1 << 1)
+
+#define GICH_LR_VIRTUALID		(0x3ff << 0)
+#define GICH_LR_PHYSID_CPUID_SHIFT	(10)
+#define GICH_LR_PHYSID_CPUID		(7 << GICH_LR_PHYSID_CPUID_SHIFT)
+#define GICH_LR_STATE			(3 << 28)
+#define GICH_LR_PENDING_BIT		(1 << 28)
+#define GICH_LR_ACTIVE_BIT		(1 << 29)
+#define GICH_LR_EOI			(1 << 19)
+
+#define GICH_VMCR_CTRL_SHIFT		0
+#define GICH_VMCR_CTRL_MASK		(0x21f << GICH_VMCR_CTRL_SHIFT)
+#define GICH_VMCR_PRIMASK_SHIFT		27
+#define GICH_VMCR_PRIMASK_MASK		(0x1f << GICH_VMCR_PRIMASK_SHIFT)
+#define GICH_VMCR_BINPOINT_SHIFT	21
+#define GICH_VMCR_BINPOINT_MASK		(0x7 << GICH_VMCR_BINPOINT_SHIFT)
+#define GICH_VMCR_ALIAS_BINPOINT_SHIFT	18
+#define GICH_VMCR_ALIAS_BINPOINT_MASK	(0x7 << GICH_VMCR_ALIAS_BINPOINT_SHIFT)
+
+#define GICH_MISR_EOI			(1 << 0)
+#define GICH_MISR_U			(1 << 1)
+
+#ifndef __ASSEMBLY__
+#include <asm/io.h>
+
+#define GIC_DIST_BASE			(gicv2_data.dist_base)
+#define GIC_CPU_BASE			(gicv2_data.cpu_base)
+
+struct gicv2_data {
+	void *dist_base;
+	void *cpu_base;
+};
+
+extern struct gicv2_data gicv2_data;
+
+static inline void gic_enable(void)
+{
+	writel(GICD_ENABLE, GIC_DIST_BASE + GIC_DIST_CTRL);
+	writel(0xff, GIC_CPU_BASE + GIC_CPU_PRIMASK);
+	writel(GICC_ENABLE, GIC_CPU_BASE + GIC_CPU_CTRL);
+}
+
+static inline void gic_irq_ack(void)
+{
+	unsigned int iar = readl(GIC_CPU_BASE + GIC_CPU_INTACK);
+	writel(iar, GIC_CPU_BASE + GIC_CPU_EOI);
+}
+
+static inline void gic_send_sgi(unsigned int cpu, unsigned int irq)
+{
+	writel(((1 << cpu) << 16) | irq, GIC_DIST_BASE + GIC_DIST_SOFTINT);
+}
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _ASMARM_GIC_H_ */
lib/arm/io.c +31 -0
index a08d394..9eae13f 100644
@@ -12,6 +12,7 @@
 #include <devicetree.h>
 #include <chr-testdev.h>
 #include <asm/spinlock.h>
+#include <asm/gic.h>
 #include <asm/io.h>
 
 extern void halt(int code);
@@ -62,10 +63,40 @@ static void uart0_init(void)
 	}
 }
 
+struct gicv2_data gicv2_data;
+static int gicv2_init(void)
+{
+	const char *compatible = "arm,cortex-a15-gic";
+	struct dt_pbus_reg reg;
+	struct dt_device gic;
+	struct dt_bus bus;
+	int node;
+
+	dt_bus_init_defaults(&bus);
+	dt_device_init(&gic, &bus, NULL);
+
+	node = dt_device_find_compatible(&gic, compatible);
+	assert(node >= 0 || node == -FDT_ERR_NOTFOUND);
+
+	if (node == -FDT_ERR_NOTFOUND)
+		return node;
+
+	assert(dt_pbus_translate_node(node, 0, &reg) == 0);
+
+	gicv2_data.dist_base = ioremap(reg.addr, reg.size);
+
+	assert(dt_pbus_translate_node(node, 1, &reg) == 0);
+
+	gicv2_data.cpu_base = ioremap(reg.addr, reg.size);
+
+	return 0;
+}
+
 void io_init(void)
 {
 	uart0_init();
 	chr_testdev_init();
+	assert(gicv2_init() == 0);
 }
 
 void puts(const char *s)
lib/arm64/asm/gic.h new file +1 -0
new file mode 100644
index 0000000..e5eb302
@@ -0,0 +1 @@
+#include "../../arm/asm/gic.h"
Signature · 1 line
2.7.1
#6 lore raw

RFC 4/11 arm/arm64: Add IPI test

In reply to Alex Bennée

From: Andrew Jones <[email protected]>

[ajb: slight tweak to .mak file]
---
 arm/ipi-test.c               | 58 ++++++++++++++++++++++++++++++++++++++++++++
 config/config-arm-common.mak |  2 ++
 2 files changed, 60 insertions(+)
 create mode 100644 arm/ipi-test.c
arm/ipi-test.c new file +58 -0
new file mode 100644
index 0000000..705295f
@@ -0,0 +1,58 @@
+/*
+ * Test sending an IPI and handling IRQ exceptions.
+ *
+ * Copyright (C) 2015, 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/setup.h>
+#include <asm/processor.h>
+#include <asm/gic.h>
+#include <asm/smp.h>
+#include <asm/barrier.h>
+
+static volatile bool ready, acked, done;
+
+static void irq_handler(struct pt_regs *regs __unused)
+{
+	gic_irq_ack();
+	acked = true;
+}
+
+static void ipi_test(void)
+{
+	gic_enable();
+#ifdef __arm__
+	install_exception_handler(EXCPTN_IRQ, irq_handler);
+#else
+	install_irq_handler(EL1H_IRQ, irq_handler);
+#endif
+	local_irq_enable();
+	ready = true;
+	wfi();
+	report("IPI", acked);
+	done = true;
+	halt();
+}
+
+int main(void)
+{
+	if (nr_cpus < 2) {
+		printf("ipi-test requires '-smp 2'\n");
+		abort();
+	}
+
+	gic_enable();
+	smp_boot_secondary(1, ipi_test);
+
+	while (!ready)
+		cpu_relax();
+
+	gic_send_sgi(1, 1);
+
+	while (!done)
+		cpu_relax();
+
+	return report_summary();
+}
config/config-arm-common.mak +2 -0
index e037507..d90eccc 100644
@@ -11,6 +11,7 @@ endif
 
 tests-common = $(TEST_DIR)/selftest.flat
 tests-common += $(TEST_DIR)/spinlock-test.flat
+tests-common += $(TEST_DIR)/ipi-test.flat
 
 all: test_cases
 
@@ -69,3 +70,4 @@ 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
+$(TEST_DIR)/ipi-test.elf: $(cstart.o) $(TEST_DIR)/ipi-test.o
Signature · 1 line
2.7.1
#7 lore raw

RFC 5/11 lib: add isaac prng library from CCAN

In reply to Alex Bennée

It's often useful to introduce some sort of random variation when testing several racing CPU conditions. Instead of each test implementing some half-arsed PRNG bring in a a decent one which has good statistical randomness. Obviously it is deterministic for a given seed value which is likely the behaviour you want.

I've pulled in the ISAAC library from CCAN:

http://ccodearchive.net/info/isaac.html

I shaved off the float related stuff which is less useful for unit testing and re-indented to fit the style. The original license was CC0 (Public Domain) which is compatible with the LGPL v2 of kvm-unit-tests.

---
 config/config-arm-common.mak |   1 +
 lib/prng.c                   | 162 +++++++++++++++++++++++++++++++++++++++++++
 lib/prng.h                   |  82 ++++++++++++++++++++++
 3 files changed, 245 insertions(+)
 create mode 100644 lib/prng.c
 create mode 100644 lib/prng.h
config/config-arm-common.mak +1 -0
index d90eccc..732c805 100644
@@ -32,6 +32,7 @@ cflatobjs += lib/devicetree.o
 cflatobjs += lib/virtio.o
 cflatobjs += lib/virtio-mmio.o
 cflatobjs += lib/chr-testdev.o
+cflatobjs += lib/prng.o
 cflatobjs += lib/arm/io.o
 cflatobjs += lib/arm/setup.o
 cflatobjs += lib/arm/mmu.o
lib/prng.c new file +162 -0

162 lines not on this page · raw message

lib/prng.h new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.7.1
#8 lore raw

RFC 6/11 arm/run: set indentation defaults for emacs

In reply to Alex Bennée
---
 arm/run | 1 +
 1 file changed, 1 insertion(+)
arm/run +1 -0
index dc0a332..0eaf23a 100755
@@ -1,4 +1,5 @@
 #!/bin/bash
+# -*- sh-basic-offset:8 indent-tabs-mode: t -*-
 
 if [ -z "$STANDALONE" ]; then
 	if [ ! -f config.mak ]; then
Signature · 1 line
2.7.1
#9 lore raw

RFC 7/11 arm/run: allow aarch64 to start arm binaries

In reply to Alex Bennée

AArch64 hosts can happily run AArch32 binaries. We just need to ensure that we use "cpu host,aarch64=off" when specifying the CPU type.

---
 arm/run | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arm/run +9 -1
index 0eaf23a..f1a6b7d 100755
@@ -38,7 +38,15 @@ if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then
 	fi
 fi
 
-qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
+    qemu="${QEMU:-qemu-system-$HOST}"
+    if [ "$ACCEL" = "kvm" ]; then
+	processor="host,aarch64=off"
+    fi
+else
+	qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+fi
+
 qpath=$(which $qemu 2>/dev/null)
 
 if [ -z "$qpath" ]; then
Signature · 1 line
2.7.1
#10 lore raw

Re: [Qemu-devel] [RFC 07/11] arm/run: allow aarch64 to start arm binaries

Quoted 15 lines · Alex Bennée

AArch64 hosts can happily run AArch32 binaries. We just need to ensure that we use "cpu host,aarch64=off" when specifying the CPU type.

---
 arm/run | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arm/run +0 -0
index 0eaf23a..f1a6b7d 100755
@@ -38,7 +38,15 @@ if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then
 	fi
 fi

arm/run if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then · line 48

Quoted 10 lines
arm/run +8 -1
 
-qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
+    qemu="${QEMU:-qemu-system-$HOST}"
+    if [ "$ACCEL" = "kvm" ]; then
+	processor="host,aarch64=off"
+    fi
+else
+	qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+fi

We've got 3382e7795 "arm/run: allow tests to run in AArch32 mode" already, so I this patch should no longer be necessary.

Thanks,
drew

Quoted 7 lines
arm/run +1 -0
+
 qpath=$(which $qemu 2>/dev/null)
 
 if [ -z "$qpath" ]; then
Signature · 1 line
2.7.1
#11 lore raw

Re: [Qemu-devel] [RFC 07/11] arm/run: allow aarch64 to start arm binaries

Quoted 17 lines · Andrew Jones
Quoted 16 lines · Alex Bennée

AArch64 hosts can happily run AArch32 binaries. We just need to ensure that we use "cpu host,aarch64=off" when specifying the CPU type.

---
 arm/run | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arm/run +0 -0
index 0eaf23a..f1a6b7d 100755
@@ -38,7 +38,15 @@ if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then
 	fi
 fi
 
Quoted 12 lines

arm/run if [ "$HOST" = "aarch64" ] && [ "$ACCEL" = "kvm" ]; then · line 48

Quoted 9 lines
arm/run +8 -1
-qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
+    qemu="${QEMU:-qemu-system-$HOST}"
+    if [ "$ACCEL" = "kvm" ]; then
+	processor="host,aarch64=off"
+    fi
+else
+	qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+fi

We've got 3382e7795 "arm/run: allow tests to run in AArch32 mode" already, so I this patch should no longer be necessary.

Ahh good spot. I'll drop that.

Thanks.

Quoted 12 lines

Thanks,
drew

Quoted 7 lines
arm/run +1 -1
+
 qpath=$(which $qemu 2>/dev/null)
 
 if [ -z "$qpath" ]; then
--

2.7.1

--
Alex Bennée

#12 lore raw

RFC 8/11 arm/tlbflush-test: Add TLB torture test

In reply to Alex Bennée

This adds a fairly brain dead torture test for TLB flushes intended for stressing the MTTCG QEMU build. It takes the usual -smp option for multiple CPUs.

By default it CPU0 will do a TLBIALL flush after each cycle. You can pass options via -append to control additional aspects of the test:

- "page" flush each page in turn (one per function)
- "self" do the flush after each computation cycle
- "verbose" report progress on each computation cycle

---
v2
- rename to tlbflush-test
- made makefile changes cleaner
- added self/other flush mode
- create specific prefix
- whitespace fixes
v3
- using new SMP framework for test runing
v4
- merge in the unitests.cfg

---
 arm/tlbflush-test.c          | 194 +++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg            |  24 ++++++
 config/config-arm-common.mak |   2 +
 3 files changed, 220 insertions(+)
 create mode 100644 arm/tlbflush-test.c
arm/tlbflush-test.c new file +194 -0
new file mode 100644
index 0000000..0375ad9
@@ -0,0 +1,194 @@
+#include <libcflat.h>
+#include <asm/smp.h>
+#include <asm/cpumask.h>
+#include <asm/barrier.h>
+#include <asm/mmu.h>
+
+#define SEQ_LENGTH 10
+#define SEQ_HASH 0x7cd707fe
+
+static cpumask_t smp_test_complete;
+static int flush_count = 1000000;
+static int flush_self = 0;
+static int flush_page = 0;
+static int flush_verbose = 0;
+
+/* Work functions
+ *
+ * These work functions need to be:
+ *
+ *  - page aligned, so we can flush one function at a time
+ *  - have branches, so QEMU TCG generates multiple basic blocks
+ *  - call across pages, so we exercise the TCG basic block slow path
+ */
+
+/* Adler32 */
+__attribute__((aligned(PAGE_SIZE))) uint32_t hash_array(const void *buf,
+							size_t buflen)
+{
+	const uint8_t *data = (uint8_t *) buf;
+	uint32_t s1 = 1;
+	uint32_t s2 = 0;
+
+	for (size_t n = 0; n < buflen; n++) {
+		s1 = (s1 + data[n]) % 65521;
+		s2 = (s2 + s1) % 65521;
+	}
+	return (s2 << 16) | s1;
+}
+
+__attribute__((aligned(PAGE_SIZE))) void create_fib_sequence(int length,
+							unsigned int *array)
+{
+	int i;
+
+	/* first two values */
+	array[0] = 0;
+	array[1] = 1;
+	for (i=2; i<length; i++) {
+		array[i] = array[i-2] + array[i-1];
+	}
+}
+
+__attribute__((aligned(PAGE_SIZE))) unsigned long long factorial(unsigned int n)
+{
+	unsigned int i;
+	unsigned long long fac = 1;
+	for (i=1; i<=n; i++)
+	{
+		fac = fac * i;
+	}
+	return fac;
+}
+
+__attribute__((aligned(PAGE_SIZE))) void factorial_array
+(unsigned int n, unsigned int *input, unsigned long long *output)
+{
+	unsigned int i;
+	for (i=0; i<n; i++) {
+		output[i] = factorial(input[i]);
+	}
+}
+
+__attribute__((aligned(PAGE_SIZE))) unsigned int do_computation(void)
+{
+	unsigned int fib_array[SEQ_LENGTH];
+	unsigned long long facfib_array[SEQ_LENGTH];
+	uint32_t fib_hash, facfib_hash;
+
+	create_fib_sequence(SEQ_LENGTH, &fib_array[0]);
+	fib_hash = hash_array(&fib_array[0], sizeof(fib_array));
+	factorial_array(SEQ_LENGTH, &fib_array[0], &facfib_array[0]);
+	facfib_hash = hash_array(&facfib_array[0], sizeof(facfib_array));
+
+	return (fib_hash ^ facfib_hash);
+}
+
+/* This provides a table of the work functions so we can flush each
+ * page individually
+ */
+static void * pages[] = {&hash_array, &create_fib_sequence, &factorial,
+			 &factorial_array, &do_computation};
+
+static void do_flush(int i)
+{
+	if (flush_page) {
+		flush_tlb_page((unsigned long)pages[i % ARRAY_SIZE(pages)]);
+	} else {
+		flush_tlb_all();
+	}
+}
+
+
+static void just_compute(void)
+{
+	int i, errors = 0;
+	int cpu = smp_processor_id();
+
+	uint32_t result;
+
+	printf("CPU%d online\n", cpu);
+
+	for (i=0; i < flush_count; i++) {
+		result = do_computation();
+
+		if (result != SEQ_HASH) {
+			errors++;
+			printf("CPU%d: seq%d 0x%x!=0x%x\n",
+				cpu, i, result, SEQ_HASH);
+		}
+
+		if (flush_verbose && (i % 1000) == 0) {
+			printf("CPU%d: seq%d\n", cpu, i);
+		}
+
+		if (flush_self) {
+			do_flush(i);
+		}
+	}
+
+	report("CPU%d: Done - Errors: %d\n", errors == 0, cpu, errors);
+
+	cpumask_set_cpu(cpu, &smp_test_complete);
+	if (cpu != 0)
+		halt();
+}
+
+static void just_flush(void)
+{
+	int cpu = smp_processor_id();
+	int i = 0;
+
+	/* set our CPU as done, keep flushing until everyone else
+	   finished */
+	cpumask_set_cpu(cpu, &smp_test_complete);
+
+	while (!cpumask_full(&smp_test_complete)) {
+		do_flush(i++);
+	}
+
+	report("CPU%d: Done - Triggered %d flushes\n", true, cpu, i);
+}
+
+int main(int argc, char **argv)
+{
+	int cpu, i;
+	char prefix[100];
+
+	for (i=0; i<argc; i++) {
+		char *arg = argv[i];
+
+		if (strcmp(arg, "page") == 0) {
+			flush_page = 1;
+                }
+
+                if (strcmp(arg, "self") == 0) {
+			flush_self = 1;
+                }
+
+		if (strcmp(arg, "verbose") == 0) {
+			flush_verbose = 1;
+                }
+	}
+
+	snprintf(prefix, sizeof(prefix), "tlbflush_%s_%s",
+		flush_page?"page":"all",
+		flush_self?"self":"other");
+	report_prefix_push(prefix);
+
+	for_each_present_cpu(cpu) {
+		if (cpu == 0)
+			continue;
+		smp_boot_secondary(cpu, just_compute);
+	}
+
+	if (flush_self)
+		just_compute();
+	else
+		just_flush();
+
+	while (!cpumask_full(&smp_test_complete))
+		cpu_relax();
+
+	return report_summary();
+}
arm/unittests.cfg +24 -0
index 5e26da1..8aebdba 100644
@@ -38,3 +38,27 @@ file = selftest.flat
 smp = $MAX_SMP
 extra_params = -append 'smp'
 groups = selftest
+
+# TLB Torture Tests
+[tlbflush::all_other]
+file = tlbflush-test.flat
+smp = $MAX_SMP
+groups = tlbflush
+
+[tlbflush::page_other]
+file = tlbflush-test.flat
+smp = $MAX_SMP
+extra_params = -append 'page'
+groups = tlbflush
+
+[tlbflush::all_self]
+file = tlbflush-test.flat
+smp = $MAX_SMP
+extra_params = -append 'self'
+groups = tlbflush
+
+[tlbflush::page_self]
+file = tlbflush-test.flat
+smp = $MAX_SMP
+extra_params = -append 'page self'
+groups = tlbflush
config/config-arm-common.mak +2 -0
index 732c805..e6ad11b 100644
@@ -12,6 +12,7 @@ endif
 tests-common = $(TEST_DIR)/selftest.flat
 tests-common += $(TEST_DIR)/spinlock-test.flat
 tests-common += $(TEST_DIR)/ipi-test.flat
+tests-common += $(TEST_DIR)/tlbflush-test.flat
 
 all: test_cases
 
@@ -72,3 +73,4 @@ 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
 $(TEST_DIR)/ipi-test.elf: $(cstart.o) $(TEST_DIR)/ipi-test.o
+$(TEST_DIR)/tlbflush-test.elf: $(cstart.o) $(TEST_DIR)/tlbflush-test.o
Signature · 1 line
2.7.1
#13 lore raw

RFC 9/11 arm/locking-tests: add comprehensive locking test

In reply to Alex Bennée

This test has been written mainly to stress multi-threaded TCG behaviour but will demonstrate failure by default on real hardware. The test takes the following parameters:

- "lock" use GCC's locking semantics
- "atomic" use GCC's __atomic primitives
- "wfelock" use WaitForEvent sleep
- "excl" use load/store exclusive semantics

Also two more options allow the test to be tweaked

- "noshuffle" disables the memory shuffling
- "count=%ld" set your own per-CPU increment count

---
v2
- Don't use thumb style strexeq stuff
- Add atomic and wfelock tests
- Add count/noshuffle test controls
- Move barrier tests to separate test file
v4
- fix up unitests.cfg to use correct test name
- move into "locking" group, remove barrier tests
- use a table to add tests, mark which are expected to work
- correctly report XFAIL

---
 arm/locking-test.c           | 302 +++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg            |  35 +++++
 config/config-arm-common.mak |   2 +
 3 files changed, 339 insertions(+)
 create mode 100644 arm/locking-test.c
arm/locking-test.c new file +302 -0
new file mode 100644
index 0000000..fcbe17c
@@ -0,0 +1,302 @@
+#include <libcflat.h>
+#include <asm/smp.h>
+#include <asm/cpumask.h>
+#include <asm/barrier.h>
+#include <asm/mmu.h>
+
+#include <prng.h>
+
+#define MAX_CPUS 8
+
+/* Test definition structure
+ *
+ * A simple structure that describes the test name, expected pass and
+ * increment function.
+ */
+
+/* Function pointers for test */
+typedef void (*inc_fn)(int cpu);
+
+typedef struct {
+	const char *test_name;
+	bool  should_pass;
+	inc_fn main_fn;
+} test_descr_t;
+
+/* How many increments to do */
+static int increment_count = 10000000;
+static int do_shuffle = 1;
+
+/* Shared value all the tests attempt to safely increment using
+ * various forms of atomic locking and exclusive behaviour.
+ */
+static unsigned int shared_value;
+
+/* PAGE_SIZE * uint32_t means we span several pages */
+__attribute__((aligned(PAGE_SIZE))) static uint32_t memory_array[PAGE_SIZE];
+
+/* We use the alignment of the following to ensure accesses to locking
+ * and synchronisation primatives don't interfere with the page of the
+ * shared value
+ */
+__attribute__((aligned(PAGE_SIZE))) static unsigned int per_cpu_value[MAX_CPUS];
+__attribute__((aligned(PAGE_SIZE))) static cpumask_t smp_test_complete;
+__attribute__((aligned(PAGE_SIZE))) struct isaac_ctx prng_context[MAX_CPUS];
+
+/* Some of the approaches use a global lock to prevent contention. */
+static int global_lock;
+
+/* In any SMP setting this *should* fail due to cores stepping on
+ * each other updating the shared variable
+ */
+static void increment_shared(int cpu)
+{
+	(void)cpu;
+
+	shared_value++;
+}
+
+/* GCC __sync primitives are deprecated in favour of __atomic */
+static void increment_shared_with_lock(int cpu)
+{
+	(void)cpu;
+
+	while (__sync_lock_test_and_set(&global_lock, 1));
+	shared_value++;
+	__sync_lock_release(&global_lock);
+}
+
+/* In practice even __ATOMIC_RELAXED uses ARM's ldxr/stex exclusive
+ * semantics */
+static void increment_shared_with_atomic(int cpu)
+{
+	(void)cpu;
+
+	__atomic_add_fetch(&shared_value, 1, __ATOMIC_SEQ_CST);
+}
+
+
+/*
+ * Load/store exclusive with WFE (wait-for-event)
+ *
+ * See ARMv8 ARM examples:
+ *   Use of Wait For Event (WFE) and Send Event (SEV) with locks
+ */
+
+static void increment_shared_with_wfelock(int cpu)
+{
+	(void)cpu;
+
+#if defined(__aarch64__)
+	asm volatile(
+	"	mov     w1, #1\n"
+	"       sevl\n"
+	"       prfm PSTL1KEEP, [%[lock]]\n"
+	"1:     wfe\n"
+	"	ldaxr	w0, [%[lock]]\n"
+	"	cbnz    w0, 1b\n"
+	"	stxr    w0, w1, [%[lock]]\n"
+	"	cbnz	w0, 1b\n"
+	/* lock held */
+	"	ldr	w0, [%[sptr]]\n"
+	"	add	w0, w0, #0x1\n"
+	"	str	w0, [%[sptr]]\n"
+	/* now release */
+	"	stlr	wzr, [%[lock]]\n"
+	: /* out */
+	: [lock] "r" (&global_lock), [sptr] "r" (&shared_value) /* in */
+	: "w0", "w1", "cc");
+#else
+	asm volatile(
+	"	mov     r1, #1\n"
+	"1:	ldrex	r0, [%[lock]]\n"
+	"	cmp     r0, #0\n"
+	"	wfene\n"
+	"	strexeq r0, r1, [%[lock]]\n"
+	"	cmpeq	r0, #0\n"
+	"	bne	1b\n"
+	"	dmb\n"
+	/* lock held */
+	"	ldr	r0, [%[sptr]]\n"
+	"	add	r0, r0, #0x1\n"
+	"	str	r0, [%[sptr]]\n"
+	/* now release */
+	"	mov	r0, #0\n"
+	"	dmb\n"
+	"	str	r0, [%[lock]]\n"
+	"	dsb\n"
+	"	sev\n"
+	: /* out */
+	: [lock] "r" (&global_lock), [sptr] "r" (&shared_value) /* in */
+	: "r0", "r1", "cc");
+#endif
+}
+
+
+/*
+ * Hand-written version of the load/store exclusive
+ */
+static void increment_shared_with_excl(int cpu)
+{
+	(void)cpu;
+
+#if defined(__aarch64__)
+        asm volatile(
+	"1:	ldxr	w0, [%[sptr]]\n"
+	"	add     w0, w0, #0x1\n"
+	"	stxr	w1, w0, [%[sptr]]\n"
+	"	cbnz	w1, 1b\n"
+	: /* out */
+	: [sptr] "r" (&shared_value) /* in */
+	: "w0", "w1", "cc");
+#else
+	asm volatile(
+	"1:	ldrex	r0, [%[sptr]]\n"
+	"	add     r0, r0, #0x1\n"
+	"	strex	r1, r0, [%[sptr]]\n"
+	"	cmp	r1, #0\n"
+	"	bne	1b\n"
+	: /* out */
+	: [sptr] "r" (&shared_value) /* in */
+	: "r0", "r1", "cc");
+#endif
+}
+
+/* Test array */
+static test_descr_t tests[] = {
+	{ "none", false, increment_shared },
+	{ "lock", true, increment_shared_with_lock },
+	{ "atomic", true, increment_shared_with_atomic },
+	{ "wfelock", true, increment_shared_with_wfelock },
+	{ "excl", true, increment_shared_with_excl }
+};
+
+/* The idea of this is just to generate some random load/store
+ * activity which may or may not race with an un-barried incremented
+ * of the shared counter
+ */
+static void shuffle_memory(int cpu)
+{
+	int i;
+	uint32_t lspat = isaac_next_uint32(&prng_context[cpu]);
+	uint32_t seq = isaac_next_uint32(&prng_context[cpu]);
+	int count = seq & 0x1f;
+	uint32_t val=0;
+
+	seq >>= 5;
+
+	for (i=0; i<count; i++) {
+		int index = seq & ~PAGE_MASK;
+		if (lspat & 1) {
+			val ^= memory_array[index];
+		} else {
+			memory_array[index] = val;
+		}
+		seq >>= PAGE_SHIFT;
+		seq ^= lspat;
+		lspat >>= 1;
+	}
+
+}
+
+static inc_fn increment_function;
+
+static void do_increment(void)
+{
+	int i;
+	int cpu = smp_processor_id();
+
+	printf("CPU%d: online and ++ing\n", cpu);
+
+	for (i=0; i < increment_count; i++) {
+		per_cpu_value[cpu]++;
+		increment_function(cpu);
+
+		if (do_shuffle)
+			shuffle_memory(cpu);
+	}
+
+	printf("CPU%d: Done, %d incs\n", cpu, per_cpu_value[cpu]);
+
+	cpumask_set_cpu(cpu, &smp_test_complete);
+	if (cpu != 0)
+		halt();
+}
+
+static void setup_and_run_test(test_descr_t *test)
+{
+	unsigned int i, sum = 0;
+	int cpu, cpu_cnt = 0;
+
+	increment_function = test->main_fn;
+
+	/* fill our random page */
+        for (i=0; i<PAGE_SIZE; i++) {
+		memory_array[i] = isaac_next_uint32(&prng_context[0]);
+	}
+
+	for_each_present_cpu(cpu) {
+		uint32_t seed2 = isaac_next_uint32(&prng_context[0]);
+		cpu_cnt++;
+		if (cpu == 0)
+			continue;
+
+		isaac_init(&prng_context[cpu], (unsigned char *) &seed2, sizeof(seed2));
+		smp_boot_secondary(cpu, do_increment);
+	}
+
+	do_increment();
+
+	while (!cpumask_full(&smp_test_complete))
+		cpu_relax();
+
+	/* All CPUs done, do we add up */
+	for_each_present_cpu(cpu) {
+		sum += per_cpu_value[cpu];
+	}
+
+	if (test->should_pass) {
+		report("total incs %d", sum == shared_value, shared_value);
+	} else {
+		report_xfail("total incs %d", true, sum == shared_value, shared_value);
+	}
+}
+
+int main(int argc, char **argv)
+{
+	static const unsigned char seed[] = "myseed";
+	test_descr_t *test = &tests[0];
+	int i;
+	unsigned int j;
+
+	isaac_init(&prng_context[0], &seed[0], sizeof(seed));
+
+	for (i=0; i<argc; i++) {
+		char *arg = argv[i];
+
+		/* Check for test name */
+		for (j = 0; j < ARRAY_SIZE(tests); j++) {
+			if (strcmp(arg, tests[j].test_name) == 0)
+				test = &tests[j];
+		}
+
+		/* Test modifiers */
+		if (strcmp(arg, "noshuffle") == 0) {
+			do_shuffle = 0;
+			report_prefix_push("noshuffle");
+		} else if (strstr(arg, "count=") != NULL) {
+			char *p = strstr(arg, "=");
+			increment_count = atol(p+1);
+		} else {
+			isaac_reseed(&prng_context[0], (unsigned char *) arg, strlen(arg));
+		}
+	}
+
+	if (test) {
+		setup_and_run_test(test);
+	} else {
+		report("Unknown test", false);
+	}
+
+	return report_summary();
+}
arm/unittests.cfg +35 -0
index 8aebdba..1a61b31 100644
@@ -62,3 +62,38 @@ file = tlbflush-test.flat
 smp = $MAX_SMP
 extra_params = -append 'page self'
 groups = tlbflush
+
+# Locking tests
+[locking::none]
+file = locking-test.flat
+smp = $MAX_SMP
+groups = locking
+accel = tcg
+
+[locking::lock]
+file = locking-test.flat
+smp = $MAX_SMP
+extra_params = -append 'lock'
+groups = locking
+accel = tcg
+
+[locking::atomic]
+file = locking-test.flat
+smp = $MAX_SMP
+extra_params = -append 'atomic'
+groups = locking
+accel = tcg
+
+[locking::wfelock]
+file = locking-test.flat
+smp = $MAX_SMP
+extra_params = -append 'wfelock'
+groups = locking
+accel = tcg
+
+[locking::excl]
+file = locking-test.flat
+smp = $MAX_SMP
+extra_params = -append 'excl'
+groups = locking
+accel = tcg
config/config-arm-common.mak +2 -0
index e6ad11b..6857261 100644
@@ -13,6 +13,7 @@ tests-common = $(TEST_DIR)/selftest.flat
 tests-common += $(TEST_DIR)/spinlock-test.flat
 tests-common += $(TEST_DIR)/ipi-test.flat
 tests-common += $(TEST_DIR)/tlbflush-test.flat
+tests-common += $(TEST_DIR)/locking-test.flat
 
 all: test_cases
 
@@ -74,3 +75,4 @@ $(TEST_DIR)/selftest.elf: $(cstart.o) $(TEST_DIR)/selftest.o
 $(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
 $(TEST_DIR)/ipi-test.elf: $(cstart.o) $(TEST_DIR)/ipi-test.o
 $(TEST_DIR)/tlbflush-test.elf: $(cstart.o) $(TEST_DIR)/tlbflush-test.o
+$(TEST_DIR)/locking-test.elf: $(cstart.o) $(TEST_DIR)/locking-test.o
Signature · 1 line
2.7.1
#14 lore raw

RFC 10/11 arm/barrier-litmus-tests: add some litmus tests

In reply to Alex Bennée

This adds a framework for adding simple barrier litmus tests against ARM. The litmus tests aren't as comprehensive as the academic exercises which will attempt to do all sorts of things to keep racing CPUs synced up. These tests do honour the "sync" parameter to do a poor-mans equivilent.

I've imported a few more of the barrier primatives from the Linux source tree so we consistently use macros.

---
- add a unittest.cfg

---
 arm/barrier-litmus-test.c    | 258 +++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg            |  21 ++++
 config/config-arm-common.mak |   2 +
 lib/arm/asm/barrier.h        |  63 ++++++++++-
 lib/arm64/asm/barrier.h      |  50 +++++++++
 5 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 arm/barrier-litmus-test.c
arm/barrier-litmus-test.c new file +258 -0
new file mode 100644
index 0000000..45cdcdc
@@ -0,0 +1,258 @@
+/*
+ * ARM Barrier Litmus Tests
+ *
+ * This test provides a framework for testing barrier conditions on
+ * the processor. It's simpler than the more involved barrier testing
+ * frameworks as we are looking for simple failures of QEMU's TCG not
+ * weird edge cases the silicon gets wrong.
+ */
+
+#include <libcflat.h>
+#include <asm/smp.h>
+#include <asm/cpumask.h>
+#include <asm/barrier.h>
+#include <asm/mmu.h>
+
+#define MAX_CPUS 8
+
+/* Array size and access controls */
+static int array_size = 100000;
+static int wait_if_ahead = 0;
+
+/*
+ * These test_array_* structures are a contiguous array modified by two or more
+ * competing CPUs. The padding is to ensure the variables do not share
+ * cache lines.
+ *
+ * All structures start zeroed.
+ */
+
+typedef struct test_array
+{
+	volatile unsigned int x;
+	uint8_t dummy[64];
+	volatile unsigned int y;
+	uint8_t dummy2[64];
+	volatile int z;
+} test_array;
+
+volatile test_array *array;
+
+/* Test definition structure
+ *
+ * The first function will always run on the primary CPU, it is
+ * usually the one that will detect any weirdness and trigger the
+ * failure of the test.
+ */
+
+typedef void (*test_fn)(void);
+
+typedef struct {
+	const char *test_name;
+	bool  should_pass;
+	test_fn main_fn;
+	test_fn secondary_fns[MAX_CPUS-1];
+} test_descr_t;
+
+/* Litmus tests */
+
+/* Simple Message Passing
+ *
+ * x is the message data
+ * y is the flag to indicate the data is ready
+ *
+ * Reading x == 0 when y == 1 is a failure.
+ */
+
+void message_passing_write(void)
+{
+	int i;
+	for (i=0; i< array_size; i++) {
+		volatile test_array *entry = &array[i];
+		entry->x = 1;
+		entry->y = 1;
+	}
+
+	halt();
+}
+
+void message_passing_read(void)
+{
+	int i;
+	int errors = 0, ready = 0;
+
+	for (i=0; i< array_size; i++) {
+		volatile test_array *entry = &array[i];
+		unsigned int x,y;
+		y = entry->y;
+		x = entry->x;
+
+		if (y && !x)
+			errors++;
+		ready += y;
+	}
+
+	report_xfail("mp: %d errors, %d ready", true, errors == 0, errors, ready);
+}
+
+/* Simple Message Passing with barriers */
+void message_passing_write_barrier(void)
+{
+	int i;
+	for (i=0; i< array_size; i++) {
+		volatile test_array *entry = &array[i];
+		entry->x = 1;
+		smp_wmb();
+		entry->y = 1;
+	}
+
+	halt();
+}
+
+void message_passing_read_barrier(void)
+{
+	int i;
+	int errors = 0, ready = 0, not_ready = 0;
+
+	for (i=0; i< array_size; i++) {
+		volatile test_array *entry = &array[i];
+		unsigned int x, y;
+		y = entry->y;
+		smp_rmb();
+		x = entry->x;
+
+		if (y && !x)
+			errors++;
+
+		if (y) {
+			ready++;
+		} else {
+			not_ready++;
+
+			if (not_ready > 2) {
+				entry = &array[i+1];
+				do {
+					not_ready = 0;
+				} while (wait_if_ahead && !entry->y);
+			}
+		}
+	}
+
+	report("mp barrier: %d errors, %d ready", errors == 0, errors, ready);
+}
+
+/* Simple Message Passing with Acquire/Release */
+void message_passing_write_release(void)
+{
+	int i;
+	for (i=0; i< array_size; i++) {
+		volatile test_array *entry = &array[i];
+		entry->x = 1;
+		smp_store_release(&entry->y, 1);
+	}
+
+	halt();
+}
+
+void message_passing_read_acquire(void)
+{
+	int i;
+	int errors = 0, ready = 0, not_ready = 0;
+
+	for (i=0; i< array_size; i++) {
+		volatile test_array *entry = &array[i];
+		unsigned int x, y;
+		y = smp_load_acquire(&entry->y);
+		x = entry->x;
+
+		if (y && !x)
+			errors++;
+
+		if (y) {
+			ready++;
+		} else {
+			not_ready++;
+
+			if (not_ready > 2) {
+				entry = &array[i+1];
+				do {
+					not_ready = 0;
+				} while (wait_if_ahead && !entry->y);
+			}
+		}
+	}
+
+	report("mp acqrel: %d errors, %d ready", errors == 0, errors, ready);
+}
+
+
+/* Test array */
+static test_descr_t tests[] = {
+
+	{ "mp",         false,
+	  message_passing_read,
+	  { message_passing_write }
+	},
+
+	{ "mp_barrier", true,
+	  message_passing_read_barrier,
+	  { message_passing_write_barrier }
+	},
+
+	{ "mp_acqrel", true,
+	  message_passing_read_acquire,
+	  { message_passing_write_release }
+	}
+};
+
+
+void setup_and_run_litmus(test_descr_t *test)
+{
+	array = calloc(array_size, sizeof(test_array));
+
+	if (array) {
+		int i = 0;
+		printf("Allocated test array @ %p\n", array);
+
+		while (test->secondary_fns[i]) {
+			smp_boot_secondary(i+1, test->secondary_fns[i]);
+			i++;
+		}
+
+		test->main_fn();
+	} else {
+		report("%s: failed to allocate memory",false, test->test_name);
+	}
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+	unsigned int j;
+	test_descr_t *test = NULL;
+
+	for (i=0; i<argc; i++) {
+		char *arg = argv[i];
+
+		for (j = 0; j < ARRAY_SIZE(tests); j++) {
+			if (strcmp(arg, tests[j].test_name) == 0)
+				test = & tests[j];
+		}
+
+		/* Test modifiers */
+		if (strstr(arg, "count=") != NULL) {
+			char *p = strstr(arg, "=");
+			array_size = atol(p+1);
+		} else if (strcmp (arg, "wait") == 0) {
+			wait_if_ahead = 1;
+		}
+	}
+
+	if (test) {
+		setup_and_run_litmus(test);
+	} else {
+		report("Unknown test", false);
+	}
+
+	return report_summary();
+}
arm/unittests.cfg +21 -0
index 1a61b31..3f05cfa 100644
@@ -97,3 +97,24 @@ smp = $MAX_SMP
 extra_params = -append 'excl'
 groups = locking
 accel = tcg
+
+[barrier-litmus::mp]
+file = barrier-litmus-test.flat
+smp = 2
+extra_params = -append 'mp'
+groups = barrier
+accel = tcg
+
+[barrier-litmus::mp-barrier]
+file = barrier-litmus-test.flat
+smp = 2
+extra_params = -append 'mp_barrier'
+groups = barrier
+accel = tcg
+
+[barrier-litmus::mp-acqrel]
+file = barrier-litmus-test.flat
+smp = 2
+extra_params = -append 'mp_acqrel'
+groups = barrier
+accel = tcg
config/config-arm-common.mak +2 -0
index 6857261..023a0c3 100644
@@ -14,6 +14,7 @@ tests-common += $(TEST_DIR)/spinlock-test.flat
 tests-common += $(TEST_DIR)/ipi-test.flat
 tests-common += $(TEST_DIR)/tlbflush-test.flat
 tests-common += $(TEST_DIR)/locking-test.flat
+tests-common += $(TEST_DIR)/barrier-litmus-test.flat
 
 all: test_cases
 
@@ -76,3 +77,4 @@ $(TEST_DIR)/spinlock-test.elf: $(cstart.o) $(TEST_DIR)/spinlock-test.o
 $(TEST_DIR)/ipi-test.elf: $(cstart.o) $(TEST_DIR)/ipi-test.o
 $(TEST_DIR)/tlbflush-test.elf: $(cstart.o) $(TEST_DIR)/tlbflush-test.o
 $(TEST_DIR)/locking-test.elf: $(cstart.o) $(TEST_DIR)/locking-test.o
+$(TEST_DIR)/barrier-litmus-test.elf: $(cstart.o) $(TEST_DIR)/barrier-litmus-test.o
lib/arm/asm/barrier.h +62 -1

75 lines not on this page · raw message

lib/arm64/asm/barrier.h +50 -0

54 lines not on this page · raw message

Signature · 1 line
2.7.1
#15 lore raw

RFC 11/11 arm/tcg-test: some basic TCG exercising tests

In reply to Alex Bennée

These tests are not really aimed at KVM at all but exist to stretch QEMU's TCG code generator. In particular these exercise the ability of the TCG to:

* Chain TranslationBlocks together (tight)
* Handle heavy usage of the tb_jump_cache (paged)
* Pathological case of computed local jumps (computed)

In addition the tests can be varied by adding IPI IRQs or SMC sequences into the mix to stress the tcg_exit and invalidation mechanisms.

---
 arm/tcg-test-asm.S           | 170 +++++++++++++++++++++++++++++
 arm/tcg-test.c               | 248 +++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg            |  90 ++++++++++++++++
 config/config-arm-common.mak |   2 +
 4 files changed, 510 insertions(+)
 create mode 100644 arm/tcg-test-asm.S
 create mode 100644 arm/tcg-test.c
arm/tcg-test-asm.S new file +170 -0
new file mode 100644
index 0000000..6e823b7
@@ -0,0 +1,170 @@
+/*
+ * TCG Test assembler functions for armv7 tests.
+ *
+ * Copyright (C) 2016, Linaro Ltd, Alex Bennée <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ *
+ * These helper functions are written in pure asm to control the size
+ * of the basic blocks and ensure they fit neatly into page
+ * aligned chunks. The pattern of branches they follow is determined by
+ * the 32 bit seed they are passed. It should be the same for each set.
+ *
+ * Calling convention
+ *  - r0, iterations
+ *  - r1, jump pattern
+ *  - r2-r3, scratch
+ *
+ * Returns r0
+ */
+
+.arm
+
+.section .text
+
+/* Tight - all blocks should quickly be patched and should run
+ * very fast unless irqs or smc gets in the way
+ */
+
+.global tight_start
+tight_start:
+        subs    r0, r0, #1
+        beq     tight_end
+
+        ror     r1, r1, #1
+        tst     r1, #1
+        beq     tightA
+        b       tight_start
+
+tightA:
+        subs    r0, r0, #1
+        beq     tight_end
+
+        ror     r1, r1, #1
+        tst     r1, #1
+        beq     tightB
+        b       tight_start
+
+tightB:
+        subs    r0, r0, #1
+        beq     tight_end
+
+        ror     r1, r1, #1
+        tst     r1, #1
+        beq     tight_start
+        b       tightA
+
+.global tight_end
+tight_end:
+        mov     pc, lr
+
+/*
+ * Computed jumps cannot be hardwired into the basic blocks so each one
+ * will cause an exit for the main execution loop to look up the next block.
+ *
+ * There is some caching which should ameliorate the cost a little.
+ */
+
+        /* Align << 13 == 4096 byte alignment */
+        .align 13
+        .global computed_start
+computed_start:
+        subs    r0, r0, #1
+        beq     computed_end
+
+        /* Jump table */
+        ror     r1, r1, #1
+        and     r2, r1, #1
+        adr     r3, computed_jump_table
+        ldr     r2, [r3, r2, lsl #2]
+        mov     pc, r2
+
+        b       computed_err
+
+computed_jump_table:
+        .word   computed_start
+        .word   computedA
+
+computedA:
+        subs    r0, r0, #1
+        beq     computed_end
+
+        /* Jump into code */
+        ror     r1, r1, #1
+        and     r2, r1, #1
+        adr     r3, 1f
+        add	r3, r2, lsl #2
+        mov     pc, r3
+1:      b       computed_start
+        b       computedB
+
+        b       computed_err
+
+
+computedB:
+        subs    r0, r0, #1
+        beq     computed_end
+        ror     r1, r1, #1
+
+        /* Conditional register load */
+        adr     r3, computedA
+        tst     r1, #1
+        adreq   r3, computed_start
+        mov     pc, r3
+
+        b       computed_err
+
+computed_err:
+        mov     r0, #1
+        .global computed_end
+computed_end:
+        mov     pc, lr
+
+
+/*
+ * Page hoping
+ *
+ * Each block is in a different page, hence the blocks never get joined
+ */
+        /* Align << 13 == 4096 byte alignment */
+        .align 13
+        .global paged_start
+paged_start:
+        subs    r0, r0, #1
+        beq     paged_end
+
+        ror     r1, r1, #1
+        tst     r1, #1
+        beq     pagedA
+        b       paged_start
+
+        /* Align << 13 == 4096 byte alignment */
+        .align 13
+pagedA:
+        subs    r0, r0, #1
+        beq     paged_end
+
+        ror     r1, r1, #1
+        tst     r1, #1
+        beq     pagedB
+        b       paged_start
+
+        /* Align << 13 == 4096 byte alignment */
+        .align 13
+pagedB:
+        subs    r0, r0, #1
+        beq     paged_end
+
+        ror     r1, r1, #1
+        tst     r1, #1
+        beq     paged_start
+        b       pagedA
+
+        /* Align << 13 == 4096 byte alignment */
+        .align 13
+.global paged_end
+paged_end:
+        mov     pc, lr
+
+.global test_code_end
+test_code_end:
arm/tcg-test.c new file +248 -0

248 lines not on this page · raw message

arm/unittests.cfg +90 -0

99 lines not on this page · raw message

config/config-arm-common.mak +2 -0
index 023a0c3..23208b0 100644
@@ -15,6 +15,7 @@ tests-common += $(TEST_DIR)/ipi-test.flat
 tests-common += $(TEST_DIR)/tlbflush-test.flat
 tests-common += $(TEST_DIR)/locking-test.flat
 tests-common += $(TEST_DIR)/barrier-litmus-test.flat
+tests-common += $(TEST_DIR)/tcg-test.flat
 
 all: test_cases
 
@@ -78,3 +79,4 @@ $(TEST_DIR)/ipi-test.elf: $(cstart.o) $(TEST_DIR)/ipi-test.o
 $(TEST_DIR)/tlbflush-test.elf: $(cstart.o) $(TEST_DIR)/tlbflush-test.o
 $(TEST_DIR)/locking-test.elf: $(cstart.o) $(TEST_DIR)/locking-test.o
 $(TEST_DIR)/barrier-litmus-test.elf: $(cstart.o) $(TEST_DIR)/barrier-litmus-test.o
+$(TEST_DIR)/tcg-test.elf: $(cstart.o) $(TEST_DIR)/tcg-test.o $(TEST_DIR)/tcg-test-asm.o
Signature · 1 line
2.7.1
#16 lore raw
In reply to Alex Bennée
Quoted 40 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Quoted 4 lines

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

drew

#17 lore raw
Quoted 46 lines · Andrew Jones
Quoted 40 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Quoted 4 lines

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

Quoted 4 lines

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

Cool.

One thing I noticed was a slight disparity between the number of IPI IRQs sent and the number received. However I'm assuming this could well be without any explicit synchronisation a second IPI can get swallowed up if the first hasn't been acknowledged yet.

Is there any sane/safe way for gic_send_sgi to know if the IRQ was pending when it flips the bit?

Quoted 2 lines

drew

--
Alex Bennée

#18 lore raw
Quoted 54 lines · Alex Bennée
Quoted 46 lines · Andrew Jones
Quoted 40 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Quoted 4 lines

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

Quoted 4 lines

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

Quoted 6 lines

Cool.

One thing I noticed was a slight disparity between the number of IPI IRQs sent and the number received. However I'm assuming this could well be without any explicit synchronisation a second IPI can get swallowed up if the first hasn't been acknowledged yet.

Hmm, this version of the test only sends/receives a single IPI, so it should always be one/one. Or, are you watching the interrupts somewhere else, and seeing more generated?

Quoted 3 lines

Is there any sane/safe way for gic_send_sgi to know if the IRQ was pending when it flips the bit?

The new version wraps the acking in an if (iar != GICC_INT_SPURIOUS) condition (I ripped that off of Marc's assembler version). That may "fix" things for you, but then the question is why do you see spurious interrupts? I'll add code that counts spurious interrupts too.

Thanks,
drew

#19 lore raw
Quoted 57 lines · Andrew Jones
Quoted 56 lines · Alex Bennée
Quoted 46 lines · Andrew Jones
Quoted 40 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Quoted 4 lines

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

Quoted 4 lines

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

Cool.

Quoted 8 lines
Quoted 4 lines

One thing I noticed was a slight disparity between the number of IPI IRQs sent and the number received. However I'm assuming this could well be without any explicit synchronisation a second IPI can get swallowed up if the first hasn't been acknowledged yet.

Hmm, this version of the test only sends/receives a single IPI, so it should always be one/one. Or, are you watching the interrupts somewhere else, and seeing more generated?

Sorry I should have been clear. In my tcg-test with the "irq" modifier which sends an IRQ to every CPU every n-iterations.

Quoted 7 lines
Quoted 2 lines

Is there any sane/safe way for gic_send_sgi to know if the IRQ was pending when it flips the bit?

The new version wraps the acking in an if (iar != GICC_INT_SPURIOUS) condition (I ripped that off of Marc's assembler version). That may "fix" things for you, but then the question is why do you see spurious interrupts? I'll add code that counts spurious interrupts too.

Not spurious, less received than sent. I'll double check the code and make sure I count them up right.

Quoted 3 lines

Thanks,
drew

--
Alex Bennée

#20 lore raw
In reply to Andrew Jones
Quoted 46 lines · Andrew Jones
Quoted 40 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Quoted 4 lines

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

Quoted 4 lines

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

I'm getting ready to post the current iteration and I realised I hadn't seen your updates. Have they gone public anywhere?

Quoted 2 lines

drew

--
Alex Bennée

#21 lore raw
Quoted 49 lines · Alex Bennée
Quoted 46 lines · Andrew Jones
Quoted 44 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

Quoted 7 lines
Quoted 4 lines

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

I'm getting ready to post the current iteration and I realised I hadn't seen your updates. Have they gone public anywhere?

Sorry. I didn't finish polishing the gicv3 stuff so didn't end up sending anything. I'll send something tomorrow (same story as last time, if not gicv3 stuff, at least updated gicv2 :-)

Thanks,
drew

#22 lore raw
Quoted 55 lines · Andrew Jones
Quoted 54 lines · Alex Bennée
Quoted 50 lines · Andrew Jones
Quoted 40 lines · Alex Bennée

Hi,

Some of these patches have been posted before and previous patches have already been accepted upstream so I'm tagging this as a new RFC series.

This is a series of tests built around kvm-unit-tests but built with the express purpose of stressing the TCG, in particular MTTCG builds.

Changes from previous appearances:

* Separated locking and barrier tests
* Included Drew's IPI patches (used in tcg-test)
* New TCG chaining test

The new barrier tests really only fails when running on MTTCG builds on a weak backend. Many thanks to Will Deacon for helping me get a working test case at the last Connect.

I'm mainly posting these for reference for others testing MTTCG as I've still got to check I've addressed any outstanding review comments. However there has been enough code churn some of the comments may no longer be relevant.

The TCG tests are also useful as benchmarks for comparing the cost of having chained basic blocks versus exiting the loop every time. The pathological case is the computed jumps test as all the addresses are within a PAGE_SIZE boundary the tb_jump_cache has no effect meaning a full look up each time.

Alex Bennée (8):
config/config-arm-common: build-up tests-common target
lib: add isaac prng library from CCAN arm/run: set indentation defaults for emacs arm/run: allow aarch64 to start arm binaries arm/tlbflush-test: Add TLB torture test arm/locking-tests: add comprehensive locking test arm/barrier-litmus-tests: add some litmus tests arm/tcg-test: some basic TCG exercising tests

Quoted 4 lines

Andrew Jones (3):
arm/arm64: irq enable/disable
arm/arm64: Add initial gic support
arm/arm64: Add IPI test

I've actually updated these patches a bit, and started extending the series to also work with a v3 gic. I'll pick that back up and get it posted for you (hopefully next week). Or I'll at least update my arm/ipi-test branch with the changes I've made for gicv2...

Quoted 6 lines
Quoted 2 lines

I'm getting ready to post the current iteration and I realised I hadn't seen your updates. Have they gone public anywhere?

Sorry. I didn't finish polishing the gicv3 stuff so didn't end up sending anything. I'll send something tomorrow (same story as last time, if not gicv3 stuff, at least updated gicv2 :-)

I didn't find enough time to play with gicv3 today, but I considered it in the framework (added some stub functions). New branch is here[*]. I hope to add the gicv3 functionality and post soon.

[*] https://github.com/rhdrjones/kvm-unit-tests/commits/arm/ipi-test-new

Thanks,
drew