From nobody Sat May 4 10:56:23 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=1616090320; cv=none; d=zohomail.com; s=zohoarc; b=ePsdif0fVUP4GR3n1JOd7tALXGFFtAJt2P4Y3/gn75uWbjSZTL/oYBJJAewJz1Q0YHshow9XWuTtVgV1sOUrVnRxs7ZZa0pFCyV28vCRfq4MuxUTDXlID2KT0ZVoFwkpJEAxJjkesDr4FeYz9mawoTw6xYsDd1RdDxA0cIA6rUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616090320; h=Content-Transfer-Encoding:Cc: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=rhXh60pf1O1m8h1ZjyuRXqhtqRaMjfljlipKZlDtlgg=; b=MDxOyJe59R97Au/pf+X8sDsb0qm/B+lbMMbDuVjlYgip+N+4kLo6ZrYyjX3+5wsnHSrSWYY63xWnicAPqrxxjqYCt6vukgd3glqyiNTQct1roGZcxoN4hN7ee29kM7EUx4lNpwYNkPWcVYCad9DB+OlgY6yvSiV+1XyWyEfYxJo= 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 1616090320019528.5951426640596; Thu, 18 Mar 2021 10:58:40 -0700 (PDT) Received: from localhost ([::1]:34504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMwus-0005fK-SE for importer@patchew.org; Thu, 18 Mar 2021 13:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMwlW-0006ci-74 for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:58 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:42554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMwlA-0008D2-BF for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:43 -0400 Received: by mail-wm1-x333.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so3907486wmj.1 for ; Thu, 18 Mar 2021 10:48:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c26sm3845915wrb.87.2021.03.18.10.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 10:48:27 -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=rhXh60pf1O1m8h1ZjyuRXqhtqRaMjfljlipKZlDtlgg=; b=PtKvwxWIKCQvXvJgbfylCry7+Hs60doxDxa1+YgNaCCQqR53bZg5WDOzeJyuGiJo2g s8ja5dQJCpP331WMB7NFfvFc++ZNGE9Nle42qcBN9pXD+pxsmuaxYT2NSyNX/w82Qwly pMyoeIMDMcDzqQHW6FWkNYHFXUuX6VaNkZxCkyP1YOVVX60W1C+fVFj7hvkb/mmBrwLm w/MyDbxHs8UR0DAWtHaguXAt3a0X36z9Eka3W+RcTcWTnLXQMPuPz9KLTuZudzryRyrK lqD6SQw0JojdkonqFjdfj/qs2CJlld56bw03xYyv/cDtf/mThJoN0wvUhK62ZSHksR+v yosA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rhXh60pf1O1m8h1ZjyuRXqhtqRaMjfljlipKZlDtlgg=; b=hm2lPEu/ZkFf8BHmn/d0Y2cIfIJQf3PNiGqalvo7mUMlosZavnSz+qVZa5KInMC76h kIx7FosfFTE9yPZ0pj2mlCR4DX7+R1JqiYuUKEJ0S4KlgozWWrtGcIYYK6Q5kXtutsme ZvBQbRZmThlN1coeh83Yx4TtY07lz0BDxKNP1TTOxS/ehw9RqcQAoj4gaO0foy+VtKz5 xJ1rY0gR8xd0IqAP8OS+Un2LUaj058ji3m8CouEa5oBSrA30yfuBXOYCXVWTmxjkj6o7 7vdvUI2ZrYE9sU8wI71Ujp7tkn409KzjRCaMKg4RgeoEaTLjLs+rTsFgXoYcJ+kfXGum vAew== X-Gm-Message-State: AOAM532uguvPsrUAyP7GWasZWxklUS3SonX/RYzlI4O/2FNC6trPtFx/ EQA0fA9eO5i09s53o2Yw/y/LVw== X-Google-Smtp-Source: ABdhPJyqVADGrftgTsnx7htJ5Aj270/Iwkfy478zlxxPAvkHXXXeiWKFQkgn9fRGlckFQsIy/6INqA== X-Received: by 2002:a05:600c:4f4f:: with SMTP id m15mr303228wmq.29.1616089707524; Thu, 18 Mar 2021 10:48:27 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 v2 1/5] memory: Make flatview_cb return bool, not int Date: Thu, 18 Mar 2021 17:48:19 +0000 Message-Id: <20210318174823.18066-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318174823.18066-1-peter.maydell@linaro.org> References: <20210318174823.18066-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::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=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: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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" 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: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 54ccf1a5f09..22c10b8496a 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 Sat May 4 10:56:23 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=1616091689; cv=none; d=zohomail.com; s=zohoarc; b=A8rJVVi/s8yCB/Etz6wuctSCvnwSJeEv4muKzCyQDMW+6h0hWFdhfJF0JcE6ce72nDHr0raaNbk+ENbSSLFyIY7B0ki7G+mKdoK5Hj62dUxoGHM3Aa2iEjQfPcZBYR07biXBBvqsPUIMQ8GUgQxdAL2CNZA3kTYe2xwfowXZUGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616091689; h=Content-Transfer-Encoding:Cc: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=Ltq0MmJYBR2ITlK/HcsP6Y5oPeWSWBMuW1aZG5jSIoA=; b=AqzjLG0df+q7WhY17avGjZy5k6vUHMpsNBYqBmPemNCLI/SdBI2GVW23/Zo8vvWgQjV8J0EiypPz1vpLr/8Iqn+0cncjzgza/qpY2unB3fhUffNJSNWy7X8Ujlj3iNBOH7mTE1WwPuARx/P3Gcar8MvzST1b/p/1Hn3SEkW00NA= 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 1616091689876802.5240431177457; Thu, 18 Mar 2021 11:21:29 -0700 (PDT) Received: from localhost ([::1]:40350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMxGx-0004RJ-Ib for importer@patchew.org; Thu, 18 Mar 2021 14:21:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMwlX-0006ft-LI for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:59 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:37597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMwlA-0008DC-C9 for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:59 -0400 Received: by mail-wr1-x431.google.com with SMTP id x16so6466630wrn.4 for ; Thu, 18 Mar 2021 10:48:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c26sm3845915wrb.87.2021.03.18.10.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 10:48:27 -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=Ltq0MmJYBR2ITlK/HcsP6Y5oPeWSWBMuW1aZG5jSIoA=; b=rnZDFnw/4MhKkXvghdGv5WdIyo5d43780wBmHxFbTR9S+s1tO08nze4nd0LTB91vTA 8y1JZ1eUDLIlOJ0gaUUUMaOrX6evjA50268+VV6N4u+UIB+hihk3IzUwf2ksDEbWUdqD mdf97oR816pNiF8n/9rF//u7bpV2+FiaogOtkl0m4b3cPfla/vUfaCzCoYPbk/T4uv/2 iU36Njmbymrccf+j6B8ibvI3kbIq28tpnCUweATV0oKN5M0wy2abX/7SsBDUDA/3y+7P UH+1+5MF+4FXd6LP/0FDOW6wreF7Qh8s436iIRiOY6iNkE40xwkuvtf3q+7aftY3Kov3 4Czg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ltq0MmJYBR2ITlK/HcsP6Y5oPeWSWBMuW1aZG5jSIoA=; b=aH6PIeFynsmtR546hxGJDCjH8XzmB9DVDYiekXAlZ99lmiXY0vaPtZy08goKOe8yoi 2PH+O/6n5i9eyIRAQ8yvXOY0zeqjbSIrdcQaRk2uWfzdZ5iJlMqS2YlLJeGzRS5jCcGN peJv5+aWrvQpvJ9JQdwsstFCIYr2zemjquyfJGA08w4ejVwc3+NlL5MhObkyI+iXdxuw tsDo9xquRYPAynqT4QvNZSJ0fzQs4/7C0QmbrHqhcs3Yh+VeXA6kjbAj/GXZoAiM/7wx UEIpoGJdDJcJ5ycTwQnK9Q5ExZIGxrsyA9wNUQBGObFV10kGEtz9/ClPvv/CpoLjpmjc WduA== X-Gm-Message-State: AOAM533RFKZm2ed/7x9srgapvzTbkT3S/x7JQ1XUhucIXqQY2mdtc679 riMsaGbFOcEONsLRwPykWbQ0eg== X-Google-Smtp-Source: ABdhPJx1hzJI/YZnLPq5XKV2XRymXDJ0VFC0HmgNV4jzYgxCIj9DbkuFI0ap6RTERTcuyoRZvpsOiQ== X-Received: by 2002:a5d:550b:: with SMTP id b11mr413920wrv.313.1616089708259; Thu, 18 Mar 2021 10:48:28 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 v2 2/5] memory: Document flatview_for_each_range() Date: Thu, 18 Mar 2021 17:48:20 +0000 Message-Id: <20210318174823.18066-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318174823.18066-1-peter.maydell@linaro.org> References: <20210318174823.18066-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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" Add a documentation comment describing flatview_for_each_range(). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 22c10b8496a..71a1841943e 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 Sat May 4 10:56:23 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=1616090742; cv=none; d=zohomail.com; s=zohoarc; b=cwtuXkn6s/S4of+YXQKubqqRVFloIH2UV7Datcmj+154byeHGKIirWA/1hEtzUhjqHCB2doOalg6LlsIAkY0UBJBXm0ICcY/TPJ+bHCyZxP+vXOlEhyp6xvJnxGGD4ZzA6hOxAiroq22AP3O9oR8tN9QPTlMF8pDwrs0CP0GCwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616090742; h=Content-Transfer-Encoding:Cc: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=QwAogQb7m4DD8GZyODnL9Y7J57TBm4/rq47dw3yQg8o=; b=m2u4TeTUa51xD/BAtSxhnhFhV12yy002+rBPcIGBsb8oO9I3cvHm8NgXYUFVlWsACS6BBBpzPXDWljXb9wnySdm7nzRQJ8us96F5QDETvexuU8tnnpvdRCQa0ZWs5qfwifALnZLMCd6HdqO16yQcCj/1zl8xd3nwvzqvlyIac3g= 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 1616090741377920.4156205552736; Thu, 18 Mar 2021 11:05:41 -0700 (PDT) Received: from localhost ([::1]:46052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMx1a-0002j0-9S for importer@patchew.org; Thu, 18 Mar 2021 14:05:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMwlW-0006ck-6r for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:58 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:41539) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMwlA-0008DN-CC for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:57 -0400 Received: by mail-wm1-x32a.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso3921359wmi.0 for ; Thu, 18 Mar 2021 10:48:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c26sm3845915wrb.87.2021.03.18.10.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 10:48:28 -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=QwAogQb7m4DD8GZyODnL9Y7J57TBm4/rq47dw3yQg8o=; b=OWSRaNzkbB7ScI3FwP3Z/RYLHumW1C1UPGbIiWR0ZX1gIhBlT9AZHChGQwedz6jiQq y47RDqEWriyQ+4Bhc/oYWikA83GBXhH++PvHQegIDoh5F+C8UgBc1uHs5Wrtg4TmlLCg rYY+mR2qVSUxqRzuZlezvB+KdpgSB552errbzkv7uGLemTJpUvvsCltBJCqaxxaJmMDt p9CVH0H0UIDa4DTERKyP3DFQfjCgjsbXQUdQk4mveOuk/Tw1ASec9vsXGdZ+lVLLJpI3 jIxx9bHYcF2M1y7u0AXQO1abNp3oIZhNN00KuxHc1Gsnq22S0BXOELZkEhUrg3EqQnuz XRig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QwAogQb7m4DD8GZyODnL9Y7J57TBm4/rq47dw3yQg8o=; b=K/p0qS1ptDkZtXyeeavA1WnDkXHM7qYWkAln3PpGGh/SC8jPu5ZgA1AtTOpt19t2Vo jLaoAiE5Iq6qlAZZHjhtwPf44glZfL51wyJ/XwdiJHxxWd6EAZiXgJHSZ4YWUy5SL9lX URqxxyUUH0NZI8/UC/eCkHrgMc4w6jmP5yd6yuVrlZCy7qzkX97oHGg0IogqR85zoF4M y58R7cKITg/ziL6UwBIY46LYOjaNhoZNQ0f362DWg232H+nJQaONVGmKlaU2JvKVo1oy 0HBGrVfr6zNeC04GlSQKpB/LKBfoO4bhZHCe6/HUe75abA5wDjIE96wPerd7TY3S0d19 ogLw== X-Gm-Message-State: AOAM533m4iHq9F5zHO1ybOaSJnnRWhBFUNe3nbiOKb4dZaZMlEFlSF77 pwDGVXybP8Tv9YZovbA/czk/HZBPDO7JKVvR X-Google-Smtp-Source: ABdhPJyHGsPP7606inJ+Ci9XImvyBbdDcRywmz+536Ff1QY6rH3Tr7hH40uEabg2Rnhiw1pUeetthg== X-Received: by 2002:a1c:67d6:: with SMTP id b205mr325807wmc.118.1616089709129; Thu, 18 Mar 2021 10:48:29 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 v2 3/5] memory: Add offset_in_region to flatview_cb arguments Date: Thu, 18 Mar 2021 17:48:21 +0000 Message-Id: <20210318174823.18066-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318174823.18066-1-peter.maydell@linaro.org> References: <20210318174823.18066-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::32a; envelope-from=peter.maydell@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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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" 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: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 71a1841943e..529152c6a85 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 Sat May 4 10:56:23 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=1616090157; cv=none; d=zohomail.com; s=zohoarc; b=Fy21D5EQPATOb9jLUOGvrWnXKVpXc84+Y5e5dIsVrvu5/isNM25JezxJXTGgl8liA+FNd6sjZmQwxb+s4J0wjObJMDS5B9mFs+0rVRW1whgCUxGBlPuBMMpjelM+LZ+/zceqYM6GAvez0YV52htBun9tLe974cjC1sRGyIiHb8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616090157; h=Content-Transfer-Encoding:Cc: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=4ONIyjP6BK1c3CvlwKGOLZZT3kEGAljz6Ydw0RSd12c=; b=gxE5Gy9LFQpkcekywLIIF+iRRJCj0kACqB5QXXCmBx+D6GS1dgYB519oHNc2RywK6BeOhchtPlx2zafHziBEwkYSXBGPpNVVGBENdK9DnuMJf6aJl1WHh98eMD5IGx7/XICQ63pWKOKiJkiAFeeCDI6gOGa3YoFAlfDy2rAe0Ok= 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 161609015733464.92917330556827; Thu, 18 Mar 2021 10:55:57 -0700 (PDT) Received: from localhost ([::1]:57682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMwsG-0003Pw-3Y for importer@patchew.org; Thu, 18 Mar 2021 13:55:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMwlW-0006cv-7B for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:58 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:39651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMwlA-0008DW-CE for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:54 -0400 Received: by mail-wr1-x442.google.com with SMTP id e18so6472126wrt.6 for ; Thu, 18 Mar 2021 10:48:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c26sm3845915wrb.87.2021.03.18.10.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 10:48:29 -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=4ONIyjP6BK1c3CvlwKGOLZZT3kEGAljz6Ydw0RSd12c=; b=Oqid0QXjB7MrldS6cbOVUG/yplPaXnnWVXs+PYDGwn9oSlyanshA7BW2b9tU4qcYsz 24FBGXfnHtYXLQeWqj3kV++oC8JxNMvEQvHE++eaDoKQvDH+aMk/ODFuBfhLuFABU08C L9vPoCgPpl+bU3/ajtP/Kt4BKSZQV5MzJPkrPqFfNnkRM0PdTnnUyJgraInolf1Nn5dz Elqw5d8aVNFaBfc9sdeRlBqZrXjQ6VWIRe6HRMhEcmDFwoUnPv6+EwTkvF/iir16GFDb 7ZIffAS3IR7UQlH6QcpoITtjVdzXcuh3prBC509qLSEQyA5xDaVJ8Dlv8jgrKwCcn6ow 6hKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4ONIyjP6BK1c3CvlwKGOLZZT3kEGAljz6Ydw0RSd12c=; b=B/Zp3o3Ky4irDxvNmoIa7mp89vRr0eZTrnendzCJvkbVsjut1prU0+ieYBAe/iGATR pe7wLiI9tQEXZY6zhM4bxgdiabdDdd9IfEyiiU51bl6smspUd3Tq2plb33GfQ5j9VVW4 rUs8mz/sDPYy17WsIpsINCaL0GM4P1EbiJENmpY44o/elAOTv8HYdNXlzgLQGxhhCm3N aN3M4LUFMCIBzcZ9HmI7PnVtwr64hV7yRQvsg8KFs9E1hKxjNDBhsI1oXw3TPt91vrpm jT2LYr+30AC3yxsq7fU2AWuwAyUBhe5cdGPfxVHZplGWF0T3Xu+MSnFBSgb8dzH0EAn7 rU8A== X-Gm-Message-State: AOAM533HD0IT+KzkzyVbpW4DqkGDnldeMnQc5Yy5hg+VhCpViOm5q67N MI3K2apHlRn57ylt4Xem4Orxtw== X-Google-Smtp-Source: ABdhPJwy83LlPYrgiZoPML/mMbw6IDimih5W3o63uwj1kcgHoAso3bRj3d9xmX+hu55+1J+Jqx3UgA== X-Received: by 2002:adf:ee8f:: with SMTP id b15mr453104wro.314.1616089709886; Thu, 18 Mar 2021 10:48:29 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 v2 4/5] hw/core/loader: Add new function rom_ptr_for_as() Date: Thu, 18 Mar 2021 17:48:22 +0000 Message-Id: <20210318174823.18066-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318174823.18066-1-peter.maydell@linaro.org> References: <20210318174823.18066-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::442; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x442.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: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 --- 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 Sat May 4 10:56:23 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=1616091403; cv=none; d=zohomail.com; s=zohoarc; b=EksXMZxRueY+2Ee2gXy/wxhI52qM1KtAZYBW31226e9ce/nji3LDjGmSR/MsZ9sl4QvY99199Qfd+6wmJLU2k3OpMf6qjJYksIWRUhaDcsZShF6pLcfxxtyQqNElpFYHNVyCllipwrvtFGn5rMAHx74rfDrArI4jmLxKP/dMyTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616091403; h=Content-Transfer-Encoding:Cc: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=gJHl0X2rAu/7uON+ZeOo5+qFY2A3sY0ecP0qtxDZcW8=; b=JMWffHQvOiLwbUX160madTAISyWJ9ps4gLwuqvDnmeOv510mdXbvXcnV+5Y1eOyTUUGiR6kxfELmw3tn008Rqq30V9hf2eLFLvrlzKZ4/3m/a2KDxvD5oxjgQyJeU2bhoh0FPuUQ4g+G2wAMvcY+KbjjaFo0ZHrCy4r3b0FBofU= 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 1616091403539412.49493182055573; Thu, 18 Mar 2021 11:16:43 -0700 (PDT) Received: from localhost ([::1]:60934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMxCM-000170-8R for importer@patchew.org; Thu, 18 Mar 2021 14:16:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMwlD-0006Xe-3P for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:39 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:35770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMwlA-0008Dd-9s for qemu-devel@nongnu.org; Thu, 18 Mar 2021 13:48:38 -0400 Received: by mail-wr1-x42b.google.com with SMTP id j18so6468640wra.2 for ; Thu, 18 Mar 2021 10:48:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c26sm3845915wrb.87.2021.03.18.10.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 10:48:30 -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=gJHl0X2rAu/7uON+ZeOo5+qFY2A3sY0ecP0qtxDZcW8=; b=yLlrJrRAedV5hgbhi6UIom6JLGOrjmONWPF+Ax66V8c33E8dUDrc9fjRsTMOI07JXd kiBXaIMZYaE/gFY8J7oXZF4Bi6C+D9Bhz86grKhYJvcFwEPSPlC3ymXtsHy/dxJ019VG WoBRjblTn5rBWwDPXv09m10IzRk94tHHn8k/6AnkCfyYjA2r9n7NpA9PnPGQ8Fsy9CJT 1/R5aP1lXksFwf4qTtePvib1oLB0MNCIUyV4n2xsnxgjXhMRXQcaY8y+s+ltN54FkbsZ teelKmUSGRIFDRMcKyklX40hOuq/DqOIdTz1bldwbprriXn7I5FyPYJJ8+BSMnRLcETk 1Sbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gJHl0X2rAu/7uON+ZeOo5+qFY2A3sY0ecP0qtxDZcW8=; b=ow7YMuO5xxdhMy5fpYZzmRBDVWsNvrfHDU59evWXkdCiTXjAkWDJLyDiZISJjizVls JuTUcAxmJFtWcS+yOucv6FZ3gTRGxhC6LAXitbJoKswga1H+2LrC+2ENglxoCM6kP1By Hn8Lwab0Yjkvf7DJSuLgRjAY9L3PrYBXQPe2x6Vdny5U4XudOb55AmEUj0osFRVA6BC2 GC8QEzjgHtiHVzx6xwvG9Yc8AGS3SaHrFcfZZpJY7ovvrPxqr/d13OssK46TZAcYtSeO R9d4n8F4hC5C6fuePq/JJH8VPW9XZwxrZoCEmK6ycfaPR7c7vh8f+G6AehJViPFak0e9 4iqg== X-Gm-Message-State: AOAM533oSlO7IycISXtpdob5bCeyDpDxaiE7j5b5pDbP+DhDK8xuWwlO 7qYudJFc4WgC5VjxCIbfaq2i1Q== X-Google-Smtp-Source: ABdhPJwNGs6Sj6+Ha40W5CxmmglfdI/Uf6MGSImwl7uHh/S7Yzh3FxIBHVxU9S8QdOTn2DtUx1yxtA== X-Received: by 2002:adf:fb42:: with SMTP id c2mr439066wrs.83.1616089710591; Thu, 18 Mar 2021 10:48:30 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.0 v2 5/5] target/arm: Make M-profile VTOR loads on reset handle memory aliasing Date: Thu, 18 Mar 2021 17:48:23 +0000 Message-Id: <20210318174823.18066-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318174823.18066-1-peter.maydell@linaro.org> References: <20210318174823.18066-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=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: , Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 --- 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