From nobody Mon Feb 9 05:37:08 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1623232900; cv=none; d=zohomail.com; s=zohoarc; b=P8Em+XbPSG8AcFICSk8AoQXtb2zcolEBHWVMijMaEB36bmB1gdeS7XtzsYwc3F3dhEcwwOSFg24QU8EmWf0Owik1dQmsTzetTzZu2FS2BhX6bmnG7Tdt3XRwt7Ptwqtuq4F4BwPlQiM3ZBc9jtJtRrDCcgV+7mSklKTRxJQPkJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623232900; 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=cynhB7H844usO/w7q82Q6cxltDJPQ4Zf1PvkeKtrTf0=; b=e5M+U51JLzn7LJ1OoqiCcTu3ZLh0aTP4//V3aQ/DF+9SU9Fw3cElX3rikyDl+lB935tMa53Lsq/UaWBpOQlyoLfE0HmKqgAxj1+Dy7kXtMhKuk2C0RvtjrT9wHfsPLi1KOhOTOWh8bZmYqvruL0ssrq3gMh+S6eKaCqfSXfw8FM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623232900143811.1845569694798; Wed, 9 Jun 2021 03:01:40 -0700 (PDT) Received: from localhost ([::1]:34064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqv1m-0008Ra-V3 for importer@patchew.org; Wed, 09 Jun 2021 06:01:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lquzU-00058G-RN for qemu-devel@nongnu.org; Wed, 09 Jun 2021 05:59:16 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:33284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lquzQ-0002u1-Fq for qemu-devel@nongnu.org; Wed, 09 Jun 2021 05:59:16 -0400 Received: by mail-lf1-x12a.google.com with SMTP id bp38so1535985lfb.0 for ; Wed, 09 Jun 2021 02:59:12 -0700 (PDT) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q6sm218751lfj.88.2021.06.09.02.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 02:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cynhB7H844usO/w7q82Q6cxltDJPQ4Zf1PvkeKtrTf0=; b=IRNUHyTf4y7Mdijcy82BwMO+ryphNeDci32XDifug2O3nb9lYr+TCx1eAwu+JrQK8h hqGlj3h96FBA4oNCwZD2fYu5yF6Mg0kLRHlcqf7Z1SEC8IGeqJz4WMsPh1PsXRxXPMTs PNugZJ2yu3KGE4sucmEVTVNqBEZazhvh53pUK7Ra66oEfa+nH3RJxBYpBicMVYMKslN9 Ekv2q/PQu/oGUyU8qawkjTAionuJRGr53pB0EWNoE6YwzDZZRBbpnFOMAxVCC8UqHA92 sR7JMnabLz9dpyUdKyN0wMv1zcB2ehb1orU50xpYm1zmW+GS0qAz77qn0TFnmtgMlg3M XGBg== 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=cynhB7H844usO/w7q82Q6cxltDJPQ4Zf1PvkeKtrTf0=; b=CRxbufzyBTeGQznGqy4dG1+PDHI30YAlGYfuMhISqdtI5yZtDT2B4D+pfO9lceuBYq W1SjNjFqcH9wI1167wNY/8r78eHOZ7OaMiJrZShJpjuQeNocNcqK9IQgLiGxP5/mD5pq 0Pdnud9ti9XjxMDnCskgVk0V8Ud8zrQyWw8l6l6gKfuycH8mjy43S3cwmYOVdrGPITCn g4VBc+NAV2guLRKQtShInKj5rGL8B/iHQatWGr4BSrGoAzO/d6c+oI9s0zRdumIm36V0 7GOatPipoepesQYZlXAAELLLhdCcSUEsP9g6+jBpYiHx3TCKUrLRCM+piy4TT6yr39Yj CmGg== X-Gm-Message-State: AOAM530HThEJagbZUm3rE8nRAAf1bI6jRzUuO4Uk1/9aawDwxQaBAMpE 85VKdUgNG3hvVEBoAG0ibW9bhg== X-Google-Smtp-Source: ABdhPJw+SgwrzbFMEF/eVSC3WKjlgBJqG1w6pNvEPNEqZA4yZmdpoRZrp6VA2l0qtkXNtzH+pn+JQw== X-Received: by 2002:a05:6512:39ca:: with SMTP id k10mr11700483lfu.473.1623232750724; Wed, 09 Jun 2021 02:59:10 -0700 (PDT) From: Andrew Melnychenko To: mst@redhat.com Subject: [PATCH 1/3] virtio-pci: Added check for virtio device presence in mm callbacks. Date: Wed, 9 Jun 2021 12:58:41 +0300 Message-Id: <20210609095843.141378-2-andrew@daynix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609095843.141378-1-andrew@daynix.com> References: <20210609095843.141378-1-andrew@daynix.com> 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: none client-ip=2a00:1450:4864:20::12a; envelope-from=andrew@daynix.com; helo=mail-lf1-x12a.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Type: text/plain; charset="utf-8" During unplug the virtio device is unplugged from virtio-bus on pci. In som= e cases, requests to virtio-pci mm may acquire during/after unplug. Added check that= virtio device is on the bus, for "common" memory region. Signed-off-by: Andrew Melnychenko --- hw/virtio/virtio-pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b321604d9b..05865b1fcb 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1146,6 +1146,10 @@ static uint64_t virtio_pci_common_read(void *opaque,= hwaddr addr, uint32_t val =3D 0; int i; =20 + if (vdev =3D=3D NULL) { + return UINT64_MAX; + } + switch (addr) { case VIRTIO_PCI_COMMON_DFSELECT: val =3D proxy->dfselect; @@ -1229,6 +1233,10 @@ static void virtio_pci_common_write(void *opaque, hw= addr addr, VirtIOPCIProxy *proxy =3D opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); =20 + if (vdev =3D=3D NULL) { + return; + } + switch (addr) { case VIRTIO_PCI_COMMON_DFSELECT: proxy->dfselect =3D val; --=20 2.31.1 From nobody Mon Feb 9 05:37:08 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1623233042; cv=none; d=zohomail.com; s=zohoarc; b=TVzMTS+iX164h4Ev4UyUFMBjBnJI3Vzfx1xJZ6uGxoqu7SmAN+oTrpislV41mEasgR7qElAtXxg72V0zNsY5G+IzZe85YBq3Q7RAmVQJYlCdCWm7iSNc60LkLC9f5zq1akqdmfoSfl/91sEKdVZO3Daf6TDH/fHCllTmjQcfZT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623233042; 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=LN3Pu6RJs3i4flwBlMNyC34bGcWkq6y11cJZxjQuFKo=; b=bSCxEOqGaa74aFuuwkK89LwKAvqSoiE3308oLmcV9CBW+s+aJZXHS8Zlu+kg2k/2mYun8m+V6R/ZP56DfPv4HOqxJZugn3mOOLOJSpiaYlpp7va+FaZonXyrIeyPvXRypFmQ1+KfPM3ujqUgDTun7zYN40XfXR3S7qdeu93qQ4o= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623233042322356.2790639498395; Wed, 9 Jun 2021 03:04:02 -0700 (PDT) Received: from localhost ([::1]:41978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqv45-0005GB-8O for importer@patchew.org; Wed, 09 Jun 2021 06:04:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lquzW-0005B9-0l for qemu-devel@nongnu.org; Wed, 09 Jun 2021 05:59:18 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:35821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lquzR-0002ug-0E for qemu-devel@nongnu.org; Wed, 09 Jun 2021 05:59:17 -0400 Received: by mail-lj1-x22f.google.com with SMTP id n17so13761090ljg.2 for ; Wed, 09 Jun 2021 02:59:12 -0700 (PDT) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q6sm218751lfj.88.2021.06.09.02.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 02:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LN3Pu6RJs3i4flwBlMNyC34bGcWkq6y11cJZxjQuFKo=; b=xNOUQPBSuWF1zjacNLh3kmGW1FKQd17jTZbCcTYEdrOAFk7YYYFbG+U7Qf3tSOcE1I InmUGR+y791bV4nWs9AVBurYG8LDAHYLtdPGVs968ENYprQTXXP0ICWs494n5QBfLknH ykf0bHd6EBp7Eu5ryaFkudFOJdImC5gOktRRoGSaaUXJvvpBPHP9jEXtbV2haMn6QuVV DHNkLWbJuz5lBzsSEeMytVEuhW3G+e+le/A7/1Dtv5vpEiabar0Io2EZJd3HST8UJKj/ YjluC/v/ELnkSq+Nzm8PYXWgxJyTnJN8hRSPISXWu8vugdcZWFBnqiA2Wkn8LGlauHt4 Qipg== 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=LN3Pu6RJs3i4flwBlMNyC34bGcWkq6y11cJZxjQuFKo=; b=XoHXPCUZQtk0ShIV79jwURXR88YMaNyPg3nBpyFn8Sr41zifjziirYF4LHUCr9V2oD DJtQSd09e2N/1jWN8zuh74kf2PKSs0geyCH3oP7qO0pG8cqhaoeaCLu1xPigjmJIKCln zcCfjRpuejLOTiDM3IY2vJK964qbDTbF+P1hAtLBzKW0EUzC6Y4qoamaLT4oU98MTFam hgRObdISHfPhnE2OXPxSIFLoN8nmZ0S9qtQ/GNipIPa0jm2ZsfpxDw+UTx7IO4zvXFxa NJAYlk7sfs18kqTzf4dM3bSNvMyTx1MrVIyCsz2vnYvyyIOb+B0KIu6FFvBNWiuKTyFX bIUg== X-Gm-Message-State: AOAM533nnVUoZCOymDQn9tqeDhJR5iEFOHKWQtHTYB16bX7l8ooxJFbX zowKZ+3OU7JGUyofjzdVJc+IAQ== X-Google-Smtp-Source: ABdhPJwGfrVAbEZlB5x1qhcbQiO5ZjYeBxR1NVfsF3atb+4Kjhv9AGsxkb5KwvaCLXLwQf53sonylw== X-Received: by 2002:a2e:8147:: with SMTP id t7mr7715643ljg.241.1623232751555; Wed, 09 Jun 2021 02:59:11 -0700 (PDT) From: Andrew Melnychenko To: mst@redhat.com Subject: [PATCH 2/3] virtio-pci: Added check for virtio device in PCI config cbs. Date: Wed, 9 Jun 2021 12:58:42 +0300 Message-Id: <20210609095843.141378-3-andrew@daynix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609095843.141378-1-andrew@daynix.com> References: <20210609095843.141378-1-andrew@daynix.com> 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: none client-ip=2a00:1450:4864:20::22f; envelope-from=andrew@daynix.com; helo=mail-lj1-x22f.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Type: text/plain; charset="utf-8" Now, if virtio device is not present on virtio-bus - pci config callbacks will not lead to possible crush. The read will return "-1" which should be interpreted by a driver that pci device may be unplugged. Signed-off-by: Andrew Melnychenko --- hw/virtio/virtio-pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 05865b1fcb..186b7bc0f6 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -423,6 +423,11 @@ static uint64_t virtio_pci_config_read(void *opaque, h= waddr addr, VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); uint32_t config =3D VIRTIO_PCI_CONFIG_SIZE(&proxy->pci_dev); uint64_t val =3D 0; + + if (vdev =3D=3D NULL) { + return UINT64_MAX; + } + if (addr < config) { return virtio_ioport_read(proxy, addr); } @@ -454,6 +459,11 @@ static void virtio_pci_config_write(void *opaque, hwad= dr addr, VirtIOPCIProxy *proxy =3D opaque; uint32_t config =3D VIRTIO_PCI_CONFIG_SIZE(&proxy->pci_dev); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + + if (vdev =3D=3D NULL) { + return; + } + if (addr < config) { virtio_ioport_write(proxy, addr, val); return; --=20 2.31.1 From nobody Mon Feb 9 05:37:08 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1623232932; cv=none; d=zohomail.com; s=zohoarc; b=jWeuO3+FbxnSugWB1ModSs4TFtCyBep6b9UAuTSIwhE3BOdNUNuF7nAGVG+hp/XptS8TnFSmdWlgzmQvcGS+nDqRpb+2kTdfhASUjHDXlvlAr2ntGlMxFeQ4mQYtpFkFO6HHBZivtTG7k9lo7cykDOdkujQbrca5A4qdEjG31Jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623232932; 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=j9YEjAoaXL5qJgDsb/3cVBnG9BkTzCCeb0C1KOR56Zg=; b=dVtS/lFJyZwGh73UpyIW9vWg03VY3ufyB8/EpB9baBOE8dMPQSGDgUetfq2evcLDx5GZj6Y24wC9qN9zOT2R8emq9C3KALCaJHtv0bdEG3t9/YvKChpKx4qmr74OZckdLsbWSvbit6I7gZgej14pUT/5VCZ7vrZifZpfDn+lQpI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623232932341554.7638424841496; Wed, 9 Jun 2021 03:02:12 -0700 (PDT) Received: from localhost ([::1]:35428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqv2J-0000vp-6s for importer@patchew.org; Wed, 09 Jun 2021 06:02:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lquzV-00059Y-Au for qemu-devel@nongnu.org; Wed, 09 Jun 2021 05:59:17 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:46678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lquzR-0002vM-NG for qemu-devel@nongnu.org; Wed, 09 Jun 2021 05:59:17 -0400 Received: by mail-lf1-x130.google.com with SMTP id m21so21390791lfg.13 for ; Wed, 09 Jun 2021 02:59:13 -0700 (PDT) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q6sm218751lfj.88.2021.06.09.02.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 02:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j9YEjAoaXL5qJgDsb/3cVBnG9BkTzCCeb0C1KOR56Zg=; b=IYDdER4UFtsSLPvXbipjGqc5ideXbwdOL/iw4tb9mb2x9Hs0pMjnwnR/6na6y5ZnFl hYKXUnqUuFUpzbup2fLJfrRd+9PNFBaWET9mtZDcdlXF+TFcIl84j8jwLXssR1UhZD1y gLUMoAJXXzjHEnbzYpRnfuGi4Qi2oDprOFcStkyUYYiXH7LKdFUqpRVKWvMZIdKoXemL bjVD7MRfXsBOlZ7qUunWufRVrMzksOhN2n+hCH7/nTJb5ajXQ87vu1JKby2qHc5FeTh0 8Pi2Cv31ByPZ3eC1SiFoNaSA0lhzWpGkQ/A7WbFDeZjMe21VRT7NWBq+Nx9svbE+bmvf PVxw== 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=j9YEjAoaXL5qJgDsb/3cVBnG9BkTzCCeb0C1KOR56Zg=; b=Tfe5Duc2JF55D6YEE5WmVwwaXu7JieNh3ogXBBQjRLAmM3N0tZN9jjT2WOSHpzb7pF P0SHiG1yMl2Etw0B1LgHsl6nVpoN2cgY9v3gTyNgvF7eq/FKczqq1fBtwkT9AqRYuKRj vkYRENVJduurfp4/MALZupdfpJhTphx4Hqf/YS+Vk+HtCKfabDQCkrDpZwuZHYlFDTZp 9jAqiLmSXGG6m5ZfxFIeT5vtL1i0hsPWW1QAm2uBW6wkolBPkUF0k5bW/5eXK04Z5qgV Ek/v1WME8d3mwORXaanANAUMpP03+hHNNdnzAu8Iy9GBDWiOmWW+ekfQI2E1ZShd2n0X piUw== X-Gm-Message-State: AOAM5323zThcQ5bNxWgKHQMv4z8qdCqymwVNzlEM2wLcipDO2J4eW7jW GNIVw8eIAWezyKYWbPvsTdLeNA== X-Google-Smtp-Source: ABdhPJykOFs1vdPAfNpGuyil+wy2hjsoMwtCoFYg28rgNvrEE9iUAqLVr0egyE+jCdUKMK+vONpqEg== X-Received: by 2002:a05:6512:681:: with SMTP id t1mr10632340lfe.640.1623232752361; Wed, 09 Jun 2021 02:59:12 -0700 (PDT) From: Andrew Melnychenko To: mst@redhat.com Subject: [PATCH 3/3] virtio-pci: Changed return values for "notify", "device" and "isr" read. Date: Wed, 9 Jun 2021 12:58:43 +0300 Message-Id: <20210609095843.141378-4-andrew@daynix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609095843.141378-1-andrew@daynix.com> References: <20210609095843.141378-1-andrew@daynix.com> 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: none client-ip=2a00:1450:4864:20::130; envelope-from=andrew@daynix.com; helo=mail-lf1-x130.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @daynix-com.20150623.gappssmtp.com) Content-Type: text/plain; charset="utf-8" Added check for "notify" memory region. Now reads will return "-1" if a vir= tio device is not present on a virtio bus. Signed-off-by: Andrew Melnychenko --- hw/virtio/virtio-pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 186b7bc0f6..447f13beae 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1348,6 +1348,11 @@ static void virtio_pci_common_write(void *opaque, hw= addr addr, static uint64_t virtio_pci_notify_read(void *opaque, hwaddr addr, unsigned size) { + VirtIOPCIProxy *proxy =3D opaque; + if (virtio_bus_get_device(&proxy->bus) =3D=3D NULL) { + return UINT64_MAX; + } + return 0; } =20 @@ -1385,7 +1390,7 @@ static uint64_t virtio_pci_isr_read(void *opaque, hwa= ddr addr, uint64_t val; =20 if (vdev =3D=3D NULL) { - return 0; + return UINT64_MAX; } =20 val =3D qatomic_xchg(&vdev->isr, 0); @@ -1406,7 +1411,7 @@ static uint64_t virtio_pci_device_read(void *opaque, = hwaddr addr, uint64_t val; =20 if (vdev =3D=3D NULL) { - return 0; + return UINT64_MAX; } =20 switch (size) { --=20 2.31.1