From nobody Tue May 14 05:37:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388105; cv=none; d=zoho.com; s=zohoarc; b=XNZDF15uwfI8KoMWFjF/Q/fvPbU7nh739donqLSqtJT/jOJZ5NO/9mODvUi9N8/u4OexDPRTTUjsPFhXDmj7U6ZBvhMxYQI0sHsWLZxjCvD0QhaXodGLYAUMiaJfoXhJuQqBB6JNdtk9S+vJrBf9wDtSSejfD0cck/RYpXGc5dI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388105; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qkrQNPdYjgzsGeZKliHj5m6aTSoldYZ7J5gDgev0N24=; b=kNsolWrL2ffEr+EKmsY5XjlSDQxUkDq0CWNAzhJ3Wn8rfYCbyg0KaFfqmkDuI7YC5+GXSoC+tcCr065h92lkQDwQ0/jtC1CZnG0/mln2ZJeIobTmDWdZGZdEplusMmZTTImid8O1duL7qDz00QKyLHhejuU3f2jL4wBtR2EwbAY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568388105478448.9494871985746; Fri, 13 Sep 2019 08:21:45 -0700 (PDT) Received: from localhost ([::1]:45108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nOK-0001Cp-2r for importer@patchew.org; Fri, 13 Sep 2019 11:21:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52056) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLW-0007cF-7R for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLU-0000JD-Uy for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:50 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:54085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLU-0000IZ-OU for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:48 -0400 Received: by mail-wm1-x342.google.com with SMTP id q18so3189309wmq.3 for ; Fri, 13 Sep 2019 08:18:48 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r18sm32090869wrx.36.2019.09.13.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 86ABB1FF8C; Fri, 13 Sep 2019 16:18:45 +0100 (BST) 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=qkrQNPdYjgzsGeZKliHj5m6aTSoldYZ7J5gDgev0N24=; b=EU1qUetOU0pLY8bfY2VPwp6pm7Duz9HzhCyXxdYas1bRV4WwdsLbAlkzCDzUvFNNXa t1XdwPw+9QgI8EpWESEW02kCCIh6STzT7M/0dJ3snbd9jB8OX0CnQTWsXu6cYOvN23Zt ZV0Iue4n7kSkaM30xrNzHPHn320p4cxGpg4F0bhwVRwjVHlZayGx4oZ7MXQoa9E4IXeK hdbHA9ke6864qcA27QKY0SMNNeMox65EshHLW0dVxLRlkfWVHkag2ZykJ4uyLAnqNVMh P+LfcG+5i7kw6j44Okh4ixCoGVcV4NJMBBsKhEVy7B2M35cM6DRzLzNi3/KqExGIpPa0 Jv5A== 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=qkrQNPdYjgzsGeZKliHj5m6aTSoldYZ7J5gDgev0N24=; b=hCwUYNwyjuarV4+droNzLSjJx4BZC36Ru9s3dIYdt141V7pbKLnk4h4m/h53ficedY mzAFF+PdGUPiFqYDa7MTs1ddfA49utXUWyBtN+tXP9baCSvriqxWsAyGK1e8k6AMeKtH Q2r7Or3QWPoEh5QTaTNc1azQWVS2cBq07vfRM1QORoju4uvLW2L7ZRbU2EkSJqAdJu73 UjtX4DQuVIFDd9+gUirKn1x26DKV30q/arbV3rzdFQb7ZMUL9NXHSkl3iqEr9GmYcDfz 54IHRn7SCUcvN4gnlsR/euTs4vEUY1gCK4Pj06zoqyxPXvHjbtiXq+K+3Pj4dvkPpem2 s+9w== X-Gm-Message-State: APjAAAUnvHhKhfOlhITiYHDXv2s1QOiAhyHqllhccHNUf6uLRJijb9Zi zAUcoGcZ19p/OsteClHH+khu3w== X-Google-Smtp-Source: APXvYqzLEzYYSCt7zh5+odjfnwIE1KnIWwRED+WSrx/N1qUUh/XeaKYy46rtXvfgH0Jzutc9ejC51A== X-Received: by 2002:a7b:cf25:: with SMTP id m5mr3831855wmg.25.1568387927507; Fri, 13 Sep 2019 08:18:47 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:40 +0100 Message-Id: <20190913151845.12582-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v6 1/6] tests/tcg: clean-up some comments after the de-tangling 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) These were missed in the recent de-tangling so have been updated to be more actuate. I've also built up ARM_TESTS in a manner similar to AARCH64_TESTS for better consistency. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell --- tests/tcg/Makefile.target | 7 +++++-- tests/tcg/aarch64/Makefile.target | 3 ++- tests/tcg/arm/Makefile.target | 15 ++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 8808beaf74b..679eb56bd37 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -74,8 +74,11 @@ TIMEOUT=3D15 endif =20 ifdef CONFIG_USER_ONLY -# The order we include is important. We include multiarch, base arch -# and finally arch if it's not the same as base arch. +# The order we include is important. We include multiarch first and +# then the target. If there are common tests shared between +# sub-targets (e.g. ARM & AArch64) then it is up to +# $(TARGET_NAME)/Makefile.target to include the common parent +# architecture in its VPATH. -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target =20 diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index e763dd9da37..9758f89f905 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -8,7 +8,7 @@ VPATH +=3D $(ARM_SRC) AARCH64_SRC=3D$(SRC_PATH)/tests/tcg/aarch64 VPATH +=3D $(AARCH64_SRC) =20 -# we don't build any other ARM test +# Float-convert Tests AARCH64_TESTS=3Dfcvt =20 fcvt: LDFLAGS+=3D-lm @@ -17,6 +17,7 @@ run-fcvt: fcvt $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) =20 +# Pauth Tests AARCH64_TESTS +=3D pauth-1 pauth-2 run-pauth-%: QEMU_OPTS +=3D -cpu max =20 diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index aa4e4e3782c..7347d3d0adb 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -8,25 +8,26 @@ ARM_SRC=3D$(SRC_PATH)/tests/tcg/arm # Set search path for all sources VPATH +=3D $(ARM_SRC) =20 -ARM_TESTS=3Dhello-arm test-arm-iwmmxt - -TESTS +=3D $(ARM_TESTS) fcvt - +# Basic Hello World +ARM_TESTS =3D hello-arm hello-arm: CFLAGS+=3D-marm -ffreestanding hello-arm: LDFLAGS+=3D-nostdlib =20 +# IWMXT floating point extensions +ARM_TESTS +=3D test-arm-iwmmxt test-arm-iwmmxt: CFLAGS+=3D-marm -march=3Diwmmxt -mabi=3Daapcs -mfpu=3Dfpv= 4-sp-d16 test-arm-iwmmxt: test-arm-iwmmxt.S $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) =20 -ifeq ($(TARGET_NAME), arm) +# Float-convert Tests +ARM_TESTS +=3D fcvt fcvt: LDFLAGS+=3D-lm # fcvt: CFLAGS+=3D-march=3Darmv8.2-a+fp16 -mfpu=3Dneon-fp-armv8 - run-fcvt: fcvt $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) -endif + +TESTS +=3D $(ARM_TESTS) =20 # On ARM Linux only supports 4k pages EXTRA_RUNS+=3Drun-test-mmap-4096 --=20 2.20.1 From nobody Tue May 14 05:37:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388274; cv=none; d=zoho.com; s=zohoarc; b=ClfzBA55xCvpwfTdBs8oUMCdjg3HplZB89qsImZ6+F8Cv0Q2lRf8dBObuEDZrf+qTqP4NBEwN7IiErJXFXY9avV3jeweTRuzLDi7+N24J5TxSrXjkAKIv6Eg2MaVr5Y4/b5TjCO2076Y3PBXZ3Txo5ze0Of5Vb/OLEEWpvW1Zm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388274; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Rhh9od3jglb/e8p3pboZpBtMsu6c6uuGIYDm01cfBo0=; b=EP+BYFo/Hlngopc0h4alc/oHSSRB4wYqeYUGrU0WcA2+kyPCikgu9gZEiOp5fjNcQIyaw/krAwutnWyBDrzJcEED1fd5vQLX1E9dUDoPHc5BGVSoe/epwETDtrPUZW6QiLk60nJ9o29CzEzoICZKMWk3bzdTFeWyJwQG3Wy0yT4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15683882749477.928613929210087; Fri, 13 Sep 2019 08:24:34 -0700 (PDT) Received: from localhost ([::1]:45162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nR3-0004ju-P9 for importer@patchew.org; Fri, 13 Sep 2019 11:24:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52073) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLW-0007d1-Lk for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLV-0000JY-DN for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:50 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:45240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLV-0000Im-6n for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:49 -0400 Received: by mail-wr1-x429.google.com with SMTP id l16so32398942wrv.12 for ; Fri, 13 Sep 2019 08:18:49 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a16sm2769685wmm.36.2019.09.13.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9D63F1FF8F; Fri, 13 Sep 2019 16:18:45 +0100 (BST) 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=Rhh9od3jglb/e8p3pboZpBtMsu6c6uuGIYDm01cfBo0=; b=qUzwKAeU+Jx1kEUMYqjScAm/evx7NJWNTK0yla7o58SjttUOAqZmHCtcZJbc71eSVv aQjQi+A/5IJygAQZ09Kj7xJWCLliRmUFKshf5hmnFnbTbAnPQdP8jeodrZ6YiJ55QVS+ peVPVqyVJMSTsbHQy5fY+OW8j+TiBmnD3nwbjVyHfI42BdbqLHMW422fd5c5ADbJCGqj EAVezv6QeWxoWHKAqttKKRd0tTb0/q/89wXI3HJI8rDnZBKClCzImZKxqvYY+J6MpK4l Q/DQABGLUSd/ZUCtksFMSd/+nu39mTgh6X1LOgvlM3zrKlbZKVPsGbL2AQI9Co6cOB1F AdZQ== 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=Rhh9od3jglb/e8p3pboZpBtMsu6c6uuGIYDm01cfBo0=; b=g/qEqwmOEWcl2TNjFJ9J0epD6MbckOLmvUeeBv+36gdye7xvQc9e0VjpapRO/tFDRn Q58/ILMZRT8PsKRSOnLK3J7pFzMtRlF8IsY3TVj0ASqFygXU8/wOQfubL+qZaq5fdbSY SCRmweGcUH6OReGv9FWRkoBGV9vqJWlRajJ5msfhYsp5xq8XxlU2zde16n781IljCzxa fSszX4N121KbOEvlkqEAtGfZ+SQph2Ns64jHoksCnrGrmM71S6mq/GSUuUU0iWYbZV1Q pRlGpnldsGWTR2oyz7NlyxA+K7QLH9B2mpWTcyzCiRiroJpqvFRYKS85yU0lQYY/Pmb0 2vsg== X-Gm-Message-State: APjAAAUaLKk/DNOOdv4KoKSEmnGztstDbw/gM5LuE5GcNmKcFVe6xkpz PeP92hJ6l8ODRMCzusJgffm8Vg== X-Google-Smtp-Source: APXvYqyWhhlLW4A4C1CCoIVflvc0topuiUn6ARO5jOSFKddC3qCwWqurSO6o7V7F03owxRQ8R8b1Vw== X-Received: by 2002:a5d:548d:: with SMTP id h13mr2242639wrv.215.1568387928086; Fri, 13 Sep 2019 08:18:48 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:41 +0100 Message-Id: <20190913151845.12582-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PATCH v6 2/6] target/arm: handle M-profile semihosting at translate time 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: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We do this for other semihosting calls so we might as well do it for M-profile as well. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v2 - update for change to gen_exception_internal_insn API v3 - update for decode tree v4 - use !IS_USER v5 - return #ifndef CONFIG_USER --- target/arm/m_helper.c | 18 ++++++------------ target/arm/translate.c | 11 ++++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 884d35d2b02..27cd2f3f964 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -2114,19 +2114,13 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) break; } break; + case EXCP_SEMIHOST: + qemu_log_mask(CPU_LOG_INT, + "...handling as semihosting call 0x%x\n", + env->regs[0]); + env->regs[0] =3D do_arm_semihosting(env); + return; case EXCP_BKPT: - if (semihosting_enabled()) { - int nr; - nr =3D arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0= xff; - if (nr =3D=3D 0xab) { - env->regs[15] +=3D 2; - qemu_log_mask(CPU_LOG_INT, - "...handling as semihosting call 0x%x\n", - env->regs[0]); - env->regs[0] =3D do_arm_semihosting(env); - return; - } - } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); break; case EXCP_IRQ: diff --git a/target/arm/translate.c b/target/arm/translate.c index 34bb280e3da..b5272119330 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8424,7 +8424,16 @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) if (!ENABLE_ARCH_5) { return false; } - gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); + if (arm_dc_feature(s, ARM_FEATURE_M) && + semihosting_enabled() && +#ifndef CONFIG_USER_ONLY + !IS_USER(s) && +#endif + (a->imm =3D=3D 0xab)) { + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + } else { + gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); + } return true; } =20 --=20 2.20.1 From nobody Tue May 14 05:37:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388117; cv=none; d=zoho.com; s=zohoarc; b=E4Ob/G3uyU30U3lDPlVdnX1ddJwqamVo3FbyjuArOpLhRHBNjAJGtQqtmMC9JyW54gRindsO6P8PiXODX7lzSn/K+hx0NHzigNoq23U+KGNMTBJ3iT+US81n6jNi0noXj7B9R6Q5oUD076Jyvrmt62j+9gbuDD3A1AWlaxInm04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388117; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=030jYKOrb3z68e1uTpgGQV2krhpB89rckomNZ9iGnkc=; b=BRwGP0aP0Fqbu09Zh23HBtNtHhJ5TPORJFBqEUdHnNVvf7es+PzyrQD3TpLVd0Xlo1/pLazC+1hSND+9hZJjzJ4NMebYt0kBppQWokuIVe+qj+K1+0V22PjZ2rOyUv2jKz4djFhtIQ5Q9XQnWgiVv8gx+GwkpOPPwIF1K0nCOj4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568388117198453.57027506652867; Fri, 13 Sep 2019 08:21:57 -0700 (PDT) Received: from localhost ([::1]:45120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nOV-0001Z3-Fc for importer@patchew.org; Fri, 13 Sep 2019 11:21:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52108) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLX-0007fl-Nx for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLW-0000KP-AZ for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:51 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:37104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLW-0000JQ-29 for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:50 -0400 Received: by mail-wm1-x341.google.com with SMTP id r195so3212846wme.2 for ; Fri, 13 Sep 2019 08:18:49 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y186sm5091013wmb.41.2019.09.13.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B13081FF90; Fri, 13 Sep 2019 16:18:45 +0100 (BST) 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=030jYKOrb3z68e1uTpgGQV2krhpB89rckomNZ9iGnkc=; b=kAXpenHhf0+ToE8W4LprDkWvMeKl4BGl+GaEvs8zfDKC3R6bc2RiDiMLcInLxgzKon Wu3KP6k8n2ZeQJMJu/P9kSjqUY9r6yIQ5q/k28lksgVuR122n0YDdoLx10mBKi/f9O8d A86usICDJQTsUpvMbmj0k2xNo1mGvkPC+ugs13D70J3KX144DCZ6Twy0J4g+0M6KgVZU HLosmQRSzecPUWQpAh2/9U9OswAgYZSnCvJU4bytWYvZGUmzVsfhozmd9TtI1KiUSqtF TULyHs+5NGjV6GMXiMGWPPV32e5JDpcrfJCFp4oe0RBlHP+BNeyUAzi3Khzykv4iZZ4Q CRLg== 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=030jYKOrb3z68e1uTpgGQV2krhpB89rckomNZ9iGnkc=; b=NFipaofBKK8dq7CX4GFsvQUx4J1xY0AoDBh0w/LzNazxrBuXeW6eo1OE7NWpD0M3Qa OeXuYCnIfOBqc65LKnG7K8GvNO/H4pam6Pzm5Y+03bxDLvKPeT4BM4+cL79B3M1cPxKO b8ySurDrbljrsW1atGw5Yc88TE8rwegqyUwSQxTNlDCkxm6RSX+xepjPleQdcD075q5p hZQmLRdTp7Quz3HAQqlffIJJ0W4mwyxf4TJSmQZV0hqr4H2Wd28N/q5R0c5i1Ywe3A3T WMutKjBjsInmkuEpTf2YbJ14td1h88wp95MwRIGBgwZrWxy3huJgbQLfgKrS6cYAxu5q fLWA== X-Gm-Message-State: APjAAAV2bljId1nAI56920iJEmve7NygXigq6OrlAoFKrusOWtqSnhNM Sqqrw5h+yIm2p02yVvqm4IhH6A== X-Google-Smtp-Source: APXvYqx9DDgI/LjGnP+K5paUzdOLBqOD3VK7H+O05+VhII/VFCsFp6/w1CuodAEXr+jtkfoosVethQ== X-Received: by 2002:a1c:1f89:: with SMTP id f131mr3600724wmf.72.1568387928890; Fri, 13 Sep 2019 08:18:48 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:42 +0100 Message-Id: <20190913151845.12582-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v6 3/6] target/arm: handle A-profile semihosting at translate time 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: qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As for the other semihosting calls we can resolve this at translate time. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell --- v2 - update for change to gen_exception_internal_insn API v3 - update for decode tree, merge T32 & A32 commits - dropped r-b due to changes v4 - !IS_USER and !arm_dc_feature(s, ARM_FEATURE_M) v5 - only if !IS_USER for softmmu, linux-user is still allowed --- target/arm/translate.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index b5272119330..698c594e8ce 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10222,14 +10222,25 @@ static bool trans_CBZ(DisasContext *s, arg_CBZ *a) } =20 /* - * Supervisor call + * Supervisor call - both T32 & A32 come here so we need to check + * which mode we are in when checking for semihosting. */ =20 static bool trans_SVC(DisasContext *s, arg_SVC *a) { - gen_set_pc_im(s, s->base.pc_next); - s->svc_imm =3D a->imm; - s->base.is_jmp =3D DISAS_SWI; + const uint32_t semihost_imm =3D s->thumb ? 0xab : 0x123456; + + if (!arm_dc_feature(s, ARM_FEATURE_M) && semihosting_enabled() && +#ifndef CONFIG_USER_ONLY + !IS_USER(s) && +#endif + (a->imm =3D=3D semihost_imm)) { + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + } else { + gen_set_pc_im(s, s->base.pc_next); + s->svc_imm =3D a->imm; + s->base.is_jmp =3D DISAS_SWI; + } return true; } =20 --=20 2.20.1 From nobody Tue May 14 05:37:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388292; cv=none; d=zoho.com; s=zohoarc; b=SJp1WbIoys7iUezpEPWWeb6MlmW2IPXMUTrbvq7FI+lQ/MWo/lhAMDolWM5crza3uwnVrWCHD2r43p0u/Q4peQqe3/BlJhDgrzlR4KsGHjg8Eyjwf8keghRzTjjHZZc8VHBRokgP9TOQV2EYyYh0YQSCR7p9x47mZUfS2rtTS3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388292; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zlpCkLPxW/plsVCAFKM/m8fldNY7IYpuz4hZ7EfXmKg=; b=nFoxbI5iLcerz21Oa7wcX6CVgKN1Kk15WXQZyzPWPxzy7klVK2zU4qIlgCFSVpM+tGGYHDudUvCdDxSpOeBwGjWd1sxqMe3trOPhKOT8Etxjsqzv7LIP74ffsABbarqcdNWxj05WC77/yWCjwZPAskuOvbxHx6sREoMOS3LHN6c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568388292289197.1696973147906; Fri, 13 Sep 2019 08:24:52 -0700 (PDT) Received: from localhost ([::1]:45170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nRG-00054z-9l for importer@patchew.org; Fri, 13 Sep 2019 11:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52138) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLY-0007h9-HI for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLX-0000LA-3C for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:52 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34218) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLW-0000K7-PU for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:51 -0400 Received: by mail-wr1-x443.google.com with SMTP id a11so22725638wrx.1 for ; Fri, 13 Sep 2019 08:18:50 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e6sm2491691wrp.91.2019.09.13.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:48 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C72D71FF91; Fri, 13 Sep 2019 16:18:45 +0100 (BST) 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=zlpCkLPxW/plsVCAFKM/m8fldNY7IYpuz4hZ7EfXmKg=; b=k3OmRINk6Vsi7l5jsDJxN0Ct0QJYjyDjUZd+5CMVF8pdEXD59M5NLKGoUs0EmhSpDe +DuhSRF8o2bP//qqlNflAEgdRebc0+j6oYub8vNAJg9004yg31CwgLLBUPTdX8zW66PT Q/blKQzmGEjdK5/FjqfLS2nWF8RxwXl7tsw2Wcognn2NB696Fd/scK0safP2tJwuGHB2 oTD0WxnoGJPoolGM2Jgu7V0jucEEUMyyUft0AsSbfUXctvd+5WpQR/kKGovZ/gzfxv+Y +f0frVOqQ0Ogu0bRD4Pqyttm6Em64k4aN91uTZzUAZ9x+Cu559IS3SwaXIKNhbMHsmzk RhsA== 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=zlpCkLPxW/plsVCAFKM/m8fldNY7IYpuz4hZ7EfXmKg=; b=tI73juzS13+5oYs6NzVsFgIr2csw60J6Dr5TVTFNRWl7g05reS/3mBS+TwshHyme1z VscFhz2VSM2eG2XkgdmGhf95NQLGdZQS28V4SjaESeCxI2P1u+nkMGv9myiXrqqZGExy zKAmXo5WUyUjBwquNwIl95pu1YxYJ564a5C4/xADdMB1Kgo6hchc+dqgqwehqIoGqo8F npAsQoprexh49miApdDUuP0xkdcNTgNz9HQ6TdhRk94/uAdbIOoj+B6aad2aaG6t2tme 9s/dvT54RcoAvcIMImYdi7l8ymoQg0jJ0LMY9VBVq3d0+2w5gegWKQDfNGv4wzPpSHEQ D0rw== X-Gm-Message-State: APjAAAW++oWVJZ/+4QKI5cnezG5uvPltau41oVBMc89wHvPTIsUruu91 glQWN3t3eOlEoiRSKR0rhaerRQ== X-Google-Smtp-Source: APXvYqzAGdy887Inur93gPt/OC7ij5XACN3bINTjKzRsFBhiuCh6PbwNQu1Y+kMwxwsjMpwwCr9dlw== X-Received: by 2002:a5d:6647:: with SMTP id f7mr40200849wrw.170.1568387929702; Fri, 13 Sep 2019 08:18:49 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:43 +0100 Message-Id: <20190913151845.12582-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v6 4/6] target/arm: remove run time semihosting checks 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: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Now we do all our checking and use a common EXCP_SEMIHOST for semihosting operations we can make helper code a lot simpler. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v2 - fix re-base conflicts - hoist EXCP_SEMIHOST check - comment cleanups v5 - move CONFIG_TCG ifdefs --- target/arm/helper.c | 96 +++++++++++---------------------------------- 1 file changed, 22 insertions(+), 74 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 507026c9154..a87ae6d46a1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8339,88 +8339,32 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *= cs) new_el, env->pc, pstate_read(env)); } =20 -static inline bool check_for_semihosting(CPUState *cs) -{ +/* + * Do semihosting call and set the appropriate return value. All the + * permission and validity checks have been done at translate time. + * + * We only see semihosting exceptions in TCG only as they are not + * trapped to the hypervisor in KVM. + */ #ifdef CONFIG_TCG - /* Check whether this exception is a semihosting call; if so - * then handle it and return true; otherwise return false. - */ +static void handle_semihosting(CPUState *cs) +{ ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; =20 if (is_a64(env)) { - if (cs->exception_index =3D=3D EXCP_SEMIHOST) { - /* This is always the 64-bit semihosting exception. - * The "is this usermode" and "is semihosting enabled" - * checks have been done at translate time. - */ - qemu_log_mask(CPU_LOG_INT, - "...handling as semihosting call 0x%" PRIx64 "\n= ", - env->xregs[0]); - env->xregs[0] =3D do_arm_semihosting(env); - return true; - } - return false; + qemu_log_mask(CPU_LOG_INT, + "...handling as semihosting call 0x%" PRIx64 "\n", + env->xregs[0]); + env->xregs[0] =3D do_arm_semihosting(env); } else { - uint32_t imm; - - /* Only intercept calls from privileged modes, to provide some - * semblance of security. - */ - if (cs->exception_index !=3D EXCP_SEMIHOST && - (!semihosting_enabled() || - ((env->uncached_cpsr & CPSR_M) =3D=3D ARM_CPU_MODE_USR))) { - return false; - } - - switch (cs->exception_index) { - case EXCP_SEMIHOST: - /* This is always a semihosting call; the "is this usermode" - * and "is semihosting enabled" checks have been done at - * translate time. - */ - break; - case EXCP_SWI: - /* Check for semihosting interrupt. */ - if (env->thumb) { - imm =3D arm_lduw_code(env, env->regs[15] - 2, arm_sctlr_b(= env)) - & 0xff; - if (imm =3D=3D 0xab) { - break; - } - } else { - imm =3D arm_ldl_code(env, env->regs[15] - 4, arm_sctlr_b(e= nv)) - & 0xffffff; - if (imm =3D=3D 0x123456) { - break; - } - } - return false; - case EXCP_BKPT: - /* See if this is a semihosting syscall. */ - if (env->thumb) { - imm =3D arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) - & 0xff; - if (imm =3D=3D 0xab) { - env->regs[15] +=3D 2; - break; - } - } - return false; - default: - return false; - } - qemu_log_mask(CPU_LOG_INT, "...handling as semihosting call 0x%x\n", env->regs[0]); env->regs[0] =3D do_arm_semihosting(env); - return true; } -#else - return false; -#endif } +#endif =20 /* Handle a CPU exception for A and R profile CPUs. * Do any appropriate logging, handle PSCI calls, and then hand off @@ -8451,13 +8395,17 @@ void arm_cpu_do_interrupt(CPUState *cs) return; } =20 - /* Semihosting semantics depend on the register width of the - * code that caused the exception, not the target exception level, - * so must be handled here. + /* + * Semihosting semantics depend on the register width of the code + * that caused the exception, not the target exception level, so + * must be handled here. */ - if (check_for_semihosting(cs)) { +#ifdef CONFIG_TCG + if (cs->exception_index =3D=3D EXCP_SEMIHOST) { + handle_semihosting(cs); return; } +#endif =20 /* Hooks may change global state so BQL should be held, also the * BQL needs to be held for any modification of --=20 2.20.1 From nobody Tue May 14 05:37:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388383; cv=none; d=zoho.com; s=zohoarc; b=ZKCAsnqcpoKJqbe8dl9/hkr9lxbByBwI5VyoomT3rYKRv21qio80Q4bucwI5dI0eQZVzfTQe1LhpyvANxtCghwZvfUurHp8R+Y++NgVtFOd48Y36TK108vT42nm3mwxmY7gfcMOJ2sh/B5o35ZZ6KU5Kj6pkEFj3Aseue5uLa0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388383; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JGS4cd+3+YzNw9t73UEu5DEiXh2KRBor/rrPcaum5qs=; b=FBD/vbp4JZQAbUhTsutyabL4YzXrrebBObVzmPshobTmzWlhYD/EtfDTmXgXg9gkFwp79eVPEweKW5B7P9jGTvrpfnBSQYVoFh0hl5JWxMOAm6zg09n8T04YLAODw8T31+Tu4/Mr3mmcAh0RH27BVuBZaFdbpGh6Mr932hi45HA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568388383748332.37122636341087; Fri, 13 Sep 2019 08:26:23 -0700 (PDT) Received: from localhost ([::1]:45192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nSl-0006Xu-B3 for importer@patchew.org; Fri, 13 Sep 2019 11:26:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52145) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLY-0007hq-Uw for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLX-0000Li-Rg for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:52 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLX-0000Ky-J1 for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:51 -0400 Received: by mail-wm1-x344.google.com with SMTP id g207so3186399wmg.5 for ; Fri, 13 Sep 2019 08:18:51 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v4sm44135003wrg.56.2019.09.13.08.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:48 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DD40C1FF92; Fri, 13 Sep 2019 16:18:45 +0100 (BST) 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=JGS4cd+3+YzNw9t73UEu5DEiXh2KRBor/rrPcaum5qs=; b=BHfEjxGIgmrPJQeBKR7yfHNuP7KYIDnq29twlVQf3EjHhlqMuXHIwn4G0ng1svRtDN Lw15xPcURZ6r6eyKjlmNvvDDDdhCO2rvqkaYNiGnB1gC93dz3x7fU01IHRLwXIUWzeS6 /ECgj/PRTuYHZHZgziKyS3lPXpMGZFQR72fYgjlzpsF4LXuEu9s9hil5D0UrRq+2LYzp C+hydzJwGF1O3q3Cil9n19KUQEMKuYBDYM6CCeQ3Gc5W5tHwOxKGMjgDzYUdp1ku8rSw velnJpgRrnIRcmQCt31L3pVES/7bcHZH3u/foQHgWgeCeJwPZKhKjxVF9I0I1giF3WaI FfhQ== 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=JGS4cd+3+YzNw9t73UEu5DEiXh2KRBor/rrPcaum5qs=; b=cBNXFEAUcNvLSFdbxsZf0I3+xabKstK+9Cjwu1Xg0a/bYOgeH1pN4m1eJNZ5o2M/l8 CXNWFVqPFn4+rszpl9463ptI9EQ1b3XplSLNChuRc3zbXz0DXQ9wrXx62iz2H/gZxSHX BZOhhPXf7JzvCmBqmJrY9LFWgZLfTiX3x98jH1aROHP3HJop7mQRI5weWWhHCv5bkdbR H4U3iuCaTqQgQxqaWAWK7clVSfSOsl5VW/ojKYmGSW3GZbzFqleFMn56LFQAdSNXC5xs nkntl4yZHp8GiEJZTmUCRspVs6mVCgUAehs3NUzmdVg0NhvyANmR5uc0XriwvqcZbRP+ MOsw== X-Gm-Message-State: APjAAAVhKJ6rUrVtm5rGqtMTE9VJxABYxmOn77aTNNe8bqSV3lpd02+3 wbr8GrOfT1IpT8ZW356lafPwYA== X-Google-Smtp-Source: APXvYqyitFLFFjPuQ+R9jOHkv6y3gV39j/Qji3vOZ/sopWGB+rkrP+qLim9LUVJgqliI21M4somGCA== X-Received: by 2002:a05:600c:230d:: with SMTP id 13mr4104310wmo.114.1568387930536; Fri, 13 Sep 2019 08:18:50 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:44 +0100 Message-Id: <20190913151845.12582-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v6 5/6] 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=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- linux-user/arm/cpu_loop.c | 3 --- linux-user/arm/target_syscall.h | 3 --- 2 files changed, 6 deletions(-) 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) =20 if (n =3D=3D ARM_NR_cacheflush) { /* nop */ - } else if (n =3D=3D ARM_NR_semihosting - || n =3D=3D ARM_NR_thumb_semihosting) { - env->regs[0] =3D do_arm_semihosting (env); } else if (n =3D=3D 0 || n >=3D ARM_SYSCALL_BASE || env->t= humb) { /* linux syscall */ if (env->thumb || n =3D=3D 0) { diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscal= l.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) =20 -#define ARM_NR_semihosting 0x123456 -#define ARM_NR_thumb_semihosting 0xAB - #if defined(TARGET_WORDS_BIGENDIAN) #define UNAME_MACHINE "armv5teb" #else --=20 2.20.1 From nobody Tue May 14 05:37:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388190; cv=none; d=zoho.com; s=zohoarc; b=VR0qeS8hJxyant71AXS+4KtCsq8tHr/NkhPwOj1AYd4ntPRyKaWSqm1/oaR927Ar4V0TTbn5YLeVxA25RbjPi+xi8YL2u1NacRdMQXk/sIUJNkCpioksBiwae077CWCd4y8I4QOMp29FPGs9tTfqbI6oIAtl3NoIpW0k2lNuSME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388190; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oUGBFAHXbEtLB6rKz0bX2N4c3TgTMSpFBwXxOPwbThM=; b=BqNKUoEBb65c8FI3y5UjiJsw4yXSyZBoi9/6Cn8q5ppGqQ9DakpNcFsAcPYHZUb0NmfZ3cZTrzJIU2+zfP9qo7t1rHsrXxZaEsc21MN7I3NYle1b9nCYnLv1YoeKmox61N/ZvKncSqHorQMSLN81N1BTPrKgDihn8UURTnVCmQ8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568388190741173.86440025001002; Fri, 13 Sep 2019 08:23:10 -0700 (PDT) Received: from localhost ([::1]:45132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nPh-00031b-3I for importer@patchew.org; Fri, 13 Sep 2019 11:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52173) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLZ-0007iX-Pi for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLY-0000MB-Cn for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:53 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:46746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLY-0000LO-5a for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:52 -0400 Received: by mail-wr1-x42e.google.com with SMTP id o18so1267440wrv.13 for ; Fri, 13 Sep 2019 08:18:52 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m2sm1504574wmi.30.2019.09.13.08.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:48 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0017C1FF93; Fri, 13 Sep 2019 16:18:46 +0100 (BST) 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=oUGBFAHXbEtLB6rKz0bX2N4c3TgTMSpFBwXxOPwbThM=; b=dDRaEnPgqbmDrdt7FbnpQcCI9+WKLDBCb7Gh9JurDGqmrK7pJ9UD9PB+GiY/oyO23j fjxhqYoRXUa3tO0CYEa/Bz4mAuX2Z63blTQU6fyOgNC+dyY4pCI7Gz6YKP3qyNAZx/tJ oVJ7lqhqYBa5XAoi/2EgX7+/FcgoA+ZW0atZcMYzqtCj2uyhNE7JHAN14ccF0+h9FOi6 4tbic3OpnOOZsrbGiesT0/+ztpyrA7B4B2Zd4Og3BoRJgPu6aIElWmUFykaNdO0cfism esKqUkGpbjLV5DkS5H7NuS35GKiKL0AxOamhT4JHIVbiqarqA+QTcaotvMXTdYoxyvw4 sz0g== 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=oUGBFAHXbEtLB6rKz0bX2N4c3TgTMSpFBwXxOPwbThM=; b=npylfsmo4Is2f//nt/pC9HBbdMH5+hFJlCLSKeVA5fQbGoo5cPHQXNjIAOt91XbJK8 cXRJ21W4Yn+uRxJnqVk+mcTuUXEh6Ne5HnucntZULVzHGG+IeIYVieCG/K7WmG4+f8Vr +d/JHNdPji647z2JuWjW+zPevXxS5OyxPGndqkAsugEpWH2PDmSng+8xUh7G4s4u4TCH 8Fp6YSWMmlH4rpbVCdXFrcbPqc6XKYOG3V2YyyUgWTIrQsgX2mNgoVn/i/NcUmnU/6zE z91swNrLtmVGUsOj/5gCg/jyPA1AwBsQsCdLVqhEOg82EKQP5XQ2owcGmK0RaIkf0BKL n5Ig== X-Gm-Message-State: APjAAAUpzc60OXZekUDaYiQnBRGb5Aqb1WmNNbs5T+kdaU/NztLZ2xpW b0fNue8SnHYsMkLQRzG0SasbkQ== X-Google-Smtp-Source: APXvYqx4MnzRpeuPlR/9YnDCpz0suKthBB7vhm5lYjuHTMrPXa738rHNg5CkwuhTyb3GUyZaEXdAQA== X-Received: by 2002:adf:de0d:: with SMTP id b13mr10723070wrm.140.1568387930984; Fri, 13 Sep 2019 08:18:50 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:45 +0100 Message-Id: <20190913151845.12582-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PATCH v6 6/6] tests/tcg: add linux-user semihosting smoke test for ARM 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: qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We already use semihosting for the system stuff so this is a simple smoke test to ensure we are working OK on linux-user. Signed-off-by: Alex Benn=C3=A9e --- tests/tcg/aarch64/Makefile.target | 5 ++++ tests/tcg/arm/Makefile.target | 5 ++++ tests/tcg/arm/semihosting.c | 45 +++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tests/tcg/arm/semihosting.c 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 +=3D pauth-1 pauth-2 run-pauth-%: QEMU_OPTS +=3D -cpu max =20 +# Semihosting smoke test for linux-user +AARCH64_TESTS +=3D semihosting +run-semihosting: semihosting + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + TESTS +=3D $(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) =20 +# Semihosting smoke test for linux-user +ARM_TESTS +=3D semihosting +run-semihosting: semihosting + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + TESTS +=3D $(ARM_TESTS) =20 # 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=C3=A9e + * + * 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") =3D type; + register uintptr_t a0 asm("r1") =3D arg0; + asm("svc 0xab" + : /* no return */ + : "r" (t), "r" (a0)); +#else + register uintptr_t t asm("x0") =3D type; + register uintptr_t a0 asm("x1") =3D 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 =3D 0x20026; +#else + uintptr_t exit_block[2] =3D {0x20026, 0}; + uintptr_t exit_code =3D (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; +} --=20 2.20.1