Prev: [tip:x86/urgent] x86, asm: Refactor atomic64_386_32.S to support old binutils and be cleaner
Next: [PATCH 0/2] kconfig: fixes for savedefconfig
From: Namhyung Kim on 12 Aug 2010 02:50 > --- a/arch/x86/lib/memcpy_32.c > +++ b/arch/x86/lib/memcpy_32.c > @@ -25,19 +25,35 @@ void *memmove(void *dest, const void *src, size_t n) > int d0, d1, d2; > > if (dest < src) { > - memcpy(dest, src, n); > + if ((dest + n) < src) > + return memcpy(dest, src, n); > + else > + __asm__ __volatile__( > + "rep\n\t" > + "movsb\n\t" > + : "=&c" (d0), "=&S" (d1), "=&D" (d2) > + :"0" (n), > + "1" (src), > + "2" (dest) > + :"memory"); > + > } else { > - __asm__ __volatile__( > - "std\n\t" > - "rep\n\t" > - "movsb\n\t" > - "cld" > - : "=&c" (d0), "=&S" (d1), "=&D" (d2) > - :"0" (n), > - "1" (n-1+src), > - "2" (n-1+dest) > - :"memory"); > + if((src + count) < dest) > + return memcpy(dest, src, count); 'count' should be 'n'. -- Regards, Namhyung Kim -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Ma, Ling on 12 Aug 2010 03:00 Thanks, I will fix it in next version. > -----Original Message----- > From: Namhyung Kim [mailto:namhyung(a)gmail.com] > Sent: Thursday, August 12, 2010 2:49 PM > To: Ma, Ling > Cc: hpa(a)zytor.com; tglx(a)linutronix.de; linux-kernel(a)vger.kernel.org; > mingo(a)elte.hu > Subject: Re: [PATCH V2] [X86] Fix potential issue on memmove > > > --- a/arch/x86/lib/memcpy_32.c > > +++ b/arch/x86/lib/memcpy_32.c > > @@ -25,19 +25,35 @@ void *memmove(void *dest, const void *src, size_t > n) > > int d0, d1, d2; > > > > if (dest < src) { > > - memcpy(dest, src, n); > > + if ((dest + n) < src) > > + return memcpy(dest, src, n); > > + else > > + __asm__ __volatile__( > > + "rep\n\t" > > + "movsb\n\t" > > + : "=&c" (d0), "=&S" (d1), "=&D" (d2) > > + :"0" (n), > > + "1" (src), > > + "2" (dest) > > + :"memory"); > > + > > } else { > > - __asm__ __volatile__( > > - "std\n\t" > > - "rep\n\t" > > - "movsb\n\t" > > - "cld" > > - : "=&c" (d0), "=&S" (d1), "=&D" (d2) > > - :"0" (n), > > - "1" (n-1+src), > > - "2" (n-1+dest) > > - :"memory"); > > + if((src + count) < dest) > > + return memcpy(dest, src, count); > > 'count' should be 'n'. > > -- > Regards, > Namhyung Kim >
From: H. Peter Anvin on 12 Aug 2010 10:20 On 08/11/2010 11:52 PM, Ma, Ling wrote: > Thanks, I will fix it in next version. Also, please split this into two patches -- one for fixing memmove, and the other for re-enabling the alias avoidance in memcpy. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: H. Peter Anvin on 12 Aug 2010 10:30
On 08/12/2010 07:15 AM, H. Peter Anvin wrote: > On 08/11/2010 11:52 PM, Ma, Ling wrote: >> Thanks, I will fix it in next version. > > Also, please split this into two patches -- one for fixing memmove, and > the other for re-enabling the alias avoidance in memcpy. > > -hpa > Nevermind, the patch doesn't actually contain the x86/mem patch. It's rather confusing to put "re-active patch id a1e5278e40f16a4611264f8da9e557c16cb6f6ed" for a patch that was caught in testing rather than ever included; it doesn't even exist under that patch ID anymore. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |