From nobody Sun Apr 28 21:28: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=1567774405; cv=none; d=zoho.com; s=zohoarc; b=ZMWAIBjrV7l3opJagH7+lXVil7bR/l5sWPp7ICUu9KX+X0LvA2y26dawL0iGe3GFTTbA12RFTzPa4VxTIyW5oswWDdcVKI4k6hpV5k3HeMHkxRunWCsZCGYRf1sRbdzQ0sYy3d4yAXOgW8hrQSircloRlHcuWcnmPAo5AKQu+Qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567774405; 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=lQHwlLQPM95FwA1k9cP7PvNCmUDAHDGdetoNJrdT6Zg=; b=AA3NAwK+CmbOgVKr70g86dZM//SmsvMjNt6878UquuEsGrNwcqVKMbkYZeO3VAV3GVqSVH6S0z2aRMJyDdd4XV8EMOgu9bZ7lcoaKJEsyQZuPNWVox/pKt/GNvkaXZsBWgTTXyG9tbG8OIaWKx0nLCFhL/bQb8Pth2qlWai33K4= 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 1567774405171417.77792761479384; Fri, 6 Sep 2019 05:53:25 -0700 (PDT) Received: from localhost ([::1]:55942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Djv-0004SL-Ni for importer@patchew.org; Fri, 06 Sep 2019 08:53:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54671) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Ddv-0007L6-Rx for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Ddu-0005qK-0i for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:11 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:36920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6Ddt-0005pD-Q8 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:09 -0400 Received: by mail-wm1-x333.google.com with SMTP id r195so6971719wme.2 for ; Fri, 06 Sep 2019 05:47:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r17sm5990270wrt.68.2019.09.06.05.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 05:47:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C31DC1FF8C; Fri, 6 Sep 2019 13:47:06 +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=lQHwlLQPM95FwA1k9cP7PvNCmUDAHDGdetoNJrdT6Zg=; b=HvmVbsQab/LsjzrZHNJFr68DD6DUnSTxwE4r+Te+uvljXTzPJKTNFFm9XkMkp4UHG6 sag5M8b46rs+a+MCYUsqYf/s2KrYSEgkMsiszHTBDRAZLmNx1pIR9ROiVvhUZXbFgUX8 9MPOJVGg1hqVbKakc6Z/TqwQSYQUXohGRx/q4BZxj4ZwjCIlvEGoT107rol1lXEdopht QwW0Vz7BGytqJS5EAzrOLqw3Hu8XJu5Bck9AAgkIIIfWzlNzSz9J7Qr/Z8cOnKm7Was3 ANI41uGkPmrk1i2qaofnidvE/ZXe09MmXKguyFNKDCEQMdpLTk4eu9jP8bVIQcNsYCx2 bBEw== 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=lQHwlLQPM95FwA1k9cP7PvNCmUDAHDGdetoNJrdT6Zg=; b=isLu0PIG2c8Up9ks4tXSKi4ZYvkvST9JZvY1/NvYspTW2DIPH1ALOF24vNyGF8e+Rr GJ3jIStojrSrmd0MNMvZ9HzqDWUDZ20lsWwgGcDRzY6ZxN4n/Qw5S1YSqZT8DTN83kNE 5HHJy6hfzte3vB8XSJ5npF77iDssKwHth6GnG6VjSLW8/lA31be/5m5G8etMy5CJk4gO jISNRKHB2L8+DXqHyG7dT/bdJ8wTsoIUDY8gn8hmHFyAYNYSAo8xqFJOIqAkEA6AXlns j9Qv/Kd+eYajTJm9OuK+kDUI3O228p/Po93lb3uIPH2B3dvef2juRb8UdH8IVN0gCOv7 +sdw== X-Gm-Message-State: APjAAAVYREQHNQLmu5CvK1KiLhmbMBIBCyJ7dEmZnIm7ysEuB4ooaCKI McGJ1YZ6cBBkeBme1PSE8uXhXg== X-Google-Smtp-Source: APXvYqyXECHB1h3UhGDptTDjWM0EkBfNgLq/V5EG3t5jNckpNkEhLC5kbcgcBCgrmJ0eoBxN+pU14A== X-Received: by 2002:a1c:98c9:: with SMTP id a192mr7284697wme.29.1567774028710; Fri, 06 Sep 2019 05:47:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 6 Sep 2019 13:47:03 +0100 Message-Id: <20190906124706.19145-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190906124706.19145-1-alex.bennee@linaro.org> References: <20190906124706.19145-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::333 Subject: [Qemu-devel] [PATCH v3 1/4] 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 --- 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..4cda7812bcb 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 + s->current_el !=3D 0 && +#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 Sun Apr 28 21:28: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=1567774254; cv=none; d=zoho.com; s=zohoarc; b=S+KV8Xl6SE/eOeMfASyCr6Jm/n+/ZJgooZ87FybIgsvbWavo8WsLUwRHdzwEGFw+U4S6R9i2TVdqy0Fry9E6SnviikHoxYXA52wj2OcsW3Lo1d5U6Ey/v2b3MRhwoxTnWFaqQqUC0xcMYsdFnRXGEy/vRbiiv6/xS+JUeKjaGdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567774254; 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=EOvVFZM+noAC6V/BvH+4ihUiEGZZA4RlqpGJMJGGkFU=; b=EapT936/efwzrzRS41m9yhixYD4d0NDatYMQYF5sx13ZSYNRjkA/o+4m7UX17TPrTK/UZiVUe4tyrUfqULe31IODe14oX1mlm95oRZgDm0ftBIwDq1tz9JWxPADQfvOGokVvJ0JD8e6uKeu0ZYdMmdYvnhkw81pz9mj5KSgWrxw= 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 1567774254375248.62316411284667; Fri, 6 Sep 2019 05:50:54 -0700 (PDT) Received: from localhost ([::1]:55824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6DhV-0001fQ-1o for importer@patchew.org; Fri, 06 Sep 2019 08:50:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54685) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Ddw-0007L9-E9 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Ddu-0005rH-QT for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:11 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6Ddu-0005q5-9p for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:10 -0400 Received: by mail-wr1-x443.google.com with SMTP id l11so6443189wrx.5 for ; Fri, 06 Sep 2019 05:47:10 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e20sm7142556wrc.34.2019.09.06.05.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 05:47:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D94221FF8F; Fri, 6 Sep 2019 13:47:06 +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=EOvVFZM+noAC6V/BvH+4ihUiEGZZA4RlqpGJMJGGkFU=; b=UbhzYfYyT0+0eBkCfuyA/NYq9gZ2zIDmpW33y6LJo7ZY8TB9TW0GhAS32ALq5py/Y1 WK1vXt8GCenaFygMYNI+QKJC4Cqu8PW5iOEScde+EPDI589+As9Nkp/A7upXlJpjs4gG koaIL/mBWoxsi2KxUI3Jry9bW9C8a4hiZH/Zhx3UMBdBHZUFcZaed/Lx8JzuRjuO2oQM ipRXHVy47F0Vgey2qPAMhPcPTsj54gdEfiqZIumON0BumAGL9qZdBYbpuZ7hb/RvzadQ ADrhfev1GPVr+aRSEXvFLZikxhMMIU7voqQlhj+TG9nu2KtoP1yjW0QhwMYHQXIM6iD+ FXYQ== 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=EOvVFZM+noAC6V/BvH+4ihUiEGZZA4RlqpGJMJGGkFU=; b=XXPRlHl1dufxHBI3xc9hYV4OZmC+WmXzCcokefeCwn5Pfud7Wdu3G+tGcX0x2+eTQ2 IFk+ahQ+gLMdZ0zSlvD9J3sC/72A4RcZISX9fq7YQUl+P/vi+zZYOZloynDnDTViSB3e JwI2eLyUUSPxxl++hieY41a4dGByjpmVjEnNNC1DdPzMotgv3cgmwpMZ9OewVmTHh27K zti9AVuCpChKXdKLdP48bl6or7mkBGTdViyE1YEgmdeHaU4cf2jYG8oX4D9z/43AHC7N +DdIfQMniLNiTYLOfU8B8ud/iJWvOuV374J4+gwrgsintMNv2+pJk9AMACb5wsMscY7b CqsQ== X-Gm-Message-State: APjAAAVYFYp8hHyPnM+jA3AlKqJdjFgmXK+j/ibfTN1zLs7js1EseEZ3 BL7JIzL2B/Tev1HZq3JnIxdsFA== X-Google-Smtp-Source: APXvYqznQWOJpDSqdVw3u+OijRpvtKqDYhwo+yPFJRBylKL1Be2pe/VpJXN5sOXrndPGB4bYbzwcoA== X-Received: by 2002:a05:6000:2:: with SMTP id h2mr6273231wrx.309.1567774029264; Fri, 06 Sep 2019 05:47:09 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 6 Sep 2019 13:47:04 +0100 Message-Id: <20190906124706.19145-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190906124706.19145-1-alex.bennee@linaro.org> References: <20190906124706.19145-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 v3 2/4] 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 --- 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 --- 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 4cda7812bcb..ed4a97cfb44 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 (semihosting_enabled() && +#ifndef CONFIG_USER_ONLY + s->current_el !=3D 0 && +#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 Sun Apr 28 21:28: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=1567774211; cv=none; d=zoho.com; s=zohoarc; b=AsL/jJ/WQR3dgMsfv3XNFTEdce3MPnX4PLlOQrbRP95aqHuKagg97gPPrmZQLaxs7xQtSfRQL1JRq5L2hRQtT+HJ81B/5ei1WWaIyWcIuSkht5rQRmnfAR2dVS+pBigIkx9f+U7npyOrAt4n6E6YNiuiJtjh+F4FVknktqSkXjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567774211; 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=lCvRo6b41f56hAddDThE5H6QfoE+uJ87vDSKRK9LY1fYfyzDPbEmRwefTJq7UO4wQNtmHmBFL2+BHTUoyCTPD/YPRWYCzC+IcjA2pkQ001wl/SH0vZm1/5htbAGWJPr3DbYjnZuti7b9T8pwRw2WId17fFlAYh4MgDXI9sbdu5M= 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 1567774211098496.82112094053525; Fri, 6 Sep 2019 05:50:11 -0700 (PDT) Received: from localhost ([::1]:55820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Dgn-00010n-Dx for importer@patchew.org; Fri, 06 Sep 2019 08:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54746) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6De0-0007M2-H6 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Ddy-0005ys-Ge for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:16 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6Ddw-0005sD-Bz for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:12 -0400 Received: by mail-wm1-x341.google.com with SMTP id n10so6972535wmj.0 for ; Fri, 06 Sep 2019 05:47:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s12sm7334448wra.82.2019.09.06.05.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 05:47:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EEC9A1FF90; Fri, 6 Sep 2019 13:47:06 +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=hE9vOr4ZBRXZClZD1JwA7TU8R3Rs5dn3wND0mtm49e5RKYlMScQh1MKld5pbzIoKVh TFjZooY/6BaClJuVYDQQDkIuD/cNvg+t6AntxL8iNj2g1eRcNzgmUsWnZSCI/Gl1Vgbb dHDEdMShjnwjRsC/Ras/7UAZH3xaIIaMXik32TwAd8deDQeu+oZ3mgtknojXfuIp/tLi wE0pNnMALikSL/YNL/b8M9rF41D3W99fVdYoWw3LYNAWkr0mrGgOQfDj+7j7yTyJR/N/ 3NAO6vexpzWhekCDDVXKr4GauQW5qrD9Huoj4ePKqbRSA/RZC0liY1Ffd8zec/0qaazI X8Aw== 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=h151mwRk0tkU1xc+sp8un9ANeOG3f0TMuIIC2Z3Wolw1wB9Zur7I9IhSaz/NHpIKcY dxaNWt/WKvfy3fGJjDhCiPvP2+enRwWRo2NvxuxWDHXSCzwR1hK5c57KQbfR8AKWHdkH H7byOoLqWxQ+6w7YDQ1ePgO5/sB+/9wTJs1CrbFBpU2tsBQejyt2PCoGjOfwqnpZPNmq PuG+5vj/QE/cOwO4yCDXhyBy3r2WVv1qB0l94WS0NyA/IHXucSZODKXi2dh2+NKdBtZ1 pVeZvWJxL5GI2UA5Xt5mT8gThNFGDnpJg2ScVmjCvFPwG/exl0eL8rTcteb+tPyooOdS TLvA== X-Gm-Message-State: APjAAAXr2XhE1tpryc540fxnugVehB31wLRVA/8bz5R4mCz0H12REn88 9O2fDIuQd/P1dmh2l1OaHqJU4g== X-Google-Smtp-Source: APXvYqyYojoSx460XgzjoV9S6CeyRfzVcV/qKfx0blL4Y50vdyAqI9MqdbNlSlBWWlpfOEQu7npuOQ== X-Received: by 2002:a1c:c78f:: with SMTP id x137mr7740433wmf.42.1567774030709; Fri, 06 Sep 2019 05:47:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 6 Sep 2019 13:47:05 +0100 Message-Id: <20190906124706.19145-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190906124706.19145-1-alex.bennee@linaro.org> References: <20190906124706.19145-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 v3 3/4] 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 Sun Apr 28 21:28: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=1567774211; cv=none; d=zoho.com; s=zohoarc; b=QRmiG0c/8tq9IC1f1zHa9IzmaX469Xq0bn8baZ2Ewyx0SWwvI+mj3yZVJXkZUoRYj+ZeLr7+oJ/saK39g1zjcM3CIqf3+pYLB1/aze7MT02dQydviKtsVDQ9y36Jk9yRHavcJRMNrFQdy9QSpEomlzaa3dmNzcNklTX8o0WUPWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567774211; 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=hEwLxmZ1/l0uu9kShjHwMMLEdP39KievYwY8GQL60m8=; b=f2a6BpiLdIITAfpmV8PTh7lmQCK91BX6kIIkZoLX5iGjpl9U4/1ebDNRDb3mDfTBsmH/YDOhjTNbRB6LrlIJ9PdyEMdUWCWixUuTkn1HFhGG10XqEsDS6NSfEB1uT7LQgOCVL3JfqvcnnbxpCZLbFxS5mr0/j8jom0Gn+KN0vG4= 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 156777421194326.51230227807264; Fri, 6 Sep 2019 05:50:11 -0700 (PDT) Received: from localhost ([::1]:55816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Dgm-0000zK-3X for importer@patchew.org; Fri, 06 Sep 2019 08:50:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54719) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Ddy-0007Lb-LC for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Ddw-0005uh-3e for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:14 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6Ddv-0005qa-CD for qemu-devel@nongnu.org; Fri, 06 Sep 2019 08:47:11 -0400 Received: by mail-wm1-x342.google.com with SMTP id q12so6965351wmj.4 for ; Fri, 06 Sep 2019 05:47:10 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l1sm6733467wrb.1.2019.09.06.05.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 05:47:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0F9861FF91; Fri, 6 Sep 2019 13:47:07 +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=hEwLxmZ1/l0uu9kShjHwMMLEdP39KievYwY8GQL60m8=; b=ISykOZyoibJVDfT6r5ER/Cdm3h0RYkfNxSmE+rhXbYyZkgRHh4yE3UlbvriKbbgMwz GP6wkhrfpFp8pd0ksP5zAT6o7mdM3obF11ynirNwIeBBH4M9+kxyuLhM8aP60evV31Kz XT3Kgj4GLOCMADjy4Cc6MLCiyxqpjrT9XXl9em0ckyRhabV26TBzC15z4yBptJLgvmzL zKNu98Jfg4d4naOEbtxpX8V01HOlTzazsk20OXgKG7T08wEGl+lpeH64jilqNY5NmFE4 vG70thB3FzsfDNvxi12OB4BT24SXlYwivf+FDGBNH9sdfisSrYs9OMn9/KeoBGuMhhhr UUBw== 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=hEwLxmZ1/l0uu9kShjHwMMLEdP39KievYwY8GQL60m8=; b=o8EE8Vd8A8sEHraS7s+IWZuwpCovgVcp9jFBqd+3FPwxx76rgTe/51/s8//TwSWCAY EiW6t6D+rHcw9CaObRFE5jhXqIgq8cLtxYujD7EeMjAMbV7bQjtpQ6yIW1wtyg+GvY37 NWMNY+sD1v21Y3QRuhr4z2OREDnKSvW9i8tZXC5yNDVs9uFgEEoXeysun4IbwJfIVkzt npUAiNrWkJecf9BfY6aYYVdUQN0zL7kbRuNcZRrRzOb/LVE8kcwaHU5iiH7PO4i7VcpS EV+kgshOzphq0zLK7bV7AwKNwodMfFK1d8d+EA6gNTYZd7pNENVNz7zaiSV+++Y/oETO Ps4w== X-Gm-Message-State: APjAAAXOtlt6J1JMDBCxkZUiomFNg50+S8DUksJF7zVHyrTLJx+k1okI LWJBDbCuI1ZDaTX8ht8gGNtv+Q== X-Google-Smtp-Source: APXvYqxfo06XiGkIY5264Adx2bgXrmb/sVFOSUGHcvmR48xOMRusHk6ba/4XgAyxjPNiFVxx4IOdlQ== X-Received: by 2002:a1c:1d85:: with SMTP id d127mr7590265wmd.14.1567774029855; Fri, 06 Sep 2019 05:47:09 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 6 Sep 2019 13:47:06 +0100 Message-Id: <20190906124706.19145-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190906124706.19145-1-alex.bennee@linaro.org> References: <20190906124706.19145-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 v3 4/4] atomic_template: fix indentation in GEN_ATOMIC_HELPER 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 , "Emilio G. Cota" , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- accel/tcg/atomic_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index df9c8388178..287433d809b 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -149,7 +149,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ul= ong addr, =20 #define GEN_ATOMIC_HELPER(X) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE val EXTRA_ARGS) \ + ABI_TYPE val EXTRA_ARGS) \ { \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ --=20 2.20.1