From patchwork Wed Sep 11 16:49:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 173623 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp997462ilq; Wed, 11 Sep 2019 09:54:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxq6EZVvwTH2+g4TulGBLdkjWGyolJOFf5wlsbthuX/AyMn+2oYhcT+F57iGqwehjadScnH X-Received: by 2002:a17:906:6403:: with SMTP id d3mr21216667ejm.99.1568220856322; Wed, 11 Sep 2019 09:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568220856; cv=none; d=google.com; s=arc-20160816; b=FUENvG2DgD3mlchP9f7RrTdAKh7RKMCWKhvBFIKkvaI6alVB1HfkeYlahIJF8k+zDh NlCqtqUn3pF9YvaBKLAfrUNpGWhJ/gWhqkKkb4nCjvCfJH0IubUAdwos4UF5gUm/mOJT 4BlTx/ya0U8P86rL72hhsllp3ifeiuPe37UD0l6yHSSHEzIR34ttcvzLXNPfi+Xio/Yp ANBraa/jFXg0aQ3Mh7TlAzwHUmwFNLIr7DdSkZaQvQDlU9iwuZ5iB9xpZh1omleXEG5m Nr9E/Og9uyqa3E6TcaQgZ3bAViigAPQvG3qqBIFnbzjElMtU9JJ0mj9t8G1dqdOfBf6u kZAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=uRjmOsEbXk15ydPmEJ99gd5DAhkd0VbLE+A+syxTleE=; b=ChG+kIOGmmD6okcbwr1UdGgL1NKMLnMs0DYS16Let8Q/mNhV9OMnlL4NjS7VzvoNUo LL00BEwz4mjur6dYspEAPRH8OF7yD2P55AOMTfDutLcFVpfYjceiN08RXHVSzt8TnwWY kgkSVZkbyM2WOCEhHWZroO265g5QRK51uQCAlvt+Rp0QHM40JTpIspaD5Q03u9XsAd0N pPEVskivYRJypn0wo1K36l2GBPzRfMcrPNJ6F+pIlOO6hVwUsmTr1AWMgsZ1BPv+Ag/b zBPKI5F7Y3uz2dBbD3l6JBzBTX2h3Zec/wN00VaKzGkMgsHcA+UpKTl+zTSAbp0e71L5 RxKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i6wfyfdH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a8si4102734edn.332.2019.09.11.09.54.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 09:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i6wfyfdH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i85sl-0002Op-Ae for patch@linaro.org; Wed, 11 Sep 2019 12:54:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43490) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i85oj-0006Uc-57 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 12:50:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i85oh-00048K-Ry for qemu-devel@nongnu.org; Wed, 11 Sep 2019 12:50:05 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i85oh-00047m-Lf for qemu-devel@nongnu.org; Wed, 11 Sep 2019 12:50:03 -0400 Received: by mail-wr1-x443.google.com with SMTP id k6so13226334wrn.11 for ; Wed, 11 Sep 2019 09:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uRjmOsEbXk15ydPmEJ99gd5DAhkd0VbLE+A+syxTleE=; b=i6wfyfdHclxGEDVmHLKAronMHhWnsi68fRV8yW7768Cwv6sjVsiIsU6ev0HN1/OJGQ 8zw7UiLInPgXcFW97vv1wqe+CyWfs6bZ3eU92iGB8HcTig4odYz6hqNMiy4HsLiHvKhT QIe3f9BSAlS7syrbFtwA96e9adlBDQ8WHM75IXfrYmiHoScqG87nIk5lr6ncJ4oWAwyY uXbIkp7LIE4AL44io5OIKcou4EulLMDcEMeqfdN9vRfzjrHJ1XAu+SkKlALLAhj52N5/ gpJQjQg5qgNe33f3Uve8W0gJod59kAQ6s05ouM/1+gaV0dlo11jyXMS6/F9y9/Xl3D7u M6cw== 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=uRjmOsEbXk15ydPmEJ99gd5DAhkd0VbLE+A+syxTleE=; b=SxeAtpvEZJjBFLD0IGF+j6nWwy38/mlhfkzVEnR/WRM7/voS6ll2QAkvBKRCQOdFUz Ska94hQ1IMgcgKkwyyJ0mlI5g+1++KY+Uxyb4DOfpjBne0vwBOF+aJ97GNdyXwujXsHH NDKyqlhnTKUWqiRnEb2LDutT3RUDkbOIl3rm5VzO1x8f+6lLe/xb3CpWzxEaNrLNhZiS VMCUH/04h1FFWl5r3DE6XLf+TwBQA3cD7Oji+6bojMcEnHUgENqve7dOJVd3Pi5b6FMA Vrl0M38uc4ccbEhJRDyI++s727mx1W74eQ5veXe0bfgtZYUo8x8GIRUXKkukqQQ5TYEO EQvA== X-Gm-Message-State: APjAAAXdvPDz2jurcT6f/jyqUVarcCssnb4zcdqqM2gG8yWRMh6CItRM ywWaRKp0w2Lm4f8ejAgDeaPaPg== X-Received: by 2002:a05:6000:b:: with SMTP id h11mr1957174wrx.270.1568220602581; Wed, 11 Sep 2019 09:50:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h21sm16378463wrc.71.2019.09.11.09.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 09:50:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4A1F71FF8F; Wed, 11 Sep 2019 17:50:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 11 Sep 2019 17:49:56 +0100 Message-Id: <20190911164959.11003-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190911164959.11003-1-alex.bennee@linaro.org> References: <20190911164959.11003-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v5 2/5] 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_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We do this for other semihosting calls so we might as well do it for M-profile as well. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - update for change to gen_exception_internal_insn API v3 - update for decode tree v4 - use !IS_USER --- target/arm/m_helper.c | 18 ++++++------------ target/arm/translate.c | 8 +++++++- 2 files changed, 13 insertions(+), 13 deletions(-) -- 2.20.1 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] = do_arm_semihosting(env); + return; case EXCP_BKPT: - if (semihosting_enabled()) { - int nr; - nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff; - if (nr == 0xab) { - env->regs[15] += 2; - qemu_log_mask(CPU_LOG_INT, - "...handling as semihosting call 0x%x\n", - env->regs[0]); - env->regs[0] = 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..6689acc911e 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8424,7 +8424,13 @@ 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() && !IS_USER(s) && + (a->imm == 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; }