linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
diff for duplicates of <20170618235108.peaxdi367jpkt542@yury-thinkpad>

diff --git a/a/1.txt b/N1/1.txt
index 99d8fc9..44b128e 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -90,60 +90,3 @@ On Fri, Jun 16, 2017 at 05:07:42PM -0700, Florian Fainelli wrote:
 > + * for function copying.
 > + */
 > +#define FNCPY_ALIGN 8
-
-From now this is not arm-only, and it's possible that some architectures
-might want to redefine it in their arch/xxx/include/asm/fncpy.h files.
-So it will be easier for them if you'll wrap FNCPY_ALIGN here with #ifdef
-guards.
-
-By the way, compiler already has an information on the proper alignment.
-Maybe it's better to use it as the default value here instead of the
-hardcoded value?
-
-#ifndef FNCPY_ALIGN
-#define FNCPY_ALIGN ({void foo(); __alignof__(&foo);})
-#endif
-
-> +
-> +#define fncpy(dest_buf, funcp, size) ({					\
-
-Do you really need to check types inside the macro? If not, you can
-declare it as function, which is better in general, with the memcpy-like
-prototype.
-
-> +	uintptr_t __funcp_address;					\
-> +	typeof(funcp) __result;						\
-> +									\
-> +	asm("" : "=r" (__funcp_address) : "0" (funcp));			\
-> +									\
-> +	/*								\
-> +	 * Ensure alignment of source and destination addresses.	\
-> +	 */								\
-> +	BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) ||		\
-
-People don't like new BUG_ONs. Maybe it's better to use BUILD_BUG_ON()
-at compile time and WARN_ON() at runtime?
-
-> +		(__funcp_address & (FNCPY_ALIGN - 1)));			\
-
-There is IS_ALIGNED() macro for things like this.
-
-And I frankly don't understand the 2nd check. One can imagine the
-situation when someone wants copy the function from the packed blob or
-some intermediate location were the function is unaligned, and it's
-impossible with the current implementation.
-
-> +									\
-> +	memcpy(dest_buf, (void const *)__funcp_address, size);		\
-> +	flush_icache_range((unsigned long)(dest_buf),			\
-> +		(unsigned long)(dest_buf) + (size));			\
-> +									\
-> +	asm("" : "=r" (__result)					\
-> +		: "0" ((uintptr_t)(dest_buf)));				\
-> +									\
-> +	__result;							\
-> +})
-> +
-> +#endif /* !__ASM_FNCPY_H */
-> -- 
-> 2.9.3
diff --git a/a/content_digest b/N1/content_digest
index a92c45c..cfe9f92 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -112,63 +112,6 @@
  "> + * Minimum alignment requirement for the source and destination addresses\n"
  "> + * for function copying.\n"
  "> + */\n"
- "> +#define FNCPY_ALIGN 8\n"
- "\n"
- "From now this is not arm-only, and it's possible that some architectures\n"
- "might want to redefine it in their arch/xxx/include/asm/fncpy.h files.\n"
- "So it will be easier for them if you'll wrap FNCPY_ALIGN here with #ifdef\n"
- "guards.\n"
- "\n"
- "By the way, compiler already has an information on the proper alignment.\n"
- "Maybe it's better to use it as the default value here instead of the\n"
- "hardcoded value?\n"
- "\n"
- "#ifndef FNCPY_ALIGN\n"
- "#define FNCPY_ALIGN ({void foo(); __alignof__(&foo);})\n"
- "#endif\n"
- "\n"
- "> +\n"
- "> +#define fncpy(dest_buf, funcp, size) ({\t\t\t\t\t\\\n"
- "\n"
- "Do you really need to check types inside the macro? If not, you can\n"
- "declare it as function, which is better in general, with the memcpy-like\n"
- "prototype.\n"
- "\n"
- "> +\tuintptr_t __funcp_address;\t\t\t\t\t\\\n"
- "> +\ttypeof(funcp) __result;\t\t\t\t\t\t\\\n"
- "> +\t\t\t\t\t\t\t\t\t\\\n"
- "> +\tasm(\"\" : \"=r\" (__funcp_address) : \"0\" (funcp));\t\t\t\\\n"
- "> +\t\t\t\t\t\t\t\t\t\\\n"
- "> +\t/*\t\t\t\t\t\t\t\t\\\n"
- "> +\t * Ensure alignment of source and destination addresses.\t\\\n"
- "> +\t */\t\t\t\t\t\t\t\t\\\n"
- "> +\tBUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) ||\t\t\\\n"
- "\n"
- "People don't like new BUG_ONs. Maybe it's better to use BUILD_BUG_ON()\n"
- "at compile time and WARN_ON() at runtime?\n"
- "\n"
- "> +\t\t(__funcp_address & (FNCPY_ALIGN - 1)));\t\t\t\\\n"
- "\n"
- "There is IS_ALIGNED() macro for things like this.\n"
- "\n"
- "And I frankly don't understand the 2nd check. One can imagine the\n"
- "situation when someone wants copy the function from the packed blob or\n"
- "some intermediate location were the function is unaligned, and it's\n"
- "impossible with the current implementation.\n"
- "\n"
- "> +\t\t\t\t\t\t\t\t\t\\\n"
- "> +\tmemcpy(dest_buf, (void const *)__funcp_address, size);\t\t\\\n"
- "> +\tflush_icache_range((unsigned long)(dest_buf),\t\t\t\\\n"
- "> +\t\t(unsigned long)(dest_buf) + (size));\t\t\t\\\n"
- "> +\t\t\t\t\t\t\t\t\t\\\n"
- "> +\tasm(\"\" : \"=r\" (__result)\t\t\t\t\t\\\n"
- "> +\t\t: \"0\" ((uintptr_t)(dest_buf)));\t\t\t\t\\\n"
- "> +\t\t\t\t\t\t\t\t\t\\\n"
- "> +\t__result;\t\t\t\t\t\t\t\\\n"
- "> +})\n"
- "> +\n"
- "> +#endif /* !__ASM_FNCPY_H */\n"
- "> -- \n"
- > 2.9.3
+ > +#define FNCPY_ALIGN 8
 
-fab7ff8a4d153a80f521089b1f9de5609f6c09e0290a63baed9da28e03fc504e
+82fa7bc0c4d0ce478dd50f3812e23dd97bcd68cfda43ba212e281a445bbafa96

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).