From patchwork Fri Aug 4 19:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 710231 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:d30:b0:129:c516:61db with SMTP id gp48csp162288rwb; Fri, 4 Aug 2023 12:18:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5fVBS3hgBaPyktIxuCfkfC2cvIhMb78Cu2IqBPmQbTNfUmuOc60NzSZnfKRLSJ+mjZ/PO X-Received: by 2002:a0c:f3c3:0:b0:625:bb19:278c with SMTP id f3-20020a0cf3c3000000b00625bb19278cmr2091426qvm.2.1691176697619; Fri, 04 Aug 2023 12:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691176697; cv=none; d=google.com; s=arc-20160816; b=Wxsn/+MhAwNh4EHcXCVKvFmEH9lawIJJdtq6pZXBxYbimIehGRU/bcf/PgjjbyxS+y akdQxQ7uB1MqEN2lAf12nppFJFRxV0UUImwMW/1i43ByoW+C1epk9GvP0YZgCIOHL4zK 1PW8BsVUCXsOhGqAA2qWAvfi68LV1eFOUBOcsj5ET7qUoodv8j3cVoYT0LeULxkw3jFK JZIZPhIAQndYtI1MQDzQblj86l9CblkObDtr3stawercrgsuhdno0o2Izcs3BP68h3hx zrZstaSw4n/ZLV6xcDgXjWyWMwH+l62/NCxdmLtvE5pGnz8bizxs4ogMHwHnCUH9O5LT 78iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=2bnxnsqKoc7Sxwgvf9h3UpbubHsGjX1Iy7DpWkohFuo=; fh=+twXHueQny8msdLYk4HIx2SowV0ZnuRfIAxEj9lDJjg=; b=R+g/vCsRd7cpARRCz8FLtu1Cbkxl7FO8pOy7N/5L95gwKZ1wy6rUdSGFfvrQMDJfo5 veTx2SHTf9u6FgIovorhWbvhLCSfozQcVxx7Ere42rn9XHtRU6AZjQ3xs+Zg3uuvZNGD oPt1/tAzRQg6Em4en6cOSxJ9vbg+602kXqqxgli/qNGo/4qqvGJiyk+DoSvuwOlvZ2jQ KNsPk44Ypk3uXRY2HcIz4g7+bHXRlI2H6Pu537lrhZOK8vcJeafIRWEvvBT3/QOuB7RY Ti6O4L1mvnPQ8Mz4ShOyaTpmDeyOZTUKle/bMmo7pPruM6Duu6omGcOs11ruZMgIDGXM pe+g== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t7-20020a0cde07000000b0063cf6f808a2si1635159qvk.441.2023.08.04.12.18.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Aug 2023 12:18:17 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qS0IP-0000NJ-8d; Fri, 04 Aug 2023 15:17:09 -0400 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 1qS0IM-0000Ls-V3; Fri, 04 Aug 2023 15:17:06 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qS0IL-0006wh-Af; Fri, 04 Aug 2023 15:17:06 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3020F18459; Fri, 4 Aug 2023 22:17:11 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 90BEC1B89C; Fri, 4 Aug 2023 22:16:50 +0300 (MSK) Received: (nullmailer pid 1875708 invoked by uid 1000); Fri, 04 Aug 2023 19:16:49 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.0.4 39/63] target/arm: Special case M-profile in debug_helper.c code Date: Fri, 4 Aug 2023 22:16:22 +0300 Message-Id: <20230804191647.1875608-8-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell A lot of the code called from helper_exception_bkpt_insn() is written assuming A-profile, but we will also call this helper on M-profile CPUs when they execute a BKPT insn. This used to work by accident, but recent changes mean that we will hit an assert when some of this code calls down into lower level functions that end up calling arm_security_space_below_el3(), arm_el_is_aa64(), and other functions that now explicitly assert that the guest CPU is not M-profile. Handle M-profile directly to avoid the assertions: * in arm_debug_target_el(), M-profile debug exceptions always go to EL1 * in arm_debug_exception_fsr(), M-profile always uses the short format FSR (compare commit d7fe699be54b2, though in this case the code in arm_v7m_cpu_do_interrupt() does not need to look at the FSR value at all) Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1775 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230721143239.1753066-1-peter.maydell@linaro.org (cherry picked from commit 5d78893f39caf94c8587141e2219b57a7d63dd5c) Signed-off-by: Michael Tokarev diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index dfc8b2a1a5..0cbc8171d5 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -21,6 +21,10 @@ static int arm_debug_target_el(CPUARMState *env) bool secure = arm_is_secure(env); bool route_to_el2 = false; + if (arm_feature(env, ARM_FEATURE_M)) { + return 1; + } + if (arm_is_el2_enabled(env)) { route_to_el2 = env->cp15.hcr_el2 & HCR_TGE || env->cp15.mdcr_el2 & MDCR_TDE; @@ -434,18 +438,20 @@ static uint32_t arm_debug_exception_fsr(CPUARMState *env) { ARMMMUFaultInfo fi = { .type = ARMFault_Debug }; int target_el = arm_debug_target_el(env); - bool using_lpae = false; + bool using_lpae; - if (target_el == 2 || arm_el_is_aa64(env, target_el)) { + if (arm_feature(env, ARM_FEATURE_M)) { + using_lpae = false; + } else if (target_el == 2 || arm_el_is_aa64(env, target_el)) { using_lpae = true; } else if (arm_feature(env, ARM_FEATURE_PMSA) && arm_feature(env, ARM_FEATURE_V8)) { using_lpae = true; + } else if (arm_feature(env, ARM_FEATURE_LPAE) && + (env->cp15.tcr_el[target_el] & TTBCR_EAE)) { + using_lpae = true; } else { - if (arm_feature(env, ARM_FEATURE_LPAE) && - (env->cp15.tcr_el[target_el] & TTBCR_EAE)) { - using_lpae = true; - } + using_lpae = false; } if (using_lpae) {