From patchwork Wed Jul 4 19:58:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Esfahani via X-Patchwork-Id: 939582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nongnu.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mail.ru header.i=@mail.ru header.b="c03lQ7+k"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41LWzS6szFz9s2g for ; Thu, 5 Jul 2018 05:59:32 +1000 (AEST) Received: from localhost ([::1]:49034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fanw2-0004v3-Fr for incoming@patchwork.ozlabs.org; Wed, 04 Jul 2018 15:59:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fanvO-0004tC-Hj for qemu-devel@nongnu.org; Wed, 04 Jul 2018 15:58:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fanvL-0001ls-BB for qemu-devel@nongnu.org; Wed, 04 Jul 2018 15:58:50 -0400 Received: from smtp37.i.mail.ru ([94.100.177.97]:51456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fanvL-0001l6-2F for qemu-devel@nongnu.org; Wed, 04 Jul 2018 15:58:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Iqwgw1AmpCeOMK+FtjGhwZzlNEyu93a52V80bEbwa9Q=; b=c03lQ7+k7KHr9tVRfkoJOQy/vMh6ld9UC1m03UB8RaG2cgtATjsc/8FJjRfTlp7dLheVuiHU9ftmAYI0KQZWqEqzFcRa7ehToNYIiUGOMTDEuR2pzsyo/RYBp6oSp1G4vpDbT+wst1Vkb0KEGupEGTeujSe2Emdtsu+49PV2M7Q=; Received: by smtp37.i.mail.ru with esmtpa (envelope-from ) id 1fanvJ-0007a4-7N; Wed, 04 Jul 2018 22:58:45 +0300 To: qemu-devel@nongnu.org Date: Wed, 4 Jul 2018 22:58:12 +0300 Message-Id: <20180704195812.28798-3-jusual@mail.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180704195812.28798-1-jusual@mail.ru> References: <20180704195812.28798-1-jusual@mail.ru> Authentication-Results: smtp37.i.mail.ru; auth=pass smtp.auth=jusual@mail.ru smtp.mailfrom=jusual@mail.ru X-7FA49CB5: 0D63561A33F958A5A8332615784465FC30657E86835CCC17BB5A7B0D773225A00A6AB1C7CE11FEE34AF66DFF1D4D208B76E601842F6C81A1F004C906525384306FED454B719173D6725E5C173C3A84C37952320C71F5F86719BF08CBC38C640DD05AD665AB97B35DC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0FECB2555BB02FD5A93B503F486389A921A5CC5B56E945C8DA X-Mailru-Sender: 7766D515518070DE138AAC7428EA760D8A8C259E07818792701FF501C2A73D5067C2D45AF0EACA2E7C4160E8B47E48163DDE9B364B0DF2898CB68AF7A628805D594FB4C9F0DBF412AE208404248635DF X-Mras: OK X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 94.100.177.97 Subject: [Qemu-devel] [RFC 2/2] tests: Add ARMv6-M reserved register test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Julia Suvorova via Qemu-devel From: Cameron Esfahani via Reply-To: Julia Suvorova Cc: Peter Maydell , Jim Mussared , =?utf-8?q?Steffen_G=C3=B6rtz?= , Joel Stanley , Stefan Hajnoczi , Julia Suvorova Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Check that reserved SCS registers return 0 at read, and writes are ignored. Based-on: <20180627143815.1829-1-joel@jms.id.au> Based-on: <20180630091343.14391-1-stefanha@redhat.com> Signed-off-by: Julia Suvorova --- Test will work if Joel's patches will use ARMv6-M. tests/Makefile.include | 2 ++ tests/tcg/arm/test-reserved-reg.c | 60 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/tcg/arm/test-reserved-reg.c diff --git a/tests/Makefile.include b/tests/Makefile.include index d323c42682..8ab0b0d15f 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -387,6 +387,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c check-qtest-arm-y += tests/boot-serial-test$(EXESUF) check-qtest-arm-y += tests/sdhci-test$(EXESUF) check-qtest-arm-y += tests/hexloader-test$(EXESUF) +check-qtest-arm-y += tests/tcg/arm/test-reserved-reg$(EXESUF) check-qtest-aarch64-y = tests/numa-test$(EXESUF) check-qtest-aarch64-y += tests/sdhci-test$(EXESUF) @@ -771,6 +772,7 @@ tests/device-introspect-test$(EXESUF): tests/device-introspect-test.o tests/rtc-test$(EXESUF): tests/rtc-test.o tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/hexloader-test$(EXESUF): tests/hexloader-test.o +tests/test-reserved-reg$(EXESUF): tests/tcg/arm/test-reserved-reg.o tests/endianness-test$(EXESUF): tests/endianness-test.o tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) tests/prom-env-test$(EXESUF): tests/prom-env-test.o $(libqos-obj-y) diff --git a/tests/tcg/arm/test-reserved-reg.c b/tests/tcg/arm/test-reserved-reg.c new file mode 100644 index 0000000000..97273ff24d --- /dev/null +++ b/tests/tcg/arm/test-reserved-reg.c @@ -0,0 +1,60 @@ +/* + * Test ARMv6-M SCS reserved registers + * + * Copyright (c) 2018 Julia Suvorova + * + * This work is licensed under the terms of the GNU GPL, version 2 + * or later. See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest.h" + +static void test_reserved_reg(void) +{ + QTestState *s; + int i; + static const uint64_t reserved_reg[] = { 0xe000ed10, /* SCR */ + 0xe000ed18, /* SHPR1 */ + 0xe000ed28, /* CFSR */ + 0xe000ed2c, /* HFSR */ + 0xe000ed34, /* MMFAR */ + 0xe000ed38, /* BFAR */ + 0xe000ed3c, /* AFSR */ + 0xe000ed40, /* CPUID */ + 0xe000ed88, /* CPACR */ + 0xe000ef00 /* STIR */ }; + static const uint8_t mini_kernel[] = { 0x00, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00 }; + ssize_t wlen, kernel_size = sizeof(mini_kernel); + int code_fd; + char codetmp[] = "/tmp/reserved-reg-test-XXXXXX"; + + code_fd = mkstemp(codetmp); + wlen = write(code_fd, mini_kernel, sizeof(mini_kernel)); + g_assert(wlen == kernel_size); + close(code_fd); + + s = qtest_startf("-kernel %s -M microbit -nographic", codetmp); + + for (i = 0; i < ARRAY_SIZE(reserved_reg); i++) { + int res; + qtest_writel(s, reserved_reg[i], 1); + res = qtest_readl(s, reserved_reg[i]); + g_assert(!res); + } + + qtest_quit(s); +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + + qtest_add_func("tcg/arm/test-reserved-reg", test_reserved_reg); + ret = g_test_run(); + + return ret; +}