From patchwork Mon Aug 15 19:03:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 597270 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp1762469maz; Mon, 15 Aug 2022 12:13:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mF7zEGlVSesBKlka9jsMjOO9p2XblW+OiIsIyrJpDFQNaC739jw3VLmI5lOaiVdWtUH7V X-Received: by 2002:ac8:5f08:0:b0:344:5cbe:c0f5 with SMTP id x8-20020ac85f08000000b003445cbec0f5mr5691752qta.356.1660590804065; Mon, 15 Aug 2022 12:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660590804; cv=none; d=google.com; s=arc-20160816; b=vyA0wjSR+7c6zRJv4OWPUGJVAVnKihDSaEvHlaAmoGzKKS2l4nUN6Zfgztnm8LLlFi DFCEhvvKNMxUuY6jm2ogj3q6V5kBistG8UJ8UxKtRMzC/b2UghFoYHTxTaw5SJRplhfF iNA8lEIL675YZX2P90RDWjyLc1UNl2ccc2FPjgifT99ebjCklNAjt24z6zyQckK/FE2r Or1SZpcs2GHxOx98tJZA3mD/KA6oruklxNb4EJDJdCAKz6viSJ1uXUvQXeMm0RCDL0uA bKx7hO4jbJILIBQV583BAd+i4D7t8aWdC+CvYNJL0b9fbanwg6auw9DjAeypsDz+PQ84 9JOA== 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:dkim-signature; bh=OGTDkR4LI4GDhkjGHuX42mV1KlnJTimkQ9agW47gbZY=; b=cj/NoGmW9JuuQ4YZeYR/cPIzOA/gUs/8VvF/tBYfSnARhmZSI3QRVM65edzwo5gLGR iiNpUQWQeyxUB12mnKLzXyKVf/43R4O6TBOMVV/0KIpMnoFHQ/RgPvYTBb3XavxOD1nm S8qRUFx7Lwj9oDznKXhxSqnQrkJQ75HgZ9g67xXD3rF4X7QW9foeXPonASyFtJe0CKhr MIlS7t8zpp3nuiuHWyvdC3vMnJaS47DuXOFaIzuv6dch5ufsmaaNoKr/QZlrXu7kxqbg qNjSEOM86S7sSWXuJeuUzB1CZYd+WxyU4ORjPtl7+GDlwKFbAZMhP/uqK3hvexAP2nM9 A5ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jknClf+t; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id hu9-20020a056214234900b00476f63f614esi6094953qvb.227.2022.08.15.12.13.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Aug 2022 12:13:24 -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; dkim=pass header.i=@linaro.org header.s=google header.b=jknClf+t; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNfWd-0001yq-Hc for patch@linaro.org; Mon, 15 Aug 2022 15:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNfN2-00031z-5g for qemu-devel@nongnu.org; Mon, 15 Aug 2022 15:03:28 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:41952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNfMt-0006K7-7E for qemu-devel@nongnu.org; Mon, 15 Aug 2022 15:03:27 -0400 Received: by mail-wr1-x435.google.com with SMTP id p10so10089810wru.8 for ; Mon, 15 Aug 2022 12:03:18 -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; bh=OGTDkR4LI4GDhkjGHuX42mV1KlnJTimkQ9agW47gbZY=; b=jknClf+toYIvPEkgUrydqqr9UCEeCEr58GLRzowOM/IR+L5/RRiMyasTBBMRmmqRh+ VXmtjuUtV6pE17LQfKKL1GbOlJaW2ahc7y2BGrrhYaOsBJt9c+92OFP70Cj8GUH4cpjt FP+5S80H/lA3PfnsxbmYnpY4GG0F1g+qU5vO2TzsFXTvUY77ZLJIIbo/FeIaxLDF36xv a2R0r4ph5J4G45NgcdWOmn1wde72VHauCcdnjAES4VC1OApf+xdpoHJrnLBL4816MbHb KfF6rPf/qLx6WS2D4wOZsqK+d6jo6DcvcytgBHs1PuU0pgP5sxVqEV35A3KcyEKUgdq8 ljuw== 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; bh=OGTDkR4LI4GDhkjGHuX42mV1KlnJTimkQ9agW47gbZY=; b=Lm1OEQhN+aEeP02Min4lhcJ8fl9Rkq6NHiPivdwK4+XLvrhjWswRU/WaBrFtu4j/h+ QhYDijkLfwYwQRaqDQXU/QqfDXAzrZ2GKWsaqimmpB8rPjsDf58W4C4U5ZjWPx1GgPSx RkvI0ZPvoXrF2unHarDLso0cO7mvGs0ynsHm6o6X29FgVFyHnbfHplRu7Rx9/8YTqSKr HsF+J21rs0pTnl8u/+D1/RB/W7Ys7x5cellf9RMXrs/Z9g7ktqHH0pbKnWfOOdke5x4w g1axd780TvwGmYJma7ufKhoLHyBi8+AOskRgLBcuogSb6YvpWM6qxlJg82NQOh/l4hE0 qjwg== X-Gm-Message-State: ACgBeo0CVhQjr5XFEmP0LOESpz0XIBYxToYHKCjsyUdwdURH8LAH4jqR TwphGE7/7LpeniM6lFg1O3HOsGONa8JH/Q== X-Received: by 2002:a5d:6047:0:b0:220:6dc5:73ee with SMTP id j7-20020a5d6047000000b002206dc573eemr9634750wrt.213.1660590198464; Mon, 15 Aug 2022 12:03:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id u4-20020a5d5144000000b00220606afdf4sm8009162wrt.43.2022.08.15.12.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 12:03:18 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Aleksandar Rikalo , Stefan Pejic , Chris Wulff , Marek Vasut , Palmer Dabbelt , Alistair Francis , Bin Meng , Max Filippov , Richard Henderson , Furquan Shaikh Subject: [PATCH 7/7] target/riscv: Honour -semihosting-config userspace=on and enable=on Date: Mon, 15 Aug 2022 20:03:03 +0100 Message-Id: <20220815190303.2061559-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815190303.2061559-1-peter.maydell@linaro.org> References: <20220815190303.2061559-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The riscv target incorrectly enabled semihosting always, whether the user asked for it or not. Call semihosting_enabled() passing the correct value to the is_userspace argument, which fixes this and also handles the userspace=on argument. Note that this is a behaviour change: we used to default to semihosting being enabled, and now the user must pass "-semihosting-config enable=on" if they want it. Signed-off-by: Peter Maydell Reviewed-by: Alistair Francis --- target/riscv/cpu_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 59b3680b1b2..49c4ea98ac9 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "tcg/tcg-op.h" #include "trace.h" +#include "semihosting/semihost.h" #include "semihosting/common-semi.h" int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) @@ -1342,7 +1343,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) target_ulong mtval2 = 0; if (cause == RISCV_EXCP_SEMIHOST) { - if (env->priv >= PRV_S) { + if (semihosting_enabled(env->priv < PRV_S)) { do_common_semihosting(cs); env->pc += 4; return;