From patchwork Wed Apr 10 07:22:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 787483 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp570199wrs; Wed, 10 Apr 2024 00:37:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXMER1ajI/iphzP/EDo+0z2cby102eAELcGMEAXAJK/WKl3H/iMpMvCf16vSFszHtXXlqQVpHHP/7S5UV2pnZ5z X-Google-Smtp-Source: AGHT+IEVJ6zw7r+o2hP07USZF4QIWNarcVVerr9Pap5Ljj0L/bKL78D6UGIUlAuGXWg1HHS3eM25 X-Received: by 2002:ad4:5de1:0:b0:696:a490:a94f with SMTP id jn1-20020ad45de1000000b00696a490a94fmr2569272qvb.30.1712734662781; Wed, 10 Apr 2024 00:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712734662; cv=none; d=google.com; s=arc-20160816; b=iYirsg39/IeOEKlQk2CX55AJD0XAy3ZR2dpwRwKPLLG3sy+F7W9qqyVwadN6PKaxBr W3S0q2NauX1DcbLkp4K7Rle4vbiTbHY1wsW1udT6hV62+yrN4yn504KT9PX3OcrzbHAK 34NTDIEWazsyAoHpHAGhgvXcMx/W2Tghy4hAloH3MDTOSyU8zmPbDSj2xLx6fhpBSlCg DvwyCUjYk8Gfd9a9UPo9W8Kimu2wOv1h7KxXBcZ54BTsCfCtz3HW/pERVswyrhNJTyYX y0qlBsKUqmNL/ZY2KDtjnpSoYNZRiQg5KdN0M+nWh5npFRxL065X0GPSUIchjFPS/Wnm Asiw== 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=omPI5ZbB80xT/Xy05t3AUNNG5qAZSkQCSw2CQDT66xU=; fh=xJ1URYKcMN3TM0/XAv5v+aCN+5tIbzAdcfBx5UNgoLw=; b=Q17eu2nwHAAWvoJuwm1ZMP6QYLG3fj54sW/Q8TPqxhdeHsWpOKWglRkuFp038MNxge gRXtKZiVwLmlEn/L7O2Ow/aWSGPyxvor3RD/gCNAbKK9IvsEeGIpJPVS4KGcJAVdBLoK +qBKnG/uCLxq9AcJvNDAVsFduzbru1Cpo2NhDu3lbctYLuXJJQhLYkhcNhpiS1DJBcoc 2o1rUPYZ7ysVanui/znHjtaHvCsvI9U7rup0RpSdonkQwSdXUZz0VQtriKdUrARH8bYF B9rm4I+3Bh3kzkB27qU/1RMpPJCVIeSk+AWSAsk1nn49ZC9iOZPeI1+4Uu/Ve6RcQ1zh O1Fw==; dara=google.com 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 s12-20020ad4438c000000b0069b22177e9csi4665161qvr.45.2024.04.10.00.37.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 00:37:42 -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 1ruSQ3-0004SU-Hk; Wed, 10 Apr 2024 03:30:55 -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 1ruSQ1-0004HR-Bk; Wed, 10 Apr 2024 03:30:53 -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 1ruSPz-0005NW-DG; Wed, 10 Apr 2024 03:30:53 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3B1F45D6BF; Wed, 10 Apr 2024 10:25:08 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id D4863B02FF; Wed, 10 Apr 2024 10:23:09 +0300 (MSK) Received: (nullmailer pid 4191889 invoked by uid 1000); Wed, 10 Apr 2024 07:23:04 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.2.3 79/87] target/arm: take HSTR traps of cp15 accesses to EL2, not EL1 Date: Wed, 10 Apr 2024 10:22:52 +0300 Message-Id: <20240410072303.4191455-79-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 The HSTR_EL2 register allows the hypervisor to trap AArch32 EL1 and EL0 accesses to cp15 registers. We incorrectly implemented this so they trap to EL1 when we detect the need for a HSTR trap at code generation time. (The check in access_check_cp_reg() which we do at runtime to catch traps from EL0 is correctly routing them to EL2.) Use the correct target EL when generating the code to take the trap. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2226 Fixes: 049edada5e93df ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20240325133116.2075362-1-peter.maydell@linaro.org (cherry picked from commit fbe5ac5671a9cfcc7f4aee9a5fac7720eea08876) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index b3660173d1..e555e885a1 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -4584,7 +4584,7 @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, tcg_gen_andi_i32(t, t, 1u << maskbit); tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label); - gen_exception_insn(s, 0, EXCP_UDEF, syndrome); + gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); /* * gen_exception_insn() will set is_jmp to DISAS_NORETURN, * but since we're conditionally branching over it, we want