From patchwork Sat Apr 30 13:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568111 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp7212237map; Sat, 30 Apr 2022 06:41:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7dlREBx5W7v6U9s6I4/6aYtlsoOWzKUvQwtT8er6I8v4z+VpJalkpaFy2ooJRHbDHObeI X-Received: by 2002:ac8:5c55:0:b0:2f3:72db:be46 with SMTP id j21-20020ac85c55000000b002f372dbbe46mr3373144qtj.669.1651326116555; Sat, 30 Apr 2022 06:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651326116; cv=none; d=google.com; s=arc-20160816; b=zb4n06TrUrLUjXwsDED4Q6EPcEooNI3/VGOf3ad+Rp3JiN4ibKQwi6zYQucQDTJtJW 18CsblTjjQ5p1CjQ5cWUT79AAGuEu199I3veii+v87VgrUqObRKup07B9JGNSNAA5RTk TfnXM3evlW7cC7wHe7aUD4mzd4fCDAbP86Ugb70ffSPvH4eCs1Seb2b1wX9xhKdQ448r GNAE0oo8TapTyaA9qved6vh4BJ2XBxK325cqtDteYmS3ifU0v3Wzx9tyLE5zFHjR4E85 JGcWsczQpbgvcx3AAxqVAZSTLTLhoMO9GO8tBj6rce8L3MPcw2mok9iGW/DCBH3eLYKa ArEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=IzZtboHFK51ahqSRhw7zz5hbdZTb6VGng4tHM8rPvXQ=; b=WyDfwF6Y1GBO/R/GkAlX4fnxnwz4v+KWu0hpL/+jD1x04/EtoW3gbPScnEPYyw4+XJ UJ14lhtNfN/oXe5CQ+jE/xJm2S7QUZbfQOroREtKfgj9Vsj3jqY46NDk+B9V0FOw2WB0 irt5tl/l67PbQxztRXq0BEYn+HQNoL/u69mkiX3z1bYJSJ/q+PZfyWoZ6W/X2r+cFDI4 jxTLPBDCTYoCxpQ9tfBdzWxzzIOLB16y5WRkSlkXcX/BbYr3JCkLr0jDPKUDP87g7l/+ Pt6BqoC5uVBPVZa4zJWEwsWxQM5p+5D7P5Hz8PbfOlcqiAjDgJLTNm7lapC2ZKIkOuW+ cEVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vKTw6K1p; 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=fail (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 o14-20020a05622a008e00b002f39228d583si2277856qtw.490.2022.04.30.06.41.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Apr 2022 06:41:56 -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=fail header.i=@linaro.org header.s=google header.b=vKTw6K1p; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nknMC-0002RP-3s for patch@linaro.org; Sat, 30 Apr 2022 09:41:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nknAY-0004mD-H3 for qemu-devel@nongnu.org; Sat, 30 Apr 2022 09:29:57 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:40588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nknAV-0006GV-Ik for qemu-devel@nongnu.org; Sat, 30 Apr 2022 09:29:53 -0400 Received: by mail-pj1-x1032.google.com with SMTP id iq2-20020a17090afb4200b001d93cf33ae9so12729370pjb.5 for ; Sat, 30 Apr 2022 06:29:51 -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=IzZtboHFK51ahqSRhw7zz5hbdZTb6VGng4tHM8rPvXQ=; b=vKTw6K1pyFSug4fM4A/3IyP/LXCWnY1JVdPKc4B05vaZvr51SjTmv1l83Ej+KvrcRn mWycv+LB8rPMXPBZFZDHvYfsV0Iq36gyJ4EGn8gQXrEyyyizkcO5UTKhNJmV95JynyJY mrt7EXo98+g4y6QtF6NFuiyNEUvcSJLeAQ67YojzH1bRgwwiydBmE+s2ru1Zgoxc5kLo NuEcso9UCJACBsQi0a/+uDLS+EDFRmkbZhDACNwDrICSibx8/yv6xPOxconEPis5tNQH T8uNHeBzi6DDU3ngzhrz7cvevSvYzc5fO6xehlCWPmB7JWBUpeefzlA6vvXdZfKCncoI sqiw== 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=IzZtboHFK51ahqSRhw7zz5hbdZTb6VGng4tHM8rPvXQ=; b=AOswZDJSl4GUxJV19n98ARbtOm4RuIjSp4XTtnw9tGdH0H5wdXGsoucL9bFnS7xwbo OUGznlHWozvbTPWfECAiiDRyZOKSIE4F9lfik97/H4SF5VFbbvKGSJyYMDy47NVQg9wZ 05ZF0ti2e2QhfkFOC7p87aRT3YwUhNJ40Zv2YA2A1MZ/OvK6CfUpG0xaVcWb1DGwXiWD zbw0qbei+944KUa9ryTT972iqkwPYfOaDcjQP5BwR+bXup1a3/uDoP8VdNoglT2ZnOUV dQl47QhNDg72tqoO02juJteNfWg4NE8Ply4EfCgaZeD0mBXjNkwMa3LSjhUjBVlsDa+o TjiA== X-Gm-Message-State: AOAM530/fEwdhBatztC67wWvGZdykStW8jT4HKk2+8WlOFDQLfpoDwJH aFmuV4TPOPyaI9wGPFiaQHt8jFk8pxDJdg== X-Received: by 2002:a17:902:8698:b0:158:99d4:6256 with SMTP id g24-20020a170902869800b0015899d46256mr3982498plo.104.1651325390340; Sat, 30 Apr 2022 06:29:50 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id x5-20020aa793a5000000b0050dc7628201sm1522606pff.219.2022.04.30.06.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Apr 2022 06:29:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 16/43] semihosting: Split common_semi_flen_buf per target Date: Sat, 30 Apr 2022 06:29:05 -0700 Message-Id: <20220430132932.324018-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220430132932.324018-1-richard.henderson@linaro.org> References: <20220430132932.324018-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: , Cc: crwulff@gmail.com, alex.bennee@linaro.org, f4bug@amsat.org, laurent@vivier.eu 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. 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 7fc60e223a..b2816e9f66 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; }