Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2574337ybb; Sun, 5 Apr 2020 10:57:20 -0700 (PDT) X-Google-Smtp-Source: APiQypL/MmFH3QByvt4vIjxLg+J8BWN0Ex6DiOE7dXP+EmwXFGMFQBKagln9TsB0bOxA+P2yJahU X-Received: by 2002:aca:f183:: with SMTP id p125mr10434555oih.74.1586109439933; Sun, 05 Apr 2020 10:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586109439; cv=none; d=google.com; s=arc-20160816; b=q2OBziR8xoqdjNfc7IR1ieVnaALin1XjwLLmSlIRjWL4tMldx7OQ5FXcylL/TZPiym +fcA1R3XNXg/FxfzjI0Sr66PN9PY/Ls+SPEWVEtNqdDY+UQboTrjWJPpJMT/nd2QuAGX qBOY+KxfTwR29EZ8NgGGIFAQgzIN4rMB/ot2++noHIZ1P3zx2UZE3JsB+x1JTR5E0jDj qo+UH9YSFHizjQZRpNw0ROVLhR0ew12/lz9WCH0UGk95HESkork5QyIAK+5bFIAK51rV 8DpTUaqfFtH1MitKhoobyPn/Cp9JvbMQ0daBYuab3V08dnLCStGpEJTBdNQG6bOC/y0W gSZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=T0suTl0BTFRF4sRPMYUbza6cd6VMEsnPiv6JirSP2TU=; b=Fsvots8/TxUm0DJAJuh1pGvVeQOM7OuQCEXuGVhKVJrKeZ0KNYwHIOXFfvfKWuEfK3 5GIFskiP2OD1x1LUxVbeN9y+2f5PUmaiQS8VfwIijGpzl0uuDiaxEQvYjbT3AWMYT+yM UcKiI/0khPc6DZnis2Cm1mDkppQGJCVyWhVFC86SYP/RW7xsQO1gi6MMGJ6MGScVoold 0xx9RkSt7+473OA/Unwcyz1WllmXboBD7hd8Grt/ZvEvOFzpE7WEsLNXN8xsLJQtAL6+ s3JZSRpFNODjsv1QUpLiL1A/BmvTc+gqXDNZP6F3scpk5CADrjWbrhmw2/XeitT9AmtK IrJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=wcWUomYD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si6925431otq.134.2020.04.05.10.56.56; Sun, 05 Apr 2020 10:57:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=wcWUomYD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727919AbgDERo4 (ORCPT + 99 others); Sun, 5 Apr 2020 13:44:56 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:16723 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727890AbgDERov (ORCPT ); Sun, 5 Apr 2020 13:44:51 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48wLf44C2mz9ty3M; Sun, 5 Apr 2020 19:44:44 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=wcWUomYD; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id KpjL9PWw_sEu; Sun, 5 Apr 2020 19:44:44 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48wLf43CLGz9ty2y; Sun, 5 Apr 2020 19:44:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1586108684; bh=T0suTl0BTFRF4sRPMYUbza6cd6VMEsnPiv6JirSP2TU=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=wcWUomYDP4YBUNujKfSRL3CNdHHtW+kAxTbIGTyQUeScsOPW7ib9w7RzyvnI60Qy1 546mp/M2lLdLWI59hclvoGT95/95o4w9FWUgdeBidgn1layLgBEIZf5jG97QxvRors tfIDSmN3c3LCSojh6wkRBRc+S77Pl3XE2AZuCXS4= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 002E08B783; Sun, 5 Apr 2020 19:44:47 +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 D4F0wqvJboPq; Sun, 5 Apr 2020 19:44:47 +0200 (CEST) Received: from pc16570vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BB95B8B774; Sun, 5 Apr 2020 19:44:47 +0200 (CEST) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 8DBB16571C; Sun, 5 Apr 2020 17:44:47 +0000 (UTC) Message-Id: <4ef6d617cfd34e09e9bf5a456b2e0b6d2a8a3c96.1586108649.git.christophe.leroy@c-s.fr> In-Reply-To: <029e1064b1ad738785718221ea468c9cfc282457.1586108649.git.christophe.leroy@c-s.fr> References: <029e1064b1ad738785718221ea468c9cfc282457.1586108649.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [RFC PATCH v2 12/13] powerpc/kernel: Do not inconditionally save non volatile registers on system call To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , npiggin@gmail.com, msuchanek@suse.de Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Sun, 5 Apr 2020 17:44:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before : 347 cycles on null_syscall After : 327 cycles on null_syscall Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/entry_32.S | 15 +++++++++++++++ arch/powerpc/kernel/head_32.h | 3 +-- arch/powerpc/kernel/syscall.c | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 103f5158bc44..b5113593e57f 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -315,13 +315,28 @@ stack_ovf: RFI #endif +save_nvgprs: + lwz r11, _TRAP(r1) + andi. r12, r11, 1 + rlwinm r11, r11, 0, ~1 + beqlr + SAVE_NVGPRS(r1) + stw r11, _TRAP(r1) + blr + .globl transfer_to_syscall transfer_to_syscall: + lwz r10, TI_FLAGS(r2) mr r9, r0 + andi. r10, r10, _TIF_SYSCALL_DOTRACE addi r10, r1, STACK_FRAME_OVERHEAD + bnel- save_nvgprs bl system_call_exception ret_from_syscall: + lwz r9, TI_FLAGS(r2) addi r4, r1, STACK_FRAME_OVERHEAD + andi. r0, r9, _TIF_SYSCALL_DOTRACE | _TIF_SINGLESTEP | _TIF_USER_WORK_MASK + bnel- save_nvgprs bl syscall_exit_prepare lwz r2, _CCR(r1) lwz r4, _NIP(r1) diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h index c301d666a3e5..1cc9a67cb42c 100644 --- a/arch/powerpc/kernel/head_32.h +++ b/arch/powerpc/kernel/head_32.h @@ -174,13 +174,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) stw r2,GPR2(r11) addi r10,r10,STACK_FRAME_REGS_MARKER@l stw r9,_MSR(r11) - li r2, \trapno + li r2, \trapno + 1 stw r10,8(r11) stw r2,_TRAP(r11) SAVE_GPR(0, r11) SAVE_4GPRS(3, r11) SAVE_2GPRS(7, r11) - SAVE_NVGPRS(r11) addi r11,r1,STACK_FRAME_OVERHEAD addi r2,r12,-THREAD stw r11,PT_REGS(r12) diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c index 630c423e089a..34fd66fd11a2 100644 --- a/arch/powerpc/kernel/syscall.c +++ b/arch/powerpc/kernel/syscall.c @@ -39,7 +39,7 @@ notrace long system_call_exception(long r3, long r4, long r5, if (!IS_ENABLED(CONFIG_PPC_BOOK3E)) BUG_ON(!(regs->msr & MSR_RI)); BUG_ON(IS_ENABLED(CONFIG_PPC64) && !(regs->msr & MSR_PR)); - BUG_ON(!FULL_REGS(regs)); + BUG_ON(IS_ENABLED(CONFIG_PPC64) && !FULL_REGS(regs)); #ifdef CONFIG_PPC64 BUG_ON(regs->softe != IRQS_ENABLED); #endif -- 2.25.0