From patchwork Wed Nov 27 19:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 845758 Delivered-To: patch@linaro.org Received: by 2002:a5d:6989:0:b0:382:43a8:7b94 with SMTP id g9csp992424wru; Wed, 27 Nov 2024 11:20:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW80L9ZvcmSZHUyDz+AvOcTj9ecrgXzr4m+8b6x7goytwgQ/WEZBsdXYkW3Qzw6S2jQr9u3Ow==@linaro.org X-Google-Smtp-Source: AGHT+IHMroMyhjgiyAl15/NmqFzHjplFSMV6gCI5Gpbi5rjUoPGoTu+ENGeZ4bsyY0vueE9Xn6WC X-Received: by 2002:a05:6358:e484:b0:1c6:33e8:18b9 with SMTP id e5c5f4694b2df-1cab15a6c91mr337797255d.1.1732735220676; Wed, 27 Nov 2024 11:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732735220; cv=none; d=google.com; s=arc-20240605; b=F2ZLegE75rVNCG89cs4Nlz+9OycYNVXsElly16/u60EYpdZB/Dd15+rxe1QnHL6GqT y+FdqJNpneha8fnn83gZChjEyVLf6ZuKokyDArvpcvw3IkNS+0nwXEtLy78Hn2UMlqJA jYjDdzTuC/SF/njeZDj6jaQT2/v90Pb0uXNJ2NGdk9nSapfRr4jfqoWU4eSc6kTpXv5W iQAJBwFShYyN5Xx/XIazKfGilO1654xwSvLvVpwrG4z5z4AP3CjfL8yD2WqbMa0u67WE UUDOO+TWZVD1WGN3TxJoRK+jc9LbHyG1UViGHsdUC0JR0ftNg86Zc1hAGOQvzbv4q47J kH1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=4ilIr5IjJMRG1FV3f50ShmHtgY8dkOoKs/arzlwSbMY=; fh=9/Q0mmHLncC82YAUt8eIuao2WX3IYyG4mRLs7zCk420=; b=TN/IbFPmRubrAVelO1WB6HHFIW3Aogy/sPb1rdPpUW3/z8e5wZs+UOh909UtR9KCY5 OZGbMlDsL7D6c6ebSvXt9aB+Do4qL18cffGaeUIA14qTCc8iV6/3B3U9b9tm86kwWFpM rnKwOo9gdOQy82GTwybssG58XEcNDVcWOBAZvOMTfdGBFjjIV3l3yF3mYQhdD8hZ8lng q00ktOkbk8uVHB/SaETtMZjPNb19ZrX8t9qcjO0178JwCkpMfR4Wpmn7hrodlrli/UMe QOp0Vhu3eUDk7/0j3Ura8EUZXA2ODGkuJNFfXseOhwqD0CPx3hq6Dfn9jwHe9ZppAPo/ 1DSw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="owq5EW/z"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4af35802c63si2127423137.191.2024.11.27.11.20.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Nov 2024 11:20:20 -0800 (PST) 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="owq5EW/z"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGNZQ-0002Li-Sl; Wed, 27 Nov 2024 14:19:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGNZK-0002LP-M9 for qemu-devel@nongnu.org; Wed, 27 Nov 2024 14:19:23 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGNZI-0006DV-W4 for qemu-devel@nongnu.org; Wed, 27 Nov 2024 14:19:22 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-434a9f2da82so23675e9.2 for ; Wed, 27 Nov 2024 11:19:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732735159; x=1733339959; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4ilIr5IjJMRG1FV3f50ShmHtgY8dkOoKs/arzlwSbMY=; b=owq5EW/zx+GIAR/+P2JbmO5VyfOQqtVDqEj/YFe+4djChhuz4ktN9LcVwF7NMlDOFx 3Z+j56+KFdvMH2+LL7DOl3t7+UAlWOhaLpXYs7JsVAMjQzWSYJ+J+4rraZO3xbF4NPI9 aoSlK3JuA6SdSdC3hb6XQPUwqPIeUJjKIyW8sUxCkJjUGW7Hl5cQDsQudClftiTQ0uuv Q9+3NdoiLxwefbjBHgaAtbntTGVzJ0WRTmpdSy6L50uKlSYMYeO4xmdLho+Cr1hQSV0F MNDgB6KsyNMkJBp6u79JjfiaDBGWK3+U5Hw0o79MgbaFUAX7zpmJAzSpsX2YvCxcDifR Qb2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732735159; x=1733339959; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4ilIr5IjJMRG1FV3f50ShmHtgY8dkOoKs/arzlwSbMY=; b=ZxWDBclP+oMNo+wnY5C4FxlTmS3ADTrSxAXc4qvwUmtskJgv+Gkp9bBj0kX1mcXT17 67O8uR7SIegdESTkpUlg0Q4oSUbiiIrMhdJQ1OJLGLyVbUR3/Yjj6BNc8Dl2tJr5uEhk Z91grlFn2ZM2U3YOM4Iov04bHRmeoFj7ueb5WIhplZIR8ANq6fDWekLlD/W6d4kwNWTj 9bymo58Ka0nJQL6xUs4uofGM9o9BLivns4mIKt7Gf+A72z0KYv0dSynT1yKWCsZcfvKa 60SvPgBkYbcBczoknyECFvCTrf3ii73+a0k3Becdqz3WRiXbb6jo4M4RzzXgsLg2ma06 s9IQ== X-Gm-Message-State: AOJu0YyTNeGOGD72O2nrbHSereo+X0H6jIASb8F6JqWwi4AxaRJ5kd5S IrN6Kw45GYtQKQgmdpEXgQ4R7V0OkCFmxhBBqhl6/OBQqF+vKRCwbFRajMMB+rrES0Pfko0uDtz W X-Gm-Gg: ASbGncuitAsJYipuWobQ5KivZGpT8ra+qosBAYN2b4XYnm/v3hcx8HEPUhDpUf754HP 6DqaWZrGTrcBa8+tXlJ9Jz4HnX4gFt7YDd71IqKfR1TQPlQDcC9egHVTWLf2VNjJjRWnTy+ltdF FIBWR5GBK0mTBQCltor4RHkJDn0DzbzlEk9AEMcQMSJ7AUFACqyITxY0l4hMONi3CXZrCgDfeOc yv633+s6b/9WWaDJSM7QMS1v/0E2uczF+5fUN8OzwrRS/lePPIW0sSHXhsr/nAI6NrDwn/FWXGc SypWGxR1257akh/2RceaHa4F8bNzWKPjfO4xq/NUagA= X-Received: by 2002:a05:600c:444e:b0:431:44fe:fd9a with SMTP id 5b1f17b1804b1-434a9dc8297mr35380195e9.19.1732735158806; Wed, 27 Nov 2024 11:19:18 -0800 (PST) Received: from localhost.localdomain (plb95-h02-176-184-14-96.dsl.sta.abo.bbox.fr. [176.184.14.96]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434aa7e256esm29599145e9.32.2024.11.27.11.19.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 27 Nov 2024 11:19:17 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Anton Johansson , Richard Henderson , Laurent Vivier , Paolo Bonzini , Fabiano Rosas , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-10.0] system/qtest: Access memory using cpu_physical_memory_rw() API Date: Wed, 27 Nov 2024 20:19:14 +0100 Message-ID: <20241127191914.34146-1-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 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-bounces+patch=linaro.org@nongnu.org There is no vCPU within the QTest accelerator (well, they are stubs doing nothing, see dummy_cpu_thread_fn). Directly use the cpu_physical_memory_rw() API -- which amusingly prefixed 'cpu_' does not use vCPU -- to access memory. This reduces accesses to the global 'first_cpu'. Signed-off-by: Philippe Mathieu-Daudé --- system/qtest.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 12703a20455..a2de9a7d5a4 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -18,6 +18,7 @@ #include "chardev/char-fe.h" #include "exec/ioport.h" #include "exec/memory.h" +#include "exec/cpu-common.h" #include "exec/tswap.h" #include "hw/qdev-core.h" #include "hw/irq.h" @@ -514,23 +515,19 @@ static void qtest_process_command(CharBackend *chr, gchar **words) if (words[0][5] == 'b') { uint8_t data = value; - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 1); + cpu_physical_memory_write(addr, &data, 1); } else if (words[0][5] == 'w') { uint16_t data = value; tswap16s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 2); + cpu_physical_memory_write(addr, &data, 2); } else if (words[0][5] == 'l') { uint32_t data = value; tswap32s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 4); + cpu_physical_memory_write(addr, &data, 4); } else if (words[0][5] == 'q') { uint64_t data = value; tswap64s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 8); + cpu_physical_memory_write(addr, &data, 8); } qtest_send_prefix(chr); qtest_send(chr, "OK\n"); @@ -548,22 +545,18 @@ static void qtest_process_command(CharBackend *chr, gchar **words) if (words[0][4] == 'b') { uint8_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 1); + cpu_physical_memory_read(addr, &data, 1); value = data; } else if (words[0][4] == 'w') { uint16_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 2); + cpu_physical_memory_read(addr, &data, 2); value = tswap16(data); } else if (words[0][4] == 'l') { uint32_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &data, 4); + cpu_physical_memory_read(addr, &data, 4); value = tswap32(data); } else if (words[0][4] == 'q') { - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - &value, 8); + cpu_physical_memory_read(addr, &value, 8); tswap64s(&value); } qtest_send_prefix(chr); @@ -583,9 +576,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) g_assert(len); data = g_malloc(len); - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, - len); - + cpu_physical_memory_read(addr, data, len); enc = qemu_hexdump_line(NULL, data, len, 0, 0); qtest_send_prefix(chr); @@ -605,8 +596,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) g_assert(ret == 0); data = g_malloc(len); - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, - len); + cpu_physical_memory_read(addr, data, len); b64_data = g_base64_encode(data, len); qtest_send_prefix(chr); qtest_sendf(chr, "OK %s\n", b64_data); @@ -640,8 +630,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) data[i] = 0; } } - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, - len); + cpu_physical_memory_write(addr, data, len); g_free(data); qtest_send_prefix(chr); @@ -663,8 +652,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) if (len) { data = g_malloc(len); memset(data, pattern, len); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, - data, len); + cpu_physical_memory_write(addr, data, len); g_free(data); } @@ -696,9 +684,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) len, out_len); out_len = MIN(out_len, len); } - - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, - len); + cpu_physical_memory_write(addr, data, len); qtest_send_prefix(chr); qtest_send(chr, "OK\n");