From 05af9b0361ac5eab58f46e5451e585c9625c3b75 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 8 Sep 2015 20:22:41 +0200 Subject: [PATCH] arm/arm64: Add IPI test Signed-off-by: Andrew Jones --- arm/ipi-test.c | 58 ++++++++++++++++++++++++++++++++++++ config/config-arm-common.mak | 4 ++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 arm/ipi-test.c diff --git a/arm/ipi-test.c b/arm/ipi-test.c new file mode 100644 index 00000000..705295f6 --- /dev/null +++ b/arm/ipi-test.c @@ -0,0 +1,58 @@ +/* + * Test sending an IPI and handling IRQ exceptions. + * + * Copyright (C) 2015, Red Hat Inc, Andrew Jones + * + * This work is licensed under the terms of the GNU LGPL, version 2. + */ +#include +#include +#include +#include +#include +#include + +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(); +} diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak index 698555d6..4262e3ae 100644 --- a/config/config-arm-common.mak +++ b/config/config-arm-common.mak @@ -11,7 +11,8 @@ endif tests-common = \ $(TEST_DIR)/selftest.flat \ - $(TEST_DIR)/spinlock-test.flat + $(TEST_DIR)/spinlock-test.flat \ + $(TEST_DIR)/ipi-test.flat all: test_cases @@ -70,3 +71,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