Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp29720rdb; Thu, 1 Feb 2024 00:40:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwZvIsi6C59RwG7D/CYp2WiH8lxFQFPb4OfVH5M9kLLOnjbbnhH6lAydu6PbLSZootxc0N X-Received: by 2002:a05:6402:2297:b0:55f:57b4:89dc with SMTP id cw23-20020a056402229700b0055f57b489dcmr3584482edb.19.1706776825271; Thu, 01 Feb 2024 00:40:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706776825; cv=pass; d=google.com; s=arc-20160816; b=kFBIsyBbmJQ/bijCnXkNHCySaUoTI+f1SaP3gA2aqNmHIYkMklTuk+NpyPSnZof6/c JgJOJ+sglqpoDPPL6dawf5tfXVqBoGQ4nFEKTVku9Jd1w5Te/o2MBVrovnTPQ8uHos6L tuI06Lx7SmydjfG9UEc2ptNUK5/Ohkr1xzWKETOPAst1NH0xUeAnd4cVpxnSXGJJpo1h eUdniOHnkAXMiocx11gQgZrG4+UcX8Imls/5gIbvg5/iOjHsohl80Rm7T9q7GaKzriZL KhKmFYMDFylBHqfqNZyBLV/diC82/vbxx1c1cJ7W1yeioHutHgwFq0EKytVocDxwTy/9 a9uA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Mmx7Ge44ylq+xRaE54Mmi5lsueMZNlgqIRQYM/UNpUU=; fh=uhZKHCCVVjyQphmBxvCj75y2wpGky7nYeci+CcN3ZSk=; b=Zndq5KwfQklDQfPT4gtF7drXvDCFDOeQ9gP19Qo2DwSAtiZODlt76zGhrzRtAz8xHC FNdtJf5yB3SsRRjg9pyvgVIJb/LYO5FJF4m1yetmNVobk6G4lnFFjYziB+Bwa7Gl7Emr PpiAq3yQJoX9xCcpmCs76GOms0KwLVw51VaLR8gkORmvtIaAQPPNBH3u16xJObRMAGI/ B47chqbS++IyhWEvLtNnyOpwvUK3/i0Dpg+x5K41rp0Bn+00H7eKkuCG42k0KuqDDPPw 52rzYQJny1TQ0NDgAEsbNzq+rljkjkU2uLe+MyoKhe18boIUAOLyzVmJn2rOaHq6NFCh 9QDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b="FTc9W/U0"; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-47788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47788-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com X-Forwarded-Encrypted: i=1; AJvYcCUqTm5o3vVNGEFx8Ea7W7h3esdsDpaYYoHAC6L/ykyEkWkp7ULLi/uP1TLLmpsJvt7pLwOItdhkrrFk6nvVMFUnKGxby8fMeaUphai8Fw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fi21-20020a056402551500b005569cab2645si6934291edb.5.2024.02.01.00.40.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 00:40:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b="FTc9W/U0"; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-47788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47788-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D4BE31F22A9A for ; Thu, 1 Feb 2024 08:40:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29C1D15AACB; Thu, 1 Feb 2024 08:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="FTc9W/U0" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 496FB15A498 for ; Thu, 1 Feb 2024 08:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706776794; cv=none; b=odry9uygpNEc0Al+tnRuaQR6lUAN+Xhih5XuVy3uZ4yCc7PpXkySVE1XMpq2vREcw6F+EMNAj9CF8PmLEU55HGr/848fZpZbSwCLpRQL/82IO0atC4mP1+Wtn/1ke7MREu5YszZXgBOTO5hp6lSvfMcgo9AQeScM7VY0eVET0Mo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706776794; c=relaxed/simple; bh=Y19IbEX3FXAZ7R2Z+dmkGvLzD3cE4MKEu+r+iHhHUaU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cxh67V/kRFoT/W/Xz+6S/K5+L/bVgBWNTg6iKaviKAlwKG4kdwyFTAfF+KdgBrUv0VUbqzi2D3omItlMmC/HUXphzFqZkTabwhzLAxW9qkOUz6JXFztYaS4hYNqOkhqNVlEuTF42IfoWhVI4UAkYEoWNfw/g8vJcf/KxOve9YrU= 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=FTc9W/U0; arc=none smtp.client-ip=209.85.128.51 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 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40ef6da20feso3123535e9.0 for ; Thu, 01 Feb 2024 00:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1706776790; x=1707381590; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Mmx7Ge44ylq+xRaE54Mmi5lsueMZNlgqIRQYM/UNpUU=; b=FTc9W/U0K6Iz1YQa0AFdLfWmj+AzqhUx3NaSA666dcrUnhZCzPDhZyMpDp6DmkAsHH CXdHxaC4SS3UocOmv6B5DOrLjbGKXDYFzibbitlteovquDPxWfD7JmavCadrXmdKn799 mD31YISgaWqEJNW2xjLkBk0EP8lg8cNJHmWTc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706776790; x=1707381590; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mmx7Ge44ylq+xRaE54Mmi5lsueMZNlgqIRQYM/UNpUU=; b=CLWrp/n7bVkFchY2ifNfWhEaOodfK9DcONuAnnFARicf8g83PGn5zMgPMp9LiqPKA1 Kcay//qUfP5/JoHKIZmIuW7Lq2kvAw1+qYSOrVS1pcfbCdVM6YNojgffVbIZXh0sqL0A E78JEqEDsM4uZAZ0BLtZhW6YgOhGinhFsCimIVDkKiyu61rhgG7dke5kR7OkhS3h5QZj 6tpCnm4ojnMJ7gzmV3syuS133X45Q05ML27XYLsl9094nMa1q1P4F69a8FJpzrbPTvSA 1CCK551fHE4uvGinROsYzTqTudgYKTxVEsNyBEo6YgdRVj3eGBpvNVIJieEANe8J5sRW qQxQ== X-Gm-Message-State: AOJu0Yyi+cg6CbZll/7WV76b9RxxdoLrxfpjeR/+O9YNATQ0Lt1KwBF0 Y8BFGGp7kACSJNu7yGYdpSWBxfzYj7MeoNhngp3bKjichO6GF0frvU/+yZhGD5I= X-Received: by 2002:a05:600c:1c9a:b0:40e:f972:9901 with SMTP id k26-20020a05600c1c9a00b0040ef9729901mr3736599wms.4.1706776790540; Thu, 01 Feb 2024 00:39:50 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXDCVhgfb0o24SN4Wqn/FgnWkJYm9QCYpD/ESYbFl4VjZTFA1lzb2EecVom9k5fEwfP12Y/uppYGzcffTRrzp/icQGv3HjGZpMbEHP1O0bmMpkENMmh/i5WpK5zIezuae0Uf4YZJFj/GIIpi8YgFkSb+ve1+U2VK0dRTY3tLYI0EKqJsftwJxoWx8X1Knfb8tnC76BuOBql1srwLsN7vGSl2wcbMkEqp6rlaRVuZC9dj8g2KKow5t0/nsSr8nJZlls/92TMW3QXD5Uc/pJNuCeeBPj2+nM9/cIi4ZkYdMgG2c7Y3W/85xx3atQ7NFnga1NjCNQMDhJbuqruZaGAYHg7aAFbNfLKQC7xPnI5wPmFp1E3D2qFqwlvqSIyLUOZrN5YudkUPsFIPL0Qk1faQOXY4FjKqsnSsDMGI58pczPV4freLpRkOBnJ+zblZe0frUgjrALk1NdUEoPj3Y9vKQ+JxYOJfr1AnKZs/vkDbp6joC8yuId8ZmXn+YeGnhlWwAZhccdcXntd3R0= Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id g10-20020a05600c4eca00b0040fbba734f3sm1082225wmq.34.2024.02.01.00.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 00:39:50 -0800 (PST) Date: Thu, 1 Feb 2024 09:39:49 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Bjorn Helgaas Cc: "Chen, Jiqian" , "Rafael J . Wysocki" , Len Brown , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Boris Ostrovsky , Bjorn Helgaas , "xen-devel@lists.xenproject.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "Hildebrand, Stewart" , "Huang, Ray" , "Ragiadakou, Xenia" Subject: Re: [RFC KERNEL PATCH v4 3/3] PCI/sysfs: Add gsi sysfs for pci_dev Message-ID: References: <20240131190014.GA593286@bhelgaas> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240131190014.GA593286@bhelgaas> On Wed, Jan 31, 2024 at 01:00:14PM -0600, Bjorn Helgaas wrote: > On Wed, Jan 31, 2024 at 09:58:19AM +0100, Roger Pau Monné wrote: > > On Tue, Jan 30, 2024 at 02:44:03PM -0600, Bjorn Helgaas wrote: > > > On Tue, Jan 30, 2024 at 10:07:36AM +0100, Roger Pau Monné wrote: > > > > On Mon, Jan 29, 2024 at 04:01:13PM -0600, Bjorn Helgaas wrote: > > > > > On Thu, Jan 25, 2024 at 07:17:24AM +0000, Chen, Jiqian wrote: > > > > > > On 2024/1/24 00:02, Bjorn Helgaas wrote: > > > > > > > On Tue, Jan 23, 2024 at 10:13:52AM +0000, Chen, Jiqian wrote: > > > > > > >> On 2024/1/23 07:37, Bjorn Helgaas wrote: > > > > > > >>> On Fri, Jan 05, 2024 at 02:22:17PM +0800, Jiqian Chen wrote: > > > > > > >>>> There is a need for some scenarios to use gsi sysfs. > > > > > > >>>> For example, when xen passthrough a device to dumU, it will > > > > > > >>>> use gsi to map pirq, but currently userspace can't get gsi > > > > > > >>>> number. > > > > > > >>>> So, add gsi sysfs for that and for other potential scenarios. > > > > > > >> ... > > > > > > > > > > > > > >>> I don't know enough about Xen to know why it needs the GSI in > > > > > > >>> userspace. Is this passthrough brand new functionality that can't be > > > > > > >>> done today because we don't expose the GSI yet? > > > > > > > > > > I assume this must be new functionality, i.e., this kind of > > > > > passthrough does not work today, right? > > > > > > > > > > > >> has ACPI support and is responsible for detecting and controlling > > > > > > >> the hardware, also it performs privileged operations such as the > > > > > > >> creation of normal (unprivileged) domains DomUs. When we give to a > > > > > > >> DomU direct access to a device, we need also to route the physical > > > > > > >> interrupts to the DomU. In order to do so Xen needs to setup and map > > > > > > >> the interrupts appropriately. > > > > > > > > > > > > > > What kernel interfaces are used for this setup and mapping? > > > > > > > > > > > > For passthrough devices, the setup and mapping of routing physical > > > > > > interrupts to DomU are done on Xen hypervisor side, hypervisor only > > > > > > need userspace to provide the GSI info, see Xen code: > > > > > > xc_physdev_map_pirq require GSI and then will call hypercall to pass > > > > > > GSI into hypervisor and then hypervisor will do the mapping and > > > > > > routing, kernel doesn't do the setup and mapping. > > > > > > > > > > So we have to expose the GSI to userspace not because userspace itself > > > > > uses it, but so userspace can turn around and pass it back into the > > > > > kernel? > > > > > > > > No, the point is to pass it back to Xen, which doesn't know the > > > > mapping between GSIs and PCI devices because it can't execute the ACPI > > > > AML resource methods that provide such information. > > > > > > > > The (Linux) kernel is just a proxy that forwards the hypercalls from > > > > user-space tools into Xen. > > > > > > But I guess Xen knows how to interpret a GSI even though it doesn't > > > have access to AML? > > > > On x86 Xen does know how to map a GSI into an IO-APIC pin, in order > > configure the RTE as requested. > > IIUC, mapping a GSI to an IO-APIC pin requires information from the > MADT. So I guess Xen does use the static ACPI tables, but not the AML > _PRT methods that would connect a GSI with a PCI device? Yes, Xen can parse the static tables, and knows the base GSI of IO-APICs from the MADT. > I guess this means Xen would not be able to deal with _MAT methods, > which also contains MADT entries? I don't know the implications of > this -- maybe it means Xen might not be able to use with hot-added > devices? It's my understanding _MAT will only be present on some very specific devices (IO-APIC or CPU objects). Xen doesn't support hotplug of IO-APICs, but hotplug of CPUs should in principle be supported with cooperation from the control domain OS (albeit it's not something that we tests on our CI). I don't expect however that a CPU object _MAT method will return IO APIC entries. > The tables (including DSDT and SSDTS that contain the AML) are exposed > to userspace via /sys/firmware/acpi/tables/, but of course that > doesn't mean Xen knows how to interpret the AML, and even if it did, > Xen probably wouldn't be able to *evaluate* it since that could > conflict with the host kernel's use of AML. Indeed, there can only be a single OSPM, and that's the dom0 OS (Linux in our context). Getting back to our context though, what would be a suitable place for exposing the GSI assigned to each device? Thanks, Roger.