Re: [PATCH v1 3/3] x86: call instrumentation hooks from copy_mc.c

From: Tetsuo Handa
Date: Tue Mar 19 2024 - 23:54:39 EST


On 2024/03/20 1:36, Alexander Potapenko wrote:
> @@ -61,10 +62,20 @@ unsigned long copy_mc_enhanced_fast_string(void *dst, const void *src, unsigned
> */
> unsigned long __must_check copy_mc_to_kernel(void *dst, const void *src, unsigned len)
> {
> - if (copy_mc_fragile_enabled)
> - return copy_mc_fragile(dst, src, len);
> - if (static_cpu_has(X86_FEATURE_ERMS))
> - return copy_mc_enhanced_fast_string(dst, src, len);
> + unsigned long ret;
> +
> + if (copy_mc_fragile_enabled) {
> + instrument_memcpy_before(dst, src, len);

I feel that instrument_memcpy_before() needs to be called *after*
copy_mc_fragile() etc. , for we can't predict how many bytes will
copy_mc_fragile() etc. actually copy.

> + ret = copy_mc_fragile(dst, src, len);
> + instrument_memcpy_after(dst, src, len, ret);
> + return ret;
> + }