Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?

Julia Lawall <[email protected]>
Newsgroups fr.inria.cocci,org.kernel.vger.kernel-janitors,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On Thu, 30 Oct 2025, Markus Elfring wrote:

> >> I “accidentally” tried also the following SmPL script variants out.
> >>
> >> A)
> >> @replacement3@
> >> expression object, size, source, target;
> >> @@
> >>  target =
> >> -object; memcpy(target, source, size)
> >> +object; memcpy(object, source, size)
> >>  ;
> >>
> >> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment3.cocci arch/arm64/kvm/arm.c
> >> …
> >> @@ -2600,8 +2600,8 @@ static int __init init_hyp_mode(void)
> >>                         goto out_err;
> >>                 }
> >>
> >> -               page_addr = page_address(page);
> >> -               memcpy(page_addr, CHOOSE_NVHE_SYM(__per_cpu_start), nvhe_percpu_size());
> >> +               page_addr =memcpy(page_address(page), CHOOSE_NVHE_SYM(__per_cpu_start),
> >> +                                 nvhe_percpu_size());page_address(page);
> >>                 kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr;
> >>         }
> …>> B)
> >> @replacement4@
> >> expression object, size, source, target;
> >> @@
> >> -target = object; memcpy(target, source, size)
> >> +target = object; memcpy(object, source, size)
> >>  ;
> >>
> >> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment4.cocci arch/arm64/kvm/arm.c
> >> …
> >> @@ -2600,8 +2600,8 @@ static int __init init_hyp_mode(void)
> >>                         goto out_err;
> >>                 }
> >>
> >> +               memcpy(page_address(page), CHOOSE_NVHE_SYM(__per_cpu_start), nvhe_percpu_size());
> >>                 page_addr = page_address(page);
> >> -               memcpy(page_addr, CHOOSE_NVHE_SYM(__per_cpu_start), nvhe_percpu_size());
> >>                 kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr;
> >>         }
> >
> > Not sure what is the point of all this.  Try:
> …
>
> Would you like to acknowledge that undesirable difference displays were generated anyhow
> for these test cases?

Sure.

>
>
> >> Would you like to reconsider implementation details accordingly?
>
> Are we looking for corresponding software improvements?

If time permits.

julia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.