From nobody Tue Nov 18 22:39:33 2025 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=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613402959586204.65478227713277; Mon, 15 Feb 2021 07:29:19 -0800 (PST) Received: from localhost ([::1]:40790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBfoM-0006lC-BS for importer@patchew.org; Mon, 15 Feb 2021 10:29:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBfnI-0005ch-H8; Mon, 15 Feb 2021 10:28:12 -0500 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]:36532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBfnG-0003gy-PK; Mon, 15 Feb 2021 10:28:12 -0500 Received: by mail-qv1-xf31.google.com with SMTP id e9so3285722qvy.3; Mon, 15 Feb 2021 07:28:09 -0800 (PST) Received: from [127.0.0.1] (ec2-3-14-82-192.us-east-2.compute.amazonaws.com. [3.14.82.192]) by smtp.gmail.com with ESMTPSA id r17sm11254239qta.78.2021.02.15.07.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 07:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:user-agent:mime-version :content-transfer-encoding; bh=K9dtiB52KD/fCCxMsNsL//tnnQH/CoxVUrg9hMxEj6o=; b=POR5zfy1djIUt8zTFSAhqA+NgBTodRGwQT89aSHAS5XXG05Ya9h6B4M293xppWz6+K 7iDJCOFoe7RpCTy9djZPt5nALA96oZdkaRnKcjrbREcUnLaLLiaimRoIJR0iIZbkz5Nx RffRc1zTKE0pypVlmBH6jUPnl1LZCJLx12HzMv8raQS5ksjLU/8lJsPGPbNtOqLmHRqo xSQ22cbSjBp3g5xxrcpmzR5vXa0+9zi+8TJk+u6XbdbG67OTyMy8qd+XQqE/jhhx043A BQgsYAK4cZTE0Pq03kVx4IbAPZ90atbmKu9ZNTKAi+EE1gNABBgmvfRa8wOVj73U4tYR 4IwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:user-agent :mime-version:content-transfer-encoding; bh=K9dtiB52KD/fCCxMsNsL//tnnQH/CoxVUrg9hMxEj6o=; b=XRLsqFaOBECtxTBB2eR98oyE7VGwX91BRAJJstv8zt3UK/E/rPwHaZFGvL6FktQgrc Rvq06rnGoD5EVesFBHkheJgLQAKWA83wN8dtwiqEyLKniyz4MvCmtjkBfDm+YabXxNd/ cbHJieBNimmHSYu+kYeQOgarxxCs/+fCO9+KxxpyJYBh8gTgi+y4YqM73rzXHcayRl+M pXT9nICowF26LwACziRZ9z34zxhiFlR1IWCW84lKqR/KEQn/+oHADosFIYF8fyraywIA 3Q7z4knWH8D/GgdnqUu4oxyHHsStIBOJku0W+y0yI8B9aZWu5TZU662PEbcT63QRDfST W2Mw== X-Gm-Message-State: AOAM532vPqtXHoDvwmVrIhRzRwv8jxwYmSvu8G4suLC2kSauyiO0IPSl r+7gfzXfr6IPnyNj0nw0aFFD+7vx4IehMBnV X-Google-Smtp-Source: ABdhPJwF7fDWEURA4BBrJqazpKJaIlBlzSB3aMJmrK6q+SgOWE/GUiY+b3WgpxG6K9NTyJ8s5JpWVg== X-Received: by 2002:a0c:83a4:: with SMTP id k33mr15283842qva.1.1613402888807; Mon, 15 Feb 2021 07:28:08 -0800 (PST) Message-ID: <74d39c65cc436dd9f23fdf1e7f471b85b05aa52a.camel@gmail.com> Subject: [PATCH v3] virtio-mmio: improve virtio-mmio unique device path assignment From: schspa To: qemu-devel@nongnu.org Date: Mon, 15 Feb 2021 23:27:59 +0800 Content-Type: text/plain; charset="utf-8" User-Agent: Evolution 3.38.3 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=2607:f8b0:4864:20::f31; envelope-from=schspa@gmail.com; helo=mail-qv1-xf31.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, FREEMAIL_FROM=0.001, 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: Eduardo Habkost , "Michael S. Tsirkin" , Kevin Zhao , Alistair Francis , QEMU Developers , Philippe =?ISO-8859-1?Q?Mathieu-Daud=E9?= , qemu-arm , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) At the moment the following QEMU command line triggers an assertion failure On xlnx-versal SOC: =C2=A0 qemu-system-aarch64 \ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -machine xlnx-versal-virt -nographic -smp 2 = -m 128 \ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -fsdev local,id=3Dshareid,path=3D${HOME}/wor= k,security_model=3Dnone \ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -device virtio-9p-device,fsdev=3Dshareid,mou= nt_tag=3Dshare \ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -fsdev local,id=3Dshareid1,path=3D${HOME}/Mu= sic,security_model=3Dnone \ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -device virtio-9p-device,fsdev=3Dshareid1,mo= unt_tag=3Dshare1 =C2=A0 qemu-system-aarch64: ../migration/savevm.c:860: =C2=A0 vmstate_register_with_alias_id: =C2=A0 Assertion `!se->compat || se->instance_id =3D=3D 0' failed. This problem was fixed on arm virt platform in commit f58b39d2d5b ("virtio-mmio: format transport base address in BusClass.get_dev_path") It works perfectly on arm virt platform. but there is still there on xlnx-versal SOC. The main difference between arm virt and xlnx-versal is they use different way to create virtio-mmio qdev. on arm virt, it calls sysbus_create_simple("virtio-mmio", base, pic[irq]); which will call sysbus_mmio_map internally and assign base address to subsys device mmio correctly. but xlnx-versal's implements won't do this. However, xlnx-versal can't switch to sysbus_create_simple() to create virtio-mmio device. It's because xlnx-versal's cpu use VersalVirt.soc.fpd.apu.mr as it's memory. which is subregion of system_memory. sysbus_create_simple will add virtio to system_memory, which can't be accessed by cpu. Besides, xlnx-versal can't add sysbus_mmio_map api call too, because this will add memory region to system_memory, and it can't be added to VersalVirt.soc.fpd.apu.mr again. We can solve this by assign correct base address offset on dev_path. This path was test on aarch64 virt & xlnx-versal platform. Signed-off-by: schspa --- =C2=A0hw/virtio/virtio-mmio.c | 12 +++++++----- =C2=A01 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index e1b5c3b81e..8fc2ccf347 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -731,6 +731,7 @@ static char *virtio_mmio_bus_get_dev_path(DeviceState *dev) =C2=A0=C2=A0=C2=A0=C2=A0 char *proxy_path; =C2=A0=C2=A0=C2=A0=C2=A0 SysBusDevice *proxy_sbd; =C2=A0=C2=A0=C2=A0=C2=A0 char *path; +=C2=A0=C2=A0=C2=A0 MemoryRegionSection section; =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 virtio_mmio_bus =3D qdev_get_parent_bus(dev); =C2=A0=C2=A0=C2=A0=C2=A0 virtio_mmio_proxy =3D VIRTIO_MMIO(virtio_mmio_bus-= >parent); @@ -749,17 +750,18 @@ static char *virtio_mmio_bus_get_dev_path(DeviceState *dev) =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 /* Otherwise, we append the base address of the tr= ansport. */ -=C2=A0=C2=A0=C2=A0 proxy_sbd =3D SYS_BUS_DEVICE(virtio_mmio_proxy); -=C2=A0=C2=A0=C2=A0 assert(proxy_sbd->num_mmio =3D=3D 1); -=C2=A0=C2=A0=C2=A0 assert(proxy_sbd->mmio[0].memory =3D=3D &virtio_mmio_pr= oxy->iomem); +=C2=A0=C2=A0=C2=A0 section =3D memory_region_find(&virtio_mmio_proxy->iome= m, 0, 0x200); +=C2=A0=C2=A0=C2=A0 assert(section.mr); =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 if (proxy_path) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 path =3D g_strdup_printf("= %s/virtio-mmio@" TARGET_FMT_plx, proxy_path, -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 proxy_sbd->mmio[0].addr); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 section.offset_within_address_space); =C2=A0=C2=A0=C2=A0=C2=A0 } else { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 path =3D g_strdup_printf("= virtio-mmio@" TARGET_FMT_plx, -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 proxy_sbd->mmio[0].addr); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 section.offset_within_address_space); =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 memory_region_unref(section.mr); + =C2=A0=C2=A0=C2=A0=C2=A0 g_free(proxy_path); =C2=A0=C2=A0=C2=A0=C2=A0 return path; =C2=A0} --=20 2.30.0