* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
@ 2011-05-23 9:06 Matthias Weisser
2011-05-23 9:30 ` Alexander Holler
2011-08-12 8:49 ` Albert ARIBAUD
0 siblings, 2 replies; 8+ messages in thread
From: Matthias Weisser @ 2011-05-23 9:06 UTC (permalink / raw)
To: u-boot
In some cases (e.g. bootm with a elf payload which is already at the right
position) there is a in place copy of data to the same address. Catching this
saves some ms while booting.
Signed-off-by: Matthias Weisser <weisserm@arcor.de>
---
arch/arm/lib/memcpy.S | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index 3b5aeec..f655256 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -60,6 +60,9 @@
.globl memcpy
memcpy:
+ cmp r0, r1
+ moveq pc, lr
+
enter r4, lr
subs r2, r2, #4
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:06 [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address Matthias Weisser
@ 2011-05-23 9:30 ` Alexander Holler
2011-05-23 9:46 ` Matthias Weißer
2011-05-23 9:49 ` Albert ARIBAUD
2011-08-12 8:49 ` Albert ARIBAUD
1 sibling, 2 replies; 8+ messages in thread
From: Alexander Holler @ 2011-05-23 9:30 UTC (permalink / raw)
To: u-boot
Am 23.05.2011 11:06, schrieb Matthias Weisser:
> In some cases (e.g. bootm with a elf payload which is already at the right
> position) there is a in place copy of data to the same address. Catching this
> saves some ms while booting.
>
> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
> ---
> arch/arm/lib/memcpy.S | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
> index 3b5aeec..f655256 100644
> --- a/arch/arm/lib/memcpy.S
> +++ b/arch/arm/lib/memcpy.S
> @@ -60,6 +60,9 @@
> .globl memcpy
> memcpy:
>
> + cmp r0, r1
> + moveq pc, lr
> +
> enter r4, lr
>
> subs r2, r2, #4
The standard clearly say to both memory regions should not overlap when
memcpy() is used, so I would say this is the wrong place to fix that.
Regards,
Alexander
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:30 ` Alexander Holler
@ 2011-05-23 9:46 ` Matthias Weißer
2011-05-23 9:51 ` Alexander Holler
2011-05-23 9:49 ` Albert ARIBAUD
1 sibling, 1 reply; 8+ messages in thread
From: Matthias Weißer @ 2011-05-23 9:46 UTC (permalink / raw)
To: u-boot
Am 23.05.2011 11:30, schrieb Alexander Holler:
> Am 23.05.2011 11:06, schrieb Matthias Weisser:
>> In some cases (e.g. bootm with a elf payload which is already at the right
>> position) there is a in place copy of data to the same address. Catching this
>> saves some ms while booting.
>>
>> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
>> ---
>> arch/arm/lib/memcpy.S | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
>> index 3b5aeec..f655256 100644
>> --- a/arch/arm/lib/memcpy.S
>> +++ b/arch/arm/lib/memcpy.S
>> @@ -60,6 +60,9 @@
>> .globl memcpy
>> memcpy:
>>
>> + cmp r0, r1
>> + moveq pc, lr
>> +
>> enter r4, lr
>>
>> subs r2, r2, #4
>
> The standard clearly say to both memory regions should not overlap when
> memcpy() is used, so I would say this is the wrong place to fix that.
Well, real world applications do this. And these two instructions
shouldn't hurt a lot.
I first send a patch fixing only "my" problem in cmd_elf.c but Wolfgang
suggested to do this globally. Please see
http://www.mail-archive.com/u-boot at lists.denx.de/msg50612.html as reference.
Matthias
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:30 ` Alexander Holler
2011-05-23 9:46 ` Matthias Weißer
@ 2011-05-23 9:49 ` Albert ARIBAUD
2011-05-23 10:01 ` Alexander Holler
2011-07-26 6:02 ` Matthias Weißer
1 sibling, 2 replies; 8+ messages in thread
From: Albert ARIBAUD @ 2011-05-23 9:49 UTC (permalink / raw)
To: u-boot
Le 23/05/2011 11:30, Alexander Holler a ?crit :
> Am 23.05.2011 11:06, schrieb Matthias Weisser:
>> In some cases (e.g. bootm with a elf payload which is already at the right
>> position) there is a in place copy of data to the same address. Catching this
>> saves some ms while booting.
>>
>> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
>> ---
>> arch/arm/lib/memcpy.S | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
>> index 3b5aeec..f655256 100644
>> --- a/arch/arm/lib/memcpy.S
>> +++ b/arch/arm/lib/memcpy.S
>> @@ -60,6 +60,9 @@
>> .globl memcpy
>> memcpy:
>>
>> + cmp r0, r1
>> + moveq pc, lr
>> +
>> enter r4, lr
>>
>> subs r2, r2, #4
>
> The standard clearly say to both memory regions should not overlap when
> memcpy() is used, so I would say this is the wrong place to fix that.
I think the intent here is not to enforce the standard but to handle an
actual, and degenerate, copy request in the most efficient manner, and
in that respect, the patch does its job.
Besides, if the patch was about enforcing the standard, then I would
consider it highly more efficient to check the areas once in the memcpy
function than duplicating this check before each call to the function,
considering that the place where the copy happens is not necessarily the
one where the source and destination were computed.
> Regards,
>
> Alexander
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:46 ` Matthias Weißer
@ 2011-05-23 9:51 ` Alexander Holler
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Holler @ 2011-05-23 9:51 UTC (permalink / raw)
To: u-boot
Am 23.05.2011 11:46, schrieb Matthias Wei?er:
>> The standard clearly say to both memory regions should not overlap when
>> memcpy() is used, so I would say this is the wrong place to fix that.
>
> Well, real world applications do this. And these two instructions
> shouldn't hurt a lot.
Real bugs to this. Just see e.g the long discussion about some changes
fo memcpy done in the glibc lately and what that did for flash-users
because flash seemed to the same stupid stuff.
Regards,
Alexander
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:49 ` Albert ARIBAUD
@ 2011-05-23 10:01 ` Alexander Holler
2011-07-26 6:02 ` Matthias Weißer
1 sibling, 0 replies; 8+ messages in thread
From: Alexander Holler @ 2011-05-23 10:01 UTC (permalink / raw)
To: u-boot
Hello,
Am 23.05.2011 11:49, schrieb Albert ARIBAUD:
>> The standard clearly say to both memory regions should not overlap when
>> memcpy() is used, so I would say this is the wrong place to fix that.
>
> I think the intent here is not to enforce the standard but to handle an
> actual, and degenerate, copy request in the most efficient manner, and
> in that respect, the patch does its job.
>
> Besides, if the patch was about enforcing the standard, then I would
> consider it highly more efficient to check the areas once in the memcpy
> function than duplicating this check before each call to the function,
> considering that the place where the copy happens is not necessarily the
> one where the source and destination were computed.
A fool proof solution would be to always use memmove() and get rid of
memcpy(). But checking for overlapped regions in memcpy() is imho the
wrong way. This just leads to more possible wrong code which uses
memcpy() when it should use memmove().
Regards,
Alexander
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:49 ` Albert ARIBAUD
2011-05-23 10:01 ` Alexander Holler
@ 2011-07-26 6:02 ` Matthias Weißer
1 sibling, 0 replies; 8+ messages in thread
From: Matthias Weißer @ 2011-07-26 6:02 UTC (permalink / raw)
To: u-boot
Dear Albert
Am 23.05.2011 11:49, schrieb Albert ARIBAUD:
> Le 23/05/2011 11:30, Alexander Holler a ?crit :
>> Am 23.05.2011 11:06, schrieb Matthias Weisser:
>>> In some cases (e.g. bootm with a elf payload which is already at the right
>>> position) there is a in place copy of data to the same address. Catching this
>>> saves some ms while booting.
>>>
>>> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
>>> ---
>>> arch/arm/lib/memcpy.S | 3 +++
>>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
>>> index 3b5aeec..f655256 100644
>>> --- a/arch/arm/lib/memcpy.S
>>> +++ b/arch/arm/lib/memcpy.S
>>> @@ -60,6 +60,9 @@
>>> .globl memcpy
>>> memcpy:
>>>
>>> + cmp r0, r1
>>> + moveq pc, lr
>>> +
>>> enter r4, lr
>>>
>>> subs r2, r2, #4
>>
>> The standard clearly say to both memory regions should not overlap when
>> memcpy() is used, so I would say this is the wrong place to fix that.
>
> I think the intent here is not to enforce the standard but to handle an
> actual, and degenerate, copy request in the most efficient manner, and
> in that respect, the patch does its job.
Can this patch go in or do I need to change anything? I really would
like to see it in mainline.
Regards,
Matthias
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
2011-05-23 9:06 [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address Matthias Weisser
2011-05-23 9:30 ` Alexander Holler
@ 2011-08-12 8:49 ` Albert ARIBAUD
1 sibling, 0 replies; 8+ messages in thread
From: Albert ARIBAUD @ 2011-08-12 8:49 UTC (permalink / raw)
To: u-boot
On 23/05/2011 11:06, Matthias Weisser wrote:
> In some cases (e.g. bootm with a elf payload which is already at the right
> position) there is a in place copy of data to the same address. Catching this
> saves some ms while booting.
>
> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
> ---
> arch/arm/lib/memcpy.S | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
> index 3b5aeec..f655256 100644
> --- a/arch/arm/lib/memcpy.S
> +++ b/arch/arm/lib/memcpy.S
> @@ -60,6 +60,9 @@
> .globl memcpy
> memcpy:
>
> + cmp r0, r1
> + moveq pc, lr
> +
> enter r4, lr
>
> subs r2, r2, #4
Applied to u-boot-arm/master, thanks.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-08-12 8:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 9:06 [U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address Matthias Weisser
2011-05-23 9:30 ` Alexander Holler
2011-05-23 9:46 ` Matthias Weißer
2011-05-23 9:51 ` Alexander Holler
2011-05-23 9:49 ` Albert ARIBAUD
2011-05-23 10:01 ` Alexander Holler
2011-07-26 6:02 ` Matthias Weißer
2011-08-12 8:49 ` Albert ARIBAUD
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.