sgx_virt_ecreate(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sgx_virt_ecreate β€” the Kernel API Manual page, but make it make sense 🫢

okay so bestie, you're in the kernel API manual section 9, and today's main character is sgx_virt_ecreate(9). yes it's a mouthful, no you don't have to say it out loud. it lives in the SGX corner of the kernel (you know, the ./arch/x86/kernel/cpu/sgx directory vibe) and it is lowkey doing a LOT of heavy lifting for KVM. let's get into it ✨


✨ SYNOPSIS ✨

int sgx_virt_ecreate (struct sgx_pageinfo *pageinfo , void __user *secs
, int *trapnr );

look at that signature. three args, returns an int, very demure, very mindful. πŸŽ€


🌸 ARGUMENTS 🌸

  • pageinfo β€” a pointer to the PAGEINFO structure. it's giving "here's the info you need". πŸ’–
  • secs β€” a userspace pointer to the SECS page. yes, userspace pointer, so be normal about it. πŸ™ˆ
  • trapnr β€” the trap number that gets injected to the guest if there's an ECREATE error. it's the "in case of emergency, here's what to throw" value. 🚨

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea, bestie. this function runs ECREATE on behalf of the guest, and it does it after KVM traps ECREATE β€” the whole point being to enforce the policies of the guest's enclaves. then it returns the trap number that should be injected to the guest in case of any ECREATE error. iconic behaviour, honestly. πŸ‘‘

no cap, it's literally: KVM catches ECREATE, this function handles it, policies get enforced, and you get your trap number back for error reporting. that's the whole vibe check. πŸ”₯


🌈 RETURN 🌈

  • 0 β€” ECREATE was successful. slay. πŸŽ‰
  • <0 β€” on error. 😭

πŸ¦‹ SEE ALSO πŸ¦‹


πŸ’€ reminder bestie: secs is a userspace pointer (void __user *), and that __user annotation is not decorative. treat it with the respect it deserves.

and that's a wrap, fr fr. this page is from the ./arch/x86/kernel/cpu/sgx part of the Kernel API Manual, dated October 2026. go forth and ECREATE responsibly, my love. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from