From nobody Sun Nov 16 04:16:12 2025 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=1598608884; cv=none; d=zohomail.com; s=zohoarc; b=nAPfw3oJRbpUH7Iq3/p18Ks+8LGp05Qum8pkhxvmB0o5Sx8/ffTSySAwD6oamVHbQ/U/saERt69mVP37pMMS8TYqqWKSH1kwDAUAr4yT560Njz1j0SHI0VbDUGUodgkEZLh5k0UxsFT554tufhIqVTf+3gHSY/pMzdVTDR10YiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598608884; h=Content-Type: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=yBBlaGrL25/xR9s7qtVE6bWSxzETDcDB7CMljtwHUuo=; b=eqiGLww/BpgYzpoo7p8TmbH42oLPrJlffL6ryqQbrvsDMWk+NrxgEZ1+d4YrDoJIyTnpaFdNv41Wtu5iVIzRAAjM86y1KItQu0bal2ZG8xLIFgSoJW2eFxQYvjNNbxMra+JbC7yOhvZqcgD7zSZ7dkC+fSZMSfAdgXCiZ1fwwug= 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 1598608884355132.53025569701663; Fri, 28 Aug 2020 03:01:24 -0700 (PDT) Received: from localhost ([::1]:33016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBbCE-0001IS-So for importer@patchew.org; Fri, 28 Aug 2020 06:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBbBL-0000FW-Ah for qemu-devel@nongnu.org; Fri, 28 Aug 2020 06:00:27 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4718 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBbBC-0000Ij-VO for qemu-devel@nongnu.org; Fri, 28 Aug 2020 06:00:27 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9376652ABFFF29C696DA; Fri, 28 Aug 2020 18:00:05 +0800 (CST) Received: from localhost (10.174.149.106) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Fri, 28 Aug 2020 17:59:56 +0800 From: Wang Xin To: Subject: [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost Date: Fri, 28 Aug 2020 17:59:52 +0800 Message-ID: <20200828095953.2276-2-wangxinxin.wang@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200828095953.2276-1-wangxinxin.wang@huawei.com> References: <20200828095953.2276-1-wangxinxin.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.149.106] X-CFilter-Loop: Reflected 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=45.249.212.191; envelope-from=wangxinxin.wang@huawei.com; helo=huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/28 06:00:05 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: Wang Xin , jianjay.zhou@huawei.com, weidong.huang@huawei.com, dgilbert@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Allow a memory region to be marked as 'no_vhost' and exclude that region from vhost's list build. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Wang Xin --- hw/virtio/vhost.c | 5 ++++- include/exec/memory.h | 21 +++++++++++++++++++++ softmmu/memory.c | 15 +++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1a1384e7a6..bd50532a30 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -415,7 +415,10 @@ static bool vhost_section(struct vhost_dev *dev, Memor= yRegionSection *section) { MemoryRegion *mr =3D section->mr; =20 - if (memory_region_is_ram(mr) && !memory_region_is_rom(mr)) { + if (memory_region_is_ram(mr) && + !memory_region_is_rom(mr) && + !memory_region_is_no_vhost(mr)) { + uint8_t dirty_mask =3D memory_region_get_dirty_log_mask(mr); uint8_t handled_dirty; =20 diff --git a/include/exec/memory.h b/include/exec/memory.h index 0cfe987ab4..7258fd6996 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -380,6 +380,7 @@ struct MemoryRegion { bool global_locking; uint8_t dirty_log_mask; bool is_iommu; + bool no_vhost; RAMBlock *ram_block; Object *owner; =20 @@ -1205,6 +1206,26 @@ static inline bool memory_region_is_romd(MemoryRegio= n *mr) return mr->rom_device && mr->romd_mode; } =20 +/** + * memory_region_set_no_vhost: Make vhost ignore a memory region + * + * Makes vhost ignore a memory region, useful if it isn't real + * DMAble memory and is at inconvenient addresses + * + * @mr: the region being updated. + * @no_vhost: true to ignore + */ +void memory_region_set_no_vhost(MemoryRegion *mr, bool no_vhost); + +/** + * memory_region_is_no_vhost: Test if memory region is marked no vhost + * + * Test if the no_vhost flag is set on the memory region + * + * @mr: the region being tested. + */ +bool memory_region_is_no_vhost(const MemoryRegion *mr); + /** * memory_region_get_iommu: check whether a memory region is an iommu * diff --git a/softmmu/memory.c b/softmmu/memory.c index 70b93104e8..5debe22978 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2125,6 +2125,21 @@ void memory_region_rom_device_set_romd(MemoryRegion = *mr, bool romd_mode) } } =20 +void memory_region_set_no_vhost(MemoryRegion *mr, bool no_vhost) +{ + if (mr->no_vhost !=3D no_vhost) { + memory_region_transaction_begin(); + mr->no_vhost =3D no_vhost; + memory_region_update_pending |=3D mr->enabled; + memory_region_transaction_commit(); + } +} + +bool memory_region_is_no_vhost(const MemoryRegion *mr) +{ + return mr->no_vhost; +} + void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size, unsigned client) { --=20 2.26.0.windows.1 From nobody Sun Nov 16 04:16:12 2025 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=1598608884; cv=none; d=zohomail.com; s=zohoarc; b=OnGfkAYYYGcIDIhMkToUn733adpl4QnnXk/5SGMCWV+7nhRi/lvvfHG24oR921y9+hPE5tx9CObcEk6z1TqS58iikoK+apeJHSWcw4lCzfUjG0je6uuZ4K595wPHxcfAsXr3SnLe5dsCNrt2iilE9wAvt+e9+LhrD2GdCDrX7cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598608884; h=Content-Type: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=URwMSrFvLF0N3sZlJammwjd4yfL8yc1xkBJSUOv5OJ4=; b=n0b+/DGE+FZnbeXlTBMiGrY266+i+Gqt4L96xwR5x9hREsEn6w1iLEz/FrnUxfnHiTh4wQVD393WMwSppgd8I4zxcLcGx2povIxm3GzhGNlOHpd095VPqLHBiXF5lemUz5uPFkgCFmC8rboMdNO1YHDqmjyjVBuksH4sGiRvkZ4= 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 159860888421883.77288957079315; Fri, 28 Aug 2020 03:01:24 -0700 (PDT) Received: from localhost ([::1]:33036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBbCE-0001Iz-Rd for importer@patchew.org; Fri, 28 Aug 2020 06:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBbBN-0000GS-6z for qemu-devel@nongnu.org; Fri, 28 Aug 2020 06:00:29 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:41174 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBbBC-0000Io-VN for qemu-devel@nongnu.org; Fri, 28 Aug 2020 06:00:28 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4D8D67CC6A9C9C0E95B8; Fri, 28 Aug 2020 18:00:06 +0800 (CST) Received: from localhost (10.174.149.106) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 28 Aug 2020 17:59:57 +0800 From: Wang Xin To: Subject: [PATCH 2/2] misc/ivshmem: Mark shared memory regions as no vhost Date: Fri, 28 Aug 2020 17:59:53 +0800 Message-ID: <20200828095953.2276-3-wangxinxin.wang@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200828095953.2276-1-wangxinxin.wang@huawei.com> References: <20200828095953.2276-1-wangxinxin.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.149.106] X-CFilter-Loop: Reflected 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=45.249.212.32; envelope-from=wangxinxin.wang@huawei.com; helo=huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/28 06:00:07 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: Wang Xin , jianjay.zhou@huawei.com, weidong.huang@huawei.com, dgilbert@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since ivshmem_bar2 not normal RAM in Guest, and it shouldn't have vhost DMAing into them, exclude it from the vhost sections, mark the shared memory regions as novhost. Signed-off-by: Wang Xin --- hw/misc/ivshmem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 2b6882face..1f3a7a1dfc 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -499,6 +499,7 @@ static void process_msg_shmem(IVShmemState *s, int fd, = Error **errp) } =20 s->ivshmem_bar2 =3D &s->server_bar2; + memory_region_set_no_vhost(s->ivshmem_bar2, true); } =20 static void process_msg_disconnect(IVShmemState *s, uint16_t posn, @@ -855,6 +856,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Erro= r **errp) =20 s->ivshmem_bar2 =3D host_memory_backend_get_memory(s->hostmem); host_memory_backend_set_mapped(s->hostmem, true); + memory_region_set_no_vhost(s->ivshmem_bar2, true); } else { Chardev *chr =3D qemu_chr_fe_get_driver(&s->server_chr); assert(chr); --=20 2.26.0.windows.1