From patchwork Wed Mar 24 17:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Nikoleris X-Patchwork-Id: 12161867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12CF9C433DB for ; Wed, 24 Mar 2021 17:15:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E251261A1A for ; Wed, 24 Mar 2021 17:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237051AbhCXROb (ORCPT ); Wed, 24 Mar 2021 13:14:31 -0400 Received: from foss.arm.com ([217.140.110.172]:36886 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236702AbhCXROQ (ORCPT ); Wed, 24 Mar 2021 13:14:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FFFC106F; Wed, 24 Mar 2021 10:14:16 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 49A363F7D7; Wed, 24 Mar 2021 10:14:15 -0700 (PDT) From: Nikos Nikoleris To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, drjones@redhat.com, alexandru.elisei@arm.com, Nikos Nikoleris Subject: [kvm-unit-tests PATCH 1/3] arm/arm64: Avoid wildcard in the arm_clean recipe of the Makefile Date: Wed, 24 Mar 2021 17:14:00 +0000 Message-Id: <20210324171402.371744-2-nikos.nikoleris@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210324171402.371744-1-nikos.nikoleris@arm.com> References: <20210324171402.371744-1-nikos.nikoleris@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This change adds recipes to discover the generated .o and .d files and removes assumptions about their locations in the arm_clean recipe. Signed-off-by: Nikos Nikoleris --- arm/Makefile.common | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arm/Makefile.common b/arm/Makefile.common index a123e85..19db50d 100644 --- a/arm/Makefile.common +++ b/arm/Makefile.common @@ -78,9 +78,12 @@ FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi) $(libeabi): $(eabiobjs) $(AR) rcs $@ $^ +generated-o = $(cflatobjs) $(eabiobjs) $(cstart.o) $(tests-all:.flat=.o) +generated-d = $(join $(dir $(generated-o)), $(addprefix ., $(notdir $(generated-o:.o=.d)))) + arm_clean: libfdt_clean asm_offsets_clean - $(RM) $(TEST_DIR)/*.{o,flat,elf} $(libeabi) $(eabiobjs) \ - $(TEST_DIR)/.*.d lib/arm/.*.d + $(RM) $(generated-d) + $(RM) $(generated-o) $(tests-all:.flat=.elf) $(tests-all) $(libeabi) generated-files = $(asm-offsets) $(tests-all:.flat=.o) $(cstart.o) $(cflatobjs): $(generated-files) From patchwork Wed Mar 24 17:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Nikoleris X-Patchwork-Id: 12161871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74C7EC433E3 for ; Wed, 24 Mar 2021 17:15:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B31861A2E for ; Wed, 24 Mar 2021 17:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237121AbhCXROd (ORCPT ); Wed, 24 Mar 2021 13:14:33 -0400 Received: from foss.arm.com ([217.140.110.172]:36892 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236975AbhCXROR (ORCPT ); Wed, 24 Mar 2021 13:14:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D6A9113E; Wed, 24 Mar 2021 10:14:17 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 548123F7D7; Wed, 24 Mar 2021 10:14:16 -0700 (PDT) From: Nikos Nikoleris To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, drjones@redhat.com, alexandru.elisei@arm.com, Nikos Nikoleris Subject: [kvm-unit-tests PATCH 2/3] arm/arm64: Add a way to specify an external directory with tests Date: Wed, 24 Mar 2021 17:14:01 +0000 Message-Id: <20210324171402.371744-3-nikos.nikoleris@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210324171402.371744-1-nikos.nikoleris@arm.com> References: <20210324171402.371744-1-nikos.nikoleris@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This change adds an argument to the configure script which allows a user to specify an external directory with extra tests. When specified, the build system will include the Makefile in that directory allowing a user to add extra tests. For example: For example, DIR contains a test in test.c which depends on symbols defined in obj.c and the Makefile: tests += $(EXT_DIR)/test.flat cflatobjs += $(EXT_DIR)/obj.o With this change, we can add DIR to the build process and generate the test using $> ./configure --ext-dir=DIR $> make Signed-off-by: Nikos Nikoleris --- configure | 7 +++++++ arm/Makefile.common | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/configure b/configure index cdcd34e..e734b9d 100755 --- a/configure +++ b/configure @@ -26,6 +26,7 @@ errata_force=0 erratatxt="$srcdir/errata.txt" host_key_document= page_size= +ext_dir= usage() { cat <<-EOF @@ -54,6 +55,8 @@ usage() { --page-size=PAGE_SIZE Specify the page size (translation granule) (4k, 16k or 64k, default is 64k, arm64 only) + --ext-dir=DIR specify an additional location with more tests; when enabled + DIR/Makefile is included to the build system (arm/arm64 only) EOF exit 1 } @@ -112,6 +115,9 @@ while [[ "$1" = -* ]]; do --page-size) page_size="$arg" ;; + --ext-dir) + ext_dir="$arg" + ;; --help) usage ;; @@ -264,6 +270,7 @@ U32_LONG_FMT=$u32_long WA_DIVIDE=$wa_divide GENPROTIMG=${GENPROTIMG-genprotimg} HOST_KEY_DOCUMENT=$host_key_document +EXT_DIR=$ext_dir EOF cat < lib/config.h diff --git a/arm/Makefile.common b/arm/Makefile.common index 19db50d..ffe1a49 100644 --- a/arm/Makefile.common +++ b/arm/Makefile.common @@ -13,6 +13,10 @@ tests-common += $(TEST_DIR)/psci.flat tests-common += $(TEST_DIR)/sieve.flat tests-common += $(TEST_DIR)/pl031.flat +ifdef EXT_DIR +include $(EXT_DIR)/Makefile +endif + tests-all = $(tests-common) $(tests) all: directories $(tests-all) From patchwork Wed Mar 24 17:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Nikoleris X-Patchwork-Id: 12161869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5424DC433E1 for ; Wed, 24 Mar 2021 17:15:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D32C61A1E for ; Wed, 24 Mar 2021 17:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237103AbhCXROd (ORCPT ); Wed, 24 Mar 2021 13:14:33 -0400 Received: from foss.arm.com ([217.140.110.172]:36898 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236983AbhCXROS (ORCPT ); Wed, 24 Mar 2021 13:14:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 390DFED1; Wed, 24 Mar 2021 10:14:18 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62B3D3F7D7; Wed, 24 Mar 2021 10:14:17 -0700 (PDT) From: Nikos Nikoleris To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, drjones@redhat.com, alexandru.elisei@arm.com, Nikos Nikoleris Subject: [kvm-unit-tests PATCH 3/3] README: Add a guide of how to run tests with litmus7 Date: Wed, 24 Mar 2021 17:14:02 +0000 Message-Id: <20210324171402.371744-4-nikos.nikoleris@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210324171402.371744-1-nikos.nikoleris@arm.com> References: <20210324171402.371744-1-nikos.nikoleris@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org litmus7 (http://diy.inria.fr/doc/litmus.html) is a tool that takes as an input a litmus test specification and generates a program that can execute on hardware. Using kvm-unit-tests, litmus7 can generate tests that run on KVM. This change adds some documentation to introduce this functionality along with a basic example of how to build and run such tests. Signed-off-by: Nikos Nikoleris --- README.litmus7.md | 125 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 README.litmus7.md diff --git a/README.litmus7.md b/README.litmus7.md new file mode 100644 index 0000000..4653488 --- /dev/null +++ b/README.litmus7.md @@ -0,0 +1,125 @@ +# Memory model litmus tests as kvm-unit-tests + +In this guide, we explain how to use kvm-unit-tests in combination +with litmus7 to generate and run litmus tests as tiny operating +systems. + +## Background + +### Memory model litmus tests + +A litmus test is a small program designed to exercise a certain +behavior. Traditionally, litmus tests have been used to demonstrate +and exercise the memory model of parallel computing systems. Litmus +tests are often described in assembly or pseudo-assembly code and +require tools like [litmus7](http://diy.inria.fr/doc/litmus.html) to +genererate executable programs that we can then run on real hardware. + +### Why kvm-unit-tests + +litmus7 uses kvm-unit-tests to encapsulate a litmus tests and generate +executables in the form of tiny operating systems. Inside these tiny +operating systems, the litmus tests can control parameters of the +execution that a user space application cannot. For example, control +virtual address translation and handle exceptions. + +## Building and running litmus kvm-unit-tests + +litmus7 is a tool that given a litmus test will generate C source +code. The generated C source code is compiled and linked with +kvm-unit-tests to generate the binary. + +## Prerequisites + +litmus7 is part of the herdtools7 toolsuite. See +https://github.com/herd/herdtools7/blob/master/INSTALL.md for +instructions of how to build and install herdtools7 from source. + +In addition to herdtools7, this guide assumes that you have a copy of +kvm-unit-tests and you have already configured and built the included +tests. + +## Building and running a litmus test + +In this guide, we use `MP` (Message Passing), a popular litmus test +which demonstrates the communication pattern between a sender (P0) and +a receiver (P1_ process of a message `x`. There is also variable `y` +which is a flag, the sender sets it after setting the message `x` and +the receiver reads it before reading the message `x`. The test also +specifies a condition after the execution of the test which is +validated when P1 reads the initial value of message `x` (0) and the +new value of flag `y` (1). + +``` +AArch64 MP +"PodWW Rfe PodRR Fre" +Generator=diyone7 (version 7.56) +Prefetch=0:x=F,0:y=W,1:y=F,1:x=T +Com=Rf Fr +Orig=PodWW Rfe PodRR Fre +{ +0:X1=x; 0:X3=y; +1:X1=y; 1:X3=x; +} + P0 | P1 ; + MOV W0,#1 | LDR W0,[X1] ; + STR W0,[X1] | LDR W2,[X3] ; + MOV W2,#1 | ; + STR W2,[X3] | ; +exists (1:X0=1 /\ 1:X2=0) +``` + +Note: [diy7](http://diy.inria.fr/doc/gen.html) and +[diyone7]](http://diy.inria.fr/doc/gen.html) from the herdtools7 +toolsuite can systematically generate litmus tests. For example to +generate the MP litmus test: + + diyone7 -arch AArch64 PodWW Rfe PodRR Fre -name MP + +Assuming the file `MP.litmus` contains the test and KUT_DIR is the top +directory of kvm-unit-tests, we can use litmus7 to generate +the C sources: + + litmus7 -mach kvm-armv8.1 -variant precise -a 4 -o ${KUT_DIR}/litmus_tests MP.litmus + +To build the test: + + cd litmus-tests && make && cd - + +This will build the test in the file `litmus-tests/MP.flat` which you +can run like any other test: + + ./arm/run litmus-tests/MP.flat -smp 4 + +The test will print whether the condition of the test was observed +(`Allowed`), stats about the observed outcomes and metadata (e.g., +hash). + +``` +Test MP Allowed +Histogram (4 states) +19865 :>1:X0=0; 1:X2=1; +20885 *>1:X0=1; 1:X2=0; +975348:>1:X0=0; 1:X2=0; +983902:>1:X0=1; 1:X2=1; +Ok + +Witnesses +Positive: 20885, Negative: 1979115 +Condition exists (1:X0=1 /\ 1:X2=0) is validated +Hash=211d5b298572012a0869d4ded6a40b7f +Cycle=Rfe PodRR Fre PodWW +Generator=diycross7 (version 7.54+01(dev)) +Com=Rf Fr +Orig=PodWW Rfe PodRR Fre +Observation MP Sometimes 20885 1979115 +Time MP 3.19 +``` + +## References + +https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/expanding-memory-model-tools-system-level-architecture +https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/running-litmus-tests-on-hardware-litmus7 +http://diy.inria.fr/doc/litmus.html +https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/generate-litmus-tests-automatically-diy7-tool +http://diy.inria.fr/doc/gen.html