Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1851861rdb; Wed, 31 Jan 2024 11:00:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiMjismhtsMWEN2UJygw+Cf6jPwy1sRieva1qGhfS9cACi8XqK3rCUopY7NfrK6fzBgLzP X-Received: by 2002:a05:6512:708:b0:511:1ed1:e1a9 with SMTP id b8-20020a056512070800b005111ed1e1a9mr210068lfs.56.1706727627771; Wed, 31 Jan 2024 11:00:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706727627; cv=pass; d=google.com; s=arc-20160816; b=JHY4esLW5MyyDa+Fv7vYqkTCQXjKcIoDZtMILfID6tqpy6dzFixt6yMD4A7cUu82y9 iLk/OaF9Zd82pLo/7jaG/VedbsxKL4Hhw5Dlonr1JOOxmNBEAjJErxaxSCQN7MP35dJF XpVxmiF6Q2QC1s7/IgYbSZN5xmrFzX0Ac+aztnGzPrGsPPZOVVtcO+K/MLS+uxfU44SR L4M2Ec4bjYt7SBHacImxQeEz8lHrVrYmsuzt84nQqHW18P1dboqx+FsmI+q0+AMfV2s7 U5dybB4lUDPVORI+WqXmO/tlbPKDrCrxEIWheKXhSCyIbJcU3ncv4mtqQSO13EC80BpH hXOw== 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 :message-id:subject:cc:to:from:date:dkim-signature; bh=aC3PLMn2/nLlK3CJarGZ/pJAt+yk5Rw0ifAB+Wo6Olk=; fh=ok0g4CtGKQVkaxGi6nRRANd2gzax0OmKKZqTjvbbUjg=; b=ghMdUz21ILnYbpBlu0/cxwnVipmSEgwfVB9Fx5MTPOu1384+1xAwgCn4vOzU1FmL+k JpA7vcJoSnD9GdRb1MqsidHkvPNzPQafaBgy4ifuEWptUyuRUL0s59ILFwsS02b4OEF+ KKO+q4fZwVuGiu5WXi6wH6kBT7lkf4DZTmQzyRpSm/kLKwWL6dV0PEzOB8+aVzezwhJX gqfp76TfsberKs1xlsqBe6fig5C/7bhk6lhH+d0hsXE5Sx78JhOfljXNr6dKiFxYeEUa FXrVxoQMubuRXwz8THDldShqnOiZ9yfV1PBnkJ3abUfkNqzDIZ0S7LZ/n+PX1yi3R6CB F6ZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SIRJHCGN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWildNRaJP00xs9ov/J/PKUG60lTrXTgK+tKxQ0TqtdFkSwSYen0fz1pRPsh2F1zJjbYb/aHxa+5dN/5MNNg4h/GRRC45181rNHzkccIA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n3-20020a170906b30300b00a367805de74si843995ejz.711.2024.01.31.11.00.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 11:00:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46996-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=@kernel.org header.s=k20201202 header.b=SIRJHCGN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 3687A1F234C2 for ; Wed, 31 Jan 2024 19:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D27043715E; Wed, 31 Jan 2024 19:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SIRJHCGN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E639333986; Wed, 31 Jan 2024 19:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706727617; cv=none; b=e/3gufGBzG+B/JKMelw3XjnXaq17rpGrczVrOX1twQEy1Fzchea43qxHb28D19KeWEQB8HBUPPJCXQsA2yPTamtIp8sGUMq0ZSV5vWZos8WZGDVL/HxjtAmyo/SpdIJWfSqhsxBtIYe7h/jcr+NvrdSYTSWLdL0YMkmusafEGjI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706727617; c=relaxed/simple; bh=RZdHkRM3P7+WME/mIEGs7U7h1w50IFiQNWO97QIu6Z4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=G4HJwACEeHLyWJSoq9kkL5Bl+Y1hE0D282DkNGTS2LXAf5PHdu04Bn3diTZLU0UbD5o0FSlHTVz/aweeVg7zrPADpETUCJKtFUSaitTZ2cJ8bobY1MG4Xshafox93Z3wfDqGO0nnvP52VYY7Gazb92E986jWphz+8FKKK5qWPuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SIRJHCGN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02AACC433C7; Wed, 31 Jan 2024 19:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706727616; bh=RZdHkRM3P7+WME/mIEGs7U7h1w50IFiQNWO97QIu6Z4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=SIRJHCGNDMqwVTzRAiLrMLdW+dkYsjK+l0LHXCGERVCfoMi4e2t93JIYx850Va7QT BGvQ2bGkqPTQRCl08dsckmMG7/8X12XOBXbK/ovMyyVPfJWNUVnHe4dp7gy6ykv8CN bbmRt1hMy9UMLho79aKU5ClxkjxcbodVDj4H68/s0G4OCEb5EFsiQ6G/TjsjcS9XwS 0JDjS+avkmcF/DbbTUZyvaT110hm0lLajDCvJQVQb3ZcwFKSKf215b+9OYbl+q+WsI O7PdE1/KIhQ2AvACX37JV3KKiBwj+QSeRJjr5YGhPc8ajcZCnRUiVvuGrGs5L+oyeo DyWkc5iLaAjQg== Date: Wed, 31 Jan 2024 13:00:14 -0600 From: Bjorn Helgaas To: Roger Pau =?utf-8?B?TW9ubsOp?= 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: <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: 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? 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? 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. Bjorn