Message ID | 20240924162359.1390487-7-edgar.iglesias@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xen/arm: Add Virtio-PCI for dom0less on ARM | expand |
On Tue, 24 Sep 2024, Edgar E. Iglesias wrote: > From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> > > Add a background PCI ECAM mmio region always reading as all ones. > This indicates to the OS that there are no PCI devices on the bus. > Once the device-model's IOREQ client connects, the OS can rescan > the bus and find PV and emulated devices. > > This avoids a race where domU's come up before the device models, > causing domU to crash into a data-abort when accessing ECAM. > > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> > --- > xen/arch/arm/dom0less-build.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c > index dab24fa9e2..bc5285e7fa 100644 > --- a/xen/arch/arm/dom0less-build.c > +++ b/xen/arch/arm/dom0less-build.c > @@ -1015,6 +1015,16 @@ static int __init construct_domU(struct domain *d, > kinfo.virtio_pci.mem.base = GUEST_VIRTIO_PCI_MEM_BASE; > kinfo.virtio_pci.pf_mem.base = GUEST_VIRTIO_PCI_PREFETCH_MEM_BASE; > } > + > + /* > + * Register a background PCI ECAM region returning ~0. This indicates > + * to the OS that there are no PCI devices on the bus. Once an IOREQ > + * client connects, the OS can rescan the bus and find devices. > + */ > + register_mmio_bg_handler(d, true, &mmio_read_const_writes_ignored, > + kinfo.virtio_pci.ecam.base, > + GUEST_VIRTIO_PCI_ECAM_SIZE, > + (void *) ULONG_MAX); > } I think GUEST_VIRTIO_PCI_ECAM_SIZE should be added to the description of virtio-pci-ranges in patch #3 to make it clear. Also any other "size" too. The ULONG_MAX -> void* -> uintptr_t -> register_t conversion works OK on both Xen 64-bit and 32-bit as far as I can tell, so: Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index dab24fa9e2..bc5285e7fa 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -1015,6 +1015,16 @@ static int __init construct_domU(struct domain *d, kinfo.virtio_pci.mem.base = GUEST_VIRTIO_PCI_MEM_BASE; kinfo.virtio_pci.pf_mem.base = GUEST_VIRTIO_PCI_PREFETCH_MEM_BASE; } + + /* + * Register a background PCI ECAM region returning ~0. This indicates + * to the OS that there are no PCI devices on the bus. Once an IOREQ + * client connects, the OS can rescan the bus and find devices. + */ + register_mmio_bg_handler(d, true, &mmio_read_const_writes_ignored, + kinfo.virtio_pci.ecam.base, + GUEST_VIRTIO_PCI_ECAM_SIZE, + (void *) ULONG_MAX); } rc = dt_property_read_string(node, "xen,enhanced", &dom0less_enhanced);