From patchwork Tue Jun 28 04:53:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585522 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp476115mab; Mon, 27 Jun 2022 23:33:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vwpvFH5XnvFDIJmBEzrt6bnmuvhD2UAT86HH1YozRSxhMgP2vH4qaY2Ur3KpN6o4AAt4mv X-Received: by 2002:a05:6214:3003:b0:462:1c15:772c with SMTP id ke3-20020a056214300300b004621c15772cmr1320327qvb.71.1656398020365; Mon, 27 Jun 2022 23:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656398020; cv=none; d=google.com; s=arc-20160816; b=gLq4OKRTIbEvxro2T+L0UdO7+M5rAsg9pJ7JYhdu1YPa9PUtGdW6lHB8Bw4XpSjnQH ITBEUj7cUHt5z//a7evHneBfCyIEb/t9d/pW/vxKqtBg3WmzM0waZEv7GOzDeAPa1k1R hWGIua19xEz34HW62uiBaN0LBbOIAMcaDVyRovEQJHDEZ/XfgsSTtpchAs4Czs2KZ+M/ u0feDtjnZ3+VnMRwFjELut3ReFWvns7FXYRtari2GXYDr5DLoEyyxAsVcCAFgMKZoMed MUw/zimod8P2N1+scwYl6v/4fFmzbU1IDfpl8erN+5IaTaLjuduKG3tMWCifxCEezy6n xOzw== 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=s5yvC5+jgu+oomjjgt/lH/bjvfcHjmqplnFnsHD+6cE=; b=h1P6xTam+rYHaEbtN3/I3/5NamKa8ualOTvVstEt6ZLyzZj4Guy4HF2gw2Do8wfhG4 UwS8Op6Rgmsq2qi+C/wcAa46WMx+NR+oEvZekj6E9P1pIzwfdrqDxy3MZctTeUepw2d3 nxOI5yH5fAS1roA8o9EZg/2c6ySewn8xywnsY4IzEInZifq1xdLpMhj6J5gKZfoK+jl0 egT7lIIedHoico1+CktxcRIP7ASG5NXXwlerlniLihRxds+9k/dycWUMIffiQz+JmGn0 wBqH0rqP5HhGjoDScgXA5Z1jCrbYhILirZEFaxXIiNQbG4h1WjnAUi7QNGozKeWUvMce Z2IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gEYpunoX; 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 v7-20020a05622a144700b00319586f870csi3522372qtx.380.2022.06.27.23.33.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jun 2022 23:33:40 -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=gEYpunoX; 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]:57802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o64n5-0007Wv-Pr for patch@linaro.org; Tue, 28 Jun 2022 02:33:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o63JS-0001yX-Ep for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:58:58 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:41887) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o63JQ-0000Vy-Ps for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:58:58 -0400 Received: by mail-pl1-x62b.google.com with SMTP id c4so10024091plc.8 for ; Mon, 27 Jun 2022 21:58:56 -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=s5yvC5+jgu+oomjjgt/lH/bjvfcHjmqplnFnsHD+6cE=; b=gEYpunoXsdElb/xsiVOf7ZhcIikAKdM//IguWcqio4khuTT9GqJ/NINnGl+1eb0BSP KKwJWZg0loTExrH0XUnpZ/QEl7V0MPH4FkPcfNEUBWpLCaVzXTykLkyp+mljoacRTLgm TKR02ugJKWVvbi8RwglFrTzjTk+bhqRZZz31gYPiQDL6j8RJG3bx+XY64acR1SoVf77t 8qesmlazB34WlcYD7ub0hIEiAhwl09Pxcaudl/pJ6A04j3pxNVXusLgDfZXR46hKxbJj iimx2Yq7/YnEH8Hl2M1+P2NiG2TpET56doooEtosqxa8GBwc3xYHHXXt3tp/fG2YwDE+ WLZA== 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=s5yvC5+jgu+oomjjgt/lH/bjvfcHjmqplnFnsHD+6cE=; b=Ju5Snip4/pfcr+265IvJu40fcvcLP4Yqxl6MwLePbfpPa2z3xvOSXGp/Lzaqp2kP7q 4VF4rLF+gz3ISHEnVBNSu3EVAEWLWW8EKhTE40vyZhgRdL6Zao77qIYMtaUZhfUTWerm d0jjDzMiEELT0vCbTAR4EK7/REQJZrZ0etsgfJv1FhSaFkK4U17p2NogSK/Blyy2O0k1 bhzuUsGNPB4l7YbrPR8l/N1cR+Rf0qelVbjMsdecJJdRJLNyll8d974lnaRa5Ovj9yRi 71z79mnDnr/SWL/7cHXYIt3cE5K+qNmIeBCBO4z1bmECgsp66H9aFzvm3TzFC8XnF3IX CWCg== X-Gm-Message-State: AJIora+Rpnz1fuAc77RRbkLbFY5EE6ihDDre32DL36sS0vsAa7FLig7R DoXlLVEN5rYYNaiF6GcKBmDkqXdERR4FLA== X-Received: by 2002:a17:902:d488:b0:16a:158e:dd0b with SMTP id c8-20020a170902d48800b0016a158edd0bmr1795761plg.162.1656392335259; Mon, 27 Jun 2022 21:58:55 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y7-20020aa78f27000000b00522c0a75c39sm8259686pfr.196.2022.06.27.21.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:58:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Luc Michel , Peter Maydell Subject: [PULL 42/60] semihosting: Pass CPUState to qemu_semihosting_console_inc Date: Tue, 28 Jun 2022 10:23:45 +0530 Message-Id: <20220628045403.508716-43-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 don't need CPUArchState, and we do want the CPUState of the thread performing the operation -- use this instead of current_cpu. Reviewed-by: Luc Michel Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/semihosting/console.h | 4 ++-- linux-user/semihost.c | 2 +- semihosting/arm-compat-semi.c | 2 +- semihosting/console.c | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/semihosting/console.h b/include/semihosting/console.h index 4f6217bf10..27f8e9ae2e 100644 --- a/include/semihosting/console.h +++ b/include/semihosting/console.h @@ -39,7 +39,7 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c); /** * qemu_semihosting_console_inc: - * @env: CPUArchState + * @cs: CPUState * * Receive single character from debug console. As this call may block * if no data is available we suspend the CPU and will re-execute the @@ -50,7 +50,7 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c); * * Returns: character read OR cpu_loop_exit! */ -target_ulong qemu_semihosting_console_inc(CPUArchState *env); +target_ulong qemu_semihosting_console_inc(CPUState *cs); /** * qemu_semihosting_log_out: diff --git a/linux-user/semihost.c b/linux-user/semihost.c index 17f074ac56..f14c6ae21d 100644 --- a/linux-user/semihost.c +++ b/linux-user/semihost.c @@ -56,7 +56,7 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr) * program is expecting more normal behaviour. This is slow but * nothing using semihosting console reading is expecting to be fast. */ -target_ulong qemu_semihosting_console_inc(CPUArchState *env) +target_ulong qemu_semihosting_console_inc(CPUState *cs) { uint8_t c; struct termios old_tio, new_tio; diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 1b0505987a..40f3730778 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -428,7 +428,7 @@ void do_common_semihosting(CPUState *cs) break; case TARGET_SYS_READC: - ret = qemu_semihosting_console_inc(env); + ret = qemu_semihosting_console_inc(cs); common_semi_set_ret(cs, ret); break; diff --git a/semihosting/console.c b/semihosting/console.c index 4e49202b2a..17ece6bdca 100644 --- a/semihosting/console.c +++ b/semihosting/console.c @@ -144,17 +144,17 @@ static void console_read(void *opaque, const uint8_t *buf, int size) c->sleeping_cpus = NULL; } -target_ulong qemu_semihosting_console_inc(CPUArchState *env) +target_ulong qemu_semihosting_console_inc(CPUState *cs) { uint8_t ch; SemihostingConsole *c = &console; + g_assert(qemu_mutex_iothread_locked()); - g_assert(current_cpu); if (fifo8_is_empty(&c->fifo)) { - c->sleeping_cpus = g_slist_prepend(c->sleeping_cpus, current_cpu); - current_cpu->halted = 1; - current_cpu->exception_index = EXCP_HALTED; - cpu_loop_exit(current_cpu); + c->sleeping_cpus = g_slist_prepend(c->sleeping_cpus, cs); + cs->halted = 1; + cs->exception_index = EXCP_HALTED; + cpu_loop_exit(cs); /* never returns */ } ch = fifo8_pop(&c->fifo);