From: Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
linuxppc-dev@lists.ozlabs.org,
Anshuman Khandual <khandual@linux.vnet.ibm.com>
Subject: Re: [RFC PATCH 1/5] powerpc: Fix inverted active predicate for setting the EBB regset
Date: Thu, 14 Jun 2018 10:52:41 -0300 [thread overview]
Message-ID: <877en1mq52.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <87fu1rtot3.fsf@concordia.ellerman.id.au>
Michael Ellerman <mpe@ellerman.id.au> writes:
> Hi Pedro,
>
> Thanks for looking into this, how did you detect this? Do you have a
> test case?
Hello,
I'm working on allowing these registers to be accessed through GDB,
which is where I saw this happen. Then I used a small program that
traces another, then reads and tries to write to the regset, but not in
linux selftest format.
> I don't think Anshuman wrote it this way on purpose, but added him to Cc
> in case he remembers.
>
> But I don't think this fix is necessarily right. If we are setting the
> EBB regs via ptrace then it doesn't matter if they were previously in
> use or not, we should just set them. What *does* matter is that at the
> end of the function we set used_ebb to true, because otherwise the
> values we have set will not actually be used when the process is
> rescheduled.
Now I'm not sure why the ptrace calls for the ebb regset are guarded
with used_ebb in the first place. The save/restore_sprs functions in
kernel/process.c seem to handle the ebb registers regardless of this
flag, and it seems to be possible for user programs to read and write to
these registers even without having first created a perf event.
The flag only appears to be used in perf/core_book3s.c in the
ebb_event_add function, and the pmu registers (mmcr0, etc) only seem to
be saved to and restored from the thread_struct through
ebb_switch_in/out. So maybe the original intent was to guard the
pmu_get/set functions with used_ebb instead?
I'm not sure about this, because I don't know if it possible for a
ptrace call to happen between ebb_event_add and the first ebb_switch_in
for a thread.
Thanks!
--
Pedro
next prev parent reply other threads:[~2018-06-14 13:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 15:25 [RFC PATCH 0/5] powerpc: Misc. ptrace regset fixes Pedro Franco de Carvalho
2018-06-07 15:25 ` [RFC PATCH 1/5] powerpc: Fix inverted active predicate for setting the EBB regset Pedro Franco de Carvalho
2018-06-13 2:15 ` Michael Ellerman
2018-06-13 4:09 ` Michael Ellerman
2018-06-14 13:52 ` Pedro Franco de Carvalho [this message]
2018-06-07 15:25 ` [RFC PATCH 2/5] powerpc: Flush checkpointed gpr state for 32-bit processes in ptrace Pedro Franco de Carvalho
2018-06-13 2:19 ` Michael Ellerman
2018-06-14 13:55 ` Pedro Franco de Carvalho
2018-06-19 19:54 ` [PATCH 1/2] " Pedro Franco de Carvalho
2024-03-12 8:07 ` Christophe Leroy
2018-06-19 19:54 ` [PATCH 2/2] powerpc: Use helper function to flush TM state " Pedro Franco de Carvalho
2018-06-07 15:25 ` [RFC PATCH 3/5] powerpc: Fix pmu get/set functions Pedro Franco de Carvalho
2018-06-07 15:25 ` [RFC PATCH 4/5] powerpc: Add VSX regset to compat_regsets Pedro Franco de Carvalho
2018-06-07 15:25 ` [RFC PATCH 5/5] powerpc: Add PMU " Pedro Franco de Carvalho
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=877en1mq52.fsf@linux.vnet.ibm.com \
--to=pedromfc@linux.vnet.ibm.com \
--cc=khandual@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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).