From nobody Tue Feb 10 17:30:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541695156379161.1771774665914; Thu, 8 Nov 2018 08:39:16 -0800 (PST) Received: from localhost ([::1]:57843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKnKt-00055a-2e for importer@patchew.org; Thu, 08 Nov 2018 11:39:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKnFg-00083d-69 for qemu-devel@nongnu.org; Thu, 08 Nov 2018 11:33:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKnFe-0004uH-6G for qemu-devel@nongnu.org; Thu, 08 Nov 2018 11:33:52 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:45701) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKnFd-0004nW-VW for qemu-devel@nongnu.org; Thu, 08 Nov 2018 11:33:50 -0500 Received: by mail-wr1-x443.google.com with SMTP id k15-v6so18957750wre.12 for ; Thu, 08 Nov 2018 08:33:36 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e8-v6sm4243641wrw.75.2018.11.08.08.33.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Nov 2018 08:33:32 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 59D063E059D; Thu, 8 Nov 2018 16:33:30 +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=ZVCeHrA6mrSycqRGwzmYpbWPY3l4jyoiyxlbXBtrWBw=; b=Ntm/WNCQ+h8DTZ6qYRlLYuMtu71ngOReYZrASRBcX/KmEMnaM3GKX5hCbQT4uyKdA1 GhIcDA6yfoO5cvXHWKejf1XTJ84cFLgTwgUHJUZUZvZRq7z4jUhzkWS/Zm90WXpL39kY cvM0UEA9NQpaZKAgWhMojc3rgnic3coIhnQto= 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=ZVCeHrA6mrSycqRGwzmYpbWPY3l4jyoiyxlbXBtrWBw=; b=cTQaN2k67CkhAzBb4nzlWM07M+Z8OhgRF+VpJ5wDOtlLb9fjF5lWm/zsMNwpJ/wTlt OxqOUi4ToOQM6jSVXqnyBMfQtANK6vTWH7lJE4rC5PimGsfAykhaTT8vRY2FbDWVgtQe vNomPGWB6AWX4wHnNQMRugPcyHjUnpcLtldGVgq6WUijfvF3ZZnAGB//snZdkxIHR1wx M9UYpStGWw9YdytUMcbQtHN9VSuxwxYLGb+BwrcvDGeakrXVPCsT+tYxWEFlAyR9F7FI N27pTSrSBfa3BSTgYcfAC4cXw/Z9UWQeVbB2/DAf5YZx4LRD6fvLHGBiA6O2MWRb9EiT j+2w== X-Gm-Message-State: AGRZ1gKP8zIkRfKep4qMZTy+Wt6RTPRUTSBR/de0+xOj9Jne1ykxGuHI EiZwsUkiMSCceRsa3wZy/DWKvA== X-Google-Smtp-Source: AJdET5emdwaPQ/zVxrbq4G0VjD3/CsksSZNK6dKiEP8+PeIF5f6fBdMBwyJgS51PnWcPINMmMhasVg== X-Received: by 2002:a5d:6a0e:: with SMTP id m14-v6mr4897102wru.76.1541694815197; Thu, 08 Nov 2018 08:33:35 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 8 Nov 2018 16:33:29 +0000 Message-Id: <20181108163329.19940-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181108163329.19940-1-alex.bennee@linaro.org> References: <20181108163329.19940-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 v2 6/6] arm: fix aa64_generate_debug_exceptions to work with EL2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, 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) The test was incomplete and incorrectly caused debug exceptions to be generated when returning to EL2 after a failed attempt to single-step an EL1 instruction. Fix this while cleaning up the function a little. Signed-off-by: Alex Benn=C3=A9e --- target/arm/cpu.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1efff21a18..a6d8eb14f6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2764,23 +2764,33 @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) !=3D 0; } =20 +/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ static inline bool aa64_generate_debug_exceptions(CPUARMState *env) { + int cur_el =3D arm_current_el(env); + int debug_el; + if (arm_is_secure(env)) { /* MDCR_EL3.SDD disables debug events from Secure state */ if (extract32(env->cp15.mdcr_el3, 16, 1) !=3D 0 - || arm_current_el(env) =3D=3D 3) { + || cur_el =3D=3D 3) { return false; } } =20 - if (arm_current_el(env) =3D=3D arm_debug_target_el(env)) { - if ((extract32(env->cp15.mdscr_el1, 13, 1) =3D=3D 0) - || (env->daif & PSTATE_D)) { - return false; - } + /* + * Same EL to same EL debug exceptions need MDSCR_KDE enabled + * while not masking the (D)ebug bit in DAIF. + */ + debug_el =3D arm_debug_target_el(env); + + if (cur_el =3D=3D debug_el) { + return extract32(env->cp15.mdscr_el1, 13, 1) + && !(env->daif & PSTATE_D); } - return true; + + /* Otherwise the debug target needs to be a higher EL */ + return debug_el > cur_el; } =20 static inline bool aa32_generate_debug_exceptions(CPUARMState *env) @@ -2833,9 +2843,6 @@ static inline bool aa32_generate_debug_exceptions(CPU= ARMState *env) * since the pseudocode has it at all callsites except for the one in * CheckSoftwareStep(), where it is elided because both branches would * always return the same value. - * - * Parts of the pseudocode relating to EL2 and EL3 are omitted because we - * don't yet implement those exception levels or their associated trap bit= s. */ static inline bool arm_generate_debug_exceptions(CPUARMState *env) { --=20 2.17.1