copy_from_user_nmi(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ copy_from_user_nmi(9) ✨

okay so bestie, welcome to the Kernel API Manual πŸ’– β€” today's main character is copy_from_user_nmi, and she's lowkey iconic.


🌸 NAME 🌸

copy_from_user_nmi β€” NMI safe copy from user πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

unsigned long copy_from_user_nmi (void *to , const void __user *from ,
unsigned long n );

like, yes, that's the whole signature, no cap ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • to β€” pointer to the destination buffer, aka where the bytes are gonna land 🫢
  • from β€” pointer to a user space address of the current task πŸ‘€
  • n β€” the number of bytes to copy, fr fr, that's literally it πŸ’œ

🌈 RETURN 🌈

she returns the number of not copied bytes 😭 β€” so 0 means success, i.e. all bytes copied. slay πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

okay so here's the vibe check: contrary to other copy_from_user variants, this function can be called from NMI context πŸ”₯. And despite the name, she's not restricted to NMI context either β€” it's safe to be called from any other context as well, no gatekeeping here 🧚.

She disables pagefaults across the copy, which means a fault will abort the copy πŸ’€ β€” yes, like, mid-copy, done, no more bytes, periodt.

For NMI context invocations, this relies on the nested NMI work to allow atomic faults from the NMI path; the nested NMI paths are careful to preserve CR2 ⭐. iykyk.


πŸ’« SEE ALSO πŸ’«

Kernel file ./arch/x86/lib/usercopy.c πŸ“


that's the whole page bestie, go read the source and stan πŸ“

with love from ./arch/x86/lib, dated October 2026, manual page copy_from_user_nmi(9) β€” mwah πŸ’‹

πŸ“¦ where this page comes from