linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 0/2] powerpc: Disable syscall emulation and stepping
Date: Fri, 28 Jan 2022 16:45:51 +0530	[thread overview]
Message-ID: <b570dda0f7d142a149b3f6eacd7b0631@imap.linux.ibm.com> (raw)
In-Reply-To: <1643268944.tltfmyu1ey.astroid@bobo.none>

On 2022-01-27 13:09, Nicholas Piggin wrote:
> Excerpts from naverao1's message of January 25, 2022 8:48 pm:
>> On 2022-01-25 11:23, Christophe Leroy wrote:
>>> Le 25/01/2022 à 04:04, Nicholas Piggin a écrit :
>>>> +Naveen (sorry missed cc'ing you at first)
>>>> 
>>>> Excerpts from Christophe Leroy's message of January 24, 2022 4:39 
>>>> pm:
>>>>> 
>>>>> 
>>>>> Le 24/01/2022 à 06:57, Nicholas Piggin a écrit :
>>>>>> As discussed previously
>>>>>> 
>>>>>> https://lists.ozlabs.org/pipermail/linuxppc-dev/2022-January/238946.html
>>>>>> 
>>>>>> I'm wondering whether PPC32 should be returning -1 for syscall
>>>>>> instructions too here? That could be done in another patch anyway.
>>>>>> 
>>>>> 
>>>>> The 'Programming Environments Manual for 32-Bit Implementations of
>>>>> the
>>>>> PowerPC™ Architecture' says:
>>>>> 
>>>>> The following are not traced:
>>>>> • rfi instruction
>>>>> • sc and trap instructions that trap
>>>>> • Other instructions that cause interrupts (other than trace
>>>>> interrupts)
>>>>> • The first instruction of any interrupt handler
>>>>> • Instructions that are emulated by software
>>>>> 
>>>>> 
>>>>> So I think PPC32 should return -1 as well.
>>>> 
>>>> I agree.
>>>> 
>>>> What about the trap instructions? analyse_instr returns 0 for them
>>>> which falls through to return 0 for emulate_step, should they
>>>> return -1 as well or am I missing something?
>> 
>> Yeah, good point about the trap instructions.
>> 
>>>> 
>>> 
>>> For the traps I don't know. The manual says "trap instructions that
>>> trap" are not traced. It means that "trap instructions that _don't_
>>> trap" are traced. Taking into account that trap instructions don't 
>>> trap
>>> at least 99.9% of the time, not sure if returning -1 is needed.
>>> 
>>> Allthought that'd probably be the safest.
>> 
>> 'trap' is a special case since it is predominantly used by debuggers
>> and/or tracing infrastructure. Kprobes and Uprobes do not allow probes
>> on a trap instruction. But, xmon can be asked to step on a trap
>> instruction and that can interfere with kprobes in weird ways.
>> 
>> So, I think it is best if we also exclude trap instructions from being
>> single stepped.
>> 
>>> 
>>> But then what happens with other instruction that will sparsely
>>> generate
>>> an exception like a DSI or so ? If we do it for the traps then we
>>> should
>>> do it for this as well, and then it becomes a non ending story.
>> 
>> For a DSI, we restart the same instruction after handling the page
>> fault.
>> The single step exception is raised on the subsequent successful
>> completion of the instruction.
> 
> Although it can cause a signal, and the signal handler can decide
> to resume somewhere else.

If a signal is generated while we are single-stepping, we delay signal
delivery (see uprobe_deny_signal()) until after the single stepping.
For fatal signals, single stepping is disabled before we allow the
signal to be delivered.

> Or kernel mode equivalent it can go to a
> fixup handler and resume somewhere else.

For kprobes, we do not allow probing instructions that have an extable
entry.

- Naveen

  reply	other threads:[~2022-01-28 11:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24  5:57 [PATCH 0/2] powerpc: Disable syscall emulation and stepping Nicholas Piggin
2022-01-24  5:57 ` [PATCH 1/2] powerpc/64: remove system call instruction emulation Nicholas Piggin
2022-01-24  5:57 ` [PATCH 2/2] powerpc/uprobes: Reject uprobe on a system call instruction Nicholas Piggin
2022-01-25 11:45   ` Michael Ellerman
2022-01-27  7:44     ` Nicholas Piggin
2022-01-28 11:30       ` Naveen N. Rao
2022-01-24  6:39 ` [PATCH 0/2] powerpc: Disable syscall emulation and stepping Christophe Leroy
2022-01-25  3:04   ` Nicholas Piggin
2022-01-25  5:53     ` Christophe Leroy
     [not found]       ` <52b03748fdeff1bb2eb67f6038311e26@imap.linux.ibm.com>
2022-01-27  7:39         ` Nicholas Piggin
2022-01-28 11:15           ` Naveen N. Rao [this message]
2022-01-28 11:11       ` Naveen N. Rao

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=b570dda0f7d142a149b3f6eacd7b0631@imap.linux.ibm.com \
    --to=naveen.n.rao@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=npiggin@gmail.com \
    /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).