From patchwork Fri Jan 19 21:29:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kl=C3=B6tzke?= X-Patchwork-Id: 13524210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1B9AC4725D for ; Fri, 19 Jan 2024 22:40:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQxXU-0001nM-92; Fri, 19 Jan 2024 17:40:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQwR5-0003hc-K7 for qemu-devel@nongnu.org; Fri, 19 Jan 2024 16:29:59 -0500 Received: from serv1.kernkonzept.com ([2a01:4f8:1c1c:b490::2] helo=mx.kernkonzept.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQwR3-0001pY-0j for qemu-devel@nongnu.org; Fri, 19 Jan 2024 16:29:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:References:In-Reply-To: Reply-To:Content-ID:Content-Description; bh=D52YVx8j+ZeyzuPrKqpnYYepjkrsS3E7FsEF80Ju8pw=; b=C16ffXUlNeiovCMyWmx0UgJvZd VK8MVu9usoqE2aqRCdlaM8ZbLdmhafwVE4KL9EvDrpu8dgp6FUNh3xuvmZDjXKD46RIPJEg53AEXj sVbTTBHhPS1FFkaiakzq4Y3CcFn/bjyZOpA/MfoEhcdYADCrTiM5WBcx19JKZoCGHQNvQWSNXn27o tqoC/Ih5hpe3wfjwRMFGbq63stR0eb6mWn3YrN/wmcuRhjohXCpxjmb3+Mev8H9sv6ohh/cD5D6kr f2mEoYDVZiXzd+wclcvCH9ofXssrmjVxk0hYZdCNXAhZzmJVTJRS/epAi/TVwCle8wvh9TbfoNh2b JjBYf0ng==; Received: from p5dd489e8.dip0.t-ipconnect.de ([93.212.137.232] helo=shark.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1rQwQy-001Gps-1K; Fri, 19 Jan 2024 22:29:52 +0100 From: =?utf-8?q?Jan_Kl=C3=B6tzke?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Jan_Kl=C3=B6tzke?= Subject: [PATCH] target/arm: fix exception syndrome for AArch32 bkpt insn Date: Fri, 19 Jan 2024 22:29:45 +0100 Message-Id: <20240119212945.2440655-1-jan.kloetzke@kernkonzept.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a01:4f8:1c1c:b490::2; envelope-from=jan.kloetzke@kernkonzept.com; helo=mx.kernkonzept.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 19 Jan 2024 17:40:38 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Debug exceptions that target AArch32 Hyp mode are reported differently than on AAarch64. Internally, Qemu uses the AArch64 syndromes. Therefore such exceptions need to be either converted to a prefetch abort (breakpoints, vector catch) or a data abort (watchpoints). Signed-off-by: Jan Klötzke --- target/arm/helper.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index e068d35383..71dd60ad2d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11013,6 +11013,26 @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) } if (env->exception.target_el == 2) { + /* Debug exceptions are reported differently on AARCH32 */ + switch (syn_get_ec(env->exception.syndrome)) { + case EC_BREAKPOINT: + case EC_BREAKPOINT_SAME_EL: + case EC_AA32_BKPT: + case EC_VECTORCATCH: + env->exception.syndrome = syn_insn_abort(arm_current_el(env) == 2, + 0, 0, 0x22); + break; + case EC_WATCHPOINT: + case EC_WATCHPOINT_SAME_EL: + /* + * ISS is compatible between Watchpoints and Data Aborts. Also + * retain the lowest EC bit as it signals the originating EL. + */ + env->exception.syndrome &= (1U << (ARM_EL_EC_SHIFT + 1)) - 1U; + env->exception.syndrome |= (EC_DATAABORT << ARM_EL_EC_SHIFT) + | ARM_EL_ISV; + break; + } arm_cpu_do_interrupt_aarch32_hyp(cs); return; }