From nobody Tue Dec 16 14:25:12 2025 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21A5A1ADC93 for ; Tue, 14 Jan 2025 10:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736850890; cv=none; b=enzMn/7QF6knd9dsAzgh6xHeOG7GOCPasiGcx2AzFC7LOa6lVW3v3jNn20PHjdeo4KyX0e0WpfwNAZ60fmSgZEh7rjkVL6PNEDj0VsnXMIvBRr6+MG8z5uSl5eYF6OJn0oQS6C7z3LWp10cn+HeYz8yyEUx7b6FyHnR2F/rhKg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736850890; c=relaxed/simple; bh=ju4WX0ov8dycuvy/xaInNl24F3ZkGvGGmbP1/0U7B/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h6JkmfYF2pHVE2z16z4tvaPikn34TDdebX5+GCZBtub7HL4ymS4BUN6wKzXyuhdwdC9N5u7BVD5KxXXzAVjTZO7Y5qPtoQGvRXJlECfg+rJeVs5dQpFRCfboG4OcQb3ZH6paTOQDlJP+UWZB+rR7MYSvbuyeaigWdI0RjVkv1gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=NXi/mdop; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="NXi/mdop" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5d3f57582a2so1588044a12.1 for ; Tue, 14 Jan 2025 02:34:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1736850887; x=1737455687; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9ZU2rMw7aFNypI2l6diI5iIm2rhPqMg33NxACGe4Tyg=; b=NXi/mdopaJKHu9FeR+0LtCeh1hCSrGpxtdYLTV/KvY7sLFKkJZGGad3We6xZHz5DJT WS8UpzBWPdbwWGSlLUKqOo1dgej5n8shn5UdU3BV7E42XQOOuoBt0nFdMPFsBgtNORym ncjFD72lgN4+7FTCfF15TaLVI6P2ARsULSMJ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736850887; x=1737455687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9ZU2rMw7aFNypI2l6diI5iIm2rhPqMg33NxACGe4Tyg=; b=Zid+AaH6k+7I1ifMmZo2vAVqZzroTvW7AQJGGWuU7HJzR7fxpsYLWAVwbNTPvWx4Ca uo5Bz6R7rFeRBfjOvEobHvVVY5ZHr4WhaEO91d07k9CZt6fsolEMgrYkeK2p7SDh9TdM uBtWeaFf+jLI4VVMUkisP4vVNNi8fzDNOH/vLESsVWJ8qPX2OG6humcrd3OdNnOYbXO1 LabkE8lrH/6fe3fj8WpT+bgCmZPUVF8m0bgzF0gi053c62OON3ttHxkQi0TYxwQCS/a7 vmDlX0lefhsCmTlcBQESwqe0nCyQbBVr0dRspGT0d3RVsXalVgh7HX1EgUQh0h/5ny90 yPkg== X-Gm-Message-State: AOJu0Yxa4NrtbfxOuSNo65ooQv1gVKocavbg1fDnyHTe8WLTJOMUWtGG 3oK2kMKdF4iPj0+PEm/9pEALVKwrNyZOZ2BRFISrvoVMWJNcLNw8bYk61REvKz/ONP1FOdiCJ1Z 0 X-Gm-Gg: ASbGncuSHtllSSnV2kp76jG7vnTxEkfrF7w9OQA0M6elfooq+rANAggDNN9hN1k8Qu5 SOehINauU9fY2GBLrl+tZpVKjNNf6uMhPApnNiTf/QxjZrRAW2IR8xVCJw2H7sw36UlIHMGxs4b 0wGr/NMNtgAPtTJRpSnTLGEW6cnsyF9EUGhwe30YshVRa/ZQjuCpwmpXLAj9R8i1CvpcSB2FrMu G5MYjDqVXGcjjuLZ0sYPD0QGtkLFvLU+LAd3qXwjx4bSt4GtHpjv9xh4A3x4JSYiD0= X-Google-Smtp-Source: AGHT+IGrlgmiY5VqhHCHxlAvhEi6Yk1f8mgu/4U5ZjNErcoWMIXni6SJK+Ov+D9vuAGhmZvwfqL6FQ== X-Received: by 2002:a17:907:3ea3:b0:aac:333:a0a1 with SMTP id a640c23a62f3a-ab2c3d3e817mr1696220466b.32.1736850887183; Tue, 14 Jan 2025 02:34:47 -0800 (PST) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c9060533sm614255366b.23.2025.01.14.02.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 02:34:46 -0800 (PST) From: Roger Pau Monne To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v2 1/3] xen/pci: do not register devices with segments >= 0x10000 Date: Tue, 14 Jan 2025 11:33:11 +0100 Message-ID: <20250114103315.51328-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250114103315.51328-1-roger.pau@citrix.com> References: <20250114103315.51328-1-roger.pau@citrix.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The current hypercall interface for doing PCI device operations always uses a segment field that has a 16 bit width. However on Linux there are buses like VMD that hook up devices into the PCI hierarchy at segment >=3D 0x1000= 0, after the maximum possible segment enumerated in ACPI. Attempting to register or manage those devices with Xen would result in errors at best, or overlaps with existing devices living on the truncated equivalent segment values. Note also that the VMD segment numbers are arbitrarily assigned by the OS, and hence there would need to be some negotiation between Xen and the OS to agree on how to enumerate VMD segments and devices behind them. Skip notifying Xen about those devices. Given how VMD bridges can multiplex interrupts on behalf of devices behind them there's no need for Xen to be aware of such devices for them to be usable by Linux. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Adjust commit message width to 75 columns. - Expand commit message. --- drivers/xen/pci.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c index 416f231809cb..08e82fd1263e 100644 --- a/drivers/xen/pci.c +++ b/drivers/xen/pci.c @@ -43,6 +43,13 @@ static int xen_add_device(struct device *dev) pci_mcfg_reserved =3D true; } #endif + + if (pci_domain_nr(pci_dev->bus) >> 16) { + dev_info(dev, + "not registering with Xen: invalid PCI segment\n"); + return 0; + } + if (pci_seg_supported) { DEFINE_RAW_FLEX(struct physdev_pci_device_add, add, optarr, 1); =20 @@ -149,6 +156,12 @@ static int xen_remove_device(struct device *dev) int r; struct pci_dev *pci_dev =3D to_pci_dev(dev); =20 + if (pci_domain_nr(pci_dev->bus) >> 16) { + dev_info(dev, + "not unregistering with Xen: invalid PCI segment\n"); + return 0; + } + if (pci_seg_supported) { struct physdev_pci_device device =3D { .seg =3D pci_domain_nr(pci_dev->bus), @@ -182,6 +195,12 @@ int xen_reset_device(const struct pci_dev *dev) .flags =3D PCI_DEVICE_RESET_FLR, }; =20 + if (pci_domain_nr(dev->bus) >> 16) { + dev_info(&dev->dev, + "unable to notify Xen of device reset: invalid PCI segment\n"); + return 0; + } + return HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_reset, &device); } EXPORT_SYMBOL_GPL(xen_reset_device); --=20 2.46.0