From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 10AB826929; Fri, 30 May 2025 00:52:17 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id F084926989; Fri, 30 May 2025 00:52:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by atuin.qyliss.net (Postfix) with ESMTPS id 2CE2F26915 for ; Fri, 30 May 2025 00:52:11 +0000 (UTC) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-4a42cb03673so20214511cf.3 for ; Thu, 29 May 2025 17:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748566329; x=1749171129; darn=spectrum-os.org; h=content-transfer-encoding:autocrypt:cc:to:content-language:subject :from:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=S6sT12Nr6EWCqjJxLYxE1sVeggp3TnRCcH4gA4iJJiQ=; b=dNONF0cayi86o3JfIjxxePgub/bIWdjXCiq2QG0n5dB9gAJXtPt8dGzKDdeWDtE4Ft 4Q3Zo46OYhQPpjwdZvXuCht3TaD3Q05tRFXDOfod0EgRgzl1XEuNEQQc8R9tc/mC8Nw8 Qa0t+7MdURYplOuGCIx9SiHvf45ycQ9vyRknj7Hp3spehyAbyym/M3tHTQRR11ueBQmU nBfipl25Ke2DfLDzsxHVN1qTvVhNdFlmUrjYPoQBhcIt78AyaalC4SM80gL/CG6BtsGg bNoREcxft185qrCWYaq4Em/KtyYEyM9HeofJi7EveNYWL6KxAjL1AQ/0PRzVFwfjkkUS AtdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748566329; x=1749171129; h=content-transfer-encoding:autocrypt:cc:to:content-language:subject :from:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=S6sT12Nr6EWCqjJxLYxE1sVeggp3TnRCcH4gA4iJJiQ=; b=pv5YUVAizd0KqsAroRja63VWk2EH2mWcPRkeM+cG1/aj+VJQh1L7Bix84oP1Sn5c9S Z3kiW73dTHmtQ88LzKtCp9wSB2Ap8hxV9xkWhysVtYQROMBnjuSYu0oF4xYGPOpGPQee Mav29ig/YySau01lS+T9feAJT1tP8BXmX4kt/CFreUBPPAGaaYi1MXygGyYuMeBY3Wta ndJrS6ub7YIkDHQugHb1KYYtDDFk6feA4dtq9Hra894pGkWEvGodu9Izzd7RNtbEZ7Pn DNFXH1Mkju+g8cfXDp9KkUMFMTrfI78Ha2TYMCX+L83joe+dE9CRufAOFO9g031/TSRc omUA== X-Gm-Message-State: AOJu0Yx5omBVxy4nU33W0xIwuNLR58qTvoy4K46HOcYm5zHmdL3SxSPZ ldHWa0OPC8eRiHtwHsT3U190DbbCgFLtf5rdkSeRqSEdzn2OlnndyaLA X-Gm-Gg: ASbGncuKQgklA6cqMfu8tO6n7jKf1WOC+ck354b7EeniXIDc5p5m8KkcqK4tnxxh/R/ ipLIRwP8/uw/aErceRr5VXFjnyDewIeE2UwRRdZUAW1hYbOQphe6gwIawusjbpOjA6VVtD2Hq+s Aixz/BmyV2alF3ur7Spw8Ap93PU03r40J7X+VbHSsfeJt4bYc7INWPyALZ9+B5K4Lci8HLTSwbq xTkIov8fKZBnLVGGCuzLVRWsGvZ8EhJiOGixf3DuOBzS25BOuJjBQIha1oZ9un+RWplTMoPaVPD DM9I0pX1aSV/21N+6WNyqJgKmuLVuv5qasRCa7kbNcEAUfn8aF4MelIl X-Google-Smtp-Source: AGHT+IH8PdXE9Toe1RQ2qYBhXZyXPPJvffNf4HUX49mXoifH9Ue8zhdQlgKUIjpMulvNF4x6mhP3gQ== X-Received: by 2002:a05:622a:229f:b0:491:20d6:75ff with SMTP id d75a77b69052e-4a44005ae51mr27515401cf.31.1748566329140; Thu, 29 May 2025 17:52:09 -0700 (PDT) Received: from [10.138.10.6] ([89.187.178.201]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d09a0f8b61sm154815085a.26.2025.05.29.17.52.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 May 2025 17:52:08 -0700 (PDT) Message-ID: Date: Thu, 29 May 2025 20:52:07 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Demi Marie Obenour Subject: [PATCH] Add interrupt remapping support Content-Language: en-US To: virtio-comment@lists.linux.dev Autocrypt: addr=demiobenour@gmail.com; keydata= xsFNBFp+A0oBEADffj6anl9/BHhUSxGTICeVl2tob7hPDdhHNgPR4C8xlYt5q49yB+l2nipd aq+4Gk6FZfqC825TKl7eRpUjMriwle4r3R0ydSIGcy4M6eb0IcxmuPYfbWpr/si88QKgyGSV Z7GeNW1UnzTdhYHuFlk8dBSmB1fzhEYEk0RcJqg4AKoq6/3/UorR+FaSuVwT7rqzGrTlscnT DlPWgRzrQ3jssesI7sZLm82E3pJSgaUoCdCOlL7MMPCJwI8JpPlBedRpe9tfVyfu3euTPLPx wcV3L/cfWPGSL4PofBtB8NUU6QwYiQ9Hzx4xOyn67zW73/G0Q2vPPRst8LBDqlxLjbtx/WLR 6h3nBc3eyuZ+q62HS1pJ5EvUT1vjyJ1ySrqtUXWQ4XlZyoEFUfpJxJoN0A9HCxmHGVckzTRl 5FMWo8TCniHynNXsBtDQbabt7aNEOaAJdE7to0AH3T/Bvwzcp0ZJtBk0EM6YeMLtotUut7h2 Bkg1b//r6bTBswMBXVJ5H44Qf0+eKeUg7whSC9qpYOzzrm7+0r9F5u3qF8ZTx55TJc2g656C 9a1P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Z/rYZ9+5 1yDoUABoNdJNSGUYl+Yh9Pw9pE3Kt4EFzUlFZWbE4xKL/NPno+z4J9aWemLLszcYz/u3XnbO vUSQHSrmfOzX3cV4yfmjM5lewgSstoxGyTx2M8enslgdXhPthZlDnTnOT+C+OTsh8+m5tos8 HQjaPM01MKBiAqdPgksm1wu2DrrwUi6ChRVTUBcj6+/9IJ81H2P2gJk3Ls3AVIxIffLoY34E +MYSfkEjBz0E8CLOcAw7JIwAaeBT Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Message-ID-Hash: ORVHGHKVJVC4EHWX4UXUD42UMO6KMPRU X-Message-ID-Hash: ORVHGHKVJVC4EHWX4UXUD42UMO6KMPRU X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: devel@spectrum-os.org, Alyssa Ross X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This adds interrupt remapping to the virtio-IOMMU device. This is needed to support deprivileged userspace drivers on x86_64 and other platforms where interrupt remapping is the job of the IOMMU. It is not needed on AArch64 and must not be supported on that platform. --- device-types/iommu/description.tex | 70 +++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/device-types/iommu/description.tex b/device-types/iommu/description.tex index f8cbe88..0a3bcab 100644 --- a/device-types/iommu/description.tex +++ b/device-types/iommu/description.tex @@ -3,7 +3,8 @@ \section{IOMMU device}\label{sec:Device Types / IOMMU Device} The virtio-iommu device manages Direct Memory Access (DMA) from one or more endpoints. It may act both as a proxy for physical IOMMUs managing devices assigned to the guest, and as virtual IOMMU managing emulated and -paravirtualized devices. +paravirtualized devices. On some platforms, it is also responsible for +interrupt remapping. The driver first discovers endpoints managed by the virtio-iommu device using platform specific mechanisms. It then sends requests to create @@ -74,6 +75,13 @@ \subsection{Feature bits}\label{sec:Device Types / IOMMU Device / Feature bits} whether endpoints that are attached to a domain are in bypass mode. +\item[VIRTIO_IOMMU_F_IRQ_MAP_UNMAP (7)] + Interrupt remapping is available. This is architecture specific + and MUST NOT be negotiated on architectures such as AArch64 where + interrupt remapping is not handled by the IOMMU. If this feature + is negotiated, all interrupts from endpoints that are not in + bypass mode are initially disabled. + \end{description} \drivernormative{\subsubsection}{Feature bits}{Device Types / IOMMU Device / Feature bits} @@ -531,6 +539,66 @@ \subsubsection{MAP request}\label{sec:Device Types / IOMMU Device / Device opera range mapped with VIRTIO_IOMMU_MAP_F_WRITE but not VIRTIO_IOMMU_MAP_F_READ. +\subsubsection{IRQ MAP request}\label{sec:Device Types / IOMMU Device / Device operations / IRQ MAP request} + +\begin{lstlisting} +struct virtio_iommu_req_irq_map { + struct virtio_iommu_req_head head; + le32 domain; + le64 msi_address; + le32 msi_payload; + le32 vector_id; + le32 vcpu_id; + le32 flags; + u8 reserved[4]; + struct virtio_iommu_req_tail tail; +}; +\end{lstlisting} + +Map a host MSI to a guest MSI directed at the given vCPU. vCPUs range from 0 to +$2^{32} - 2$ inclusive. $2^{32} - 1$ is reserved and means ``no vCPU'', +effectively disabling the interrupt. Any previous mapping of the MSI is overwritten. + +This request takes effect immediately. It is the device's job to flush caches if +necessary. However, any interrupts that are pending remain pending. + +The set of permitted values for \field{msi_address} and \field{msi_payload} +is architecture-dependent. Invalid values include, but are not limited to: + +\begin{itemize} +\item Values that are not in the architecture-dependent range of MSI addresses. +\item Values that have bits set that are ignored by the physical IOMMU. +\item Values that have reserved bits set. +\item Values that would cause the MSI to not be subject to interrupt remapping, + and which the host must therefore block for its own security. +\end{itemize} + +This request is only available when VIRTIO_IOMMU_F_IRQ_MAP_UNMAP has been negotiated. + +\drivernormative{\paragraph}{IRQ MAP request}{Device Types / IOMMU Device / Device operations / IRQ MAP request} + +The driver SHOULD set undefined \field{flags} bits to zero. + +The driver SHOULD NOT send IRQ MAP requests on a bypass domain. + +The driver SHOULD NOT choose values for \field{msi_address} or \field{msi_payload} +that are invalid for the CPU architecture. + +The driver SHOULD NOT choose a \field{vcpu_id} that corresponds to a vCPU that does +not exist and is not $2^{32} - 1$. + +\devicenormative{\paragraph}{IRQ MAP request}{Device Types / IOMMU Device / Device operations / IRQ MAP request} + +If \field{msi_address} or \field{msi_payload} is invalid for the CPU architecture, +the device SHOULD reject the request and set \field{status} to VIRTIO_IOMMU_S_INVAL. + +If \field{domain} does not exist, the device SHOULD reject the request and +set \field{status} to VIRTIO_IOMMU_S_NOENT. + +If \field{vcpu_id} does not correspond to a CPU that is running in the guest +and is not $2^{32} - 1$, the device SHOULD reject the request and set +\field{status} to VIRTIO_IOMMU_S_NOENT. + \subsubsection{UNMAP request}\label{sec:Device Types / IOMMU Device / Device operations / UNMAP request} \begin{lstlisting} -- Sincerely, Demi Marie Obenour