From nobody Fri Dec 19 04:27:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585575664; cv=none; d=zohomail.com; s=zohoarc; b=T1ZS2/zGJZ0GQJektK9/O4IBtX2qM8yDhdhae6uQPj790aDhVAT2PuNJzxG1dgcjt3Ck+4k9iw+iJOtp/fR7rn5uqwp2DEYk3tecIWGZtv0u8Xts7DrZU3kANmFVCY+etyUbJ/U0GAhmkd6ybrFNEYXoSY+AusyOljjBRsB/rwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585575664; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rpCKxKnHkUDXLH/ndhCEOHbuUN0g52+ytampKGXhXJ8=; b=CzRapj0FepD24ldrJLB0/Bu5wwWWGBeMOAuOWf9WG+1bS/AjKASkrXfV1Y+iW84rwHiP6k7Ixf0T6oUc0tX4o0ygB01Tr6SGlUPIWhLwEyXOOAhUwP1rK/mPW7p+cWXRa/KHko+30Cn6fPCm9ZNs6pMT7aSZ5OCpZPKBfkJ/r+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585575664846544.7493831754136; Mon, 30 Mar 2020 06:41:04 -0700 (PDT) Received: from localhost ([::1]:50160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIuf1-0001ya-KP for importer@patchew.org; Mon, 30 Mar 2020 09:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49520) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIub5-0004Rw-9e for qemu-devel@nongnu.org; Mon, 30 Mar 2020 09:37:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIub4-0001DW-8D for qemu-devel@nongnu.org; Mon, 30 Mar 2020 09:36:59 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:42253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jIub4-0001CZ-1f for qemu-devel@nongnu.org; Mon, 30 Mar 2020 09:36:58 -0400 Received: by mail-wr1-x443.google.com with SMTP id h15so21634619wrx.9 for ; Mon, 30 Mar 2020 06:36:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o14sm20756504wmh.22.2020.03.30.06.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 06:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rpCKxKnHkUDXLH/ndhCEOHbuUN0g52+ytampKGXhXJ8=; b=z2dn1tQv8XYK97w5RFrs6g3FJVaZv+/emuEh1L2FrwZj4kJjIU67exGbemYF+q2NEc 4Uv70IsP5VtiDDvpE1tA2o30GWu9ruriRshNmXfDPDc/J9RgxFbhw5GKuZQ2pxmnmyeX EAH1VTy5Qp0mBZCyv0vMcv88Vdb0ofenUVJ1usRjt7eV+Pf5qwSbulCrZByOogqJ+l30 rKzTsqMCUt8tAyDj4uCah+OfvnR1uS+mmjQg8FCPuEy7TKiucn3rBZrj8MZiC4QJhjEm 13f+V5S97a3AW+9szQVuS9sjU8r8GO+sHszCN1Ex3Usbh0anE34ipVaZkQ189llBEPRW UFHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rpCKxKnHkUDXLH/ndhCEOHbuUN0g52+ytampKGXhXJ8=; b=k8cc1wJlYWoLl0mHe0biaFNCOVmIRlzWgLVq5NTkEeCYB8Z8Fkj/M9HrWuCHFJwz7H EYiaUbE9zjORHVjIqXd68mciackQZuqsBX1lxSdKJ1qRSVFmwJbZl3giPFrcQbODAobt PKY/sPnHkgvoVXvgH9V+CEt/Y4yhpSJKxGzkV5ONVVjFpvH4aafReHgcjXzMr7w8jTL8 asExYCNvzlBO0ncW8cyWiVEFd3/+VRITPCqohKlvjZi/earY5P7iJBlQVWG6saW76+ea /eZpM5cLPmNas8CZ8QyC2mhI2JhuvtN2xGBUC4oq7ecL1bFFYOjj51aUrbLRKeTxy2bm h7bw== X-Gm-Message-State: ANhLgQ2gdNH+4MG1BN6uJvifwU3RRLYcjCp6qgF4AQaNY9q+VHBNBa/a BrazcuksysyWwO0g4APKahioVoVOu9ZWjA== X-Google-Smtp-Source: ADFU+vuK295ww31BQw1m+e9H1PyWjfLIQN1npMXZZxW6r/OfltSiyIniL9m3WZf78lwfPu8/rxDCOQ== X-Received: by 2002:a5d:518b:: with SMTP id k11mr14643626wrv.256.1585575416770; Mon, 30 Mar 2020 06:36:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/6] target/arm: fix incorrect current EL bug in aarch32 exception emulation Date: Mon, 30 Mar 2020 14:36:48 +0100 Message-Id: <20200330133648.22297-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200330133648.22297-1-peter.maydell@linaro.org> References: <20200330133648.22297-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Changbin Du The arm_current_el() should be invoked after mode switching. Otherwise, we get a wrong current EL value, since current EL is also determined by current mode. Fixes: 4a2696c0d4 ("target/arm: Set PAN bit as required on exception entry") Signed-off-by: Changbin Du Reviewed-by: Richard Henderson Message-id: 20200328140232.17278-1-changbin.du@gmail.com Signed-off-by: Peter Maydell --- target/arm/helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index b7b6887241d..163c91a1ccd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9172,7 +9172,6 @@ static void take_aarch32_exception(CPUARMState *env, = int new_mode, =20 /* Change the CPU state so as to actually take the exception. */ switch_mode(env, new_mode); - new_el =3D arm_current_el(env); =20 /* * For exceptions taken to AArch32 we must clear the SS bit in both @@ -9184,6 +9183,10 @@ static void take_aarch32_exception(CPUARMState *env,= int new_mode, env->condexec_bits =3D 0; /* Switch to the new mode, and to the correct instruction set. */ env->uncached_cpsr =3D (env->uncached_cpsr & ~CPSR_M) | new_mode; + + /* This must be after mode switching. */ + new_el =3D arm_current_el(env); + /* Set new mode endianness */ env->uncached_cpsr &=3D ~CPSR_E; if (env->cp15.sctlr_el[new_el] & SCTLR_EE) { --=20 2.20.1