[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v1 3/6] xen/arm: create dom0less virtio-pci DT node
On 9/24/24 19:55, Stefano Stabellini wrote: > On Tue, 24 Sep 2024, Edgar E. Iglesias wrote: >> diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c >> index 09b65e44ae..dab24fa9e2 100644 >> --- a/xen/arch/arm/dom0less-build.c >> +++ b/xen/arch/arm/dom0less-build.c >> @@ -744,11 +934,24 @@ static int __init alloc_xenstore_evtchn(struct domain >> *d) >> return 0; >> } >> >> +static u64 combine_u64(u32 v[2]) > > Let's make this a static inline or a macro. I can't believe we don't > have one already. We have dt_read_number(). You'd need to use it with dt_get_property(). In this case, it might look something like: __be32 *val = dt_get_property(node, "virtio-pci-ranges", &len); /* TODO: check len */ ...ecam.base = dt_read_number(&val[0], 2); ...mem.base = dt_read_number(&val[2], 2); ...pf_mem.base = dt_read_number(&val[4], 2); >> +{ >> + u64 v64; >> + >> + v64 = v[0]; >> + v64 <<= 32; >> + v64 |= v[1]; >> + return v64; >> +} >> + >> static int __init construct_domU(struct domain *d, >> const struct dt_device_node *node) >> { >> struct kernel_info kinfo = KERNEL_INFO_INIT; >> const char *dom0less_enhanced; >> + const char *virtio_pci; >> + /* virtio-pci ECAM, MEM, PF-MEM each carrying 2 x Address cells. */ >> + u32 virtio_pci_ranges[3 * 2]; >> int rc; >> u64 mem; >> u32 p2m_mem_mb; >> @@ -779,6 +982,41 @@ static int __init construct_domU(struct domain *d, >> >> kinfo.vpl011 = dt_property_read_bool(node, "vpl011"); >> >> + rc = dt_property_read_string(node, "virtio-pci", &virtio_pci); >> + if ( !rc ) >> + { >> + if ( !strcmp(virtio_pci, "enabled") ) >> + kinfo.virtio_pci.mode = VIRTIO_PCI; >> + else if ( !strcmp(virtio_pci, "grants") ) >> + kinfo.virtio_pci.mode = VIRTIO_PCI_GRANTS; >> + else >> + { >> + printk("Invalid \"virtio-pci\" property value (%s)\n", >> virtio_pci); >> + return -EINVAL; >> + } >> + } >> + else if ( rc == -ENODATA ) >> + { >> + /* Handle missing property value */ >> + kinfo.virtio_pci.mode = dt_property_read_bool(node, "virtio-pci"); >> + } >> + >> + if ( kinfo.virtio_pci.mode != VIRTIO_PCI_NONE ) >> + { >> + rc = dt_property_read_u32_array(node, "virtio-pci-ranges", >> + virtio_pci_ranges, >> + ARRAY_SIZE(virtio_pci_ranges)); >> + if ( rc == 0 ) { >> + kinfo.virtio_pci.ecam.base = combine_u64(&virtio_pci_ranges[0]); >> + kinfo.virtio_pci.mem.base = combine_u64(&virtio_pci_ranges[2]); >> + kinfo.virtio_pci.pf_mem.base = >> combine_u64(&virtio_pci_ranges[4]); >> + } else { >> + kinfo.virtio_pci.ecam.base = GUEST_VIRTIO_PCI_ECAM_BASE; >> + kinfo.virtio_pci.mem.base = GUEST_VIRTIO_PCI_MEM_BASE; >> + kinfo.virtio_pci.pf_mem.base = >> GUEST_VIRTIO_PCI_PREFETCH_MEM_BASE; >> + } >> + } >> + >> rc = dt_property_read_string(node, "xen,enhanced", &dom0less_enhanced); >> if ( rc == -EILSEQ || >> rc == -ENODATA ||
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |