From patchwork Thu Apr 25 10:39:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 792018 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1313397wrq; Thu, 25 Apr 2024 03:46:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcE9SMl/2K91G77UJjnpUR4DaJq0Uhzwg6Dvs092bsY2V7w7hzjYmct8BS9pN7VGPmaqb7qCZVOI3UTJTZlPus X-Google-Smtp-Source: AGHT+IEfAhRTY8rTwOOqoc7p7X+RAGfSOHEagJYMfkYjTNPs2eHwhoi/BmzJkOWAdwcF4bnRottG X-Received: by 2002:ac8:58d0:0:b0:437:a1a2:f832 with SMTP id u16-20020ac858d0000000b00437a1a2f832mr5005282qta.11.1714041997382; Thu, 25 Apr 2024 03:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714041997; cv=none; d=google.com; s=arc-20160816; b=exgAFuh88p8CprXSdcLnicjtNz/Ug1q/YTaCzEBBq0n40/pwl5Ls/6ulxZR5Zws5oh hY06bPj2KlrsPg8vWsZbwOdyG8YVC2ayuz2tAwINjCG1SAWfwEyys8A1lQ1ufGOYMFY4 FqfmPryXBxh/UG6B1DK3AhUnX7Lc4OvQDeKqbPRxCxbguSLfTB1PNW+VdAJD2h5HJTJv DNKF4giITKIAj8qlgbHu1OqrmbpH01U0FQgl5uu5MBOpfriNTjEWnLavrEMeDPfg4TAD jRW96NadghLRivQVO1j8gzNuCfgfSPn+y4ObC2PM9TIbRSVtkPZHiyqcsKJL2ubdZVtP UFSA== 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:to:from :dkim-signature; bh=y6I7eopQEiXePMFfuuglLJED0IgYNow8XyLPv9LxTAY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=EAJdYJRzAKVi0mZ9aG+HYUpAA0LmrbGHW8hxqCsXmHj1jkvsc0g8qHC4jdn6kp34YH kbph6Fmq2CP6+bxJrV/huf6+o804vOT/yQAAM2/GHzv1t+6xfC8So7Z1H2sUaVgHjDAO GWarTimBBN+jZ/ixjslnXe8lAdutJdFUUV3gqH17zbGE4tbhFUj13S0qDySf2RdZzjAl +6DCJxe3dOPAs7rEphM8Rdp2vi9pKtYSpVgLzNNyMfboqXgPmaqlbba8f5Gulo+ZxWpq s3QiNJVRsbRXhKjI4So8QptUPQkCM/x/tvD6lp+F86yazkDdvO18wB6yEheOEonE1ve6 OPHg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R98+e1E2; 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=pass (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 bb16-20020a05622a1b1000b0043a145c0516si4123650qtb.479.2024.04.25.03.46.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 03:46:37 -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=pass header.i=@linaro.org header.s=google header.b=R98+e1E2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzwWN-0001xn-3y; Thu, 25 Apr 2024 06:40:07 -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 1rzwWL-0001x3-Mm for qemu-devel@nongnu.org; Thu, 25 Apr 2024 06:40:05 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzwWI-0006xm-To for qemu-devel@nongnu.org; Thu, 25 Apr 2024 06:40:05 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-34be34b3296so784167f8f.1 for ; Thu, 25 Apr 2024 03:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714041601; x=1714646401; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=y6I7eopQEiXePMFfuuglLJED0IgYNow8XyLPv9LxTAY=; b=R98+e1E23BMmnj6FZ+bXoWlaPh+mxHpL1Qb+4PSBxsPfJ1fAgXgEMDflEm1IFSlvYb A8MQeC1imZkBG1uvpqVtTZW3fN2dM6j6HADlqdRjsBuM7RudH42TxpEzB8JrYzG7IDXh L+5Q0Lj24nx3aT3MqgtLrUkodz92XiYIO+dKgAYufc9ohtVC95AJF4f+Hve+bJ6d9A1L vZVMwON7uutgjQjZi6qfTCRedVN8fB8HQBGDb3qWX2NZxLd2WwJPTpdVvhoTjgJOLYnO MtuOUDJHU8myzaJV1vA4nnuNcKJem4FYGg4v1mbiBHWeKC3R+GhSO0NR/4JcplLOV5D+ B3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714041601; x=1714646401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y6I7eopQEiXePMFfuuglLJED0IgYNow8XyLPv9LxTAY=; b=cjFMXzjuipjcyTxVvTA+9nEVLj6S0t3bLWGnGVBIZWdeze/p9it5kF9Cog8mYDgdu7 OT1ysQ9kEeVowO9p00GHTiVqIL6zv0meu0lD08ljifXVgydAFExoW7GrJ8QnPFesHTg5 qhs8sDgNYxSmS649AxrzA3vRkipWurXM4Iftafzels20mydU7gyo1+d73Gh/LMcI1nZ0 SqSXEo66yLBqYNhvpPf+xuijm8jCTDzuOzlsgSgSKJL5BhPFR0icgKLQX48rLrRTrm41 rxk26WsFiEJuLVtpZI7ouHEahuPwLrr8/WwCs3IrNd+VWuqUQUI6D4sKUoWjGcvROz2i yKNw== X-Gm-Message-State: AOJu0Yy935zI+bzsFCg3QUT5GOq+UZ9T9r4AoG6KE2b7OWcmswn3rr6w 7MkEfh5WBLp/xlHqUI0BDS4jsSHqoOXX7iZGSFKGeR535LS53cCq/BTYVhA4zD5FpaqXONTxhXG 5 X-Received: by 2002:a05:6000:1042:b0:343:a183:4218 with SMTP id c2-20020a056000104200b00343a1834218mr4625611wrx.52.1714041601143; Thu, 25 Apr 2024 03:40:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id h15-20020a056000000f00b003434c764f01sm19485768wrx.107.2024.04.25.03.40.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 03:40:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/37] target/arm: Add PSTATE.ALLINT Date: Thu, 25 Apr 2024 11:39:23 +0100 Message-Id: <20240425103958.3237225-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425103958.3237225-1-peter.maydell@linaro.org> References: <20240425103958.3237225-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.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, RCVD_IN_DNSWL_NONE=-0.0001, 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: Jinjie Ruan When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to ELx, with or without superpriority is masked. As Richard suggested, place ALLINT bit in PSTATE in env->pstate. In the pseudocode, AArch64.ExceptionReturn() calls SetPSTATEFromPSR(), which treats PSTATE.ALLINT as one of the bits which are reinstated from SPSR to PSTATE regardless of whether this is an illegal exception return or not. So handle PSTATE.ALLINT the same way as PSTATE.DAIF in the illegal_return exit path of the exception_return helper. With the change, exception entry and return are automatically handled. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20240407081733.3231820-3-ruanjinjie@huawei.com Signed-off-by: Peter Maydell --- target/arm/cpu.h | 1 + target/arm/tcg/helper-a64.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index bc0c84873ff..de740d223fa 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1430,6 +1430,7 @@ void pmu_init(ARMCPU *cpu); #define PSTATE_D (1U << 9) #define PSTATE_BTYPE (3U << 10) #define PSTATE_SSBS (1U << 12) +#define PSTATE_ALLINT (1U << 13) #define PSTATE_IL (1U << 20) #define PSTATE_SS (1U << 21) #define PSTATE_PAN (1U << 22) diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index ebaa7f00df3..29f3ef274ae 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -892,8 +892,8 @@ illegal_return: */ env->pstate |= PSTATE_IL; env->pc = new_pc; - spsr &= PSTATE_NZCV | PSTATE_DAIF; - spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF); + spsr &= PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT; + spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT); pstate_write(env, spsr); if (!arm_singlestep_active(env)) { env->pstate &= ~PSTATE_SS;