On Thu, Nov 12, 2026 at 05:53:47AM -0500, Michael S. Tsirkin wrote: > vhost had a TODO to replace page pinning with a version > of set_bit that works on userspace memory, since forever. > > It is really best to avoid GUP on fast path entirely. > Implement set_user_bit and use it in vhost, to do just that. > > Should not be too hard for non-x86 too. > > Reported-by: Khan Zhao <[email protected]> > Link: > https://lore.kernel.org/all/[email protected]/ > Signed-off-by: Michael S. Tsirkin <[email protected]> > --- > > > lightly tested. pls test and resubmit with your tool. > > arch/x86/include/asm/uaccess.h | 18 ++++++++++++++++++ > drivers/vhost/vhost.c | 7 +++++++ > 2 files changed, 25 insertions(+) > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 3a0dd3c2b233e..ba1e7c3f83c8e 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -594,6 +594,24 @@ _label: > \ > __ret; \ > }) > > +/* set_bit() on a byte of user memory; returns -EFAULT on fault. */ > +#define set_bit_user(nr, addr) \
Please make this an inline that actually has proper __user annotations for sparse type checking.
