From patchwork Wed Sep 11 16:49:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 173621 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp994855ilq; Wed, 11 Sep 2019 09:51:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVSnhlyF7dIlQbxN3vJeS5gJpMsUsD0TXQDZ6BvosdGne4iCwd4AZtHN6qpSm7d8gNz/wM X-Received: by 2002:a0c:fc05:: with SMTP id z5mr16058218qvo.128.1568220708974; Wed, 11 Sep 2019 09:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568220708; cv=none; d=google.com; s=arc-20160816; b=Qjz54fM1410CQczG7dVHCIrRxfio3DDZuq/8iuEhHQnbqfxphyeVrtqnNqegdQ15Sh 5ofGjGgsG1uo0b0lLk3es616s6hmj6Re3Z1a197yo3MOHu5B2E/c0gsdtplq3Wgis0K0 dq77RekpggyMY720we1B/Uy5ZLs0P0XphaCnUpRYGp734f9+bKWWKQejyxUDK6gk4mzM QUGcr4asEKCtyaAD3GIztYWjcVyoL1i/Yxn+uD3SUC6kUNlUUF+1a+Qc4rnPo+GaaiIM NzClN7SOTzFJYaz7CPeehEWf3mS9C3CDMwHvOpch/csLdBpHNlXyNxmauo5XWMPmlb2Z bLAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AP1T2XSjOl2lJh+/fDSQgEAsr5iAzl9ejFzzWbjY7Ww=; b=ZJyxFglQk9vqscGdCBfl2YmFpYr/Mn2za+w8kDLiPWeCVoQonQdtRYyN0ij/eo9Z7e tWd+RcwtbDx36rufrtqd/6Sp8T4k/nsW7VTOoTqTENbBFthHUXyhUwUt8QtX9RV48zN9 6+tYFedV+bIHkCSnyY7TKJotRwjxdjy4Mfv9l7pEezLKzFduTRgKP5JckouYZ9I2sj1G spWj6EXqHDy1oJW9/+i9wrrw0C2oYlq0gS8vqlnauPTL/GrIy4JpG6u08/b/qxzsK4cD FujaaUgb9BxoW1ysQ9RPlnWFsrAT7LrHPqo3G4nys8ZTaZVffSNlmjirsGoT5/s9IDcJ mo+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ff+00vDx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 89si8553421qtc.116.2019.09.11.09.51.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 09:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ff+00vDx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i85qO-0006y5-11 for patch@linaro.org; Wed, 11 Sep 2019 12:51:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43569) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i85ol-0006Wb-Lp for qemu-devel@nongnu.org; Wed, 11 Sep 2019 12:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i85ok-0004AU-67 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 12:50:07 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:53732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i85oj-00049a-Rz for qemu-devel@nongnu.org; Wed, 11 Sep 2019 12:50:06 -0400 Received: by mail-wm1-x341.google.com with SMTP id q18so4306269wmq.3 for ; Wed, 11 Sep 2019 09:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AP1T2XSjOl2lJh+/fDSQgEAsr5iAzl9ejFzzWbjY7Ww=; b=Ff+00vDxm782CQz2NYha0vGGnSqPvqMC1mrq5f3BS497P9RqA0L6hs3rFIs6J2A3z5 kwXN5pdHvH7xeLNOcuo+oQ+4lZApbgi2KqaB674LAq/FC7MZqQLetoG2u6JFjLAJegzJ bN3BEdt7K/dk7Pc3TuWVfBBMc19/52AFUZnKVS+sk/cOtCj+2QoWcr/hb+TJng0Qj/o4 p9DYSwmUaOEVZsVD3pSZwTt7KJ4nryBWHr6NklmmJPjpqUrSntWLS8zAHKxa8Ce/CDO5 JpFzCKug0mCtyNsu1FbHc92g7kLTRDtDn1RPukSG2rBfWFHSQAg6Cggwbdo9vviAcS/x OUNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AP1T2XSjOl2lJh+/fDSQgEAsr5iAzl9ejFzzWbjY7Ww=; b=b3SeBKUonriVF32AGoo6/XIu7y0k05GnwtVcg2S/gVVwBUUQGsNNbjD0eGt3YQKbYQ MgcgZ+JkGfYWL3kWwpakFVidJ8CYIwd9DwtjQKKc5ihfQ8Q9TMn3ePxChRlYs8EI1URJ VX3TpV3zoxi+XepYb/m8JEAIYGet1EEMxAcfEbHAgaHmg3QxaanCPNjDqdgIAW/Pegcb e0NRiEC/xM2+Hqn1H7NjTeRJd2sYfxsD3Qa5pRTKXvG55H8s5vvvZxcI8IlAcqz6BDMg F7B/zBTXw+BSaNdcZ1FyIIXKCkSi6/Lt8Zc0gLKXMlCWu7Sps4kSfu1neo1pf4XZvQYL VSLg== X-Gm-Message-State: APjAAAV2KRSH9DA47G9wBxnPM2iOhu4oNMhJrmq+x6SbA+Yv0FTwnra9 2VYm2pTSzGfDbg0tD0K4dy2nqrBzjD0= X-Received: by 2002:a05:600c:293:: with SMTP id 19mr4466815wmk.37.1568220604685; Wed, 11 Sep 2019 09:50:04 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a7sm25915726wra.43.2019.09.11.09.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 09:50:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D3B691FF92; Wed, 11 Sep 2019 17:50:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 11 Sep 2019 17:49:59 +0100 Message-Id: <20190911164959.11003-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190911164959.11003-1-alex.bennee@linaro.org> References: <20190911164959.11003-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v5 5/5] target/arm: remove run-time semihosting checks for linux-user X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , qemu-arm@nongnu.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now we do all our checking at translate time we can make cpu_loop a little bit simpler. We also introduce a simple linux-user semihosting test case to defend the functionality. The out-of-tree softmmu based semihosting tests are still more comprehensive. Signed-off-by: Alex Bennée --- linux-user/arm/cpu_loop.c | 3 --- linux-user/arm/target_syscall.h | 3 --- tests/tcg/aarch64/Makefile.target | 5 ++++ tests/tcg/arm/Makefile.target | 5 ++++ tests/tcg/arm/semihosting.c | 45 +++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 tests/tcg/arm/semihosting.c -- 2.20.1 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 8d65de5b9f4..e28c45cd4ab 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -325,9 +325,6 @@ void cpu_loop(CPUARMState *env) if (n == ARM_NR_cacheflush) { /* nop */ - } else if (n == ARM_NR_semihosting - || n == ARM_NR_thumb_semihosting) { - env->regs[0] = do_arm_semihosting (env); } else if (n == 0 || n >= ARM_SYSCALL_BASE || env->thumb) { /* linux syscall */ if (env->thumb || n == 0) { diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h index afc0772e194..f85cbdaf56f 100644 --- a/linux-user/arm/target_syscall.h +++ b/linux-user/arm/target_syscall.h @@ -18,9 +18,6 @@ struct target_pt_regs { #define ARM_NR_set_tls (ARM_NR_BASE + 5) #define ARM_NR_get_tls (ARM_NR_BASE + 6) -#define ARM_NR_semihosting 0x123456 -#define ARM_NR_thumb_semihosting 0xAB - #if defined(TARGET_WORDS_BIGENDIAN) #define UNAME_MACHINE "armv5teb" #else diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 9758f89f905..509f1afa93d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -21,4 +21,9 @@ run-fcvt: fcvt AARCH64_TESTS += pauth-1 pauth-2 run-pauth-%: QEMU_OPTS += -cpu max +# Semihosting smoke test for linux-user +AARCH64_TESTS += semihosting +run-semihosting: semihosting + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + TESTS += $(AARCH64_TESTS) diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 7347d3d0adb..3b7fc9a64be 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -27,6 +27,11 @@ run-fcvt: fcvt $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) +# Semihosting smoke test for linux-user +ARM_TESTS += semihosting +run-semihosting: semihosting + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + TESTS += $(ARM_TESTS) # On ARM Linux only supports 4k pages diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/arm/semihosting.c new file mode 100644 index 00000000000..09c89cb481a --- /dev/null +++ b/tests/tcg/arm/semihosting.c @@ -0,0 +1,45 @@ +/* + * linux-user semihosting checks + * + * Copyright (c) 2019 + * Written by Alex Bennée + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include + +#define SYS_WRITE0 0x04 +#define SYS_REPORTEXC 0x18 + +void __semi_call(uintptr_t type, uintptr_t arg0) +{ +#if defined(__arm__) + register uintptr_t t asm("r0") = type; + register uintptr_t a0 asm("r1") = arg0; + asm("svc 0xab" + : /* no return */ + : "r" (t), "r" (a0)); +#else + register uintptr_t t asm("x0") = type; + register uintptr_t a0 asm("x1") = arg0; + asm("hlt 0xf000" + : /* no return */ + : "r" (t), "r" (a0)); +#endif +} + +int main(int argc, char *argv[argc]) +{ +#if defined(__arm__) + uintptr_t exit_code = 0x20026; +#else + uintptr_t exit_block[2] = {0x20026, 0}; + uintptr_t exit_code = (uintptr_t) &exit_block; +#endif + + __semi_call(SYS_WRITE0, (uintptr_t) "Hello World"); + __semi_call(SYS_REPORTEXC, exit_code); + /* if we get here we failed */ + return -1; +}