[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


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Wed, 25 Sep 2024 09:03:23 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wnSbTolLKan6/waZuI4pJKgVcVd8wtWAesmkfOsessY=; b=eSjEPFqiIU6djltvF/iTFDwVao5SKEtfWXNJlALNt6XU8dDKEgpqb/YcOdHb5+LLHX2MNWNRiO4YeFXvuWXTEkBpGYeaqxl5+ZWvSJ2CHth0mAYKAzmdAiP+CabNahxjQ52LqK5pr6pySPw1gZ50mCabTNVMZuBFpYjQftQQuMj3/ORFl2+BEmwkynfo+s/3BSr+ym1WeUHibaQU9dpoTYKxpsYoFoPJQAVh8hlyz3JsedCG81r4oRy1jSlomKUkl+8vdhwoa0w07PLz2fWJsrko6xW8bEgeIs1UD48SZPu4sd3LkG7U7FvMFNuBsOMLAmGofBDhU0I8JBkLhLsUgg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p5Zdyv6PRoRZPVVrKhblUqXOeME2s128i/4pp9aaGB492/587XpPbVfz6Mxn9KxlhWhoA73NNtjCzGLLhffIbsQzjlPzuOdq+cVuwE/ZSsdofrwnWajlHhtBUKilKqb8TmrQLp9IP0j//emcNML4UDe3Ul9uZZl7kxXUH3gxzH8XayHmhRN+OpcbYbkZQh3Y0SdqGSEmg3G9yUDHvx/bYPL5jdMgWvjC9TmfY+E1wCoCDTIdljsK2I7Nbpkbg8DXtojoITNfq2LkEhPWkAUhYevN1dazFUX/sVG8G2SZ8hNS/3vMX1AqKB69BwDivrxgCcLr3qdGGbTck3MN8dYvmg==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <julien@xxxxxxx>, <bertrand.marquis@xxxxxxx>, <michal.orzel@xxxxxxx>, <Volodymyr_Babchuk@xxxxxxxx>, <dpsmith@xxxxxxxxxxxxxxxxxxxx>, <edgar.iglesias@xxxxxxx>
  • Delivery-date: Wed, 25 Sep 2024 13:04:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 ||



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.