From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [216.12.86.13]) by sourceware.org (Postfix) with ESMTPS id 2D2263865470 for ; Fri, 22 Jan 2021 14:44:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2D2263865470 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=libc.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=dalias@libc.org Date: Fri, 22 Jan 2021 09:44:05 -0500 From: Rich Felker To: Florian Weimer Cc: Nicholas Piggin , linuxppc-dev@lists.ozlabs.org, Alan Modra , musl@lists.openwall.com, libc-alpha@sourceware.org Subject: Re: [musl] Re: [PATCH v2] powerpc/64/signal: balance return predictor stack in signal trampoline Message-ID: <20210122144402.GP23432@brightrain.aerifal.cx> References: <20200511101952.1463138-1-npiggin@gmail.com> <87im7pp5yl.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87im7pp5yl.fsf@oldenburg.str.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2021 14:44:09 -0000 On Fri, Jan 22, 2021 at 12:27:14PM +0100, Florian Weimer wrote: > * Nicholas Piggin: > > > diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S b/arch/powerpc/kernel/vdso64/sigtramp.S > > index a8cc0409d7d2..bbf68cd01088 100644 > > --- a/arch/powerpc/kernel/vdso64/sigtramp.S > > +++ b/arch/powerpc/kernel/vdso64/sigtramp.S > > @@ -6,6 +6,7 @@ > > * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp. > > * Copyright (C) 2004 Alan Modra (amodra@au.ibm.com)), IBM Corp. > > */ > > +#include /* IFETCH_ALIGN_BYTES */ > > #include > > #include > > #include > > @@ -14,21 +15,17 @@ > > > > .text > > > > -/* The nop here is a hack. The dwarf2 unwind routines subtract 1 from > > - the return address to get an address in the middle of the presumed > > - call instruction. Since we don't have a call here, we artificially > > - extend the range covered by the unwind info by padding before the > > - real start. */ > > - nop > > .balign 8 > > + .balign IFETCH_ALIGN_BYTES > > V_FUNCTION_BEGIN(__kernel_sigtramp_rt64) > > -.Lsigrt_start = . - 4 > > +.Lsigrt_start: > > + bctrl /* call the handler */ > > addi r1, r1, __SIGNAL_FRAMESIZE > > li r0,__NR_rt_sigreturn > > sc > > .Lsigrt_end: > > V_FUNCTION_END(__kernel_sigtramp_rt64) > > -/* The ".balign 8" above and the following zeros mimic the old stack > > +/* The .balign 8 above and the following zeros mimic the old stack > > trampoline layout. The last magic value is the ucontext pointer, > > chosen in such a way that older libgcc unwind code returns a zero > > for a sigcontext pointer. */ > > As far as I understand it, this breaks cancellation handling on musl and > future glibc because it is necessary to look at the signal delivery > location to see if a system call sequence has result in an action, and > that location is no longer in user code after this change. > > We have a glibc test in preparation of our change, and it started > failing: > > Linux 5.10 breaks sigcontext_get_pc on powerpc64 > > > Isn't it possible to avoid the return predictor desynchronization by > adding the appropriate hint? Maybe I'm missing something but I don't see how this would break musl; we just inspect the PC in the mcontext, which I don't see any changes to and which should still point to the next instruction of the interrupted context. I don't have a test environment though so I'll have to wait for feedback from ppc users to be sure. Are there any further details on how it's breaking glibc? Rich