From nobody Sat Nov 15 20:48:54 2025 Delivered-To: importer@patchew.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=linux.dev ARC-Seal: i=1; a=rsa-sha256; t=1747854227; cv=none; d=zohomail.com; s=zohoarc; b=VvixaNU/UttB9j5TAkFfJ0CVO9vxmyfGfy91hQnG/yXcEDlJBJ1u6V17tkWlkCAGsS85JarLyoQrzwhT+W75zQ6emMhgzkNLgoTyV+jUxh9LXn5eEPzEertunre3ZjCyf3rUQU3gVMlE4uF5MC+fEgAnINfLcDi2c5lzHpsbKJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747854227; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gbo7c8K7ZQW1KsUAQVl9YazIunWDHbR+34oXLOE67OM=; b=Iohseoz2l5BGh+bTorJ3tJqUIdypJDA5Nfn5TxZcJ/aASNcUQimljP0uh6xK8+rQISPZcIp5wXEMtjA15hGc8JyUAsebcl+WPFwP2h9lNzNtC1Hz7UPwyh8rg6nd6CMZD0uQv84WLSGi8HGc+wopekt4CRPsGak6PcXmPfs9s8w= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747854226909851.0516914317868; Wed, 21 May 2025 12:03:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHoiQ-0004jQ-SY; Wed, 21 May 2025 15:02:59 -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 1uHoiO-0004ik-Am; Wed, 21 May 2025 15:02:56 -0400 Received: from out-176.mta1.migadu.com ([2001:41d0:203:375::b0]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHoiM-0004mB-3S; Wed, 21 May 2025 15:02:56 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1747854169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=gbo7c8K7ZQW1KsUAQVl9YazIunWDHbR+34oXLOE67OM=; b=NeLXob/mo++FupiN9iUyB9N+4YcJh3pzi+G04gcKyCIWnK2zFXw7rOsCiNSY1BU0wZpugH boDpUT/PTmhtf3+aPLiKKshFY05rx8Px69549HWh7a5NzTr4/6rnB2OyLNT7EtjJFuwYr0 +sxL0l6GwUq3EbFVmT3CUa6FvQ9Je3E= From: Oliver Upton To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Oliver Upton Subject: [PATCH] target/arm: Ignore SCTLR_EL2.EnSCXT when !ELIsInHost() Date: Wed, 21 May 2025 12:02:28 -0700 Message-Id: <20250521190228.3921172-1-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT 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; Received-SPF: pass client-ip=2001:41d0:203:375::b0; envelope-from=oliver.upton@linux.dev; helo=out-176.mta1.migadu.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_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linux.dev) X-ZM-MESSAGEID: 1747854228094116600 Content-Type: text/plain; charset="utf-8" Using an EL2 that enables SCXTNUM_ELx for guests while disabling the feature for the host generates erroneous traps to EL2 when running under TCG. Fix the issue by only evaluating SCTLR_EL2.EnSCXT when ELIsInHost(). Signed-off-by: Oliver Upton --- target/arm/helper.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7631210287..83d4236417 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7389,16 +7389,16 @@ static CPAccessResult access_scxtnum(CPUARMState *e= nv, const ARMCPRegInfo *ri, { uint64_t hcr =3D arm_hcr_el2_eff(env); int el =3D arm_current_el(env); + uint64_t sctlr; =20 - if (el =3D=3D 0 && !((hcr & HCR_E2H) && (hcr & HCR_TGE))) { - if (env->cp15.sctlr_el[1] & SCTLR_TSCXT) { - if (hcr & HCR_TGE) { - return CP_ACCESS_TRAP_EL2; - } - return CP_ACCESS_TRAP_EL1; + sctlr =3D el_is_in_host(env, el) ? env->cp15.sctlr_el[2] : + env->cp15.sctlr_el[1]; + + if (el =3D=3D 0 && (sctlr & SCTLR_TSCXT)) { + if (hcr & HCR_TGE) { + return CP_ACCESS_TRAP_EL2; } - } else if (el < 2 && (env->cp15.sctlr_el[2] & SCTLR_TSCXT)) { - return CP_ACCESS_TRAP_EL2; + return CP_ACCESS_TRAP_EL1; } if (el < 2 && arm_is_el2_enabled(env) && !(hcr & HCR_ENSCXT)) { return CP_ACCESS_TRAP_EL2; --=20 2.39.5