From patchwork Tue Jun 28 04:53:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585549 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp515903mab; Tue, 28 Jun 2022 00:39:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tuGxdJ1/x5w5PnBJuULxzRzdSLXkmLR7YoMXqp42+0wSXRCOD3ytp5I1rg/Bo5zob4mTTx X-Received: by 2002:ae9:f718:0:b0:6af:5c0:6cdf with SMTP id s24-20020ae9f718000000b006af05c06cdfmr10559200qkg.426.1656401942484; Tue, 28 Jun 2022 00:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656401942; cv=none; d=google.com; s=arc-20160816; b=c5F+0B6k98QYoAt8cDi7g6QYjw1G7P+PFzAZziP/0dmffXBHYeGop92JByXI5zabfA 76Lx/Gc/BQ2RYVDs1SVINaDBMH2YC6kGm5cm1Qssje0R8+WiOYifVeZNbBuKntn2o3nQ XtMHg4KzpRcHkgu7O05uz8GwI25T5nCApalRDFT56I4ufL7erEpSkJCuTJ7y0ry1rIPD kAdtYyN3iuPvq5sjaipZ8Lol/Kby+Dcoca9xi/CcEwcwRcieWgDpoOwFxsJHuwDZiNY1 EbxiwwdrgclD5ULu3kmRHChfu6OuCWzp3fSe5AxvR/7e5KQxx0/vfekdjW+9kC4T+20l u0SA== 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=zVpqLWTsPExWd6f8jF1EY/VDSSozWoVLxOFKhLPqh5c=; b=BMuSFjRkCsQhRbNJHzvLMQo2DLoXWWuxsbim4ILLdZx8bLaToZci6zVORAe2WX7g4t oQVYvTgATbk3841q35gzIMz2QMhai9Ab1iw6tT+xViEhhMM+iDm24F8vs+OCzDuec5AJ TzXg+m9ESo7P9mT3tNr16ZgiGmnlx1U+cyfQ7cqvURvrc5iT/fa2oostW1XYEciWlanY 0gAPFoL1JRSVtvWgsDOKsH8izqGxsgE3NteARg3jcsPrw2nl7udaVTXr+aEKEvuFz4cH H2axsXazxyFBnAKfLFUcVu3z+uxhqoYT2hsItfntEIoD+IoOKjzMUZVlEKF7LjWWf1i/ 7tYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UhoFZJZJ; 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 o18-20020a05622a139200b00306fd63b901si5838261qtk.105.2022.06.28.00.39.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 00:39:02 -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=UhoFZJZJ; 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]:42000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o65oL-0002YU-Vd for patch@linaro.org; Tue, 28 Jun 2022 03:39:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o63Fh-0003H7-Eh for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:55:06 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:42606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o63Fe-0008M2-PU for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:55:04 -0400 Received: by mail-pg1-x536.google.com with SMTP id d129so11056785pgc.9 for ; Mon, 27 Jun 2022 21:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zVpqLWTsPExWd6f8jF1EY/VDSSozWoVLxOFKhLPqh5c=; b=UhoFZJZJ7sf6X6sDYSJ8kTUIHJnjrJP35kzXRhk1u5KJpN92OMg6fqNgAcj7Iz9h9B Af0kPXlAAmiOOghBCSYt6A7+LWnT1ihWPwkqXFEXJnwPURNLaJ8pX28Zul3Wq096sO85 nIX5TPGgjO4Kwq8GlREq8jMjG4+Xpzt2wm70Tn2oMbjoXh8suf4pmfz4ZijmFCjda3DN 83FoTide3wolQjJAeCTnLDVxZx9m8dg4U6KU2RKISdO46BdCHCHMFTMKK4d6tHb9gpC3 aK804d607hTjEbVZxhe2192SbMoHWVfLjRxVA/HWDatfYqkYshqRTDx1ZFnysslOZd1u xhVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zVpqLWTsPExWd6f8jF1EY/VDSSozWoVLxOFKhLPqh5c=; b=ZB2cQ3gGeMP1DSOiXrGoWxNOMRFwJOtyYLRZiFy4l+7g3iLnijudV1X2vIkJ0bTNRI 6Qi7XDdJ1WWDgcIZoGfi06DNJOfuQ/Ggy9LhYKNvnUaFkwjHdk4tXIyBjRzWIppDW0j8 E5Mnd7U8f/22WIvZbCQFhvLbUee/ki7dTCNsiqYe/Lq2F44UCB/XtUhcUeqdw3xnUBJX 3uI83afAaYQy9jlFazlZJNjvuQXEP4Oqc9zNpp/35L9y+ltAhFKe2Iy325ARQ/OatRDf iY4cvR955FDt/PfnCprLwtecPTmoHEC7u0q0WF08rUuY2ZgLXleiWNwDF+ixwmBMig+R /kcg== X-Gm-Message-State: AJIora+0sCyiZavLBsISkFDB5Ey8Tc6BO5Ifu75dB5wtrIsYSVOVSbgr wH65FrdLhcd6wIYxEq9YkMlfVFT50tv2DQ== X-Received: by 2002:a63:81c1:0:b0:411:6433:b4ba with SMTP id t184-20020a6381c1000000b004116433b4bamr19251pgd.585.1656392101383; Mon, 27 Jun 2022 21:55:01 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id w8-20020a1709026f0800b00168c523032fsm8073735plk.269.2022.06.27.21.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:55:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell , Alistair Francis Subject: [PULL 22/60] semihosting: Split common_semi_flen_buf per target Date: Tue, 28 Jun 2022 10:23:25 +0530 Message-Id: <20220628045403.508716-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628045403.508716-1-richard.henderson@linaro.org> References: <20220628045403.508716-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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" We already have some larger ifdef blocks for ARM and RISCV; split out common_semi_stack_bottom per target. Reviewed-by: Peter Maydell Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- semihosting/arm-compat-semi.c | 44 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index d2ce214078..7550dce622 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -217,6 +217,13 @@ static inline bool is_64bit_semihosting(CPUArchState *env) { return is_a64(env); } + +static inline target_ulong common_semi_stack_bottom(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + return is_a64(env) ? env->xregs[31] : env->regs[13]; +} #endif /* TARGET_ARM */ #ifdef TARGET_RISCV @@ -246,6 +253,13 @@ static inline bool is_64bit_semihosting(CPUArchState *env) { return riscv_cpu_mxl(env) != MXL_RV32; } + +static inline target_ulong common_semi_stack_bottom(CPUState *cs) +{ + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + return env->gpr[xSP]; +} #endif /* @@ -301,31 +315,15 @@ static void common_semi_cb(CPUState *cs, target_ulong ret, target_ulong err) common_semi_set_ret(cs, ret); } +/* + * Return an address in target memory of 64 bytes where the remote + * gdb should write its stat struct. (The format of this structure + * is defined by GDB's remote protocol and is not target-specific.) + * We put this on the guest's stack just below SP. + */ static target_ulong common_semi_flen_buf(CPUState *cs) { - target_ulong sp; -#ifdef TARGET_ARM - /* Return an address in target memory of 64 bytes where the remote - * gdb should write its stat struct. (The format of this structure - * is defined by GDB's remote protocol and is not target-specific.) - * We put this on the guest's stack just below SP. - */ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - if (is_a64(env)) { - sp = env->xregs[31]; - } else { - sp = env->regs[13]; - } -#endif -#ifdef TARGET_RISCV - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; - - sp = env->gpr[xSP]; -#endif - + target_ulong sp = common_semi_stack_bottom(cs); return sp - 64; }