Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] pci/p2pdma: numerical x86_vfm comparison matches older unsupported CPUs
--

commit 8df450ad902e18b3a50517392110d5d4750ef685
Author: Pavel Popov <[email protected]>

PCI/P2PDMA: Allow P2PDMA in Hyper-V guests on Intel hosts

Peer-to-Peer DMA (P2PDMA) between two devices requires either a shared
upstream bridge or a host bridge matching pci_p2pdma_whitelist[]. In
Hyper-V guests, each passthrough device appears in a PCI domain of its
own without a host bridge device. Consequently, P2PDMA checks evaluate
endpoint Device IDs against the host bridge whitelist, causing P2PDMA
requests to fail regardless of host support.

> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index d96f44d0738a8..76fadfbc1814a 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -544,7 +544,8 @@ static bool hypervisor_supports_p2pdma(void)
>       /* Hypervisor hides host topology, allow p2pdma on Skylake and newer */
>       if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
>           boot_cpu_data.x86_vfm >= INTEL_SKYLAKE_X &&

[Severity: High]
Does this numerical comparison correctly filter out older, unsupported CPUs?

Since x86_vfm encodes the model number in the lower bits, older architectures
like Broadwell-D (model 0x56) or Atom Goldmont (model 0x5C) evaluate to being
numerically greater than INTEL_SKYLAKE_X (model 0x55).

Because Broadwell-generation CPUs do not support cross-host-bridge P2PDMA,
bypassing the check in the guest will allow transactions the host physical
hardware cannot route, which can result in PCIe Unsupported Requests and
potentially lead to AER panics or device aborts.

Is there a better way to check for supported architectures rather than a
strict numeric comparison of the VFM?

> -         hypervisor_is_type(X86_HYPER_VMWARE))
> +         (hypervisor_is_type(X86_HYPER_VMWARE) ||
> +          hypervisor_is_type(X86_HYPER_MS_HYPERV)))
>               return true;
>  #endif
>

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to