Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1961089pxb; Mon, 23 Aug 2021 08:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKL+HSindIk0fuwd6Elg0SlT0jLNdglpuHgl1ijf4XaQZsahFf2j9f+LBEt8h/kEQ+YOG3 X-Received: by 2002:a6b:fc17:: with SMTP id r23mr27121851ioh.89.1629733147259; Mon, 23 Aug 2021 08:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629733147; cv=none; d=google.com; s=arc-20160816; b=WyK89rLFqDiPpa9Qmg+b3EC9EQOkl6TRQ0vmr02WHdVOz2hrNjz5tvLSC+21Jg9PTQ 1g2lSaXHvM0YMW0l7cfM3hqo4tCYkF+fcQGCSbtVRqCK0RLz3egBMBy9uMI3RT18uVAt ThF+1yn3D6RP8nVVmv3vuuVIOFWJtdovIkM/9DbIhDrmjUKh/AQIYghPY/+/tDI+9dto JqSgg+Rw/q26GyLSpQz8c+Q8SfkL4LkYv/FJEYAkx1RHg9PFw4o94cF0GLKgfxM90M8E zXc8SnxWLgofBkP6XHRDkfFKJfxjyQBa9R/JA+RYBP6wU5ZRlgM0BJth4pKamnOwgn93 hPOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:references:in-reply-to :message-id; bh=B3+jGePmA9F3xZYuK+iPUcEI7Vmf40DgNLVIzGwveLs=; b=Fuoo5SLnO7qrGF2rxiE8I+d7sgbjEGQKoW6YOdA2HuaQT0kawJnYH7O8dJzkS993Qk aTOPVjfhA1UklnL65PPJO6pTQ4TmZStohuyN72I4AxGEUk4xgU+m37FuNGn+Z0D2Tso5 6G4ejeGi892mLLYFFZWVQt9QB2KJ9UTh4N1lbDPzH4xghPAy33nGZzm1Zz70keVuyCMB lqXYfOl8LJnGeinJEu1XABQ2zUw8JPpAMDxtJV5xRoPlC1lEIJ84XS7QF5ANbneAIp5p dBchW//DBD8zFrpEhJgqhbU56PWOJLPrX9L/ikUH3tCOKuQQCcBL2WcMF9NJJdEM2pil vdbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si15492166iln.118.2021.08.23.08.38.55; Mon, 23 Aug 2021 08:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbhHWPgu (ORCPT + 99 others); Mon, 23 Aug 2021 11:36:50 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:60915 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbhHWPgs (ORCPT ); Mon, 23 Aug 2021 11:36:48 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GtbtN6ThDz9sWx; Mon, 23 Aug 2021 17:35:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q3MsoyM3ZJve; Mon, 23 Aug 2021 17:35:56 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4GtbtM5bkyz9sWm; Mon, 23 Aug 2021 17:35:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9035A8B7AF; Mon, 23 Aug 2021 17:35:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id R3keXlOwx4s6; Mon, 23 Aug 2021 17:35:55 +0200 (CEST) Received: from po18078vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 728DF8B7AD; Mon, 23 Aug 2021 17:35:55 +0200 (CEST) Received: by po18078vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 6B4476BC7C; Mon, 23 Aug 2021 15:35:55 +0000 (UTC) Message-Id: <7d391d915d2bd1c0f601f55f61f8dd4c70066229.1629732940.git.christophe.leroy@csgroup.eu> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v2 5/5] powerpc/signal: Use unsafe_copy_siginfo_to_user() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 23 Aug 2021 15:35:55 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use unsafe_copy_siginfo_to_user() in order to do the copy within the user access block. On an mpc 8321 (book3s/32) the improvment is about 5% on a process sending a signal to itself. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/signal_32.c | 13 ++++++------- arch/powerpc/kernel/signal_64.c | 5 +---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index ff101e2b3bab..f9e16d108bc8 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -710,12 +710,6 @@ static long restore_tm_user_regs(struct pt_regs *regs, struct mcontext __user *s } #endif -#ifdef CONFIG_PPC64 - -#define copy_siginfo_to_user copy_siginfo_to_user32 - -#endif /* CONFIG_PPC64 */ - /* * Set up a signal frame for a "real-time" signal handler * (one which gets siginfo). @@ -779,14 +773,19 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, asm("dcbst %y0; sync; icbi %y0; sync" :: "Z" (mctx->mc_pad[0])); } unsafe_put_sigset_t(&frame->uc.uc_sigmask, oldset, failed); +#ifndef CONFIG_COMPAT + unsafe_copy_siginfo_to_user(&frame->info, &ksig->info, failed); +#endif /* create a stack frame for the caller of the handler */ unsafe_put_user(regs->gpr[1], newsp, failed); user_access_end(); - if (copy_siginfo_to_user(&frame->info, &ksig->info)) +#ifdef CONFIG_COMPAT + if (copy_siginfo_to_user32(&frame->info, &ksig->info)) goto badframe; +#endif regs->link = tramp; diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 2cca6c8febe1..82b73fbd937d 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -901,15 +901,12 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, } unsafe_copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set), badframe_block); + unsafe_copy_siginfo_to_user(&frame->info, &ksig->info, badframe_block); /* Allocate a dummy caller frame for the signal handler. */ unsafe_put_user(regs->gpr[1], newsp, badframe_block); user_write_access_end(); - /* Save the siginfo outside of the unsafe block. */ - if (copy_siginfo_to_user(&frame->info, &ksig->info)) - goto badframe; - /* Make sure signal handler doesn't get spurious FP exceptions */ tsk->thread.fp_state.fpscr = 0; -- 2.25.0