Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1613056
| From | Alexey Dobriyan <adobriyan@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC][CFT][PATCHSET v1] uaccess unification |
| Date | 2017-03-30 15:30 +0200 |
| Message-ID | <tqIjf-6VF-7@gated-at.bofh.it> (permalink) |
| References | <tqIjf-6VF-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[cc linux-kernel] On Thu, Mar 30, 2017 at 4:25 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote: >> void *to, const void *from, unsigned long size > > Type of the last argument should be "unsigned int", > for the following reasons: > * on x86_64 actual copying is done as 32-bit: types flip to "unsigned" > at some point and 32-bit registers are used in assembly > > * 4GB+ copies simply do not exist: > kernel doesn't have data structures that big, > > huge copies are done with cond_resched() in between > (with or without proxy pages), > > even if they exist, they do not work on x86_64 now and can be > trivially wrapped as copy_from_user64() or something. > > VFS truncates everything at INT_MAX exactly to not deal with all > the bugs associated with implicit type conversions. > > * Binary code becomes smaller: it doesn't matter for constant sizes, > but people tend to maintain type "safety" by using size_t and > do 64-bit arithmetic where it is unnecessary. I've sent some > patches to networking people already and have much more > which exterminate "size_t" from net/ and they give smaller code > size overall. > > Same arguments apply to kmalloc(), strlen(), memcpy() and > all functions which are "size_t len". > > There was one time when Xen(?) people asked for 64-bit memcpy(), > I can't remember any other example. > > A
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [RFC][CFT][PATCHSET v1] uaccess unification Alexey Dobriyan <adobriyan@gmail.com> - 2017-03-30 15:30 +0200
csiph-web