Re: [RFC PATCH v1 34/38] coco: guest: arm64: Validate mmio range found in the interface report

Bjorn Helgaas
2025-08-04T22:31:04Z

On Mon, Jul 28, 2025 at 07:22:11PM +0530, Aneesh Kumar K.V (Arm) wrote:
> This starts the sequence to transition the realm device to the TDISP RUN
> state by writing 1 to 'tsm/accept'.

> +++ b/drivers/virt/coco/arm-cca-guest/rsi-da.c

> +int rsi_update_interface_report(struct pci_dev *pdev, bool validate)
> +{
> + int ret;
> + struct resource *r;
> + int msix_tbl_bar, msix_pba_bar;
> + unsigned int range_id;
> + unsigned long mmio_start_phys;
> + unsigned long mmio_flags = 0; /* non coherent, not limited order */
> + struct pci_tdisp_mmio_range *mmio_range;
> + struct pci_tdisp_device_interface_report *interface_report;
> + struct cca_guest_dsc *dsm = to_cca_guest_dsc(pdev);
> + int vdev_id = (pci_domain_nr(pdev->bus) << 16) |
> + PCI_DEVID(pdev->bus->number, pdev->devfn);
> +
> +
> + interface_report = (struct pci_tdisp_device_interface_report *)dsm->interface_report;
> + mmio_range = (struct pci_tdisp_mmio_range *)(interface_report + 1);
> +
> +
> + msix_tbl_bar = get_msix_bar(pdev, PCI_MSIX_TABLE);
> + msix_pba_bar = get_msix_bar(pdev, PCI_MSIX_PBA);
> +
> + for (int i = 0; i < interface_report->mmio_range_count; i++, mmio_range++) {
> +
> + /*FIXME!! units in 4K size*/

I guess you intend to fix this?

> + /* no secure interrupts */
> + if (msix_tbl_bar != -1 && range_id == msix_tbl_bar) {
> + pr_info("Skipping misx table\n");
> + continue;
> + }
> +
> + if (msix_pba_bar != -1 && range_id == msix_pba_bar) {
> + pr_info("Skipping misx pba\n");

s/misx/MSI-X/ (twice)
s/pba/PBA/