[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] x86/string: correct memmove()'s forwarding to memcpy()
On 03/02/2021 14:22, Jan Beulich wrote: > With memcpy() expanding to the compiler builtin, we may not hand it > overlapping source and destination. We strictly mean to forward to our > own implementation (a few lines up in the same source file). > > Fixes: 78825e1c60fa ("x86/string: Clean up x86/string.h") > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> I agree that the current logic is buggy, but I'm not sure this is an improvement. You've switched from relying on GCC's builtin to operate forwards, to relying on Xen's implementation operating forwards. At the very least, can we get a code comment stating something like "depends on Xen's implementation operating forwards" ? > --- > An alternative would be to "#undef memcpy" near the top of the file. But > I think the way it's done now is more explicit to the reader. An #undef > would be the only way if the macro was an object-like one. I chose not to use undef's to avoid impacting the optimisation of other functions in this file. I can't remember if this made a difference in practice. > At least with gcc10 this does alter generated code: The builtin gets > expanded into a tail call, while after this change our memcpy() gets > inlined into memmove(). This would change again once we separate the 3 > functions here into their own CUs for placing them in an archive. As (perhaps) a tangent, how do we plan to provide x86-optimised versions in combination with the library work? We're long overdue needing to refresh our fast-strings support to include fast rep-mov/stosb. ~Andrew > > --- a/xen/arch/x86/string.c > +++ b/xen/arch/x86/string.c > @@ -43,7 +43,7 @@ void *(memmove)(void *dest, const void * > return dest; > > if ( dest < src ) > - return memcpy(dest, src, n); > + return (memcpy)(dest, src, n); > > asm volatile ( > " std ; "
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |