From: Linus Torvalds > Sent: 25 April 2023 17:29 > > On Tue, Apr 25, 2023 at 5:34 AM Christian Brauner <brauner@xxxxxxxxxx> wrote: > > > > Hell, you could even extend that proposal below to wrap the > > put_user()... > > > > struct fd_file { > > struct file *file; > > int fd; > > int __user *fd_user; > > }; > > So I don't like this extended version, but your proposal patch below > looks good to me. > > Why? Simply because the "two-word struct" is actually a good way to > return two values. But a three-word one would be passed on the stack. > > Both gcc and clang return small structs (where "small" is literally > just two words) in registers, and it's part of most (all?) ABIs and > we've relied on that before. It is definitely architecture dependant. x86-64 and arm-64 will return two 64bit values in registers. x86-32 and arm-32 return two 32bit values on stack. Pretty much everything passes short structures directly by value. (I'm not sure about sparc-32 though, I'm sure it passed all structures by reference back in the 1980s) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)