From nobody Sun May 12 20:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1578495899; cv=none; d=zohomail.com; s=zohoarc; b=UGvQpOA6dmwKdGEvZKXKaPxAjcV10dbKV7e6Or29he45DWIcn65dWz/TFkEqV6rnGA6WYl13F/WOUf0WL/m2jDew8ynpTFmp9S/kmLRUsj4AQQ/rGNfDmfHVgo5uT7AopOcclWr/OoT5DexezIELYgMjCfn8DHNKBooKkN871Gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578495899; 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; bh=84JoBWqx+ve5fbgwlbi9R0MpJnP9SRzR7nMEMgeLfQI=; b=ghQZQPj5G4Gi7EtptMGW4fVHJMu3ZrsyKtJ9BLbfuxwY5JJEnLqb/K6TH6VHyFvT9EMgDyFInu1DGR6Lt45qLnPLlsjQ8/zgS0+hxADwNYhENSKPRlyj3lefiFd27bwvMJd1UoWp92uuteNudbC9g7HemxGi85YQKiGko9f3/Vo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1578495899462625.8532087931799; Wed, 8 Jan 2020 07:04:59 -0800 (PST) Received: from localhost ([::1]:45326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCtF-0006fl-Mf for importer@patchew.org; Wed, 08 Jan 2020 10:04:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43664) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCrK-0004gr-9A for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:02:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipCrI-0000qk-Ur for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:02:58 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipCrI-0000px-LM for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:02:56 -0500 Received: by mail-wr1-x442.google.com with SMTP id q10so3683772wrm.11 for ; Wed, 08 Jan 2020 07:02:56 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l15sm4289805wrv.39.2020.01.08.07.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 07:02:53 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0631B1FF8C; Wed, 8 Jan 2020 15:02:53 +0000 (GMT) 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=84JoBWqx+ve5fbgwlbi9R0MpJnP9SRzR7nMEMgeLfQI=; b=hkH/zDta4bkX6o89XOdDN1FOrOM11ZKFDXmgt57fJvE2y0UPY65jsjJDpJcguXVXyo uasx38TZWbtaxD03l8oQFIoVa6OIqMIskRj3y/kKDduUcaaC5aUT7Jibdx7bkWf1cOHK zbHK8UqA084N3FoCQzHp2yuDQ1d6hhLxtRJg+MzexGEu2ixVHilNrJSrqrywQqLyil85 KjB4NVbMS6Ng6qMdGsevgSgWCoc30zg2b3AWohamgsC7u4szn8wd1eXtCe0Cq944GF5Z VSLFcZCmCeQ52hm190umQ8f/d0DICNflmzNYJYqZS70h7f+R817JEvJi2zRn+sh4g6PU 2Fsg== 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=84JoBWqx+ve5fbgwlbi9R0MpJnP9SRzR7nMEMgeLfQI=; b=Dyvtyloqv4MdbyDdUA/hKXSEI7q2smkz7uHDmBMXZdo5IGxbJ5KlakevcBg6PkCdpK Hj0TjmlHei/kmONi8M5fnaYXOARst8uQBTl3cCVk0o27GPizqqLwvfCqrr4CewHutiuT DW+G5Ioni8sKsc1PUemMnZ3tID2f8NzRPgDd18hZKQDS6Wdh4ZD6D5KWowElHIzkbnnA ABewJr5MO/mnBwAUfy1F8iAbciJlgnbfpE8cdvCvCNDUf6pQwZBvJ65mvqOpxs36GNxj wiHvyTSG6FCER1VDmR0hQM/a+tE/oAgk/W7H95YKwa8+hmST1WtK/xPznuRBFii8D7Ko 3xXg== X-Gm-Message-State: APjAAAWEE7HgZ4yGDCgmFsUX0f8vH899/jzOGcy+pvL1s12XB+8svdKi iNdrblwPpYFfUZRHdWD7dpwT2g== X-Google-Smtp-Source: APXvYqybbNvW9ojxN3wpBnZC5S/h/Mcx53YAFZYRtG3XOxtOLnvW0xz5uwrW94M+/s9DXl/UsN9Itg== X-Received: by 2002:adf:df03:: with SMTP id y3mr5500605wrl.260.1578495775242; Wed, 08 Jan 2020 07:02:55 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 1/6] target/arm: remove unused EXCP_SEMIHOST leg Date: Wed, 8 Jan 2020 15:02:47 +0000 Message-Id: <20200108150252.6216-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108150252.6216-1-alex.bennee@linaro.org> References: <20200108150252.6216-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::442 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 , keithp@keithp.com, qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) All semihosting exceptions are dealt with earlier in the common code so we should never get here. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Keith Packard Tested-by: Keith Packard --- target/arm/helper.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index b6bec42f48e..da22c198006 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8566,12 +8566,6 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *c= s) case EXCP_VFIQ: addr +=3D 0x100; break; - case EXCP_SEMIHOST: - 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; default: cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); } --=20 2.20.1 From nobody Sun May 12 20:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1578496155; cv=none; d=zohomail.com; s=zohoarc; b=MnA2UIcgZbGZ3LSfg2uiBAExHNsInoZK/68bCH7H0UiU8oDXappkylQiv4dhJDAm6eko9/zS41XM0AFxufofADumRzfL3hOUmHj7X2MSqeWHXhXEGpt1ep/KCSFxB/sQBfBDkg6vM0u8mrz8yr3mgZG7/PrL3+GifJuDhtX/yrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578496155; 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; bh=GkQMpXBItYchKMRXNbiM3948XtOa8lICwzCMGGprBPg=; b=LoAVWdCMQG6rC1qfrc1E2dfsJsk5AII2W3GQS0D70/tEk7PVeuuyMsFH+plvt02x0nIQmw+MYEgpPuqQ2i/OAZc0zq5Syz2MfynVa7m/M+YCYrIvkuvIGjpaal8uFTrBpXjcTe8LUKinu8hxkudu5MeP6IJwaVNWZDlWt+APoEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1578496155218689.2793743010928; Wed, 8 Jan 2020 07:09:15 -0800 (PST) Received: from localhost ([::1]:45448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCxN-0005X9-GL for importer@patchew.org; Wed, 08 Jan 2020 10:09:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43732) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCrM-0004iq-4e for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipCrK-0000sc-Oi for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:00 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:38533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipCrK-0000rk-Hb for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:02:58 -0500 Received: by mail-wm1-x341.google.com with SMTP id u2so2849326wmc.3 for ; Wed, 08 Jan 2020 07:02:58 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id d8sm4591072wre.13.2020.01.08.07.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 07:02:53 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 22CF71FF8F; Wed, 8 Jan 2020 15:02:53 +0000 (GMT) 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=GkQMpXBItYchKMRXNbiM3948XtOa8lICwzCMGGprBPg=; b=XzqPqRjSHWRRWBkpxQXgLOt8FDe72XV7p3VtRVLdeaSp8TJp7wFKl65Lz1OWe6/wSC pGuvNkLYn9JCzNoTOWbet1RiJlQq21B3E0M/rIaJARHaLCTXEbbjGw39WSD/ISmWbDBQ pZDZCa3HkYbTKdX/kHyJ574lkuwr1n6avG9OV4a30Y8JAOK53J94fxU7Yq1l68LT/aww cvtWByZJchnPDxJwm4codLelrVsT8S4BXplZCYyPUzopK5MqiRRKto0NZQPHiH0biu9E TbMbvcIymjX8/1Rs0u6vzgvnFOVLxIErbvIDYqF7fJ4zuoAfKuDMqPFiCDdkuQMcvYlj r9qg== 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=GkQMpXBItYchKMRXNbiM3948XtOa8lICwzCMGGprBPg=; b=q3hoYKLTWN12N7ISA+ScBFasZzaMdD5jxeuFazuWVRna/imMwNxdHRiY8tjw9k8H9o MHVL0Ah2zF+kQ3HThp04/AoczLlH1YXp2SVdFcuA7/MLM7pc5cINIXL+kFoXQ9EBiQ43 kmunqjhe7jI9iqhlTVs4Dg++oF6WNb6msMlsiIYP0eQ53+PiDQx/zpf+H39Mja8eRZj+ CdI+jhoUZFSanyQ239T3xMLd9Q5n2jVfRoP9HFwXRfWUOn4fEbX8wBx4EeEFaupIwAWl 9mV8Mtz0BPThF5y9EGtFtc/KGfPZBCJpj04m1jH6JX3yyjvWQ/gudi16Cz57UH9j7vgV 3L/w== X-Gm-Message-State: APjAAAWaBIXJ5pTugOLNRH2G9dod6K+ASguQUxBOcr33CE+ubSZ/KeJK s+tD42dgDa3D8oiQUpdwLWa2bg== X-Google-Smtp-Source: APXvYqwh61/qCoiE8OIlzvZ981NvXmwqYM0qxurEt8liMHVMsvaGFU+p+O3drkbhGRe0aalsVV7p6w== X-Received: by 2002:a1c:cc06:: with SMTP id h6mr4167784wmb.118.1578495777551; Wed, 08 Jan 2020 07:02:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 2/6] target/arm: only update pc after semihosting completes Date: Wed, 8 Jan 2020 15:02:48 +0000 Message-Id: <20200108150252.6216-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108150252.6216-1-alex.bennee@linaro.org> References: <20200108150252.6216-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 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: Peter Maydell , keithp@keithp.com, Riku Voipio , Richard Henderson , Laurent Vivier , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Before we introduce blocking semihosting calls we need to ensure we can restart the system on semi hosting exception. To be able to do this the EXCP_SEMIHOST operation should be idempotent until it finally completes. Practically this means ensureing we only update the pc after the semihosting call has completed. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Keith Packard Tested-by: Keith Packard --- linux-user/aarch64/cpu_loop.c | 1 + linux-user/arm/cpu_loop.c | 1 + target/arm/helper.c | 2 ++ target/arm/m_helper.c | 1 + target/arm/translate-a64.c | 2 +- target/arm/translate.c | 6 +++--- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 31c845a70d4..bbe9fefca81 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -130,6 +130,7 @@ void cpu_loop(CPUARMState *env) break; case EXCP_SEMIHOST: env->xregs[0] =3D do_arm_semihosting(env); + env->pc +=3D 4; break; case EXCP_YIELD: /* nothing to do here for user-mode, just resume guest code */ diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 7be40717518..1fae90c6dfc 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -377,6 +377,7 @@ void cpu_loop(CPUARMState *env) break; case EXCP_SEMIHOST: env->regs[0] =3D do_arm_semihosting(env); + env->regs[15] +=3D env->thumb ? 2 : 4; break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ diff --git a/target/arm/helper.c b/target/arm/helper.c index da22c198006..19a57a17da5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8614,11 +8614,13 @@ static void handle_semihosting(CPUState *cs) "...handling as semihosting call 0x%" PRIx64 "\n", env->xregs[0]); env->xregs[0] =3D do_arm_semihosting(env); + env->pc +=3D 4; } else { qemu_log_mask(CPU_LOG_INT, "...handling as semihosting call 0x%x\n", env->regs[0]); env->regs[0] =3D do_arm_semihosting(env); + env->regs[15] +=3D env->thumb ? 2 : 4; } } #endif diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 76de317e6af..33d414a684b 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -2185,6 +2185,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) "...handling as semihosting call 0x%x\n", env->regs[0]); env->regs[0] =3D do_arm_semihosting(env); + env->regs[15] +=3D env->thumb ? 2 : 4; return; case EXCP_BKPT: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index d4bebbe6295..972c28c3c95 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1937,7 +1937,7 @@ static void disas_exc(DisasContext *s, uint32_t insn) break; } #endif - gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { unsupported_encoding(s, insn); } diff --git a/target/arm/translate.c b/target/arm/translate.c index 2b6c1f91bf9..5185e08641b 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1124,7 +1124,7 @@ static inline void gen_hlt(DisasContext *s, int imm) s->current_el !=3D 0 && #endif (imm =3D=3D (s->thumb ? 0x3c : 0xf000))) { - gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); return; } =20 @@ -8457,7 +8457,7 @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) !IS_USER(s) && #endif (a->imm =3D=3D 0xab)) { - gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); } @@ -10266,7 +10266,7 @@ static bool trans_SVC(DisasContext *s, arg_SVC *a) !IS_USER(s) && #endif (a->imm =3D=3D semihost_imm)) { - gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { gen_set_pc_im(s, s->base.pc_next); s->svc_imm =3D a->imm; --=20 2.20.1 From nobody Sun May 12 20:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1578496266; cv=none; d=zohomail.com; s=zohoarc; b=kL9MFnG08nkXzOltW27pe30C4pEpxoYJ65reHcUv+HpkmkiFZcDY1WyNeScBXnCVNQU8XJEgKM4EeqHD4v+x4ztauDmeduIfqesQWD/gKX6qsA8dLlrTHSP8XN265UIYMmjXUN3aL16ENR9S/LlpVsS67SM9HzBYqM+DsxuMZQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578496266; 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; bh=2YVOpIOtSyC/c7WmIdJk8VidRAiPdqEmA0xEFBm4BzI=; b=ew4/HJ/ZEzH3Yoiwt8VAXlqlRUdDcSUBJ/LOW9SR/aQA1/XqrBnn5b/SSSwjgdSn2B4lODZon6R2VE55cGs5r0ys3EM+6zkhEuvXL9wFF1JXR/BJd+Wol++66Dv590Qo5p5LuggZMPl1nTKrk56ch5Ed4BQwQgj5/h+axqO2YDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1578496266413685.8443267358978; Wed, 8 Jan 2020 07:11:06 -0800 (PST) Received: from localhost ([::1]:45494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCzA-0000Qj-SH for importer@patchew.org; Wed, 08 Jan 2020 10:11:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43840) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCrR-0004pJ-1s for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipCrO-0000vZ-T2 for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:04 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:50444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipCrO-0000ur-L1 for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:02 -0500 Received: by mail-wm1-x344.google.com with SMTP id a5so2843935wmb.0 for ; Wed, 08 Jan 2020 07:03:02 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k82sm4222082wmf.10.2020.01.08.07.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 07:02:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 424631FF90; Wed, 8 Jan 2020 15:02:53 +0000 (GMT) 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=2YVOpIOtSyC/c7WmIdJk8VidRAiPdqEmA0xEFBm4BzI=; b=pMO8Sn+9eGhn5dNV0/fsjQ0/oCRbPtCxDxoIv6TPJJlv+dVU7IAKl592JU2QdAZehQ aSRo71g6+rrJtQLMp9YZLttjcgn0pQ5LVmZup0aKjmsvOUKPM8PtCwKrrlmqricgTUxH 8eSxPVQ2HI4U/HAXp4vDEEehuzzLlwcRkHIL+xygMplKGr7kH8Zga6RK3hTPtlTkNT5l a2wxOSm+L3PpOAbEsCzYrxsXPugZ88vuE/vEkeSgXZkDvXkcGzrXyIkqRCvc5ROnn7MW 0VrKyeVsZsWL+gtmjQWHlWGrKFIXYJ8IueOQ6K5X7gEzuw338CrTBgLMbTCqWB7lTlTK dgOQ== 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=2YVOpIOtSyC/c7WmIdJk8VidRAiPdqEmA0xEFBm4BzI=; b=qMgQnFRN+jL1zJBaY3uKjsGijgMRF7RiNr+klnAOGGOhU7wwcKoHZyfHpMw/bbSn7w CalfbcSjpYKc2eQzONSnLj+R4x/a9oaaX5JWO9UTeKz7s+ArVlbYG8mIJdzFqxaPnIXs Kmvy2q9wJiA5Fajfg/X33SxOle72vnYlhpeoIJ37HNsnueuIWaP+OUh0FzycL+J8npP/ 3az1f+jdw4r7dY04ZjQrKQ/2haasy1HczRThhsx9/nEN9QKz1FGGcwDX2hC0+WdwOaRP 0F6i3XZRVeEyMXIDOfO86Umnen0dWgNl1KC8funYkeZCnq4Nvnpjk+bamD7NtRFgpOcO Ryhg== X-Gm-Message-State: APjAAAWaoHsDikfwSfo3mRn13BH0nlSKw4+AHt1ggtkTgNWxsKw4G8Pf Cdi7WE6WX/gOxhcLo3n+bl40Qg== X-Google-Smtp-Source: APXvYqyviDmmdbncatXTETmHelR242tM4NMHUmFu6Ha0HvCw96c2pXB+/1eWF8WCgdb5B+Vqik9vvQ== X-Received: by 2002:a1c:9e15:: with SMTP id h21mr4137247wme.95.1578495781460; Wed, 08 Jan 2020 07:03:01 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 3/6] semihosting: add qemu_semihosting_console_inc for SYS_READC Date: Wed, 8 Jan 2020 15:02:49 +0000 Message-Id: <20200108150252.6216-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108150252.6216-1-alex.bennee@linaro.org> References: <20200108150252.6216-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 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: Peter Maydell , keithp@keithp.com, Riku Voipio , Richard Henderson , Laurent Vivier , qemu-arm@nongnu.org, Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Keith Packard Provides a blocking call to read a character from the console using semihosting.chardev, if specified. This takes some careful command line options to use stdio successfully as the serial ports, monitor and semihost all want to use stdio. Here's a sample set of command line options which share stdio between semihost, monitor and serial ports: qemu \ -chardev stdio,mux=3Don,id=3Dstdio0 \ -serial chardev:stdio0 \ -semihosting-config enable=3Don,chardev=3Dstdio0 \ -mon chardev=3Dstdio0,mode=3Dreadline This creates a chardev hooked to stdio and then connects all of the subsystems to it. A shorter mechanism would be good to hear about. Signed-off-by: Keith Packard Message-Id: <20191104204230.12249-1-keithp@keithp.com> [AJB: fixed up deadlock, minor commit title reword] Signed-off-by: Alex Benn=C3=A9e Cc: Paolo Bonzini Reviewed-by: Keith Packard Tested-by: Keith Packard Reviewed-by: Richard Henderson --- v8 - allow linux-user to block using unbuffered IO - spelling and wording fixes v7 - reword commit title - remove mutexs, halt CPU until data available - document cpu_loop_exit behavior in function API squash! semihosting: add qemu_semihosting_console_inc for SYS_READC --- include/hw/semihosting/console.h | 16 +++++++ include/hw/semihosting/semihost.h | 4 ++ hw/semihosting/console.c | 79 +++++++++++++++++++++++++++++++ linux-user/arm/semihost.c | 27 +++++++++++ stubs/semihost.c | 4 ++ target/arm/arm-semi.c | 3 +- vl.c | 3 ++ 7 files changed, 134 insertions(+), 2 deletions(-) diff --git a/include/hw/semihosting/console.h b/include/hw/semihosting/cons= ole.h index 9be9754bcdf..0238f540f4b 100644 --- a/include/hw/semihosting/console.h +++ b/include/hw/semihosting/console.h @@ -37,6 +37,22 @@ int qemu_semihosting_console_outs(CPUArchState *env, tar= get_ulong s); */ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c); =20 +/** + * qemu_semihosting_console_inc: + * @env: CPUArchState + * + * Receive single character from debug console. This may be the remote + * gdb session if a softmmu guest is currently being debugged. As this + * call may block if no data is available we suspend the CPU and will + * re-execute the instruction when data is there. Therefore two + * conditions must be met: + * - CPUState is synchronized before calling this function + * - pc is only updated once the character is successfully returned + * + * Returns: character read OR cpu_loop_exit! + */ +target_ulong qemu_semihosting_console_inc(CPUArchState *env); + /** * qemu_semihosting_log_out: * @s: pointer to string diff --git a/include/hw/semihosting/semihost.h b/include/hw/semihosting/sem= ihost.h index 60fc42d851e..b8ce5117ae0 100644 --- a/include/hw/semihosting/semihost.h +++ b/include/hw/semihosting/semihost.h @@ -56,6 +56,9 @@ static inline Chardev *semihosting_get_chardev(void) { return NULL; } +static inline void qemu_semihosting_console_init(void) +{ +} #else /* !CONFIG_USER_ONLY */ bool semihosting_enabled(void); SemihostingTarget semihosting_get_target(void); @@ -68,6 +71,7 @@ Chardev *semihosting_get_chardev(void); void qemu_semihosting_enable(void); int qemu_semihosting_config_options(const char *opt); void qemu_semihosting_connect_chardevs(void); +void qemu_semihosting_console_init(void); #endif /* CONFIG_USER_ONLY */ =20 #endif /* SEMIHOST_H */ diff --git a/hw/semihosting/console.c b/hw/semihosting/console.c index b4b17c8afbc..6346bd7f506 100644 --- a/hw/semihosting/console.c +++ b/hw/semihosting/console.c @@ -20,8 +20,15 @@ #include "hw/semihosting/semihost.h" #include "hw/semihosting/console.h" #include "exec/gdbstub.h" +#include "exec/exec-all.h" #include "qemu/log.h" #include "chardev/char.h" +#include +#include "chardev/char-fe.h" +#include "sysemu/sysemu.h" +#include "qemu/main-loop.h" +#include "qapi/error.h" +#include "qemu/fifo8.h" =20 int qemu_semihosting_log_out(const char *s, int len) { @@ -98,3 +105,75 @@ void qemu_semihosting_console_outc(CPUArchState *env, t= arget_ulong addr) __func__, addr); } } + +#define FIFO_SIZE 1024 + +/* Access to this structure is protected by the BQL */ +typedef struct SemihostingConsole { + CharBackend backend; + GSList *sleeping_cpus; + bool got; + Fifo8 fifo; +} SemihostingConsole; + +static SemihostingConsole console; + +static int console_can_read(void *opaque) +{ + SemihostingConsole *c =3D opaque; + int ret; + g_assert(qemu_mutex_iothread_locked()); + ret =3D (int) fifo8_num_free(&c->fifo); + return ret; +} + +static void console_wake_up(gpointer data, gpointer user_data) +{ + CPUState *cs =3D (CPUState *) data; + /* cpu_handle_halt won't know we have work so just unbung here */ + cs->halted =3D 0; + qemu_cpu_kick(cs); +} + +static void console_read(void *opaque, const uint8_t *buf, int size) +{ + SemihostingConsole *c =3D opaque; + g_assert(qemu_mutex_iothread_locked()); + while (size-- && !fifo8_is_full(&c->fifo)) { + fifo8_push(&c->fifo, *buf++); + } + g_slist_foreach(c->sleeping_cpus, console_wake_up, NULL); + c->sleeping_cpus =3D NULL; +} + +target_ulong qemu_semihosting_console_inc(CPUArchState *env) +{ + uint8_t ch; + SemihostingConsole *c =3D &console; + g_assert(qemu_mutex_iothread_locked()); + g_assert(current_cpu); + if (fifo8_is_empty(&c->fifo)) { + c->sleeping_cpus =3D g_slist_prepend(c->sleeping_cpus, current_cpu= ); + current_cpu->halted =3D 1; + current_cpu->exception_index =3D EXCP_HALTED; + cpu_loop_exit(current_cpu); + /* never returns */ + } + ch =3D fifo8_pop(&c->fifo); + return (target_ulong) ch; +} + +void qemu_semihosting_console_init(void) +{ + Chardev *chr =3D semihosting_get_chardev(); + + if (chr) { + fifo8_create(&console.fifo, FIFO_SIZE); + qemu_chr_fe_init(&console.backend, chr, &error_abort); + qemu_chr_fe_set_handlers(&console.backend, + console_can_read, + console_read, + NULL, NULL, &console, + NULL, true); + } +} diff --git a/linux-user/arm/semihost.c b/linux-user/arm/semihost.c index a16b525eec0..a1f0f6050ea 100644 --- a/linux-user/arm/semihost.c +++ b/linux-user/arm/semihost.c @@ -14,6 +14,7 @@ #include "cpu.h" #include "hw/semihosting/console.h" #include "qemu.h" +#include =20 int qemu_semihosting_console_outs(CPUArchState *env, target_ulong addr) { @@ -47,3 +48,29 @@ void qemu_semihosting_console_outc(CPUArchState *env, ta= rget_ulong addr) } } } + +/* + * For linux-user we can safely block. However as we want to return as + * soon as a character is read we need to tweak the termio to disable + * line buffering. We restore the old mode afterwards in case the + * program is expecting more normal behaviour. This is slow but + * nothing using semihosting console reading is expecting to be fast. + */ +target_ulong qemu_semihosting_console_inc(CPUArchState *env) +{ + uint8_t c; + struct termios old_tio, new_tio; + + /* Disable line-buffering and echo */ + tcgetattr(STDIN_FILENO, &old_tio); + new_tio =3D old_tio; + new_tio.c_lflag &=3D (~ICANON & ~ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &new_tio); + + c =3D getchar(); + + /* restore config */ + tcsetattr(STDIN_FILENO, TCSANOW, &old_tio); + + return (target_ulong) c; +} diff --git a/stubs/semihost.c b/stubs/semihost.c index f90589259c0..1d8b37f7b2f 100644 --- a/stubs/semihost.c +++ b/stubs/semihost.c @@ -69,3 +69,7 @@ void semihosting_arg_fallback(const char *file, const cha= r *cmd) void qemu_semihosting_connect_chardevs(void) { } + +void qemu_semihosting_console_init(void) +{ +} diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 6f7b6d801bf..47d61f6fe1f 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -802,8 +802,7 @@ target_ulong do_arm_semihosting(CPUARMState *env) =20 return guestfd_fns[gf->type].readfn(cpu, gf, arg1, len); case TARGET_SYS_READC: - qemu_log_mask(LOG_UNIMP, "%s: SYS_READC not implemented", __func__= ); - return 0; + return qemu_semihosting_console_inc(env); case TARGET_SYS_ISTTY: GET_ARG(0); =20 diff --git a/vl.c b/vl.c index 86474a55c9e..b2119212587 100644 --- a/vl.c +++ b/vl.c @@ -4238,6 +4238,9 @@ int main(int argc, char **argv, char **envp) qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); =20 + /* connect semihosting console input if requested */ + qemu_semihosting_console_init(); + if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) exit(1); if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) --=20 2.20.1 From nobody Sun May 12 20:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1578495921; cv=none; d=zohomail.com; s=zohoarc; b=M2cR5yVXTNPLadNu299+e1chvRJyQev+EmvdJGoAfSswoi8yWXm7081HnCyVpQ4fjPAI2Rtw/wyVCvfmHTylzYk2yHgsnW5OR6Mj9dWPBid+irsxRZNwJKTmTJYtAOWW+0yqONvVFuD90IGaPzjIKBA1IMg1wfamLbnAVEBB9QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578495921; 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; bh=tWCHuSggB5szQdLA+HidJI7cGodm3lgcmToLZIxmHFk=; b=jdOsE9WyoH7gH6l8P4lFLM8HAWCFdhZ39roGgWZcx0kx153oBODq/q5dXWXoIV47JiqLofRvdWILrdULUoHtCnfizjL5Kuu7yAFUqYJGWxmWrxFCsitk1oRavyATymeFvvip9bdYhUHkDm343IWXIEWmnET6rNr3DhqiqGe2HbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1578495921694365.9508165469787; Wed, 8 Jan 2020 07:05:21 -0800 (PST) Received: from localhost ([::1]:45334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCtb-0007B8-VK for importer@patchew.org; Wed, 08 Jan 2020 10:05:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43855) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCrR-0004qG-Ia for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipCrQ-0000wW-6m for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:05 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35862) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipCrQ-0000wA-05 for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:04 -0500 Received: by mail-wm1-x341.google.com with SMTP id p17so2854442wma.1 for ; Wed, 08 Jan 2020 07:03:03 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z21sm3922551wml.5.2020.01.08.07.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 07:02:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 58E2E1FF91; Wed, 8 Jan 2020 15:02:53 +0000 (GMT) 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=tWCHuSggB5szQdLA+HidJI7cGodm3lgcmToLZIxmHFk=; b=swGWagYMry1Jdy12VPJ1h2eLBouDR70SwNzTte+TF26FtU5WCEIaxEnS2dq2yBzpld jdv5P0tQHPfjxi9PVkobAPNRaMuDlImo2BsUX4/wWBd/4gViCm6pNSnNQEPSEv7hqpSb Y4IAWZmuDc8MO+K3AWf7atsTgzk/E55gTqzBXaGAbaGcgwPRrCsr5q2ccWIu3cJTNb7t ZaChmjWwCDt+OHAs2kWrW1j3O1V23KvSLeoJDiGqV2334It23SaPP9CQkvM6yedP/vcy QIQextG/jzqUnqprCFLQM9nElqYWNAxS2YleMCxyTA+XjD22Q97pRl97RJ4TkHjrpA8r XhAA== 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=tWCHuSggB5szQdLA+HidJI7cGodm3lgcmToLZIxmHFk=; b=oESQjMw5cVDOwOYC3ivAKk3ex7qoeMaqtKaxinXfDugGmJPCaSV2jyxSvc2ccT97eJ RMPW5Kp5SuTzsjyMfsfTX2EqD+XcP3GBl732dMqDfU8O/6aQ3MiaQ83tjwfpj7wSmRc+ WKQSa7eO7eDnSLe1ystBJcbQwz9qNZvvxMWe5OM0Ot21tR/FzMROjCoBvRKTEzkhGM6d tJ3d1zYeT4T/xRfJLdivp441DWBCm6d1yHDfZ2vI0uTp2uEdCJaiD9j7f2YoEg5WydQ6 KQIo9w66opIYnZ+95FJnQ3aFd73jXdX9jHuojX08vzN/ETfWv0Jze0i0fDcfRp0yeFER /2WA== X-Gm-Message-State: APjAAAWi76D/c4tG4OjQ3LzVmMqrU3TU6sTIUTaWY96blpxzhI5THsAp cCe4upHjpS/LDG512sBVYPYYeQ== X-Google-Smtp-Source: APXvYqz78JEN1/xD/Vaisyak2INRO53JvRa3CY0pP177yI4npGLT+ZuJ3QPBEpAR+ONW7yWof/2swQ== X-Received: by 2002:a7b:cb46:: with SMTP id v6mr4323837wmj.117.1578495782807; Wed, 08 Jan 2020 07:03:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 4/6] tests/tcg: add a dumb-as-bricks semihosting console test Date: Wed, 8 Jan 2020 15:02:50 +0000 Message-Id: <20200108150252.6216-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108150252.6216-1-alex.bennee@linaro.org> References: <20200108150252.6216-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 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 , keithp@keithp.com, qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We don't run this during check-tcg as we would need to check stuff is echoed back. However we can still build the binary so people can test it manually. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v8 - actually return the result! --- tests/tcg/aarch64/system/semiconsole.c | 38 +++++++++++++++++++++++ tests/tcg/aarch64/Makefile.softmmu-target | 9 +++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/system/semiconsole.c diff --git a/tests/tcg/aarch64/system/semiconsole.c b/tests/tcg/aarch64/sys= tem/semiconsole.c new file mode 100644 index 00000000000..bfe7c9e26b4 --- /dev/null +++ b/tests/tcg/aarch64/system/semiconsole.c @@ -0,0 +1,38 @@ +/* + * Semihosting Console Test + * + * Copyright (c) 2019 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +#define SYS_READC 0x7 + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("x0") =3D type; + register uintptr_t a0 asm("x1") =3D arg0; + asm("hlt 0xf000" + : "=3Dr" (t) + : "r" (t), "r" (a0)); + + return t; +} + +int main(void) +{ + char c; + + ml_printf("Semihosting Console Test\n"); + ml_printf("hit X to exit:"); + + do { + c =3D __semi_call(SYS_READC, 0); + __sys_outc(c); + } while (c !=3D 'X'); + + return 0; +} diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/= Makefile.softmmu-target index 950dbb4bac2..9bdcfd9e7e4 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -31,7 +31,14 @@ LDFLAGS+=3D-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS)= -lgcc memory: CFLAGS+=3D-DCHECK_UNALIGNED=3D1 =20 # Running -QEMU_OPTS+=3D-M virt -cpu max -display none -semihosting-config enable=3Do= n,target=3Dnative,chardev=3Doutput -kernel +QEMU_BASE_MACHINE=3D-M virt -cpu max -display none +QEMU_OPTS+=3D$(QEMU_BASE_MACHINE) -semihosting-config enable=3Don,target= =3Dnative,chardev=3Doutput -kernel + +# console test is manual only +QEMU_SEMIHOST=3D-chardev stdio,mux=3Don,id=3Dstdio0 -semihosting-config en= able=3Don,chardev=3Dstdio0 -mon chardev=3Dstdio0,mode=3Dreadline +run-semiconsole: QEMU_OPTS=3D$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") =20 # Simple Record/Replay Test .PHONY: memory-record --=20 2.20.1 From nobody Sun May 12 20:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1578496005; cv=none; d=zohomail.com; s=zohoarc; b=fbTIerP2tfAQBQlZVxobqmh/XNVAmtf5Bof7pNjY5TYs8gpyD+V1r3uzAMshv1EaUY27uztcs6Tg7P0SUlaSa+0h6Zutm6LKQ2ctgsUrakIGsBwuSF8F2raQXgb3Li9Mw+BH2WlU2Sg1EkZKCESMhwuvoaBvqOHQ8+u7HRh47I8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578496005; 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; bh=13ZcuAVLK0Aa+lF09oRhBPxRKXVMthPAmhqkjcYOQ/g=; b=WDyJGiPdj3DUCBaovIjGI7DHpG2DBkMK2qjx88Dmer2inY3Mfas7TXZFyut4NkUgTMI3E+0/zMgftJ7zMtIVs+yxxYnTU43X8lg67GThq5jvrQYMeqLC2Hy6LL739nFkzQ7xNhL8MN3Cki4WOGHtSmABUt4b2L7RHG4LZwkgMEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1578496005718253.19513833761357; Wed, 8 Jan 2020 07:06:45 -0800 (PST) Received: from localhost ([::1]:45386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCux-0001ag-2M for importer@patchew.org; Wed, 08 Jan 2020 10:06:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43858) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCrR-0004qX-Pr for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipCrM-0000ts-IP for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:05 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:36104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipCrM-0000tP-Bf for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:00 -0500 Received: by mail-wr1-x441.google.com with SMTP id z3so3754292wru.3 for ; Wed, 08 Jan 2020 07:03:00 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c4sm4108167wml.7.2020.01.08.07.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 07:02:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6FCF41FF92; Wed, 8 Jan 2020 15:02:53 +0000 (GMT) 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=13ZcuAVLK0Aa+lF09oRhBPxRKXVMthPAmhqkjcYOQ/g=; b=zuzsxxqFB4aKSiv+LnHFe36HHixGaqv3x9Wb4+Ksbh5vwWynzsIrjSpYlKY1H1Tcqx eBwJVYg7NJdgCVUUWnrWafeHMvZvYZLoR1U6/QpnIlmCSTUPtLs/zHzdr5JMPrMlspGF jNGnG5MaSfqz0bv7rel88RsSPUrZyRWZ0J5bBQ2R2FqiqzoIC6BDgn6ipPCi4U60iKg/ K18W8kl0eMaliO8q+bQ08G27yCwL4nVUpIQoS+0ijquAdHJ+oRpFt8XWEnINtGeqSiZd Q/eXxA2xHurWBLzXkngLYE1Mcv28/mSqbi0lJ3Fgyn0rMyi/gNiBo7Xp5rBChUyqTkLr l0xA== 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=13ZcuAVLK0Aa+lF09oRhBPxRKXVMthPAmhqkjcYOQ/g=; b=K9Ejss/jssa4LfGV7lgDrk1rrD3tBdRStIpovKQLCPsUi+ukLdMytLQCKhKgZKKz1N RU65LvukI5La0PnWkFrce8H71F8hg1lPiGIEZrGJldZKxofSJdnFR0WnxEiaqkwgemnY 8LV7BJ3J3CLwjWDXfV6Rf60QXRbJy54ZH09fn/+qFVSGvACyuSkuF1SbaGkbHt1ykcku l+w6RfrglIGk/n90i7RUJIwa6JfWIYieg6mKAgWDGcdSvasU6d9Lc201flPNCEreny3b Vpe/NZCs+/JF4E/0c8LnDIST6qeWL2Yu4XbPRaYUte8bAv8BkSAbIR6a+nIekJp4sNCU 63kg== X-Gm-Message-State: APjAAAXtb2grsfjQi/pGStTV0+gg84iB+3bkP4X65TD2naKZ5JmlrFB2 H6ntzomPLJbk3oVSDKPR/pu0+Q== X-Google-Smtp-Source: APXvYqzc9qLhYYEsmRj0hPKOqOU2axnOqgIUCSUcew2ds5sbIClQg3D+LwkcDEH1ryP3LLG8vOPRyQ== X-Received: by 2002:adf:e984:: with SMTP id h4mr4917895wrm.275.1578495779318; Wed, 08 Jan 2020 07:02:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 5/6] tests/tcg: extract __semi_call into a header and expand Date: Wed, 8 Jan 2020 15:02:51 +0000 Message-Id: <20200108150252.6216-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108150252.6216-1-alex.bennee@linaro.org> References: <20200108150252.6216-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::441 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: Peter Maydell , keithp@keithp.com, qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) There are two types of ARM semicall - lets test them both. Putting the logic in a header will make re-using the functions easier later. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- tests/tcg/arm/semicall.h | 35 +++++++++++++++++++++++++++++++++++ tests/tcg/arm/semihosting.c | 21 +-------------------- tests/tcg/arm/Makefile.target | 9 +++++++++ 3 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 tests/tcg/arm/semicall.h diff --git a/tests/tcg/arm/semicall.h b/tests/tcg/arm/semicall.h new file mode 100644 index 00000000000..d4f6818192d --- /dev/null +++ b/tests/tcg/arm/semicall.h @@ -0,0 +1,35 @@ +/* + * Semihosting Tests + * + * Copyright (c) 2019 + * Written by Alex Benn=C3=A9e + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define SYS_WRITE0 0x04 +#define SYS_READC 0x07 +#define SYS_REPORTEXC 0x18 + +uintptr_t __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; +#ifdef __thumb__ +# define SVC "svc 0xab" +#else +# define SVC "svc 0x123456" +#endif + asm(SVC : "=3Dr" (t) + : "r" (t), "r" (a0)); +#else + register uintptr_t t asm("x0") =3D type; + register uintptr_t a0 asm("x1") =3D arg0; + asm("hlt 0xf000" + : "=3Dr" (t) + : "r" (t), "r" (a0)); +#endif + + return t; +} diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/arm/semihosting.c index 09c89cb481a..33faac9916e 100644 --- a/tests/tcg/arm/semihosting.c +++ b/tests/tcg/arm/semihosting.c @@ -8,26 +8,7 @@ */ =20 #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 -} +#include "semicall.h" =20 int main(int argc, char *argv[argc]) { diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 0765f37ff04..41aa26f4e17 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -31,9 +31,18 @@ run-fcvt: fcvt =20 # Semihosting smoke test for linux-user ARM_TESTS +=3D semihosting +semihosting: CFLAGS +=3D -mthumb run-semihosting: semihosting $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") =20 +ARM_TESTS +=3D semihosting-arm +semihosting-arm: CFLAGS +=3D -marm +semihosting-arm: semihosting.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +run-semihosting-arm: semihosting-arm + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + run-plugin-semihosting-with-%: $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ --=20 2.20.1 From nobody Sun May 12 20:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1578496051; cv=none; d=zohomail.com; s=zohoarc; b=Y53uKgVrGCVu9ORXBk9Aw8xnV0Ym2t/+nWctONit9IsbbL+mTjG4ObtRDWomhSgeBCbt4edqm3G7Kx+RD+eaJvI/UVN/nGZ4B/igkxCLahrSkegujHdSx7X7hXrfvAE5nXtrrr+D+/TE3M484XK69hN8A6sMgHm3aV8h5suuJM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578496051; 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; bh=O+jDkffcXWGWrl2ViCkscRGcA34TMzzu2DuCiFiOkiM=; b=K1EasPXYCo1hV5m8uj6AH2YlPNxcUNvCVlJ/KEWezeP5qbwdQeXPHpKirFjyssYd/CYB8gMc57bsE7CvE1cx7EtCkp6sR2Ci5gYvX6h1++v0EB+GFRYWj9VVu4ys28FkMYNnnI+v58tH6vDp+xGw4EzeinPdjYWgeHJiI3TdelA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1578496051660889.207982681966; Wed, 8 Jan 2020 07:07:31 -0800 (PST) Received: from localhost ([::1]:45416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCvi-00036e-HN for importer@patchew.org; Wed, 08 Jan 2020 10:07:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43797) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipCrP-0004nA-Bw for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipCrO-0000v3-3x for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:03 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:50651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipCrN-0000uM-T4 for qemu-devel@nongnu.org; Wed, 08 Jan 2020 10:03:02 -0500 Received: by mail-wm1-x32d.google.com with SMTP id a5so2843879wmb.0 for ; Wed, 08 Jan 2020 07:03:01 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 5sm4621418wrh.5.2020.01.08.07.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 07:02:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 884581FF93; Wed, 8 Jan 2020 15:02:53 +0000 (GMT) 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=O+jDkffcXWGWrl2ViCkscRGcA34TMzzu2DuCiFiOkiM=; b=WC6Pb645SD32eTokZLUUFYs16cSub/2drjdA+E2dHVPXHCoITQo+4MOI2iIlM9L0yh wZTp+GZCuI0QOi8H5O7P66tyCrpGh2C3uSd5wGboDdrnZn7hYE+NZ5IhMM942mEx67a7 VDJdb1XHwWd2wgHRA4/I62AOEsiyNm/gP2TgKxi7IfoPWdrqdjGgqh2BeRX0Un72EPKF 6iNQCOLl6djXbA4C1Apv2zWt0xRVNf5gwjGI9ot9zXvGzVW2k50l/LU9nVFwGkq/PytP UIYu0SGXryxT5b+3xv/5hYPPLECpv3KQzWubDNxzBcSnJOGdyntAlJhwVlHqk0TXIfZV wodg== 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=O+jDkffcXWGWrl2ViCkscRGcA34TMzzu2DuCiFiOkiM=; b=VWYaapDSRZy/bbFm2WCCL/cNdfZSCS3+IRredNr8wUTbf0fFVYYKfNIn0ZUyNHDhV0 DBfQayGr07YL33IXYZZRc+o3vScIndHtfmCM0y/vFiBm6Qp6vmceO7uL7RqWyJsoqJtq hvSyjmx8UMeO2OFiJ7ByZsSQ1B394VjPz31cG0uV11fqU6XaDgKrEyIbSMNHv5Fn0BCQ 3rqXvPBs7kVmLnbGBw/tkKCqPD4DaZ9vMso8whbUBZeqwkZXrfHWO1yENQtek2M9WxjU lqscRbV29El0ZzrMqrgXbmMgGGaPxjOsX0Sr4Shg+ARqcXSaMJqaWHn2ElsdT2+/WZ+Y RSYQ== X-Gm-Message-State: APjAAAVx5WjLlsTvLM1aK/ep/M1oBA4diyvS1VpUp4VIbSfExQ3peN1F Fv2vS6TvhJx0IuobV+sREI58Mw== X-Google-Smtp-Source: APXvYqyrOjzFqVs9HXdTkjmY5ZCQNJebEOqxQ1qsQZruXODVEdPuukZHmOIrYKffjMS5i1ZuJnzyDA== X-Received: by 2002:a7b:c183:: with SMTP id y3mr4474756wmi.0.1578495780862; Wed, 08 Jan 2020 07:03:00 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 6/6] tests/tcg: add user version of dumb-as-bricks semiconsole test Date: Wed, 8 Jan 2020 15:02:52 +0000 Message-Id: <20200108150252.6216-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108150252.6216-1-alex.bennee@linaro.org> References: <20200108150252.6216-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::32d 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: Peter Maydell , keithp@keithp.com, qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) There are linux-user users of semihosting so we'd better check things work for them as well. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v3 - include aarch64 version v4 - use common semicall.h, test thumb & arm --- tests/tcg/arm/semiconsole.c | 27 +++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 7 +++++++ tests/tcg/arm/Makefile.target | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/tcg/arm/semiconsole.c diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/arm/semiconsole.c new file mode 100644 index 00000000000..6ef0bd24500 --- /dev/null +++ b/tests/tcg/arm/semiconsole.c @@ -0,0 +1,27 @@ +/* + * linux-user semihosting console + * + * Copyright (c) 2019 + * Written by Alex Benn=C3=A9e + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include +#include +#include "semicall.h" + +int main(void) +{ + char c; + + printf("Semihosting Console Test\n"); + printf("hit X to exit:"); + + do { + c =3D __semi_call(SYS_READC, 0); + printf("got '%c'\n", c); + } while (c !=3D 'X'); + + return 0; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index 96d2321045a..4281c766419 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -32,4 +32,11 @@ run-plugin-semihosting-with-%: $(call strip-plugin,$<) 2> $<.err, \ "$< on $(TARGET_NAME) with $*") =20 +AARCH64_TESTS +=3D semiconsole +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + +run-semiconsole-with-%: + $(call skip-test, $<, "MANUAL ONLY") + TESTS +=3D $(AARCH64_TESTS) diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 41aa26f4e17..a104ca30281 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -49,6 +49,25 @@ run-plugin-semihosting-with-%: $(call strip-plugin,$<) 2> $<.err, \ "$< on $(TARGET_NAME) with $*") =20 +ARM_TESTS +=3D semiconsole semiconsole-arm + +semiconsole: CFLAGS +=3D -mthumb +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + +run-semiconsole-with-%: + $(call skip-test, $<, "MANUAL ONLY") + +semiconsole-arm: CFLAGS +=3D -marm +semiconsole-arm: semiconsole.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +run-semiconsole-arm: semiconsole-arm + $(call skip-test, $<, "MANUAL ONLY") + +run-semiconsole-arm-with-%: + $(call skip-test, $<, "MANUAL ONLY") + TESTS +=3D $(ARM_TESTS) =20 # On ARM Linux only supports 4k pages --=20 2.20.1