From nobody Mon Apr 29 09:17:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1617021428; cv=none; d=zohomail.com; s=zohoarc; b=iwgVLZalYhhb1yFYQZXh3wMJOgl3fGKSmXrIdD+OdEb09NIFWlY1Y6Yg8ExlSll7BElk9h3kCufNKZTFIZdlgXwJgrfnDV6Kt/15B1P2cTJHSkj8NXr2Msyn7M4RNM5kgsylOv3+c6dAeuUEX+5LOUXPBgTvBjbjMrpDlWqWE4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617021428; h=Content-Type: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=D5NwEdgs290pj4hiSwlBp6Oe/uih4LwC8Yd8Mo5sj3w=; b=U+bPrM4K+Vu66mL03OT1m5b9rk39RVbWUEHfivpuXDs9uN/h8F3kZKbP61wI/zDjRCHaX+gUYKxcQNwiMum7dQj8Ao6bS0cDdrUC++42hk2F3gclPEWVafbiL3jCBXf0SIr3wBZDVGn5dueapKf3onzrgEjqoeSewwvdsr1klMA= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16170214283405.014879393735896; Mon, 29 Mar 2021 05:37:08 -0700 (PDT) Received: from localhost ([::1]:34066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQr8k-0007Q1-JT for importer@patchew.org; Mon, 29 Mar 2021 08:37:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQr7W-0006N8-IY for qemu-devel@nongnu.org; Mon, 29 Mar 2021 08:35:50 -0400 Received: from zxshcas2.zhaoxin.com ([203.148.12.82]:12961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lQr7S-00070B-U7 for qemu-devel@nongnu.org; Mon, 29 Mar 2021 08:35:50 -0400 Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS2.zhaoxin.com (10.28.252.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 29 Mar 2021 20:14:22 +0800 Received: from localhost.localdomain (10.28.252.160) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 29 Mar 2021 20:14:20 +0800 From: FelixCuioc To: Paolo Bonzini , Richard Henderson , Eduardo Habkost , Alex Williamson Subject: [PATCH 1/1] Remove flatview_simplify() Date: Mon, 29 Mar 2021 20:14:08 +0800 Message-ID: <20210329121408.17862-2-FelixCui-oc@zhaoxin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210329121408.17862-1-FelixCui-oc@zhaoxin.com> References: <20210329121408.17862-1-FelixCui-oc@zhaoxin.com> MIME-Version: 1.0 X-Originating-IP: [10.28.252.160] X-ClientProxiedBy: ZXSHMBX2.zhaoxin.com (10.28.252.164) To zxbjmbx1.zhaoxin.com (10.29.252.163) 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=203.148.12.82; envelope-from=FelixCui-oc@zhaoxin.com; helo=ZXSHCAS2.zhaoxin.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: RaymondPang-oc@zhaoxin.com, qemu-devel@nongnu.org, CobeChen-oc@zhaoxin.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Flatview_simplify() can merge many small memory ranges into a large one and contains EHCI dma buffers. For example,the merged range maybe0xc0000-0xbfffffff. When seabios write PAM register to change the properties of part of the merged range from RW to readonly, this action cause the merged IOVA mapping will be unmapped.But EHCI device still send DMA cycles and then IOMMU blocks the DMA cycles of EHCI device. Because the merged range is too large,there will be problems even if EHCI device is configured to not allocate buffers in low memory. So this patch wants to remove flatview_simplify() completely. Signed-off-by: FelixCuioc --- softmmu/memory.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index d4493ef9e4..aaace8c03f 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -314,42 +314,6 @@ void flatview_unref(FlatView *view) } } =20 -static bool can_merge(FlatRange *r1, FlatRange *r2) -{ - return int128_eq(addrrange_end(r1->addr), r2->addr.start) - && r1->mr =3D=3D r2->mr - && int128_eq(int128_add(int128_make64(r1->offset_in_region), - r1->addr.size), - int128_make64(r2->offset_in_region)) - && r1->dirty_log_mask =3D=3D r2->dirty_log_mask - && r1->romd_mode =3D=3D r2->romd_mode - && r1->readonly =3D=3D r2->readonly - && r1->nonvolatile =3D=3D r2->nonvolatile; -} - -/* Attempt to simplify a view by merging adjacent ranges */ -static void flatview_simplify(FlatView *view) -{ - unsigned i, j, k; - - i =3D 0; - while (i < view->nr) { - j =3D i + 1; - while (j < view->nr - && can_merge(&view->ranges[j-1], &view->ranges[j])) { - int128_addto(&view->ranges[i].addr.size, view->ranges[j].addr.= size); - ++j; - } - ++i; - for (k =3D i; k < j; k++) { - memory_region_unref(view->ranges[k].mr); - } - memmove(&view->ranges[i], &view->ranges[j], - (view->nr - j) * sizeof(view->ranges[j])); - view->nr -=3D j - i; - } -} - static bool memory_region_big_endian(MemoryRegion *mr) { #ifdef TARGET_WORDS_BIGENDIAN @@ -735,7 +699,6 @@ static FlatView *generate_memory_topology(MemoryRegion = *mr) addrrange_make(int128_zero(), int128_2_64()), false, false); } - flatview_simplify(view); =20 view->dispatch =3D address_space_dispatch_new(view); for (i =3D 0; i < view->nr; i++) { --=20 2.17.1