[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: Don't use copy_from_paddr for DTB relocation


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Wed, 26 Feb 2025 12:01:34 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=WSydAJw4QM/jTo5VeR6MsPtWMXgEeqvpLUqV+1a2FLI=; b=ONNm/oKASNHPcqRH6t8feG6wCamHH3wxGq05c6pfkH4fXl9q9NwlrcddAlmNDu7eQOoPBjMHlc0CcawPutMwUaX0dlLRoeyvxiGWG1Nb53JIqQrewOQjGX1CM9DdFu/j7psd38QMqMBl8yR7Fs6BFWddDOtLkEZ/DxsgUS52DeHf3NWqcXWlKI82RywnZKTsCWkKaWRkeF84bluLcGTq1d8IPh3TtZ9hFFQgerQdDA3m0b3LZxKONKxlGtOakhqZalewlefjh0sIi6MKZKzMT9UlzK7PEemrj8BVTX7FpxY2KaIWyLozL+VIDXlbhkpJzppr8a+CsqHwPCbTWaUBhg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qlq6qXGaPWkm66iwi2WNTA0sU4rTo+psd4MkuxWhde0koFXoVJ7TyUv0o3oZJjMyG2q9JdO3FKYTrp1U69xTT9fdraQCs7AK+MYBbYg+pWoJCfho2Pv2ERuqH6ADDtWqhrmLCvIYFB8uRVb9bHIBLVIg9VIWz6Pmcj/0GRdEX7IrqCHUoST/K3x0g80h9GkyhIg0lIumJAQ0V67R/0ofdx7imAApSZJ63xUO5AVY5VKD/vNg9WyB5BQ39rl1T0yve1zBAvRyhrvQdQ9m67/deU0RqKTaBBksTHBP7UC8xAz/h916xNy5bVCNJAATTNJ8d2a/oGAMyRkM5r++Chhp+w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 26 Feb 2025 11:01:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 26/02/2025 11:59, Luca Fancellu wrote:
> 
> 
>>>
>>>>
>>>>>
>>>>>    return fdt;
>>>>> }
>>>>> @@ -362,7 +363,7 @@ void asmlinkage __init start_xen(unsigned long 
>>>>> fdt_paddr)
>>>>>    if ( acpi_disabled )
>>>>>    {
>>>>>        printk("Booting using Device Tree\n");
>>>>> -        device_tree_flattened = relocate_fdt(fdt_paddr, fdt_size);
>>>>> +        device_tree_flattened = relocate_fdt(device_tree_flattened, 
>>>>> fdt_size);
>>>> NIT: It can be just my PoV but it reads odd. Why can't relocate_fdt modify
>>>> device_tree_flattened pointer directly in the function?
>>>
>>> you mean something like:
>>>
>>> static void * __init relocate_fdt(size_t dtb_size)
>>> {
>>> void *fdt = xmalloc_bytes(dtb_size);
>>>
>>> if ( !fdt )
>>> panic("Unable to allocate memory for relocating the Device-Tree.\n");
>>>
>>> memcpy(fdt, device_tree_flattened, dtb_size);
>> You already make assumption about device_tree_flattened being global, so why
>> not assigning device_tree_flattened = fdt in the function as well?
> 
> just because it’s more easy to follow the global variable changes when 
> reading the start_xen(…)
> code as the function is the only one modifying it.
> 
> If you strongly oppose to that I’ll change, but imo it’s easier to follow the 
> code in this way
How about:
static void __init relocate_fdt(void *dtb_vaddr, size_t dtb_size)
{
    void *fdt = xmalloc_bytes(dtb_size);

    if ( !fdt )
        panic("Unable to allocate memory for relocating the Device-Tree.\n");

    memcpy(fdt, dtb_vaddr, dtb_size);
    clean_dcache_va_range(fdt, dtb_size);

    dtb_vaddr = fdt;
}

This would be best IMO. That said, I don't care that much. Choose whatever makes
sense.

~Michal




 


Rackspace

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