diff options
author | Oleg Nesterov <oleg@redhat.com> | 2020-11-19 19:02:21 +0300 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2020-11-26 14:05:42 +0300 |
commit | 640586f8af356096e084d69a9909d217852bde48 (patch) | |
tree | f25479b356c791dfd0087c2fd5f7d18638d71d63 /include | |
parent | 20fa40b147bda9b976227c11ea7afb369827e7d4 (diff) | |
download | linux-640586f8af356096e084d69a9909d217852bde48.tar.xz |
powerpc/ptrace: Simplify gpr_get()/tm_cgpr_get()
gpr_get() does membuf_write() twice to override pt_regs->msr in
between. We can call membuf_write() once and change ->msr in the
kernel buffer, this simplifies the code and the next fix.
The patch adds a new simple helper, membuf_at(offs), it returns the
new membuf which can be safely used after membuf_write().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
[mpe: Fixup some minor whitespace issues noticed by Christophe]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201119160221.GA5188@redhat.com
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/regset.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/regset.h b/include/linux/regset.h index c3403f328257..a00765f0e8cf 100644 --- a/include/linux/regset.h +++ b/include/linux/regset.h @@ -46,6 +46,18 @@ static inline int membuf_write(struct membuf *s, const void *v, size_t size) return s->left; } +static inline struct membuf membuf_at(const struct membuf *s, size_t offs) +{ + struct membuf n = *s; + + if (offs > n.left) + offs = n.left; + n.p += offs; + n.left -= offs; + + return n; +} + /* current s->p must be aligned for v; v must be a scalar */ #define membuf_store(s, v) \ ({ \ |