On Tue, Jun 30, 2020 at 09:53:12AM -0700, Linus Torvalds wrote: > On Tue, Jun 30, 2020 at 6:25 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > > > > How about ->regset_get()? > > Sounds good to me. And if you ever do something similar for 'set', you > have a natural name to pick. Umm... Something similar for 'set' would, AFAICS, work reasonably well with the following primitives. membuf_read(&from, data, size) -- copy min(size, amount left) membuf_fetch(&from, data) -- copy min(sizeof(data), amount left) into data (obviously a macro) membuf_skip(&from, size) -- obvious membuf_pick(&from, size), along the lines of if (unlikely(size > p->left) return ERR_PTR(-EINVAL); res = p->p; p->p += size; p->left -= size; return res; So it would be something like int regset_tls_set(struct task_struct *target, const struct user_regset *regset, struct membuf from) { const struct user_desc *info; int n = from.left / sizeof(*info); int i; info = membuf_pick(&from, n * sizeof(*info)); // can't fail here for (i = 0; i < n; i++) if (!tls_desc_okay(info + i)) return -EINVAL; set_tls_desc(target, GDT_ENTRY_TLS_MIN, info, n); return 0; } and static int genregs32_set(struct task_struct *target, const struct user_regset *regset, struct membuf from) { int err; unsigned pos, v; for (pos = 0; from.left; pos += sizeof(u32)) { membuf_fetch(&from, v); err = putreg32(target, pos, v); if (err) return err; } return 0; } or /* * Copy the supplied 64-bit NT_MIPS_DSP buffer to the DSP context. */ static int dsp64_set(struct task_struct *target, const struct user_regset *regset, struct membuf from) { if (!cpu_has_dsp) return -EIO; membuf_read(&from, target->thread.dsp.dspr, NUM_DSP_REGS * sizeof(u64)); return membuf_read(&from, target->thread.dsp.dspcontrol, sizeof(u64)); } etc.