From patchwork Fri Sep 6 20:26:32 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: 173296 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1210907ilq; Fri, 6 Sep 2019 13:27:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgWnGwUu9kTmW31mKfbVWobXqlENGVzc1Rx60wFo5EJUf3+JbeoVzKv/6gOYvXEQb6BY2m X-Received: by 2002:a17:906:1317:: with SMTP id w23mr8924037ejb.312.1567801633298; Fri, 06 Sep 2019 13:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567801633; cv=none; d=google.com; s=arc-20160816; b=IfmFLet81ysTXM7nzh52dxFf3vTouBBDEwHCtYHDSigPvaH438iYeJDzk7UxozUolg 05o7OM7tvsvZ4T9RGuB/P31DLxC8Q7jNlkmB2ZKfLj4gE3fKFGizG2HCKcCJT9TY8aKD t9UnssVJ3GM61dTmJHfhnaCVCbOHVj7fgVi5a/tIrotijtyiljignLM2kSfrXwCceThv mqW7a6tREM7np7rOS8V6z2Bj87xZH6n7JINNqKQmQnElt/6ce7nFLI56LjCEQOctYRyd Ya7/YiI+GAYVhb8w+m4NjdzQ246J/gI1m+r8oAXAOx4vNelGXhPJYsdVMRNtaDbV3SOG sCrQ== 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=Uz7sgUAP0L8aqr3dJc1aRVuOaDTbROnIDJsWBPURkPGkhRoNLtJ27j6ap0IhiyUr+4 1wY3LirGcqsUxQ6nfMjjGeTJM+gcGefgcdnOHH6RcvA9NFHN7DVj0TicMEV7OlOjOd5f V2tIPzIt32BJYW1uqV7WTxcLOQ0PFt5ZATe4eQbS0D0xgygF/jMFnXgyhKel1PC2ZecS NYfHNIovM6qiBncX0GsVs0P+SF6PKycVoFH4BE/cmzh7Bqjt30evSAiKoTHM5tih6Dng ThEc0OU3LynoMYd3nyRn9LIlMVHosw5Y3MInsbHu5LQ31PHYZMbpOeFwVv/FhUIcKnrg JQ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="cFeW/KPm"; 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 k53si4204505edb.303.2019.09.06.13.27.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2019 13:27:13 -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="cFeW/KPm"; 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]:60042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Kp6-000379-2k for patch@linaro.org; Fri, 06 Sep 2019 16:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58054) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Koa-00036b-PL for qemu-devel@nongnu.org; Fri, 06 Sep 2019 16:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6KoZ-0002Ql-Ku for qemu-devel@nongnu.org; Fri, 06 Sep 2019 16:26:40 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:36083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6KoZ-0002QG-Cb for qemu-devel@nongnu.org; Fri, 06 Sep 2019 16:26:39 -0400 Received: by mail-wm1-x32b.google.com with SMTP id p13so8445368wmh.1 for ; Fri, 06 Sep 2019 13:26:39 -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=cFeW/KPm39yoZlIL/v/yZICYrcxotgsE73fpad1iCm6MLu2U7zzMjmplcmvP1wO9RS zcFUXkraLWxi1NbyFGbY1uopjdrSeFnLoihWbUSx5G1gyKM5HkdbMnfryZa89SjhdpuB 2Urv+c7Irt3ZSzN77A3LIrU0S4BJ746+WZioWzQuROz8u0VkcDh4krgeEdsT3yap0NGo 2aT9L5FJ6W6Q6S4HUqC41s0eGKQhaTMpDBNI1q91cEYHxUeD6t5ud+UY9TzprwUYl9tm BDZ0J/d9S2Cj1KwaMOM2l8M7WbWarB0NilcDwgtJ1z18MNLii+kn9/rUexiMKZbaiVrI XNNg== 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=CW7xmD/8zqPgBYlieQM3dtYsK00qUzf0LXrPcD6TR4S4Ckv/Z06iXItoS6rbtvwJhT zw43yl4y9+xf3jaxDuVIeRDI09O8FS+Av5oAcRP0kx9n172X8rhri+c0jBKz4p9E4ITR 0qMtDcydlAmB8vbCnZhExfEUUiPPkRiHgo3rapnq+Q4YCio3QQHydmY885V52dJN+lh+ p3INsPIxC4nGZ+9JVVYGGBaFd+v5KV7lLtKHZujWofzqZ3Hk9ksFWg57vJFwkrkIbIHv G8S+zj7PvT1xn/La57g0kJB9zMinIpyZilhZ8hPhAyg35aOFYs9WAzGdjkxQYHjj88Kv iaeg== X-Gm-Message-State: APjAAAWUcEp9SX379vzZbJ4O/vWCDEgqZyf51yztJH0REqnSXAGvra7k KgXGtEKwzF2CYZdihdp5iStdkg== X-Received: by 2002:a1c:cf8c:: with SMTP id f134mr9015976wmg.174.1567801598306; Fri, 06 Sep 2019 13:26:38 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l62sm8689030wml.13.2019.09.06.13.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 13:26:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 521711FF8C; Fri, 6 Sep 2019 21:26:36 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 6 Sep 2019 21:26:32 +0100 Message-Id: <20190906202636.28642-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190906202636.28642-1-alex.bennee@linaro.org> References: <20190906202636.28642-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::32b Subject: [Qemu-devel] [PATCH v4 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_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; }