From nobody Wed Feb 5 15:55:54 2025 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 F0F411D63DE for ; Tue, 14 Jan 2025 10:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736850892; cv=none; b=bTgvwSdC7L/d3QtpqNV6WYG2dRJuSQ7KsN4GTLYC+GuAj/U5N+uJOxWJKXyOdviSMbjjLq3v2pxOt7NRfgbss33sVodgytocxOtKMAOG4eLwB/JEvpp0PmCMhCS4rUIrdNVk1rnwKrIL2PK9ViZT4vt1er0BptJ6kjEC2A+a0+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736850892; c=relaxed/simple; bh=VSqmcVBfwXIY69B6YqMhcuiidU9hF5xOgQJpsgmErXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L+DnL4wSbt0ggDKT90D0o/mXQ87eqkpuj8nUNRVZcuo98ArJ84/jEnWDs9wcljdNuBfQmZLNsGht9JN6vsb0WLCjmtILhLVeJvt4OL0fnKnCB2X7IdG8mv+HFhpV7/WGiQyjOde1uf28as3VqMmkKhaKZPdr6shbzHHIfPrI85k= 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=jJySU+1K; arc=none smtp.client-ip=209.85.218.54 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="jJySU+1K" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-aa67ac42819so765791366b.0 for ; Tue, 14 Jan 2025 02:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1736850889; x=1737455689; 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=8aKUOtOG9BVgReGI+Nw2NzmnaZPU8conWgd+JDzRbKo=; b=jJySU+1KCSAaJcLXDvlC0zF7jGDof+k0ld6Ex7CHTEhONmyml9pp2Fvqyl/oOl5bs2 HKboPPde3o2hSvv+jhcTWf/eoHF+sLsQpTvssqJPjNKrCuHdAxASCUqjj/6JEfyJ+pqm 0ssLfkTHOIRHZp/4S0BcrOtq2YSuXOGiYVCy8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736850889; x=1737455689; 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=8aKUOtOG9BVgReGI+Nw2NzmnaZPU8conWgd+JDzRbKo=; b=i+GUeiN5Ce3hdnHdtAxe2dhL2aph7PXqnZgFEMshS+nXTZdHFxWM75X/Oot8QqCI/7 80Fit17kb7b1PTTcuUKfdDDBGOv6WWyxj3Iy18u1VgN9dSpg1ZTUbJY+2dLhTUnK2OiU P2eayQLt9wXTVH1URLbFEUzTBmBuQOQ3vmf4axOVNlxc+0e6z5XGfhDE2BoHtyWRVyqa RfUMuiVnHebK0hyhjMzNxUOA93PwtZo5KNKtFqaBnYMoIHL4aAivuMEnIJ1c2wdDl+6w JfGw6e0i0N2bGAysvjg2tGiPZMFeBvl7bLxGvK+qxV04ITc99MOU7wKAQ9FeRj+GP34Y l1Hg== X-Gm-Message-State: AOJu0YxgT0q+JaHUb0TpdUjLCbkKjSS1+3GY1fjZGignKFjeh1LXczjx qzqq+2U16B0TfhDXiayxSQQ4PwHb5PzEsV6mLLVPcgU9yJVPv9Kp1Mnnsw/jpwGSlgXSR2RPFuo f X-Gm-Gg: ASbGncvBmwj1b49qUjn6UU6T8buoa/tVeNp2P+8ztmCV440b7VwjNWZzuzt9PYAplY5 xS8nqei6G8qsTrm/4BrqxPUAgWS7ZHYbrz6Yh+Zw0ONzkncVGHKzGc5EHea5nifG+YxgIacU7uV XM4+fyd0IR3nmi6hP/t9x+O2YsxA3r/A4YWrRT0c/kXHbwnw5Fl5Qj7mDYdHaxDvch1ytiWsn9F 9MGHWTBYQFcbgHJEBkDl75nV0w5N53GFaHwsaZAp5Tuu8owr4YOayC2lQTo5+5hjYM= X-Google-Smtp-Source: AGHT+IHu5De2z/QFEQRsmLROwHRAnH4F5r3sr8PBreqTBE5z0L97HWAie9gr7imKD5uPM/cH1y3q+A== X-Received: by 2002:a17:906:4fcb:b0:ab2:fefe:7156 with SMTP id a640c23a62f3a-ab2fefe94f8mr1052272666b.43.1736850889114; Tue, 14 Jan 2025 02:34:49 -0800 (PST) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c913605csm608116266b.82.2025.01.14.02.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 02:34:48 -0800 (PST) From: Roger Pau Monne To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-pci@vger.kernel.org Cc: Roger Pau Monne , Nirmal Patel , Jonathan Derrick , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas Subject: [PATCH v2 2/3] vmd: disable MSI remapping bypass under Xen Date: Tue, 14 Jan 2025 11:33:12 +0100 Message-ID: <20250114103315.51328-3-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 MSI remapping bypass (directly configuring MSI entries for devices on the VMD bus) won't work under Xen, as Xen is not aware of devices in such bus, and hence cannot configure the entries using the pIRQ interface in the PV case, and in the PVH case traps won't be setup for MSI entries for such devices. Until Xen is aware of devices in the VMD bus prevent the VMD_FEAT_CAN_BYPASS_MSI_REMAP capability from being used when running as any kind of Xen guest. The MSI remapping bypass is an optional feature of VMD bridges, and hence when running under Xen it will be masked and devices will be forced to redirect its interrupts from the VMD bridge. That mode of operation must always be supported by VMD bridges and works when Xen is not aware of devices behind the VMD bridge. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v1: - Add xen header. - Expand comment. --- drivers/pci/controller/vmd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 264a180403a0..33c9514bd926 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -17,6 +17,8 @@ #include #include =20 +#include + #include =20 #define VMD_CFGBAR 0 @@ -965,6 +967,23 @@ static int vmd_probe(struct pci_dev *dev, const struct= pci_device_id *id) struct vmd_dev *vmd; int err; =20 + if (xen_domain()) + /* + * Xen doesn't have knowledge about devices in the VMD bus + * because the config space of devices behind the VMD bridge is + * not known to Xen, and hence Xen cannot discover or configure + * them in any way. + * + * Bypass of MSI remapping won't work in that case as direct + * write by Linux to the MSI entries won't result in functional + * interrupts, as it's Xen the entity that manages the host + * interrupt controller and must configure interrupts. + * However multiplexing of interrupts by the VMD bridge will + * work under Xen, so force the usage of that mode which must + * always be supported by VMD bridges. + */ + features &=3D ~VMD_FEAT_CAN_BYPASS_MSI_REMAP; + if (resource_size(&dev->resource[VMD_CFGBAR]) < (1 << 20)) return -ENOMEM; =20 --=20 2.46.0