From nobody Tue Feb 10 21:41:13 2026 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1663165414; cv=none; d=zohomail.com; s=zohoarc; b=QWt0FgiDTP18YX+1J0pDui0pW04ICUb2NHfnirqSsry76iXwfRGLkXLtDEjUcGucji4NkoC8fa4z4pbBDmgbGQSCQwkKTNdeZ9vdqRLfKykxCB4y8nxc2uD1kPPbg2Xz73772X7EX3Imm0UtKOYjQxuIAKEvWbLNgdG6EF5R1Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663165414; h=Content-Transfer-Encoding:Cc: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=udcxGrqKWJR20Uk0cyTbsUdJXJIm7W+gSlqAXkcUlZ0=; b=eMrNlfV7U8POjzi6JvwljKvU5oUXctodDQsNcDUH9tVGC2XRgBz78y8IcP6BC5Zq4LCqc5l9mG2h2GAKswdpvz9EeffO32MMMu+UjIofIsc0gQ6Z3A9COalsBwAT+IlMptGCWRJJ+r5MXnN17qGLzaN1HUKxeY583FNujFtd7ps= 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 1663165414345427.06367110736574; Wed, 14 Sep 2022 07:23:34 -0700 (PDT) Received: from localhost ([::1]:35152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYTIZ-0007F8-SW for importer@patchew.org; Wed, 14 Sep 2022 10:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYSML-00081t-05 for qemu-devel@nongnu.org; Wed, 14 Sep 2022 09:23:21 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:51170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYSMH-0000b6-NR for qemu-devel@nongnu.org; Wed, 14 Sep 2022 09:23:19 -0400 Received: by mail-wm1-x332.google.com with SMTP id ay36so1983828wmb.0 for ; Wed, 14 Sep 2022 06:23:17 -0700 (PDT) Received: from stoup.. ([89.101.193.70]) by smtp.gmail.com with ESMTPSA id p15-20020a5d48cf000000b00226dedf1ab7sm13768244wrs.76.2022.09.14.06.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 06:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=udcxGrqKWJR20Uk0cyTbsUdJXJIm7W+gSlqAXkcUlZ0=; b=CFWNTdFlBm9Tpf3eNqp1hBojEiMgoFPN9E997SH8FQUCZ+opyyrUDeqs3C+Ra4O7PF 0YmhEJXIp2YEHczjegatgiEQ05EllFv/14Rs1n4vjD+q6jgKm54N7qxJe+N+dwHq1UMS mc9S6xaIVbrV9Xdvwbsg+6qsza7f1J4K0vtp9n5mIPjM/7bXX/yGBroXQk6a+LjNtDCs DRwt73lISUihfj4ek2YFJh9RVLEU8z07hy6CDFA1Aihh0XQM17K044meNlInp0xt0xjg RlGFCK7aDsEnH9vnxK6amINuittI8mWXvuhTrbHyUwoa2QRMtq5Pr/momiWJKVlVxC6y TmIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=udcxGrqKWJR20Uk0cyTbsUdJXJIm7W+gSlqAXkcUlZ0=; b=6CB15NhpBFqNlhPlQ4Qd9GAfo7TSt2U+nr0XyM25k6s0/gE1H/z3RMMh+rYDPiZ8hg aD2sP0pITqSXeg9t65bgkO9dtPjW+7UiMOckM/Q24bMkpj1XAinxPSHGiYxvT6ImoIvs kcz74V1AGynkDh5ZN8uZ986eUqS8p1uQDppAUSD6Ph+LtDn9VOYY9OEeg2jJjcaBDp1+ z8IomQPMyxYtjtO7FhLt5/l0oXGXwSe71CxiR92l5A2fw8U4az+nkmCmnrcchs/UM33a /TAMo8QcPtizHQdDuoEIz2CXpxEZeVnB2SI36gH3wFHf8UdP3HAWeRrmdZNv1zlhzQZQ RH5w== X-Gm-Message-State: ACgBeo2mPbDmBNTY7nW3MKWNJx4ybyrTE3RYPIFDw+UhY8xzHOTF99H9 AEt0KSabQFr7a3xpfKFifEaa67ha1x6fBfG9 X-Google-Smtp-Source: AA6agR4Uv3/f4QCZWK+w83occXUwUkZw/Y590KGMB7M+mfbhIPPI/2mxl4q879TTRXGrwESrGQNoUg== X-Received: by 2002:a05:600c:2949:b0:3b4:85b2:c1d7 with SMTP id n9-20020a05600c294900b003b485b2c1d7mr3074528wmd.183.1663161796029; Wed, 14 Sep 2022 06:23:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 06/11] target/arm: Honour -semihosting-config userspace=on Date: Wed, 14 Sep 2022 14:23:03 +0100 Message-Id: <20220914132308.118495-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220914132308.118495-1-richard.henderson@linaro.org> References: <20220914132308.118495-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663165417059100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Honour the commandline -semihosting-config userspace=3Don option, instead of never permitting userspace semihosting calls in system emulation mode, by passing the correct value to the is_userspace argument of semihosting_enabled(), instead of manually checking and always forbidding semihosting if the guest is in userspace and this isn't the linux-user build. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20220822141230.3658237-3-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 12 +----------- target/arm/translate.c | 16 ++++------------ 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 3decc8da57..9bed336b47 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2219,17 +2219,7 @@ static void disas_exc(DisasContext *s, uint32_t insn) * it is required for halting debug disabled: it will UNDEF. * Secondly, "HLT 0xf000" is the A64 semihosting syscall instructi= on. */ - if (semihosting_enabled(false) && imm16 =3D=3D 0xf000) { -#ifndef CONFIG_USER_ONLY - /* In system mode, don't allow userspace access to semihosting, - * to provide some semblance of security (and for consistency - * with our 32-bit semihosting). - */ - if (s->current_el =3D=3D 0) { - unallocated_encoding(s); - break; - } -#endif + if (semihosting_enabled(s->current_el =3D=3D 0) && imm16 =3D=3D 0x= f000) { gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { unallocated_encoding(s); diff --git a/target/arm/translate.c b/target/arm/translate.c index b1e013270d..5aaccbbf71 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1169,10 +1169,7 @@ static inline void gen_hlt(DisasContext *s, int imm) * semihosting, to provide some semblance of security * (and for consistency with our 32-bit semihosting). */ - if (semihosting_enabled(false) && -#ifndef CONFIG_USER_ONLY - s->current_el !=3D 0 && -#endif + if (semihosting_enabled(s->current_el !=3D 0) && (imm =3D=3D (s->thumb ? 0x3c : 0xf000))) { gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); return; @@ -6556,10 +6553,7 @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) /* BKPT is OK with ECI set and leaves it untouched */ s->eci_handled =3D true; if (arm_dc_feature(s, ARM_FEATURE_M) && - semihosting_enabled(false) && -#ifndef CONFIG_USER_ONLY - !IS_USER(s) && -#endif + semihosting_enabled(s->current_el =3D=3D 0) && (a->imm =3D=3D 0xab)) { gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { @@ -8764,10 +8758,8 @@ static bool trans_SVC(DisasContext *s, arg_SVC *a) { const uint32_t semihost_imm =3D s->thumb ? 0xab : 0x123456; =20 - if (!arm_dc_feature(s, ARM_FEATURE_M) && semihosting_enabled(false) && -#ifndef CONFIG_USER_ONLY - !IS_USER(s) && -#endif + if (!arm_dc_feature(s, ARM_FEATURE_M) && + semihosting_enabled(s->current_el =3D=3D 0) && (a->imm =3D=3D semihost_imm)) { gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { --=20 2.34.1