[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: "Orzel, Michal" <michal.orzel@xxxxxxx>
- From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
- Date: Wed, 26 Feb 2025 10:45:05 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; 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=ahkzpFp764oeABYiJpXbFCFvfI31JfSTIRsIhKibOfU=; b=n6hhGtOP5BeXabnjEtowwLcjYqMh0RNBpGYej3Dp3E6FoYwaWhnmi/ni+D0JYO9KKsEGkTkvqAGlt3mOIdcDZFuhYr+UcWd2J53LarYFIoRKAsmJQcHVnaN5oWAOUasEOroCGLkX9fckFJuGfwYR2vf0sDBZ+hVO2bqjFhkk4mQFQztwpXhe8YMME3ra8HShJKdDx9oFi3Kti171B/wctmaHPbTtqFQZ/H7Ad4xJFniuJjsO2qE6Qt1xY8lgKQX9VqT1o3IcqorBR1L9/vQO9Lc3+dk+PrBc9uc8EZYzF3yPRXI0kLsF8zPudrd2rwNVinc7sCj8wdK6gdbhkZ4DfQ==
- 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=ahkzpFp764oeABYiJpXbFCFvfI31JfSTIRsIhKibOfU=; b=GiN6rgB3+q3uccTDZu7BxeVl3IEhM+1lIdR8vg6gUUb/7+E+WEze+7FdRYukGKVVybQWTN7KdztoMmNfEeSX6NPCKPt7piS5vK0w6cWLcSk6zd4Qa7lsLaG0YY4S6uhXGBbMkPaHwvD+a5wDqRB4ub3ZbuiApzcdrQFb0WY9IoeeoPBmWkN6ZfX7RHblMTCbTbCDZzIIxlOyvZTDfem3+UqZKCejzNlLRonKQm6e6aV61vmBFgfBVlHSFyLRkvswRfGWHz/SIdiKbWCuejHBaqtjYkKfJ61Wnyl4szNbddsfsLKkZdQ6E4Gkw+bP8MApijvESupsSYY4CuNNflXQXw==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=ylJ877UFiF/SYrfEGiqh20lG3j1Wxpjefn96vS7HV/NfPqmpgc4yLdlWI8Gj54RJ2HA918BOED2GBcxoIMzMCurYZr67Vv0EtXL0OixX4GcH7Z34E0cnErVZ44Ti4LG3qZlD19DQzv9ufJYihqxjSzCS9kNlD9d7pHGdOocZvGPE/btUQsjmt4iJutdI44Mso/hUmRyNmq9MEiU2kaUZ0BK+XwTMIUbL0cZtP2xq5/9m1+AbQg9KQn2MJ+NlHZzb252yEuVnUl7gkHYko/Ia6jToe2MzGHZx5BmYDwxiaLnwlS4RCFr7URgIQrPyxHont1znAtybGOLgrTg9h/CICQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tyDLzYEbvbDAoQqMs79aVECLLUIuOQkUOqGbPTl0zm4610yOYjw16kI5VuobkY55N0JQkk4Nxfdq/51Yu5EIpsWVb+lI1IT0/T+dBzkz4o9HCza98ZtTBHdvQMNsPvKBl3xOCiG2fLR/X1/s8qiEJlXsvY2FQcfPkVUcqxejyFU6EpRHHcgjJfJDRPkWrsZCLbczRXkX8uHzhxFTgZ0J4p6bnVT7LXanvs3GzuMmQxdP0y8+qzfKrZ0yMMUgZb1dZvQM8l+3GnHm7UlXPzfNCFzsPjbMdjcdF4ZgURWEtlwOiS06rojcZRg5sVLsfD5WFf5DPXtFyV3JiUCiZyWiKg==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.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 10:46:33 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHbiCmjnkyna+WuREGzHZ/umIzQ77NZZMaAgAABvwA=
- Thread-topic: [PATCH] xen/arm: Don't use copy_from_paddr for DTB relocation
Hi Michal,
> On 26 Feb 2025, at 10:38, Orzel, Michal <michal.orzel@xxxxxxx> wrote:
>
>
>
> On 26/02/2025 09:36, Luca Fancellu wrote:
>>
>>
>> Currently the early stage of the Arm boot maps the DTB using
>> early_fdt_map() using PAGE_HYPERVISOR_RO which is cacheable
>> read-only memory, later during DTB relocation the function
>> copy_from_paddr() is used to map pages in the same range on
>> the fixmap but using PAGE_HYPERVISOR_WC which is non-cacheable
>> read-write memory.
>>
>> The Arm specifications, ARM DDI0487L.a, section B2.11 "Mismatched
>> memory attributes" discourage using mismatched attributes for
>> aliases of the same location.
>>
>> Given that there is nothing preventing the relocation since the region
>> is already mapped, fix that by open-coding copy_from_paddr inside
>> relocate_fdt, without mapping on the fixmap.
>>
>> Fixes: 1bdc81dac816 ("arm: setup MM using information from the device tree")
> Why Fixes tag? I don't see it as a bug and something we need to backport...
ok I’ll remove it
>
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>> ---
>> xen/arch/arm/setup.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>> index c1f2d1b89d43..b1fd4b44a2e1 100644
>> --- a/xen/arch/arm/setup.c
>> +++ b/xen/arch/arm/setup.c
>> @@ -237,14 +237,15 @@ void __init discard_initial_modules(void)
>> }
>>
>> /* Relocate the FDT in Xen heap */
>> -static void * __init relocate_fdt(paddr_t dtb_paddr, size_t dtb_size)
>> +static void * __init relocate_fdt(const 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");
>>
>> - copy_from_paddr(fdt, dtb_paddr, dtb_size);
>> + memcpy(fdt, dtb_vaddr, dtb_size);
>> + clean_dcache_va_range(dtb_vaddr, dtb_size);
> The purpose of cleaning dcache after memcpy is to clean the new area i.e.
> destination == fdt, not source region.
woops, my bad, I’ll fix
>
>>
>> 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);
clean_dcache_va_range(fdt, dtb_size);
return fdt;
}
Cheers,
Luca
|