From nobody Mon Feb 9 17:24:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1620391171; cv=none; d=zohomail.com; s=zohoarc; b=Zw+/zrFwjbV+tPUi7+uTeC94nr/2cduKmFu5JNDHDLlyP5BpyewVMPQkr5Se1gzQqWC6XVKRj+mS6Cvw8HUKN8eo0fdcY8um7Zb7n8MdCIom6XnmTSewgZIcmZLS0bmLCY1A7r8wCJ2UMcw6wyAWo+GrVC2Zqc7F/5eZXu+oxjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620391171; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=fM+XV4xsrJ0PL8iFkG3vUaunvGZ6nUCTkbxCVv9GgRc=; b=lOWUvsjeUYXojPn7+TtnyUoDPzxzi9197S5B7DkU46R+tCVhpK/GI4fI61Q+B0ogYpFkhbbxcCojGGl/HswhfbSFXtmHVYzOqz4B+QLX0TOUbd2JKhnlmR+ITr6DdK19rcq3GXAWOGf/bxkZ3u5J3HQb9OAwTtSfqy6MDfSe8q4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1620391171150211.77517159820377; Fri, 7 May 2021 05:39:31 -0700 (PDT) Received: from localhost ([::1]:57234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lezlR-0000kh-8i for importer@patchew.org; Fri, 07 May 2021 08:39:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lezbP-0000VN-MM for qemu-devel@nongnu.org; Fri, 07 May 2021 08:29:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:40470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lezbG-0001Q1-IL for qemu-devel@nongnu.org; Fri, 07 May 2021 08:29:07 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 147CDx3a096787; Fri, 7 May 2021 12:28:53 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 38ctd89d15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:28:53 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 147CFkKJ168068; Fri, 7 May 2021 12:28:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3020.oracle.com with ESMTP id 38csrh1sv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:28:53 +0000 Received: from userp3020.oracle.com (userp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 147CSqAO014186; Fri, 7 May 2021 12:28:52 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 38csrh1su6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:28:52 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 147CSoxC016365; Fri, 7 May 2021 12:28:50 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 May 2021 05:28:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=fM+XV4xsrJ0PL8iFkG3vUaunvGZ6nUCTkbxCVv9GgRc=; b=UKBAJgRvsOjZK3iLXOx9nn74tygy8tqHF0JEsPLRAtN0RqppUphu7wr4hoJJd+mVmphH ZCWSMuPyox9YtKcrAMQYxXgkSDM4oMqYwpvFPBzBBsVrpiZMXh7yQ76xRE1T5o5Ln5F6 kouev89pBcj1cTCRgtC9iBtI0NkqDpVcY1lcfQzY21LYhXCiu2R/LvhjvF8RToHTtha1 yhyWcnxiizrqcKVpj6SpktjoSbOYhAzuD3J4fPb4V+9u5OT2kLao7jCNqhBzUhgSkeOo TCVFBlQ/TJPJoK1kW75YhjxaQHBTF+yKQLQHN+5UPaSGmeGH6bQyRdqvXFpgidPD6NC/ VA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V3 01/22] as_flat_walk Date: Fri, 7 May 2021 05:24:59 -0700 Message-Id: <1620390320-301716-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1620390320-301716-1-git-send-email-steven.sistare@oracle.com> References: <1620390320-301716-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-GUID: 4Ap3RWcocOSL9lU7LYBrZKcYeZFgslAd X-Proofpoint-ORIG-GUID: 4Ap3RWcocOSL9lU7LYBrZKcYeZFgslAd X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9976 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 adultscore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105070085 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=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=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: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add an iterator over the sections of a flattened address space. Signed-off-by: Steve Sistare --- include/exec/memory.h | 17 +++++++++++++++++ softmmu/memory.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 5728a68..2e5495a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2003,6 +2003,23 @@ bool memory_region_present(MemoryRegion *container, = hwaddr addr); */ bool memory_region_is_mapped(MemoryRegion *mr); =20 +typedef int (*qemu_flat_walk_cb)(MemoryRegionSection *s, + void *handle, + Error **errp); + +/** + * as_flat_walk: walk the ranges in the address space flat view and call @= func + * for each. Return 0 on success, else return non-zero with a message in + * @errp. + * + * @as: target address space + * @func: callback function + * @handle: passed to @func + * @errp: passed to @func + */ +int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, + void *handle, Error **errp); + /** * memory_region_find: translate an address/size relative to a * MemoryRegion into a #MemoryRegionSection. diff --git a/softmmu/memory.c b/softmmu/memory.c index d4493ef..75d7d17 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2570,6 +2570,24 @@ bool memory_region_is_mapped(MemoryRegion *mr) return mr->container ? true : false; } =20 +int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, + void *handle, Error **errp) +{ + FlatView *view =3D address_space_get_flatview(as); + FlatRange *fr; + int ret; + + FOR_EACH_FLAT_RANGE(fr, view) { + MemoryRegionSection section =3D section_from_flat_range(fr, view); + ret =3D func(§ion, handle, errp); + if (ret) { + return ret; + } + } + + return 0; +} + /* Same as memory_region_find, but it does not add a reference to the * returned region. It must be called from an RCU critical section. */ --=20 1.8.3.1