From patchwork Mon Sep 26 13:38:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 609327 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1891997pvb; Mon, 26 Sep 2022 07:28:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hCNKoCyXboIII03rwjpa0M1fi5OchMW7tbI05UTCgLkFbdv0odxngXBXE4l94UXXGMvuN X-Received: by 2002:a0c:d987:0:b0:4a5:192c:faff with SMTP id y7-20020a0cd987000000b004a5192cfaffmr17606271qvj.106.1664202528419; Mon, 26 Sep 2022 07:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664202528; cv=none; d=google.com; s=arc-20160816; b=Qx2SAx9oZ5S9l6+Ky/e3IWX5IwAG+l5aek1bpRgZG9UwjqhypItXnRn6d0ycptOTFM nTo/vdMnNJeMQxY1gZa1h+78FRDeCgq2xKAxWt+072AfDQc3xWjbkLWe7KiMCs6h8oFT f4sLH7yDJ4ZzRYfNMlDgMJVGQDWRNteNbfVIU5Ana9D8sb6GZa09tQjbpSZGcYysmSfa Zne+x6AwNUqWygFtU9Sz5ejlao4CPDh/inUM6nJrAQDY8teC60E2MaKGUvQmPxZAPiLu MMC+1YJ7KLe41pEZxHQlHAR0CiAnqcDZiVF9vns+DQnUcob1mDHnE4+zuk0+Nc/QHD+K uM5w== 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=Wq3HlctCe78yvKE2dJl/lmSv5/GtdmA9RfU6fehuz/0=; b=l6pu/QfkeCfxpzd3UXUlv7bzYoBuJRUOTqk0Sa+lHAUx7v18JBCPHduLlZMNdSF9PH lOc+t7np1sr4h4qqg6tiUyNpR/pGd/N9FuMQnD3/LaJtmK9DkT72fVwL2g9NYikfYuDJ PY0ojlVP5hZcGAl4sxSz70gNv/f9JRKDZQL2EkaarH4Mzmke6YTvbrZkWMq/ehffuvxa eWQmTCwJzuvSlaAaYxyrYvoVmGFWhJwmTTI995wFDkmtnFAJ0ODQqs8KTtJzLlAvRwgA 5qovZbrAWMHeW3K68FuA3d4ZGipfur3gIzAdCmf0Cvsu+zKsMARVAYnb+nu2onozreq2 Pc2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nbf0JDLC; 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 iy2-20020a0562140f6200b004ad77a0f08asi8705203qvb.379.2022.09.26.07.28.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Sep 2022 07:28:48 -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=nbf0JDLC; 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]:60302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocp6F-0007H8-Vz for patch@linaro.org; Mon, 26 Sep 2022 10:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocoKH-00021Z-R4 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 09:39:15 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:39703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocoKE-0005eg-Q8 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 09:39:13 -0400 Received: by mail-wr1-x42a.google.com with SMTP id cc5so10284043wrb.6 for ; Mon, 26 Sep 2022 06:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Wq3HlctCe78yvKE2dJl/lmSv5/GtdmA9RfU6fehuz/0=; b=nbf0JDLCbS7Mk6WEjkuhwiaJen9kjRaVw/QmaQWthNEq2ISdDRy1Lmux/vPiJYTJg7 6LYrpPpF/f9fmLjyPIXdPWKROZJgCUc9QrtSGCMgM2euWeSObgjcKM7morAdA7WDPRPE w94t9OPUO856dscvookhz0waI/JRSkWOQNImLJshWvSDkOSzQ13VpRUhwexIEJ80dHAv cOYDlrdLGr37Ci+NhQTvcrQ1FVVz1t5H22H+U/chzE3FTKt2FdbljQPnL3auWx4z2ip4 Q+c/c2GvYPS4rbBTzU4Jyaxv0zp4LC2HcejtsifBhxJhse/oUUl30JHoanGqbEX2+nX8 877w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Wq3HlctCe78yvKE2dJl/lmSv5/GtdmA9RfU6fehuz/0=; b=NjOg9cr5eur5LaE6oS7FLzJbgY57Ec/ZZu5BaN9QDR79N0A5rYpi0JpdMxanBOS+mQ oYiuqjAcy5EWdUdoOzOU7kkWoFNutrxyVgyH659rYvEcPYZr3TJ+dBicutzC6y2oAOgp n5J6DiYaPPF+F7RAd1IqBI9HS/WfhDdawHsXWZ89OnHTQzT7eZMk5sPBSJd+nrLbLSNL GItQ/el2emIeczXNWT5yPZY8zAeDuV3td2uZYKn4tThrfxRMOYlF9HyZp0phrN8i1FNf Md0mzx8LPJo1AP2LNXjBDqlIyCgA426+gww8BjOhCxXTBAGwpiqqZicXZT48oXraCbS9 BIiw== X-Gm-Message-State: ACrzQf0gSeBRqQ4jaMF53kuxvWxxLds+81rls3LEMy/67SbR9n0LZg+R BsWpLRbc63xbedEGWCVTawMJRQ== X-Received: by 2002:a05:6000:15c2:b0:228:dc85:d1b0 with SMTP id y2-20020a05600015c200b00228dc85d1b0mr13467958wry.9.1664199549054; Mon, 26 Sep 2022 06:39:09 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id h6-20020a05600c2ca600b003b4c40378casm11773005wmc.39.2022.09.26.06.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:39:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 16B9E1FFBC; Mon, 26 Sep 2022 14:39:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, mads@ynddal.dk, qemu-arm@nongnu.org, =?utf-8?q?Alex_Ben?= =?utf-8?q?n=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 04/11] qtest: make read/write operation appear to be from CPU Date: Mon, 26 Sep 2022 14:38:57 +0100 Message-Id: <20220926133904.3297263-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926133904.3297263-1-alex.bennee@linaro.org> References: <20220926133904.3297263-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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=unavailable 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" The point of qtest is to simulate how running code might interact with the system. However because it's not a real system we have places in the code which especially handle check qtest_enabled() before referencing current_cpu. Now we can encode these details in the MemTxAttrs lets do that so we can start removing them. Signed-off-by: Alex Bennée Acked-by: Thomas Huth --- v2 - use a common macro instead of specific MEMTXATTRS_QTEST v3 - macro moved to earlier --- softmmu/qtest.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index f8acef2628..3aa2218b95 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -520,22 +520,22 @@ 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, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 1); } else if (words[0][5] == 'w') { uint16_t data = value; tswap16s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 2); } else if (words[0][5] == 'l') { uint32_t data = value; tswap32s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 4); } else if (words[0][5] == 'q') { uint64_t data = value; tswap64s(&data); - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 8); } qtest_send_prefix(chr); @@ -554,21 +554,21 @@ 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, + address_space_read(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 1); value = data; } else if (words[0][4] == 'w') { uint16_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + address_space_read(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 2); value = tswap16(data); } else if (words[0][4] == 'l') { uint32_t data; - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + address_space_read(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &data, 4); value = tswap32(data); } else if (words[0][4] == 'q') { - address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + address_space_read(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), &value, 8); tswap64s(&value); } @@ -589,7 +589,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, + address_space_read(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), data, len); enc = g_malloc(2 * len + 1); @@ -615,7 +615,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, + address_space_read(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), data, len); b64_data = g_base64_encode(data, len); qtest_send_prefix(chr); @@ -650,7 +650,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) data[i] = 0; } } - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), data, len); g_free(data); @@ -673,7 +673,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, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), data, len); g_free(data); } @@ -707,7 +707,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) out_len = MIN(out_len, len); } - address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, + address_space_write(first_cpu->as, addr, MEMTXATTRS_CPU(first_cpu->cpu_index), data, len); qtest_send_prefix(chr);