From: Oleg Nesterov <oleg@redhat.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org,
Nicholas Piggin <npiggin@gmail.com>,
linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [PATCH v3 1/2] powerpc/ptrace: simplify gpr_get/tm_cgpr_get
Date: Thu, 19 Nov 2020 19:18:04 +0100 [thread overview]
Message-ID: <20201119181804.GA5138@redhat.com> (raw)
In-Reply-To: <94c56c46-e336-f61c-3623-1b2014fcbb2e@csgroup.eu>
On 11/19, Christophe Leroy wrote:
>
>
> Le 19/11/2020 à 17:02, Oleg Nesterov a écrit :
> >gpr_get() does membuf_write() twice to override pt_regs->msr in between.
>
> Is there anything wrong with that ?
Nothing wrong, but imo the code and 2/2 looks simpler after this patch.
I tried to explain this in the changelog.
> > int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
> > struct membuf to)
> > {
> >+ struct membuf to_msr = membuf_at(&to, offsetof(struct pt_regs, msr));
> >+
> > if (!cpu_has_feature(CPU_FTR_TM))
> > return -ENODEV;
> >@@ -97,17 +99,12 @@ int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
> > flush_altivec_to_thread(target);
> > membuf_write(&to, &target->thread.ckpt_regs,
> >- offsetof(struct pt_regs, msr));
> >- membuf_store(&to, get_user_ckpt_msr(target));
> >+ sizeof(struct user_pt_regs));
>
> This looks mis-aligned. But it should fit on a single line, now we allow up to 100 chars on a line.
OK, I can change this.
> >- BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
> >- offsetof(struct pt_regs, msr) + sizeof(long));
> >+ membuf_store(&to_msr, get_user_ckpt_msr(target));
> >- membuf_write(&to, &target->thread.ckpt_regs.orig_gpr3,
> >- sizeof(struct user_pt_regs) -
> >- offsetof(struct pt_regs, orig_gpr3));
> > return membuf_zero(&to, ELF_NGREG * sizeof(unsigned long) -
> >- sizeof(struct user_pt_regs));
> >+ sizeof(struct user_pt_regs));
>
> I can't see any change here except the alignment. Can you leave it as is ?
I just tried to make tm_cgpr_get() and gpr_get() look similar.
Sure, I can leave it as is.
Better yet, could you please fix this problem somehow so that I could forget
about the bug assigned to me?
I know nothing about powerpc, and personally I do not care about this (minor)
bug, I agree with any changes.
> >- membuf_write(&to, target->thread.regs, offsetof(struct pt_regs, msr));
> >- membuf_store(&to, get_user_msr(target));
> >+ membuf_write(&to, target->thread.regs,
> >+ sizeof(struct user_pt_regs));
>
> This should fit on a single line.
>
> > return membuf_zero(&to, ELF_NGREG * sizeof(unsigned long) -
> >- sizeof(struct user_pt_regs));
> >+ sizeof(struct user_pt_regs));
>
> This should not change, it's not part of the changes for this patch.
See above, I can leave it as is.
> >--- 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;
>
> Is there any point in using a struct membuf * instaed of a struct membuf as parameter ?
This matches other membuf_ helpers.
Oleg.
next prev parent reply other threads:[~2020-11-19 18:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 16:01 [PATCH v3 0/2] powerpc/ptrace: Hard wire PT_SOFTE value to 1 in gpr_get() too Oleg Nesterov
2020-11-19 16:02 ` [PATCH v3 1/2] powerpc/ptrace: simplify gpr_get/tm_cgpr_get Oleg Nesterov
2020-11-19 17:16 ` Christophe Leroy
2020-11-19 18:18 ` Oleg Nesterov [this message]
2020-11-19 16:02 ` [PATCH v3 2/2] powerpc/ptrace: Hard wire PT_SOFTE value to 1 in gpr_get() too Oleg Nesterov
2020-11-19 16:05 ` Oleg Nesterov
2020-11-19 17:18 ` Christophe Leroy
2020-11-19 21:10 ` Christophe Leroy
2020-11-19 22:43 ` Oleg Nesterov
2020-11-23 18:01 ` Oleg Nesterov
2020-11-24 0:53 ` Michael Ellerman
2020-11-19 17:19 ` [PATCH v3 0/2] " Christophe Leroy
2020-11-19 18:22 ` Oleg Nesterov
2020-12-10 11:30 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201119181804.GA5138@redhat.com \
--to=oleg@redhat.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=christophe.leroy@c-s.fr \
--cc=christophe.leroy@csgroup.eu \
--cc=jan.kratochvil@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.vnet.ibm.com \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).