From patchwork Tue Jun 28 04:53:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585551 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp522059mab; Tue, 28 Jun 2022 00:48:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tfUHgOiu18vbboIbqXWTFgwx34og7gR6naDO/ZLC3PFNi1/r6+KsFsSaMsKus8SXA5G829 X-Received: by 2002:a0c:fa8c:0:b0:470:3ec6:5ca3 with SMTP id o12-20020a0cfa8c000000b004703ec65ca3mr2514867qvn.8.1656402499839; Tue, 28 Jun 2022 00:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656402499; cv=none; d=google.com; s=arc-20160816; b=Mv7bl/+KRmhTMHqnz3g2kmru/LCW167vk+bNhTbNIpcQgBxa0IQuyoselKi9MMtOjG gA7V0eoUNB3hHxfCNdkGwCalb2Qni8WOMN12rC4hqXvccuLT7QFqV0l3UKIFy0+oV6Le cbxtWQjuGM2GqHWex2/VgOWdZMO1XzU6ZzA+favwNur/zqbGuMz4gTUc199BrOgMi8RB 9/doAMKe/qppImyDVMvtOLhQ06mCgfe9PKgWHmFmC56ydwF0dYUTs9QLsei3SjyTGPPA AIfFBCIl3po8NNyTtU/ntpukm0SoHwBQXOBrUpLA57oE7gpGYsnzHr8DE5uGqdSY3E3u KBQA== 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=lqFv93ItJHKCx8rfb3Csr21RF/dQfiqOGTpOdE1PXrY=; b=fLSDfpjcNFcR5mmypJQNL2MZi+mYseagJHUa7B7bwjfpR8lGadUWjbGpOFvY0PuDUY Vg21XsivbZvaWY0nvKxRZscqheglm4IjHIqV/ftO3JWCxXkAktsTM6dMQLaYrM043o+l MTFqEANwMKrcCy83uZBrK0u1sQWbcRuDGM8tcgPH44di2VlLJyIaNpIF6ovihit8s+rL K5Etapm5TovICHZZHGHUj6OiQz5DuDBRPEhOfsa066vO531k3venK4p+Koi3fT1voU2f cgTem06EIrl7NM7Gb9aBciCW/lGkk2YlZiqyATzxYVNbHU+UnwUorcB9EdPJWglsGKi/ 9ZJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=brQzbWzc; 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 dx12-20020a05620a608c00b006af18494b34si3726794qkb.272.2022.06.28.00.48.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 00:48:19 -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=brQzbWzc; 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]:59100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o65xL-0006Gx-D6 for patch@linaro.org; Tue, 28 Jun 2022 03:48:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o63Fr-0003O1-E4 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:55:15 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:44961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o63Fp-00004s-N1 for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:55:15 -0400 Received: by mail-pg1-x52e.google.com with SMTP id v126so6903695pgv.11 for ; Mon, 27 Jun 2022 21:55:11 -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=lqFv93ItJHKCx8rfb3Csr21RF/dQfiqOGTpOdE1PXrY=; b=brQzbWzcKgPiQuN9jQo/y0wegbplxcfDNNwyXKTNLg8m9iMcGOgffYDWVk640fq0no CNPWz0Y7FEHFag2Wf3l2wzcaJLURapML1PyGJn7KavX/KdQvcpRP62uDsuC4hYx/WkHY M2VIeCUJuo79A/vzvScEf3GAetUlA0ZTIAodCary1j4me+ZWzhxTn6+dsDRaAVCnbI4h 2a5H8u0Q9jKtTZ8IGsHOIfo3LjHquBk1j4i/LoL4wrjLCiRSXZWbT0C3s8xpfccOX9HU Z4KW040l09D3/mEKg+ZqAfJSGT7UlKKWGXVfa2OVio+CotYuCW9AK8wCyAlO06p9oJfW +PiA== 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=lqFv93ItJHKCx8rfb3Csr21RF/dQfiqOGTpOdE1PXrY=; b=uMFtw1JXPHB7Ub/NlHKaKq2p5B/TeGc/KVE23THk52KLQvT9NTAGvinNiMxh7LSWLD PnCEyaSlwvYbjclxiymnXrq5eBUgSZIevBFSGKiZ4zTiAjjp8equdfbWPezzagRq9WaQ OqKyie8l2HTQR6UjolnP+0IwegxecLxtk7EDltnh9h5SbuhMQNxN1e5spbAN3zeCcyIC 2rXUBVRs0S2k/xwLXMJ6IR1BsNr4/SPsvMUmODe4sq1AjCZBzZ/3cV3lzAAL7v+Q7Mqq MhMLgPt38E0ILeGzp+F5O12aKkKUrvKMsTeCB5sfh95FWVlAXtMi+12dyWy/7M2+wWMS 4FMw== X-Gm-Message-State: AJIora9DQGA1rnP4pSesRUzHn6g+XwtkCWyCyyDImNcMT8HmvGr98wrY f0aLcfMqOUGGNqnToL9y0r+8WSImj7YZog== X-Received: by 2002:a05:6a00:2185:b0:520:7276:6570 with SMTP id h5-20020a056a00218500b0052072766570mr2801950pfi.84.1656392111018; Mon, 27 Jun 2022 21:55:11 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id w8-20020a1709026f0800b00168c523032fsm8073735plk.269.2022.06.27.21.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:55:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Subject: [PULL 26/60] semihosting: Move GET_ARG/SET_ARG earlier in the file Date: Tue, 28 Jun 2022 10:23:29 +0530 Message-Id: <20220628045403.508716-27-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::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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" Moving this to be useful for another function besides do_common_semihosting. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- semihosting/arm-compat-semi.c | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index adb4e5b581..72a1350512 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -181,6 +181,30 @@ static LayoutInfo common_semi_find_bases(CPUState *cs) #include "common-semi-target.h" +/* + * Read the input value from the argument block; fail the semihosting + * call if the memory read fails. Eventually we could use a generic + * CPUState helper function here. + */ + +#define GET_ARG(n) do { \ + if (is_64bit_semihosting(env)) { \ + if (get_user_u64(arg ## n, args + (n) * 8)) { \ + goto do_fault; \ + } \ + } else { \ + if (get_user_u32(arg ## n, args + (n) * 4)) { \ + goto do_fault; \ + } \ + } \ +} while (0) + +#define SET_ARG(n, val) \ + (is_64bit_semihosting(env) ? \ + put_user_u64(val, args + (n) * 8) : \ + put_user_u32(val, args + (n) * 4)) + + /* * The semihosting API has no concept of its errno being thread-safe, * as the API design predates SMP CPUs and was intended as a simple @@ -507,30 +531,6 @@ static const GuestFDFunctions guestfd_fns[] = { }, }; -/* - * Read the input value from the argument block; fail the semihosting - * call if the memory read fails. Eventually we could use a generic - * CPUState helper function here. - */ - -#define GET_ARG(n) do { \ - if (is_64bit_semihosting(env)) { \ - if (get_user_u64(arg ## n, args + (n) * 8)) { \ - goto do_fault; \ - } \ - } else { \ - if (get_user_u32(arg ## n, args + (n) * 4)) { \ - goto do_fault; \ - } \ - } \ -} while (0) - -#define SET_ARG(n, val) \ - (is_64bit_semihosting(env) ? \ - put_user_u64(val, args + (n) * 8) : \ - put_user_u32(val, args + (n) * 4)) - - /* * Do a semihosting call. *