From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9703FC6FA8A for ; Wed, 14 Sep 2022 14:23:28 +0000 (UTC) Received: from localhost ([::1]:35152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYTIU-0007F8-8n for qemu-devel@archiver.kernel.org; Wed, 14 Sep 2022 10:23:26 -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) 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) 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) 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: 8bit 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Honour the commandline -semihosting-config userspace=on 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 instruction. */ - if (semihosting_enabled(false) && imm16 == 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 == 0) { - unallocated_encoding(s); - break; - } -#endif + if (semihosting_enabled(s->current_el == 0) && imm16 == 0xf000) { 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 != 0 && -#endif + if (semihosting_enabled(s->current_el != 0) && (imm == (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 = 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 == 0) && (a->imm == 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 = s->thumb ? 0xab : 0x123456; - 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 == 0) && (a->imm == semihost_imm)) { gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { -- 2.34.1