Re: [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value()

Dmitry V. Levin
2025-01-21T12:42:42Z

On Tue, Jan 21, 2025 at 05:55:40PM +0530, Madhavan Srinivasan wrote:
> On 1/21/25 4:58 PM, Christophe Leroy wrote:
> > Le 21/01/2025 à 12:13, Madhavan Srinivasan a écrit :
> >> On 1/20/25 10:42 PM, Dmitry V. Levin wrote:
> >>> On Mon, Jan 20, 2025 at 02:51:38PM +0100, Christophe Leroy wrote:
> >>>> Le 14/01/2025 à 18:04, Dmitry V. Levin a écrit :
> >>>>> On Mon, Jan 13, 2025 at 06:34:44PM +0100, Christophe Leroy wrote:
> >>>>>> Le 13/01/2025 à 18:10, Dmitry V. Levin a écrit :
> >>>>>>> Bring syscall_set_return_value() in sync with syscall_get_error(),
> >>>>>>> and let upcoming ptrace/set_syscall_info selftest pass on powerpc.
> >>
> >> Sorry for getting to this thread late.
> >>
> >> Tried the series without this patch in
> >>
> >> 1) power9 PowerNV system and in power10 pSeries lpar
> >>
> >> # ./set_syscall_info
> >> TAP version 13
> >> 1..1
> >> # Starting 1 tests from 1 test cases.
> >> #  RUN           global.set_syscall_info ...
> >> #            OK  global.set_syscall_info
> >> ok 1 global.set_syscall_info
> >> # PASSED: 1 / 1 tests passed.
> >> # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> >>
> >> and in both case set_syscall_info passes.
> >> Will look at it further.
> >
> > I guess it works because power9/10 are using scv not sc for system call, hence using the new ABI ?
>
> yeah, I guess.
> This is from the a Power8 pSeries lpar without this patch
>
> # ./set_syscall_info
> TAP version 13
> 1..1
> # Starting 1 tests from 1 test cases.
> # RUN global.set_syscall_info ...
> # set_syscall_info.c:428:set_syscall_info:wait #5: unexpected stop signal 11
> # set_syscall_info: Test terminated by assertion
> # FAIL global.set_syscall_info
> not ok 1 global.set_syscall_info
> # FAILED: 0 / 1 tests passed.
> # Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0

I've enhanced error diagnostics of the test a bit. Inspired by this
powerpc bug, in the next iteration of the patchset the test would also
invoke PTRACE_GET_SYSCALL_INFO right after PTRACE_SET_SYSCALL_INFO to
check whether the changes are applied by the kernel correctly.
Without the fix, in non-svc case the test would complain this way:

# set_syscall_info.c:119:set_syscall_info:Expected exp_exit->rval (-38) == info->exit.rval (38)
# set_syscall_info.c:120:set_syscall_info:wait #4: PTRACE_GET_SYSCALL_INFO #2: exit stop mismatch

--
ldv