From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616509887; cv=none; d=zohomail.com; s=zohoarc; b=C25I6l8eliHZM//0Y/ACcwesGxYe9GIb14vY+ja5k36LHtAe68DS/l3RM4XDb0UPP/Yvu1ewpna57G+HZTVOWEmXDvZWPoZ/61X3RhVWiG+ItC20Yb+qKFwIR53upSp8+FV+vhftbVX8dHAaPSwQ63lnxJ6li3E6URfWEKjtvn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616509887; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qQ5V1NDs1ebp5KV2Gl+GAsF9d/1idJ3pehCUcDnuXTQ=; b=COxhSEDk98CHDanTT6XroljsFVI/hvwinlFYK10wadbCkUJCif9k6tDT5hz5z3Mt65IJBtWmHKO+9TMcMAuoBkVzDiE7R26lBBpbroctt11XJ/StoMROEGJNn0FYDqiyXJF+IigVWCd4+EHKAHtdAI8ONW5tJpWahULDONFtJaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616509887478539.2093539545915; Tue, 23 Mar 2021 07:31:27 -0700 (PDT) Received: from localhost ([::1]:47588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi46-00040z-Ln for importer@patchew.org; Tue, 23 Mar 2021 10:31:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOhzz-0006ZY-JK for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:16 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:46707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzm-0007Ah-0B for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:10 -0400 Received: by mail-wr1-x433.google.com with SMTP id v4so20976217wrp.13 for ; Tue, 23 Mar 2021 07:26:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qQ5V1NDs1ebp5KV2Gl+GAsF9d/1idJ3pehCUcDnuXTQ=; b=oq6ERoy2l5OU0JoWUzrvyHS7qlDYxPhYoQVx5GSa3difJ5LisVqAr1R7aPzBJRucNm 56w1T91T9D7hJBfu9Q32jbYOEyhTZ4D+fZXG05iAvbpn/NjAhsxRk/XVq295PEuO7mQT ieUpq3E/fiRagYO/qGxKHM70It7NBhgLIFqsp/yfZsNrC7LCdmIEIADY8kQOqlOb6wjL LGRMO/qx8lYgjt7xAOvqHXhbhZ9Cf9HUNKKzoQ1Ib8sbbf3rDKa/hIDGFyAglSG9vSqG 5m4ocCAl5KVOWLYxTK4N/Fhm5ud4rWaGEotd/Yz+XXQA7Omh+H85/4o1wpEtGI6oQbNO WBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qQ5V1NDs1ebp5KV2Gl+GAsF9d/1idJ3pehCUcDnuXTQ=; b=cWtqQ+OWwLyWoG2UZ5Uu7CHF47M7cQ9Swf115CLhSZkcFZMw7MidMD9cjrcoq5Stge koAJYD1OToe1mv8LNtXfDQKGcyul/6HZmtFqViOyiH5J44mD1ALcOnt+DWA+ADAehlGe 3iG7jkijE3ul6i8hMQNzxLMyfJ70CSi2apjV2v9AbRMA03NJ4BrMICZYqyMm/T9mXB6d 0TpCfVvG+zA4m/YjlmrD6+B7Aq2hy3LIGIRHTLzoeO9vcvxEt34YbKaqs544q+ao4TV/ MUaI39lCpFEIoJxPE0m+HNtvHcUO5Q2pY0aU6wOCSsb/eTQpM5bcRlZHgszJhzlItd3i n76Q== X-Gm-Message-State: AOAM531fJvb3Rd1OcRTdcxDIrG30oiPhGE5rM+70q/BrNph8ZHbKS9uO sWryDNvsZuApi7SjyDDbNvY2CtjHael+qPc9 X-Google-Smtp-Source: ABdhPJwOa0l8mrIuIbs25HB93orxToxNxIhTaEN1ficMCjRw+fprGTZpDILo9iAd8ETinS6ouO8fkw== X-Received: by 2002:adf:ef4c:: with SMTP id c12mr4349729wrp.112.1616509616409; Tue, 23 Mar 2021 07:26:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/7] hw/arm/virt: Disable pl011 clock migration if needed Date: Tue, 23 Mar 2021 14:26:47 +0000 Message-Id: <20210323142653.3538-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Gavin Shan A clock is added by commit aac63e0e6ea3 ("hw/char/pl011: add a clock input") since v5.2.0 which corresponds to virt-5.2 machine type. It causes backwards migration failure from upstream to downstream (v5.1.0) when the machine type is specified with virt-5.1. This fixes the issue by following instructions from section "Connecting subsections to properties" in docs/devel/migration.rst. With this applied, the PL011 clock is migrated based on the machine type. virt-5.2 or newer: migration virt-5.1 or older: non-migration Cc: qemu-stable@nongnu.org # v5.2.0+ Fixes: aac63e0e6ea3 ("hw/char/pl011: add a clock input") Suggested-by: Andrew Jones Signed-off-by: Gavin Shan Reviewed-by: Andrew Jones Message-id: 20210318023801.18287-1-gshan@redhat.com Signed-off-by: Peter Maydell --- include/hw/char/pl011.h | 1 + hw/char/pl011.c | 9 +++++++++ hw/core/machine.c | 1 + 3 files changed, 11 insertions(+) diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index 33e5e5317b8..dc2c90eedca 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -50,6 +50,7 @@ struct PL011State { CharBackend chr; qemu_irq irq[6]; Clock *clk; + bool migrate_clk; const unsigned char *id; }; =20 diff --git a/hw/char/pl011.c b/hw/char/pl011.c index c5621a195ff..dc85527a5f9 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -322,10 +322,18 @@ static const MemoryRegionOps pl011_ops =3D { .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 +static bool pl011_clock_needed(void *opaque) +{ + PL011State *s =3D PL011(opaque); + + return s->migrate_clk; +} + static const VMStateDescription vmstate_pl011_clock =3D { .name =3D "pl011/clock", .version_id =3D 1, .minimum_version_id =3D 1, + .needed =3D pl011_clock_needed, .fields =3D (VMStateField[]) { VMSTATE_CLOCK(clk, PL011State), VMSTATE_END_OF_LIST() @@ -363,6 +371,7 @@ static const VMStateDescription vmstate_pl011 =3D { =20 static Property pl011_properties[] =3D { DEFINE_PROP_CHR("chardev", PL011State, chr), + DEFINE_PROP_BOOL("migrate-clk", PL011State, migrate_clk, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index 257a664ea2e..9935c6ddd56 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -52,6 +52,7 @@ GlobalProperty hw_compat_5_1[] =3D { { "virtio-scsi-device", "num_queues", "1"}, { "nvme", "use-intel-id", "on"}, { "pvpanic", "events", "1"}, /* PVPANIC_PANICKED */ + { "pl011", "migrate-clk", "off" }, }; const size_t hw_compat_5_1_len =3D G_N_ELEMENTS(hw_compat_5_1); =20 --=20 2.20.1 From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616510068; cv=none; d=zohomail.com; s=zohoarc; b=IKWE6bAC8RAgpN6589BmAUjWGDGjZVpTr9wt82wJZ3c/Og8hfUaOpvxjaeCffIHTJUAn98hPVWJhvik6gVODA96rl1G5YYo/PVssyrK6UXQVKhNcWRuyer+LZSdoQuBjREyPG0Z8fTjeKRUO5njAmmJ/GXefsSStV62Co5iyme4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616510068; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bai26WipCTifnbK8KTHEvIfiuURCYGq1Q4Uwj4/TFi8=; b=AUD8vEEexa/ZsbuoZCCZSWGcSefgSCmczCYlPZulpg+oJDSSGuS6mt6UaUqMjh6NaHPvxaUNnO11fsXmXfuKmE2MtfnSvdJkOD/GTrnnrbrdBPQVKUjYNab9EmV/5IiehIX9f4Euxqe69SZopM9UZaDJh8k8X7gRRrQzB83bgmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616510068547210.6846585919593; Tue, 23 Mar 2021 07:34:28 -0700 (PDT) Received: from localhost ([::1]:53896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi70-0007CZ-Sx for importer@patchew.org; Tue, 23 Mar 2021 10:34:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOi05-0006ax-SX for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:18 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzn-0007Ao-AM for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:17 -0400 Received: by mail-wr1-x436.google.com with SMTP id v11so20966568wro.7 for ; Tue, 23 Mar 2021 07:26:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Bai26WipCTifnbK8KTHEvIfiuURCYGq1Q4Uwj4/TFi8=; b=ndXK/vBObFhX367GoUu9PbcBjZDxFtJpflkQr5/2LIno5iEoO4/lPthE147GMplsGz ZoW+9ORta+RzwWz0ZQJV6mHMcPCGugpShlxew4BUzwUROnCcFYWzYMWr/jTpjSJClbST NrOvN4b+OF/dd6g2VaamZT3ayZzqpkIoVVy0yeEYpzr5Zg89gDO6wPj0TlIfs0hjI1yC glw2gkPdQxqnp0XbZGLiG/5xxMCgHyN9XmKXyIAb+687iVCAWNHxvJu2uqwgK/6udnnP PXBkNcHo86C+kCDe0h98zoTDeNNpX2/jr+Ot0ia1Bk4zP2i68Jf95w1Oyl5idKrQDMI9 ljzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bai26WipCTifnbK8KTHEvIfiuURCYGq1Q4Uwj4/TFi8=; b=T4xgZ+Jinl3qJY4ur9gd09asI0lUcPwK/yLaBt9ntwUOXPkoc8My/5WrNl5LJQWbxQ Ewx4DNt/Yo1xJwqRcyAp4HEEovRZ5Qgjho10O80JsPZyfbgHmo1+orVkEJTWwg4xCL3O QG4UwQyfkf+jUzfSRw6B5l4ici+93yVVXEbyrmSKeEIkTn1Jbgk8XWEGR9VGnZ87wTna KJKapLI4Vc7ZIIs8hvhl0jG5hoFwsSDPSBi3TMy0kHWB95EHpZEfWEndn8cnvfyioMM2 5HCXlE7BfiIKCKLit4wZ6NOTm1bp2/p3w/ga3E6KzmAfzfdOqXOUUjACdcUtJt3MlcIY p2Sw== X-Gm-Message-State: AOAM532bbgdl8bsvyKe9p2Y1JmZk5MrcywNCON7E/QIGgbYKyD9h9YEN eLy9p1xLebDcsjpJrHYB2PCTFftnSa1oAkPF X-Google-Smtp-Source: ABdhPJwnUsBgBvfGkl9rEpvpIatEqybf8ys0Ok7KZJ4VqODGyTq4vWpYs/TS5/AiduUuWGY0bDrBog== X-Received: by 2002:adf:8562:: with SMTP id 89mr4317955wrh.101.1616509617190; Tue, 23 Mar 2021 07:26:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/7] memory: Make flatview_cb return bool, not int Date: Tue, 23 Mar 2021 14:26:48 +0000 Message-Id: <20210323142653.3538-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The return value of the flatview_cb callback passed to the flatview_for_each_range() function is zero if the iteration through the ranges should continue, or non-zero to break out of it. Use a bool for this rather than int. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210318174823.18066-2-peter.maydell@linaro.org --- include/exec/memory.h | 6 +++--- tests/qtest/fuzz/generic_fuzz.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 260ddd8ade8..500bfc0abd2 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -776,9 +776,9 @@ static inline FlatView *address_space_to_flatview(Addre= ssSpace *as) return qatomic_rcu_read(&as->current_map); } =20 -typedef int (*flatview_cb)(Int128 start, - Int128 len, - const MemoryRegion*, void*); +typedef bool (*flatview_cb)(Int128 start, + Int128 len, + const MemoryRegion*, void*); =20 void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque); =20 diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuz= z.c index b5fe27aae18..b6af4cbb18b 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -98,19 +98,19 @@ struct get_io_cb_info { address_range result; }; =20 -static int get_io_address_cb(Int128 start, Int128 size, - const MemoryRegion *mr, void *opaque) { +static bool get_io_address_cb(Int128 start, Int128 size, + const MemoryRegion *mr, void *opaque) { struct get_io_cb_info *info =3D opaque; if (g_hash_table_lookup(fuzzable_memoryregions, mr)) { if (info->index =3D=3D 0) { info->result.addr =3D (ram_addr_t)start; info->result.size =3D (ram_addr_t)size; info->found =3D 1; - return 1; + return true; } info->index--; } - return 0; + return false; } =20 /* --=20 2.20.1 From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616510025; cv=none; d=zohomail.com; s=zohoarc; b=eXwFWV7JB3/rrIQVerlupuyl+lGGtMzI3O80CvdRdW4M7kg4F7wRjJY5QvvB0yli7d2JmFO6boI+mWaf4Pc7S1mlNIMNtfzFgddJJtPPO0UGgswNTO2T9Fc3OLxlBqG9EtIGwD33jc0NXT0YlA4RxuII95nJLu65/R3o/wPkeGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616510025; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OseTDtXoEYYYH2dfnvEztM2TnARc4pO+j/Uy4TyW2QY=; b=Kjqq5Dwvhkduv7ii6dbG8szABxzno43RzxW1uh0PnMTG+y8YTuec5Vra7JCKYFFLiWBbJ3FInQluZ7kB+jMITGiLmxviotouRn0jpgNAGHR0jqzJpmoWtUz5rO32SL9KLo6rkyMgUYHpAkXRo7kuurmYxMzQYmqlOufXIxCY0Wo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616510025230977.8374946136034; Tue, 23 Mar 2021 07:33:45 -0700 (PDT) Received: from localhost ([::1]:52854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi6J-0006fC-RR for importer@patchew.org; Tue, 23 Mar 2021 10:33:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOhzs-0006XU-Tf for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:06 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:44791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzp-0007Ax-IX for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:04 -0400 Received: by mail-wm1-x329.google.com with SMTP id j4-20020a05600c4104b029010c62bc1e20so10953610wmi.3 for ; Tue, 23 Mar 2021 07:26:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OseTDtXoEYYYH2dfnvEztM2TnARc4pO+j/Uy4TyW2QY=; b=x0N2s6Z3vtrDfbDfxO82R3zVtafxfjAV+OfjOpFykQICVJqtU9StDM1loUj3HRsElz Lat4xPRTeGvCaasDUu+Hspjb96+wqLRiWRBqjKxy4R0yaVJV7UOYRfKzDYSRWP1ZspJ8 +pAgY0QQaiVLvhKei1XdrEWwzrlyk2kQ1lhMrbma11JGnsv71MpjRUIQJPPwjQQ5WuW/ B0QWwJ6uf1cQEwobbKnDL+/N9hw9mZoNHeTPqILMkQ7nak8Tw0FTmHYGlEsmqdWhUp1B 5KfIbjMPieOULxSJM1L7BXWP0UWHsYMMaHDi8/OkEzRNc7KhQGoryDSb/kaFZSiVrs7W GIvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OseTDtXoEYYYH2dfnvEztM2TnARc4pO+j/Uy4TyW2QY=; b=gc7DTbStkkUPXs5oglpzozsNOuLStAA7oD1a9MfcXEb8ePK3wqySzyEGZ0b8f70B0n X+p9NAyfyi/sWPKJe0MnnX68iE0thn5nfhf8iCPsJ2H3eQnPirwdy0q5lIywmlqYzWQ2 hBC/XfSvSdKsqM6+qoaN9QkOet9oohPd13KbvpQuLdhft2h/YFwVmRstw+Qff+6v6oSj 6+CCR8DfRx9/6nhRZarmk5tm481yEweCFJ5DhRLkUmkhZ7sl0tIce/FHxzNbPXXKvn5w NA3iVm4+jJBvv0W2uL5AaTg+uGR5DK257FZJ6MKe1wZkYlzbtbWNvu7ZTwOLpr/GImo9 dlcQ== X-Gm-Message-State: AOAM532X77p4UT4z2X8LCZveLafRqHkH0A/K0cJIucFXGvd7vAW4AiL1 jaT7Yv+9YBtZdkiSopJy7rSSO8jeGGiXgM/3 X-Google-Smtp-Source: ABdhPJxAfkDCyCec7033ttlroL0YjSE9OcPG8ypLR0WpkMCP1v35wZNHDZk6hj4dGVxE33rE5PmonQ== X-Received: by 2002:a7b:cc84:: with SMTP id p4mr3703721wma.10.1616509617893; Tue, 23 Mar 2021 07:26:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/7] memory: Document flatview_for_each_range() Date: Tue, 23 Mar 2021 14:26:49 +0000 Message-Id: <20210323142653.3538-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Add a documentation comment describing flatview_for_each_range(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210318174823.18066-3-peter.maydell@linaro.org --- include/exec/memory.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 500bfc0abd2..88c2451c066 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -776,11 +776,33 @@ static inline FlatView *address_space_to_flatview(Add= ressSpace *as) return qatomic_rcu_read(&as->current_map); } =20 +/** + * typedef flatview_cb: callback for flatview_for_each_range() + * + * @start: start address of the range within the FlatView + * @len: length of the range in bytes + * @mr: MemoryRegion covering this range + * @opaque: data pointer passed to flatview_for_each_range() + * + * Returns: true to stop the iteration, false to keep going. + */ typedef bool (*flatview_cb)(Int128 start, Int128 len, - const MemoryRegion*, void*); + const MemoryRegion *mr, + void *opaque); =20 -void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque); +/** + * flatview_for_each_range: Iterate through a FlatView + * @fv: the FlatView to iterate through + * @cb: function to call for each range + * @opaque: opaque data pointer to pass to @cb + * + * A FlatView is made up of a list of non-overlapping ranges, each of + * which is a slice of a MemoryRegion. This function iterates through + * each range in @fv, calling @cb. The callback function can terminate + * iteration early by returning 'true'. + */ +void flatview_for_each_range(FlatView *fv, flatview_cb cb, void *opaque); =20 /** * struct MemoryRegionSection: describes a fragment of a #MemoryRegion --=20 2.20.1 From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616509708; cv=none; d=zohomail.com; s=zohoarc; b=IXSBqxf9xhIbUpZCh+Kz7HmWD7vLLPBlnBG7HCpAIM74Nj51py4bEAY6rWuZkslQATS1Y0BYJqFDZY3BEEqP1Yke9+iNn8kAm2t+CigfdV1Z7S42fZDvFjgPWOZKITkIe3DNbhjj4bdMqrQjOmTes56CRQcuXh70AXxhcmeGF/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616509708; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ANKfaI+3HtDgrtrUD4nkRjqYILHHidfMfgvGr268mts=; b=cPKaAhLttX9MNh/SRvP4KQ8mVnkIdlArdvF40xS4Vu0pFsPXwrUGA2m0VmfR1Pdo26TYCOrcSewPh3nHSrlQxB2uuBZZ8fT+lji/mWb6CpvaIPHuRK3HbS4r1pJBPlvMyjNEFKzdLoXOJNlTJTdlZIySu9D+s93kOxRiUYRZMZw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616509708513450.755816218668; Tue, 23 Mar 2021 07:28:28 -0700 (PDT) Received: from localhost ([::1]:39520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi1D-0008MQ-NN for importer@patchew.org; Tue, 23 Mar 2021 10:28:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOhzv-0006Xq-0F for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:08 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:43945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzq-0007BX-Kk for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:06 -0400 Received: by mail-wm1-x333.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so10953585wmj.2 for ; Tue, 23 Mar 2021 07:26:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ANKfaI+3HtDgrtrUD4nkRjqYILHHidfMfgvGr268mts=; b=S1ggtOdjNopiy5uyYZH62EAqm5xE7lEbX25tUL20kOIkfgGXY9YZsSfQ0LZXH7lWV8 yBHdTo2ANakgZWcjPvzy+urHfHdLZ1jS4d5I6Wvm67NoOs8xbRWYCZofY0aEas3zBtTN 0xq6IJvIwLFG2NFCsFkXla2M80bwAWJ/1sxIF062ah17L9Ybwlz70aBKsy51r3VljaWs k3KLskrFQQzlz3g48iW6WmpNzISrA0CWb5fpz3k9885QokoWo0te8giptATwR9WS9HOA 4uM/BVbjI2IpVhGHV6sP52t28vllQzpoVT6dWWt/aCsQyQrPhjF7ktsO04I787xtGBua PQDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ANKfaI+3HtDgrtrUD4nkRjqYILHHidfMfgvGr268mts=; b=lTA9Hm1sc1w7tASf1hoNddzhKL8mJItOlH4/Z1WQYdDUzv+SAXIS8O1Qfut4rrvf9M KpwNz5vS8VC6KNFJJM3kqwoFLLS6N3tkI7yDAf+ZkCq/N1lAYELOo8A3dsU+anOx6q5C EJ2ZwGamU8X6HYaZTnN87nNBs+muCG6pTJOxFum/HD7l2fq40VMpouKsXN9BFKWVeyRQ XzcaNfZx3DLxwhNfoo1db/tnVASTPWob/0PdokXMN8W0cvWuDDseaG2gxlk+5LIz7dba 5J8qR8ByP55CDo7mkeeWmgzFq1UCq2YLGCWhmBity8IYX+NCI+bsCWwS8ri6a42O3C7q wS5A== X-Gm-Message-State: AOAM532muS4w3/BjBtKtefo7hrVNCdU2ZsG8LCeeX4ffJc50nFoQOv+K A3J5aUwAf6j4U6R/qyI/WUak0NjRIcWftt2o X-Google-Smtp-Source: ABdhPJz/KDQzUoHecMNZGJ5MnS/d6jVC4T93s0JqiQmfcKo3BI53xpfwMMgltPdN3xGsTBxX9Brz1w== X-Received: by 2002:a05:600c:4f03:: with SMTP id l3mr3648676wmq.149.1616509618484; Tue, 23 Mar 2021 07:26:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/7] memory: Add offset_in_region to flatview_cb arguments Date: Tue, 23 Mar 2021 14:26:50 +0000 Message-Id: <20210323142653.3538-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The function flatview_for_each_range() calls a callback for each range in a FlatView. Currently the callback gets the start and length of the range and the MemoryRegion involved, but not the offset within the MemoryRegion. Add this to the callback's arguments; we're going to want it for a new use in the next commit. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210318174823.18066-4-peter.maydell@linaro.org --- include/exec/memory.h | 2 ++ softmmu/memory.c | 4 +++- tests/qtest/fuzz/generic_fuzz.c | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 88c2451c066..5728a681b27 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -782,6 +782,7 @@ static inline FlatView *address_space_to_flatview(Addre= ssSpace *as) * @start: start address of the range within the FlatView * @len: length of the range in bytes * @mr: MemoryRegion covering this range + * @offset_in_region: offset of the first byte of the range within @mr * @opaque: data pointer passed to flatview_for_each_range() * * Returns: true to stop the iteration, false to keep going. @@ -789,6 +790,7 @@ static inline FlatView *address_space_to_flatview(Addre= ssSpace *as) typedef bool (*flatview_cb)(Int128 start, Int128 len, const MemoryRegion *mr, + hwaddr offset_in_region, void *opaque); =20 /** diff --git a/softmmu/memory.c b/softmmu/memory.c index c4730ec47ae..d4493ef9e43 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -671,8 +671,10 @@ void flatview_for_each_range(FlatView *fv, flatview_cb= cb , void *opaque) assert(cb); =20 FOR_EACH_FLAT_RANGE(fr, fv) { - if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque)) + if (cb(fr->addr.start, fr->addr.size, fr->mr, + fr->offset_in_region, opaque)) { break; + } } } =20 diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuz= z.c index b6af4cbb18b..ae219540b42 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -99,7 +99,10 @@ struct get_io_cb_info { }; =20 static bool get_io_address_cb(Int128 start, Int128 size, - const MemoryRegion *mr, void *opaque) { + const MemoryRegion *mr, + hwaddr offset_in_region, + void *opaque) +{ struct get_io_cb_info *info =3D opaque; if (g_hash_table_lookup(fuzzable_memoryregions, mr)) { if (info->index =3D=3D 0) { --=20 2.20.1 From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616509718; cv=none; d=zohomail.com; s=zohoarc; b=ZJjFvlubfMyfBwcAafIOT0qnBvUjFeffXUSRzxVidWjYjp77rcuctmb7dEU6+n3xmcnWRooVVLyiqv1ScIeD+A0bNqZ2Kp8LUHUUXqokaWiAG+g1lfPvs1SVwv98Q2lDHRAMGsHX5KOIGkA7+eZ25jfOG/XMYcUA7sSkY/vzSys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616509718; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pOCeLNKBwgz69betEJZyVMFStpbhcpCwBwGtvhDAJik=; b=VXBz5CkqZ1j3JqSx7URzQ2aTacH79GXUpmTfEG0tjg8sF/8jPB8JVjJMSIYgN3rs/XASIN6KbjAIwzE+zTe09BLZeO2Zn+o2al6w5xeP0b6KLCYdH+0PuDkw9v7TCehRDJZj2IWYofLGeX8poFpyIlswR1hTLvTVmsuqzrlPZuQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616509718236307.6705952448292; Tue, 23 Mar 2021 07:28:38 -0700 (PDT) Received: from localhost ([::1]:40424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi1N-0000IO-GS for importer@patchew.org; Tue, 23 Mar 2021 10:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOhzz-0006ZZ-Ka for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:16 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzq-0007Bf-LF for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:11 -0400 Received: by mail-wm1-x343.google.com with SMTP id g20so11166128wmk.3 for ; Tue, 23 Mar 2021 07:27:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pOCeLNKBwgz69betEJZyVMFStpbhcpCwBwGtvhDAJik=; b=fdJsbvLeG68pcwt4OkQBhh/ZJd9lWwz1I/B9YqlS0lq29w97gqTaiRhWugAgPpwDE+ 7ILnW/7N9C7aOi6x6VK1y9LfIelIWr+LrzgbXKtlGQfMpSFGKCGLjMNfcVi3BZb3f0hq UpBR1riKBcnp9VWbvf5hsQGj8yIYS0xRParodCIhKkVpTgJaPE+vYd+RgfAxH4GQQzpS d3OHrTZUfjg3uRzmwJBsBHcerAfVyukUaH/0jcKV+g9usRRmRLKnfPQ91YW0qFv4DRSm x5TrNH+ECh0y7o3aqZyMebm0uwakI3/dN/kN6JY1wSCm4ftiwWecJ1AZl7odTjec8+VP K1Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pOCeLNKBwgz69betEJZyVMFStpbhcpCwBwGtvhDAJik=; b=Gs8Q/cF6faAsfPeZneE9IKxRHAumWBFED+QPg6q24KHYRyIhHGmBu7vnQWupEbRiFh e9Gz5+Va+VnfrQ0j/UTUa9Uwbv9vz95FBtp/jZUDZthIsHCKrD0u6VgaO2iFQqkWi/NW tVmg3Af2LSP3z4n6yTLvCx7QnSgjQ6SQ4wi93MjyETWrBeaXeQMECrbQkkX4in/IVxFs WndqgbgDZ3rKxIDH3JRwAyEArrSJtxfl9GcWgxOK8DcipK29w1bkj4/ycTBjrvhJnriw 3NgZQtbyjBtbFaNsGE1oly3tusSLTNavqchG9g1gKt+xjHgRcCGwA2i/jPWWIPChjgu/ e+aQ== X-Gm-Message-State: AOAM532xT0pkYeWagio+43mGT0ysONqCZWmJiw0nXUXII9Yoqt2dHVZE klCJ0aCJ1R5yHVzLAxKynlQxNXjcTfbMlPHk X-Google-Smtp-Source: ABdhPJzu2PLdck2AGXCHX87TYOSoE6/BirJOobHf4hcwdK1RoLlvYc2u+Ojo7ODQGQd5UvpUU0JpPg== X-Received: by 2002:a1c:22c2:: with SMTP id i185mr3607507wmi.99.1616509619154; Tue, 23 Mar 2021 07:26:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/7] hw/core/loader: Add new function rom_ptr_for_as() Date: Tue, 23 Mar 2021 14:26:51 +0000 Message-Id: <20210323142653.3538-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x343.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" For accesses to rom blob data before or during reset, we have a function rom_ptr() which looks for a rom blob that would be loaded to the specified address, and returns a pointer into the rom blob data corresponding to that address. This allows board or CPU code to say "what is the data that is going to be loaded to this address?". However, this function does not take account of memory region aliases. If for instance a machine model has RAM at address 0x0000_0000 which is aliased to also appear at 0x1000_0000, a rom_ptr() query for address 0x0000_0000 will only return a match if the guest image provided by the user was loaded at 0x0000_0000 and not if it was loaded at 0x1000_0000, even though they are the same RAM and a run-time guest CPU read of 0x0000_0000 will read the data loaded to 0x1000_0000. Provide a new function rom_ptr_for_as() which takes an AddressSpace argument, so that it can check whether the MemoryRegion corresponding to the address is also mapped anywhere else in the AddressSpace and look for rom blobs that loaded to that alias. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20210318174823.18066-5-peter.maydell@linaro.org --- include/hw/loader.h | 31 +++++++++++++++++++ hw/core/loader.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/include/hw/loader.h b/include/hw/loader.h index a9eeea39521..cbfc1848737 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -290,6 +290,37 @@ void rom_transaction_end(bool commit); =20 int rom_copy(uint8_t *dest, hwaddr addr, size_t size); void *rom_ptr(hwaddr addr, size_t size); +/** + * rom_ptr_for_as: Return a pointer to ROM blob data for the address + * @as: AddressSpace to look for the ROM blob in + * @addr: Address within @as + * @size: size of data required in bytes + * + * Returns: pointer into the data which backs the matching ROM blob, + * or NULL if no blob covers the address range. + * + * This function looks for a ROM blob which covers the specified range + * of bytes of length @size starting at @addr within the address space + * @as. This is useful for code which runs as part of board + * initialization or CPU reset which wants to read data that is part + * of a user-supplied guest image or other guest memory contents, but + * which runs before the ROM loader's reset function has copied the + * blobs into guest memory. + * + * rom_ptr_for_as() will look not just for blobs loaded directly to + * the specified address, but also for blobs which were loaded to an + * alias of the region at a different location in the AddressSpace. + * In other words, if a machine model has RAM at address 0x0000_0000 + * which is aliased to also appear at 0x1000_0000, rom_ptr_for_as() + * will return the correct data whether the guest image was linked and + * loaded at 0x0000_0000 or 0x1000_0000. Contrast rom_ptr(), which + * will only return data if the image load address is an exact match + * with the queried address. + * + * New code should prefer to use rom_ptr_for_as() instead of + * rom_ptr(). + */ +void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size); void hmp_info_roms(Monitor *mon, const QDict *qdict); =20 #define rom_add_file_fixed(_f, _a, _i) \ diff --git a/hw/core/loader.c b/hw/core/loader.c index 9feca32de98..d3e5f3b423f 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1383,6 +1383,81 @@ void *rom_ptr(hwaddr addr, size_t size) return rom->data + (addr - rom->addr); } =20 +typedef struct FindRomCBData { + size_t size; /* Amount of data we want from ROM, in bytes */ + MemoryRegion *mr; /* MR at the unaliased guest addr */ + hwaddr xlat; /* Offset of addr within mr */ + void *rom; /* Output: rom data pointer, if found */ +} FindRomCBData; + +static bool find_rom_cb(Int128 start, Int128 len, const MemoryRegion *mr, + hwaddr offset_in_region, void *opaque) +{ + FindRomCBData *cbdata =3D opaque; + hwaddr alias_addr; + + if (mr !=3D cbdata->mr) { + return false; + } + + alias_addr =3D int128_get64(start) + cbdata->xlat - offset_in_region; + cbdata->rom =3D rom_ptr(alias_addr, cbdata->size); + if (!cbdata->rom) { + return false; + } + /* Found a match, stop iterating */ + return true; +} + +void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size) +{ + /* + * Find any ROM data for the given guest address range. If there + * is a ROM blob then return a pointer to the host memory + * corresponding to 'addr'; otherwise return NULL. + * + * We look not only for ROM blobs that were loaded directly to + * addr, but also for ROM blobs that were loaded to aliases of + * that memory at other addresses within the AddressSpace. + * + * Note that we do not check @as against the 'as' member in the + * 'struct Rom' returned by rom_ptr(). The Rom::as is the + * AddressSpace which the rom blob should be written to, whereas + * our @as argument is the AddressSpace which we are (effectively) + * reading from, and the same underlying RAM will often be visible + * in multiple AddressSpaces. (A common example is a ROM blob + * written to the 'system' address space but then read back via a + * CPU's cpu->as pointer.) This does mean we might potentially + * return a false-positive match if a ROM blob was loaded into an + * AS which is entirely separate and distinct from the one we're + * querying, but this issue exists also for rom_ptr() and hasn't + * caused any problems in practice. + */ + FlatView *fv; + void *rom; + hwaddr len_unused; + FindRomCBData cbdata =3D {}; + + /* Easy case: there's data at the actual address */ + rom =3D rom_ptr(addr, size); + if (rom) { + return rom; + } + + RCU_READ_LOCK_GUARD(); + + fv =3D address_space_to_flatview(as); + cbdata.mr =3D flatview_translate(fv, addr, &cbdata.xlat, &len_unused, + false, MEMTXATTRS_UNSPECIFIED); + if (!cbdata.mr) { + /* Nothing at this address, so there can't be any aliasing */ + return NULL; + } + cbdata.size =3D size; + flatview_for_each_range(fv, find_rom_cb, &cbdata); + return cbdata.rom; +} + void hmp_info_roms(Monitor *mon, const QDict *qdict) { Rom *rom; --=20 2.20.1 From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616509878; cv=none; d=zohomail.com; s=zohoarc; b=LzrXkDuol6YmrAtZFqy+vehtTCJ59VHwH77tfie9Ddyia4tM1YtJ8hGxM+vpMPEwhXQoTx3Hn1OzPSwZl74lUTuRYOBgxidiVtX+8MXIMBDAKCymz9z0U+Z3COvcmoQUmZH0Kgj7kupGUBgrV+lAGPeVmDS1VsyX9yPO/ul6P40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616509878; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZAFdAmHYOhy8/8TjVO2eDKG5wM7c2ft17CTE4VtZph4=; b=jGOZnSKTMLRoR1mJcY1m8+0nVUYBWTt/1CLkTSg+LNRx6bWkN+UgGCKs/HpsE4nlbNXxkicJKVoFONdCnQPfHRqqNlTNUDQi+klol3EEtbEaSxrpmO/yd4FQOvz60mc5r4guuNqN+RGJemOSqPrnuzwG8zQBVr+Cg+VDPjaxUQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616509878926931.0318673317503; Tue, 23 Mar 2021 07:31:18 -0700 (PDT) Received: from localhost ([::1]:46964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi3y-0003Z1-5A for importer@patchew.org; Tue, 23 Mar 2021 10:31:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOi04-0006Zj-Jv for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:16 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:38517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzq-0007Bk-4t for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:13 -0400 Received: by mail-wr1-x42b.google.com with SMTP id z2so20995565wrl.5 for ; Tue, 23 Mar 2021 07:27:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZAFdAmHYOhy8/8TjVO2eDKG5wM7c2ft17CTE4VtZph4=; b=TtfdmxgP5begRA2GpjA+kSNI6PIUEyQwuqweXvG+QdiDVAGx1pNyjCHUtllIUBpD8A zc3vVBcyzIReqIBYH/ahkSyOzG6gSKIgf94evfkxw9nlsN4md+d90Dzwjw7dIpPHYN4w /aqtBfgzEYHS35YCPSovAZGo8raWuSfo7K/UtUe72xhcH6Z1h4m/vQHwI5QMDMCtY2Ae LDg/h4A+QWrbmsuasgiSu4QX/8kfsIjBWV6h56p764LYm+LCkiS8z2MOtbtQH8B7SkHv DPiLYzIIjNIPB2UZ0ybkkWgIjtoYmWiL0KrXRV3HuJBYz1rE3aJTbeVr6GhZNw5xs4Q8 PLSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZAFdAmHYOhy8/8TjVO2eDKG5wM7c2ft17CTE4VtZph4=; b=JcWYyQKPOLNM6N60lrPR/RSKuHsMKWYEU8WGfrhr9xKn4XmHPNn5DLETezA2shQWTh BLx11kpgsc+ggj9eIjxmFCv/QsKyIW17wsoRKOHuh6zoUSYYQYBxli7ixids2SZi9+wC CrnGGnWKPOWwy30xSPQ2rE3CKOQ1U+1E0LMKIDhqMF+0eL/j/RizNeTWgCEHnPTWmK5x 96C/+StfihUVWax0nXUmShfq1mLa/y1kRBFUTBuauHc3thJeAum0IARj2f7aughSJGN6 qDCBMRiLk0URwX+1a/rO5yIeB3cPUqQX4mGg4w2BjwVCMBb5L1WS553vb2FotwP9YtHr TWog== X-Gm-Message-State: AOAM531eDwydMT3AK+7xXdERFDwanelnPAmZohPjyux5lh4OUcCtTbFG FVe7CGJ8kPELr9CVFZtVIipKm+A4kag864xA X-Google-Smtp-Source: ABdhPJztos/BQHjRqnUNlmM8KSDdgjn8KlQqegMNS1jizN+YrjGeEEorZlhu/2CgOXsjgLhgt9faug== X-Received: by 2002:a5d:5088:: with SMTP id a8mr4348271wrt.294.1616509619803; Tue, 23 Mar 2021 07:26:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/7] target/arm: Make M-profile VTOR loads on reset handle memory aliasing Date: Tue, 23 Mar 2021 14:26:52 +0000 Message-Id: <20210323142653.3538-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" For Arm M-profile CPUs, on reset the CPU must load its initial PC and SP from a vector table in guest memory. Because we can't guarantee reset ordering, we have to handle the possibility that the ROM blob loader's reset function has not yet run when the CPU resets, in which case the data in an ELF file specified by the user won't be in guest memory to be read yet. We work around the reset ordering problem by checking whether the ROM blob loader has any data for the address where the vector table is, using rom_ptr(). Unfortunately this does not handle the possibility of memory aliasing. For many M-profile boards, memory can be accessed via multiple possible physical addresses; if the board has the vector table at address X but the user's ELF file loads data via a different address Y which is an alias to the same underlying guest RAM then rom_ptr() will not find it. Use the new rom_ptr_for_as() function, which deals with memory aliasing when locating a relevant ROM blob. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20210318174823.18066-6-peter.maydell@linaro.org --- target/arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ae04884408c..0dd623e5909 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -331,7 +331,7 @@ static void arm_cpu_reset(DeviceState *dev) =20 /* Load the initial SP and PC from offset 0 and 4 in the vector ta= ble */ vecbase =3D env->v7m.vecbase[env->v7m.secure]; - rom =3D rom_ptr(vecbase, 8); + rom =3D rom_ptr_for_as(s->as, vecbase, 8); if (rom) { /* Address zero is covered by ROM which hasn't yet been * copied into physical memory. --=20 2.20.1 From nobody Mon Apr 29 09:08:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616510228; cv=none; d=zohomail.com; s=zohoarc; b=Vt1VJkJUxtfeKSp9OueHwJGuMbWgv9wt+dVSNOG9+9K9BGUIvLZgyxdVvqj8IfmURQKwOOBD0+YhlNuLMFSYKghS6V9slh0lt8PWFLsHKbNRoeoL0KUs74a7bAbs0E+tSk942ChMde8wSahCD72QDU2Snh/mYuUPeto+0tUEG2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616510228; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=040Av6eKFFO8DY7RlEdIpWKnOUZEmCANS3COgK9hh4Y=; b=SEiwLNvZln/Uz+9fr57aPQ7IHch1Nfkle8fOgTrR+nvBhfqmPf5ldsWlCZQ/FegsXMI2NdVwb5okq06pTPVV15ilPTexkY6P7Oe9yvtqNXcpPLroxY2BEL2Ac1LTplkiSkCM0no0RWiZ3PPd9tsMdBYwiAyD/T+aJJ8bFLbtsnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616510228372183.56671886552454; Tue, 23 Mar 2021 07:37:08 -0700 (PDT) Received: from localhost ([::1]:60402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOi9a-0001yV-VS for importer@patchew.org; Tue, 23 Mar 2021 10:37:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOi00-0006Za-Ee for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:16 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:38519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOhzq-0007Bs-Ma for qemu-devel@nongnu.org; Tue, 23 Mar 2021 10:27:12 -0400 Received: by mail-wr1-x42d.google.com with SMTP id z2so20995611wrl.5 for ; Tue, 23 Mar 2021 07:27:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a131sm2861292wmc.48.2021.03.23.07.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=040Av6eKFFO8DY7RlEdIpWKnOUZEmCANS3COgK9hh4Y=; b=gIL5o7Vf/LBG9a/6NzcNDX2YbQrKuySVagISYCn+KV5KNBLEluyouRTpEw3oLFAxF4 RFASvFYG9jbEgNtlWHCRn0lGI25LMlrvo1SyFWh7CZtJPxy3jgWNBkr5goF8FEcDmDBe F8bJdkdbv2jH92Cccm0M49ahumcKKHQOtK51f6WXI871u6Ousa5RbsC978uW7hQrZPyR HckHfvslR+q0OY2i04BUirNvaAri7XKPLQjCJfj5rs+MQ/6XqysU4PINGExk0bkcdouQ yVbqRyHtR9DnT4Ga0zjuMJeKDbcZdoKXB++cFNNCbpp+gy/A7z45DN5VHWU/MkWGDx2H J07Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=040Av6eKFFO8DY7RlEdIpWKnOUZEmCANS3COgK9hh4Y=; b=F9na5XJFCwVjJW7/1aC8aVC4rFxGyFrWgGVdFxDCpBXc2VRE2P85p0HqwMEBBzQCLb v2AWvhube8+b00JK73T9AQ48H23+8WkQmtsWQfANplxPG9W7jndjVmKnUke9pjKokKmG ISb3lRbXbJWnBAmkqKZULpG6Mj6EWLVZL9NvWiawZPDQ33S9POtuRaj+SLPxnf6ootWi toMNAiqLIR9Wg1dxsAgZ0ZcvKOL7RVoRoEKK/dCoblAaAvDqtGnru4ATOdqpx0W0uMzp M+eAQUuAqmH3wSGl6XdYbhdfPMjcsNfSQL4UKaTq/zCiC/5ysHGIhOtyMH/oEvZUFD0+ y61Q== X-Gm-Message-State: AOAM531MyY4J19MlsVxMd0iDmAEEvEaRX8CN1iQ+TUXmuq3hl7Vj1qm2 L3Zbg/5OSf4VGXeVBSfEPE92hyqRdqPgduOb X-Google-Smtp-Source: ABdhPJyd3RjAlSawSKzwz/L6zdLjeH/ExLij+P87sI9mpLHtZpE8rL4k6pmASGeb8btajDLj9EBaBA== X-Received: by 2002:adf:f44b:: with SMTP id f11mr4350216wrp.345.1616509620404; Tue, 23 Mar 2021 07:27:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 7/7] target/arm: Set ARMMMUFaultInfo.level in user-only arm_cpu_tlb_fill Date: Tue, 23 Mar 2021 14:26:53 +0000 Message-Id: <20210323142653.3538-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210323142653.3538-1-peter.maydell@linaro.org> References: <20210323142653.3538-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson Pretend the fault always happens at page table level 3. Failure to set this leaves level =3D 0, which is impossible for ARMFault_Permission, and produces an invalid syndrome, which reaches g_assert_not_reached in cpu_loop. Fixes: 8db94ab4e5db ("linux-user/aarch64: Pass syndrome to EXC_*_ABORT") Reported-by: Laurent Vivier Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20210320000606.1788699-1-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/tlb_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index 9609333cbdf..3107f9823ef 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -163,6 +163,7 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int = size, } else { fi.type =3D ARMFault_Translation; } + fi.level =3D 3; =20 /* now we have a real cpu fault */ cpu_restore_state(cs, retaddr, true); --=20 2.20.1