From patchwork Tue Jun 7 20:45:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579439 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5582729max; Tue, 7 Jun 2022 15:51:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpKzmdW+deSkNQ/OGhIIT11rR1MDVMhQgW/q/MWkFdxOgFJEWr7L2hgqMcSELlmz4bYqbS X-Received: by 2002:a05:622a:1a82:b0:304:da37:85bb with SMTP id s2-20020a05622a1a8200b00304da3785bbmr22133563qtc.347.1654642284349; Tue, 07 Jun 2022 15:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654642284; cv=none; d=google.com; s=arc-20160816; b=oW98Q2gMXHycgq5JvnPqq9lsC2POHhb1z3VHhZGu0h0aSazVYzTA4jspcjoBIRvOVv /9GjFpjkq32Z1OUYXWpZAxF9MRH0kClgkBTW/7KaaeKQ9gC0lRDBvE7YbqZq4/cJLtDF M3ixtwsPkMJYpTCoZ1MCVaPEekUVOznSol3A0QlOxerpf/PA13Mo07saDjW32F3PpR+a Jkv7qwVEj5bMZen8bkW8vyRNQf4J72no/jIO1dXBKCdIN6S828dNcVwLNtfCBUGh8yfn ZtuynvPcR2R57dvRdyQOZl1qe5w3GzNycO1e7oOXvJcIUkf02Ek67ijqsRO/kanm7CuI lZnA== 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=kcKcbuHpae2wG44hmgdN3EhtSwRafPOrATlYMDNb6tY=; b=ZYkvz1OZWSHYxB8AfeapjjYqYCVLHfy+CqdaepjqfhNv95f8/aHg3EuB8aJaUI+ZJF AfZNDDwet00fpJ6UddhTK/U4K57o2HrQsRhH0dLGfPUpd13a7g+au76WQ/YAumzhtp3S tCV4ZVvsJ6shP+bS1SwuXfXP/FTLtthT61nEEQZ8ytWL/bRY6saA5jGBNCv/Fz84MpXQ VLj6iYx3K7tqkRK4Tbdc72jPJ7Xe7eVIWipm6vYA6NNJGrILB9aRLAmDnF0U2Tzo816p +xmhIerfFzBqLw78VRuEsBkwDXGvzPhFzJdaC8wI2fpmyDvtIMwd0EVjDzlJDEmElwBU KL8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yA3NsPgg; 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 m9-20020ad45dc9000000b0046b966e12c3si4022359qvh.543.2022.06.07.15.51.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 15:51: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=yA3NsPgg; 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]:47556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyi2l-0001vf-UZ for patch@linaro.org; Tue, 07 Jun 2022 18:51:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyg92-0005eg-J3 for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:49:46 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:38711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyg8x-0001om-IR for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:49:43 -0400 Received: by mail-pg1-x532.google.com with SMTP id 123so6623232pgb.5 for ; Tue, 07 Jun 2022 13:49:38 -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=kcKcbuHpae2wG44hmgdN3EhtSwRafPOrATlYMDNb6tY=; b=yA3NsPggRY6PlKoxCtskat9jAtjNtJFt2H/gxHCx2O8dD2Ghl894VQoI+OmNoO/PH4 JQKJp+XqdFzDHGbx7qefXcPC4VhMcNumesNVnI5d4/KucFbH/V++9RWYTIoGDlBkxk+G fQIud1qgpbJQXW5DytUg92g+yRka/RS8eWZT3fSZJmyegKxNwXvueXKmhsatn73W+nt5 ikxlSK+SanwQ7haE8I+DZmtQwUpI9FwmqIJMAnZo3acAexrYBCIYtBuQ7aZfmkAJxFNc RtuyNoWiYBF5wiXrYJs1Gjd60BpWQ8BL6GYxpuK8keZKNkoSWi9iuVdqxLHoJjw8UhF5 5kYw== 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=kcKcbuHpae2wG44hmgdN3EhtSwRafPOrATlYMDNb6tY=; b=ubRFjLs1Ie6CCTW2M+o+Gq4FcEZsQteH+mdSU/hEr+SoayxnIwVoFqGJW9O2RnVSwH nWZOB1lB9tMJSVmBXkv83BxltBBUZUQgoqe3ocQNzE+N9j5gZmzXgsCDU+2s25CLIkgN 7pQ/BSoJLvjS3MZtChhn/H0TVUcfYv9UYZMr1VofEyKHnCHTSp4w0IyIFhJa4QMxptDd 9lJSJsQIgeHHvhaOREtfa1rXMDHEHOUdtQaTMcKhSnqDjuJTlfktwvm+HBlviR3Nykky H+b1Gie1zkTJt+wUMB/bD8zNPR3PeB638d3dXwQ5yTFiowo2kfYbUF6waXHe6coUSJps Ie7g== X-Gm-Message-State: AOAM5333ySMHoVWGinJhM+OZRvwoM8kBRJw1ewwGgFlua0/KhhXfm3QC k6qXdSfn0bHjt4T8IKWH/2pZU0fbV6mrQA== X-Received: by 2002:a63:b1e:0:b0:3fd:43d9:5354 with SMTP id 30-20020a630b1e000000b003fd43d95354mr18769073pgl.294.1654634977428; Tue, 07 Jun 2022 13:49:37 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id 128-20020a620686000000b00518b4cfbbe0sm13152327pfg.203.2022.06.07.13.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:49:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PATCH v4 42/53] semihosting: Pass CPUState to qemu_semihosting_console_inc Date: Tue, 7 Jun 2022 13:45:46 -0700 Message-Id: <20220607204557.658541-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607204557.658541-1-richard.henderson@linaro.org> References: <20220607204557.658541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Luc Michel --- 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 f992b60b6b..e7de52d042 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -427,7 +427,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 3dd0ac60e2..7b896fe43b 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);