From nobody Sun Nov 24 15:06:54 2024 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=1723529819; cv=none; d=zohomail.com; s=zohoarc; b=nhuwkkDn6aOp+oa15QgIaNTgWGvnKqaVyDRi9wZ7Gfg+TfRqKkREzEnw7c2+3RUs2yV70H6hovAp8m/cVevl55qrAjWACHqlWgUIT7hYWJl5NGvXrVwTdUKRS8aoaeJvv1zOkgCSunnhxnUnc41iK21lcbS0e9wpnTgRlF/08O0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723529819; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NowZm/EG31u8eyDPWUoV8f+k0nmNu308nWwlnQDkLrY=; b=e5cIklUW8jd6tKZfpSBrRyaDJV5WcF0ttv7u1/dlPJxaUnnvwIAjF20BWocYJOiEFrrC6PGa3p5fNeq2xMJj3j1JKgWljcJAbdHtWmBIT0WCv1gpV/xswZIxii+BG+YYPHliCqtiitGmfhKBIw3mbBaCJD5DwfiU11OmSqRbRP4= 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 1723529819740282.41313961669164; Mon, 12 Aug 2024 23:16:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdkos-0007g8-EP; Tue, 13 Aug 2024 02:15:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdkon-0007JI-SS for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:42 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdkol-0003aB-Qz for qemu-devel@nongnu.org; Tue, 13 Aug 2024 02:15:41 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-76cb5b6b3e4so3298989a12.1 for ; Mon, 12 Aug 2024 23:15:39 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d1fd01a448sm6262703a91.49.2024.08.12.23.15.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 23:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1723529738; x=1724134538; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NowZm/EG31u8eyDPWUoV8f+k0nmNu308nWwlnQDkLrY=; b=JNhj31OMU2Q8FTRRWBCwRX5s0ML0f5TF/At5rmvB1FlHD58tFTz9vueHZV4jAhD/Di +265OUliBOuTJc4AVmYlSUn8TkiIBOylUFZa5ymGu9nAXrgco6AGwkkEaoTdsigbgtAN Lup4OXmXmuWTHNxwEP0MYwVjL1lL4kwHAIT8YUt3flPdBoELu1ETP7qk1YmBlhIyE0wv yayfdpoUi1bUP4ZVhZquaFD8htpAAvg9ZfHD+q26IHYio0YnUioDbbDG7y9oBhiBQGRl xO9YulUcsHUcPYuxkn20vFOXFXoRwG0lfR2CYl1VK/pnxOhoolfqdbUMuT1GRByKVVvR j3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723529738; x=1724134538; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NowZm/EG31u8eyDPWUoV8f+k0nmNu308nWwlnQDkLrY=; b=RIPUhb/bZprDzt+OBM9c7OI+pOo9r3rwKKtMtev+NL02MxFNCd10JqiTW8pdZjQx0f LRDt5ZGdAIkKj7QswJ5vvahtZTaiSY9HDBs30TAiikHdcB6m5JW7eEhpXKoeQtrwFwb3 rU0nW9geBC95kL27gGl0BeBETUoBXLFrnStmYSrXHbBG7K9Bah7Mo6O6/3GPGJtm7UC+ tMwQylTwburkW7DoRjI+a12/NFbsw8UGy1CC9ak4kHLxYTctx9fsdQ0NSM9bm/MQEDTF nC4ftNK6JknCHYIwm6tGpkHUk0MclHMrXVpfjycUTLKNgwgZ+/DOPaZ644K3I/nTXLjn l/eQ== X-Gm-Message-State: AOJu0YzrtPFHJfTjZPVOmOLQrWt4YNJ/0QBO4TM9RT3LXMCnJTE0eChi hVeeN3rWZNml6LneFbf/1AH8y+nYXhdcodskLQ8cGWR2INhOE6uIh9nVA74e1ok= X-Google-Smtp-Source: AGHT+IFph3uB81Z1nge6y0CzHfO4q1huFVg5pC9dVwXpB4kQeZgvWpHeCxg+8/LcZzEePVujQHi5JQ== X-Received: by 2002:a05:6a20:2d0e:b0:1c4:8293:76d0 with SMTP id adf61e73a8af0-1c8d7444e36mr3399329637.4.1723529738011; Mon, 12 Aug 2024 23:15:38 -0700 (PDT) From: Akihiko Odaki Date: Tue, 13 Aug 2024 15:14:53 +0900 Subject: [PATCH for-9.2 v14 10/11] hw/pci: Use -1 as the default value for rombar MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240813-reuse-v14-10-4c15bc6ee0e6@daynix.com> References: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> In-Reply-To: <20240813-reuse-v14-0-4c15bc6ee0e6@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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=2607:f8b0:4864:20::531; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x531.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1723529820898116600 vfio_pci_size_rom() distinguishes whether rombar is explicitly set to 1 by checking dev->opts, bypassing the QOM property infrastructure. Use -1 as the default value for rombar to tell if the user explicitly set it to 1. The property is also converted from unsigned to signed. -1 is signed so it is safe to give it a new meaning. The values in [2 ^ 31, 2 ^ 32) become invalid, but nobody should have typed these values by chance. Suggested-by: Markus Armbruster Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster --- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 2 +- hw/vfio/pci.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 1ff3ce94e25b..8fa845beee5e 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -148,7 +148,7 @@ struct PCIDevice { uint32_t romsize; bool has_rom; MemoryRegion rom; - uint32_t rom_bar; + int32_t rom_bar; =20 /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4c7be5295110..d2eaf0c51dde 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -71,7 +71,7 @@ static Property pci_props[] =3D { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_INT32("rombar", PCIDevice, rom_bar, -1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present, diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2407720c3530..dc53837eac73 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size =3D cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset =3D vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev =3D DEVICE(vdev); char *name; int fd =3D vdev->vbasedev.fd; =20 @@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } =20 if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (vdev->pdev.rom_bar > 0) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); error_printf("Proceeding anyway since user specified" - " non zero value for rombar\n"); + " positive value for rombar\n"); } else { warn_report("Rom loading for device at %s has been disabled" " due to system instability issues", --=20 2.46.0