On Fri, Jul 1, 2022 at 2:29 AM Jason Gunthorpe <jgg@xxxxxxxx> wrote: > On Thu, Jun 30, 2022 at 10:41:23AM +0200, Linus Walleij wrote: > > Functions that work on a pointer to virtual memory such as > > virt_to_pfn() and users of that function such as > > virt_to_page() are supposed to pass a pointer to virtual > > memory, ideally a (void *) or other pointer. However since > > many architectures implement virt_to_pfn() as a macro, > > this function becomes polymorphic and accepts both a > > (unsigned long) and a (void *). > > I wonder if there is merit to convert x86 to use an inline after this > goes in to prevent this polymorphic mistake? I have a patch like that, x86 uses the asm generic version IIUC: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator.git/patch/?id=ed4befbf783c06820e9d4620c7fd254a36d608fe There was also Xen: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator.git/patch/?id=43ab4e5d6738273055dca21031e23b53b3721889 The plan is to trickle in a few of those after I fixed up all the mm and drivers that were doing this with unsigned longs. I managed to convert all architectures except one to use static inlines for virt_to_pfn. I was actually a bit surprised how few sites there were. Yours, Linus Walleij