mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Naman Jain <namjain@linux.microsoft.com>
To: mhklinux@outlook.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, corbet@lwn.net, skhan@linuxfoundation.org,
	rdunlap@infradead.org, linux-kernel@vger.kernel.org,
	linux-hyperv@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH 1/1] Documentation: hyperv: Update docs for PCI pass-thru device support
Date: Tue, 3 Nov 2026 14:12:59 +0530	[thread overview]
Message-ID: <e7eacfc8-7bf1-4dde-b62a-607a490fdd06@linux.microsoft.com> (raw)
In-Reply-To: <20261101022257.52819-1-mhklinux@outlook.com>



On 11/1/2026 7:52 AM, Michael Kelley wrote:
> Add a section to the documentation describing the IRQ domain and IRQ chip
> hierarchy that is created for virtual PCI devices, including the
> differences on x86 and arm64, and the reasons for those differences.
> 
> In the context of the IRQ domain and chip hierarchies, describe how the
> CPU selected for effective affinity is spread across CPUs in the affinity
> masks. Again, account for the differences in x86 and arm64.
> 
> Finally, rework existing text on how MSI messages are composed. Provide
> an expanded section on the overall approach that Hyper-V takes to MSI
> messages. The section provides more context on the handling of MSI messages
> in the Hyper-V vPCI driver, and why it is structured the way it is.
> 
> Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> ---

<snip>

> +MSI Messages
> +------------
> +In a typical guest on KVM, the VMM traps guest writes to a vPCI
> +device's MSI/MSI-X registers/tables. The guest writes a virutal
> +message (with a guest APIC address and a guest vector), and VMM
> +emulation translates the message to program the physical device and
> +physical device interrupt remapping (IR) tables on the guest's
> +behalf. The guest never sees or handles the host-level MSI message.
> +
> +Hyper-V takes a different approach in which MSI/MSI-X register or
> +table writes are not trapped. The guest writes the device's MSI/MSI-X
> +registers/tables directly with a host-valid MSI message. The physical
> +IOMMU and its remapping table are still owned by the host, so the
> +guest must ask the host for the proper message.
> +

Could we distinguish MSI-X table writes from MSI configuration-space
writes here?

pci_write_msg_msi() programs the MSI address/data through
pci_write_config_*(), which goes through the Hyper-V config-space
access mechanism. As described in the existing "PCI Device Setup"
and "PCI config space access in a CoCo VM" sections, those accesses
trap to Hyper-V in normal VMs, or use explicit hypercalls in CoCo VMs.

The distinction seems to be that Hyper-V requires the guest to obtain
a host-valid MSI message explicitly over VMBus, rather than relying
on interception of guest MSI programming to establish the interrupt
mapping. That is separate from whether the programming accesses
themselves are trapped. We should probably make that distinction instead
of saying that both MSI and MSI-X writes are untrapped?

> +The "asking" is done by the .irq_compose_msi_msg function for the
> +"Hyper-V PCIe MSI" chip, which is hv_compose_msi_msg(). The
> +implementation requires sending a VMBus message to the Hyper-V host
> +and awaiting an interrupt indicating receipt of a reply message.
> +Since .irq_compose_msi_msg can be called with IRQ spin locks held, it
> +doesn't work to do the normal sleep until awakened by the interrupt.
> +Instead hv_compose_msi_msg() must send the VMBus message, and
> +poll for the completion message. As further complexity, the vPCI
> +device could be ejected/rescinded while the polling is in progress,
> +so this scenario must be detected as well. See comments in the code
> +regarding this very tricky area. A synchronous hypercall to get the
> +MSI message would be a much nicer interface, but the code makes do
> +with what's available.
> +
> +Once the host-valid MSI message is obtained, the guest must treat it
> +as a black-box that the guest does not interpret or modify. The only
> +valid guest action is to write it to the MSI/MSI-X registers/tables
> +using the .irq_chip_write_msi_msg function on the HV-PCI-MSIX-<PCIaddr>
> +chip. That function is pci_msi_domain_write_msg(), which calls
> +__pci_write_msi_msg().
> +
> +If the affinity of an IRQ changes, the steps must be
> +repeated. A new host-valid MSI message is requested via the
> +.irq_compose_msi_msg function and that message is written
> +to the MSI/MSI-X registers using the .irq_chip_write_msi_msg
> +function.

I don't think ordinary affinity changes require a new MSI message,
including with the companion arm64 spreading patch applied.

hv_pcie_init_dev_msi_info() installs irq_chip_set_affinity_parent
instead of the generic compose-and-write affinity handler.

On arm64, the new hv_pci_arm64_set_affinity() selects a CPU and passes
a single-CPU mask to the parent. gic_set_affinity() then updates the
SPI's GICD_IROUTER and effective affinity, without recomposing or
rewriting the device's MSI message.

Similarly, on x86, the new CPU/vector is communicated through the
Hyper-V unmask/retarget path using the existing MSI descriptor.

Could this paragraph describe updating the routing of the existing
message, rather than obtaining and programming a new one?

Regards,
Naman

> +
>   DMA
>   ---
>   By default, Hyper-V pins all guest VM memory in the host


      parent reply	other threads:[~2026-11-03  8:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01  2:22 Michael Kelley
2026-11-03  2:12 ` Daniel Pereira
2026-11-03  4:50   ` Michael Kelley
2026-11-03  8:42 ` Naman Jain [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7eacfc8-7bf1-4dde-b62a-607a490fdd06@linux.microsoft.com \
    --to=namjain@linux.microsoft.com \
    --cc=corbet@lwn.net \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®