Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp646940ybz; Wed, 15 Apr 2020 15:53:39 -0700 (PDT) X-Google-Smtp-Source: APiQypJxXKTSrRxigkOLPw9UXVhfJ10iEgw6ZyO1LOIxF05a72R+v95M/ahNlA1xJde0aO+AVcvl X-Received: by 2002:a17:906:85d3:: with SMTP id i19mr6918436ejy.153.1586991219469; Wed, 15 Apr 2020 15:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586991219; cv=none; d=google.com; s=arc-20160816; b=BkD8aXkG0RslG2Xo/WU6qrnlFyI/r7xaOeikx1sq8IWlDo2H7Hb/iBKSrW4orcfEBv ISBbl7FpfkSbIeW8f59371cNXMxin1UgiSL8ycyY9YjJyYHhNimULHF518we4Ovrxb9d b9Lknh7gIiA8MeGK1T5yX5rt3LhAll1LiOdmxOsx7Qom8niieJ0SEzru6p3gocDEMGjg QoF3Rt+SobMUzUaWDDmva+2UFm/BXtyKO4WVVSkpB9IprWg4jGVqhx1tWqZ+vJ13+/GX vwD6OHeK3VRmZ5y+Tqw0iZVgqQK1iXPIzNtSd0P1HK84bKY0fApQlZPvPzXu9wgZZr+d X/qg== 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:message-id :dkim-signature; bh=hkKFu8sRpCUMXlHi4pfwxQk9xCM6GrmMLh79FA+H4VM=; b=rc4+y9gNTrE24LAPoKtKSeFKb58/xij5QQYGPRSRdZ27pvC4QvA+GZH2bjqfV9g0uN qY158lvMu5cLBYcDl/BXh4jX35JK5qvb+ooKrnWpOM4TMzRincHj/5tnchFG8clbV8yN +eR3QAkK+pV8hrMdb46AHglrGFImkUiXw0sNiyGj1UxSKiNQ5gb/hDTG/xdo4inwWhBj PclHf/6XIctwkvTg2ObKvlKlaPLMMYvVjASFrzBO7aN4fBs86srdfi4vfh32B35PMM1T D8zMIdeSkDazT9VNYjtN4Zryk4zk/nz8tLvm2k7Qw4Cefyi36YWJUCrRpzuphHoJ/1OS wyCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=DymTGaOS; 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 pk26si7082473ejb.404.2020.04.15.15.53.16; Wed, 15 Apr 2020 15:53:39 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=DymTGaOS; 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 S2896143AbgDOKGT (ORCPT + 99 others); Wed, 15 Apr 2020 06:06:19 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:32691 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896141AbgDOKGO (ORCPT ); Wed, 15 Apr 2020 06:06:14 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 492J0L1h7rz9tyL2; Wed, 15 Apr 2020 12:06:10 +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=DymTGaOS; 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 7JeZM0syd1tt; Wed, 15 Apr 2020 12:06:10 +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 492J0K6Xg5z9tyKn; Wed, 15 Apr 2020 12:06:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1586945169; bh=hkKFu8sRpCUMXlHi4pfwxQk9xCM6GrmMLh79FA+H4VM=; h=From:Subject:To:Cc:Date:From; b=DymTGaOSUGHMez5hZSMw2s+fHEnCnX98xDcqO2/KRXf0+LGRlkpmXwGY0LwJ+wmzT s0O2Jz2fO0puohDRUAJ4JE8BGK/gpME8CN8M0ncam5zX2FtU7fwA/5ycw1lp6/1Eru r0NIG4xUrZvyrwW9vS6gB22meZXOz4YZqlzupRC8= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 19ACA8B977; Wed, 15 Apr 2020 12:06:11 +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 5lJGUnSjmWgq; Wed, 15 Apr 2020 12:06:11 +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 9FBB18B978; Wed, 15 Apr 2020 12:06:10 +0200 (CEST) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id E158B65789; Wed, 15 Apr 2020 10:06:09 +0000 (UTC) Message-Id: <57425c33dd72f292b1a23570244b81419072a7aa.1586945153.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] powerpc/8xx: Reduce time spent in allow_user_access() and friends To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 15 Apr 2020 10:06:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To enable/disable kernel access to user space, the 8xx has to modify the properties of access group 1. This is done by writing predefined values into SPRN_Mx_AP registers. As of today, a __put_user() gives: 00000d64 : d64: 3d 20 4f ff lis r9,20479 d68: 61 29 ff ff ori r9,r9,65535 d6c: 7d 3a c3 a6 mtspr 794,r9 d70: 39 20 00 00 li r9,0 d74: 90 83 00 00 stw r4,0(r3) d78: 3d 20 6f ff lis r9,28671 d7c: 61 29 ff ff ori r9,r9,65535 d80: 7d 3a c3 a6 mtspr 794,r9 d84: 4e 80 00 20 blr Because only groups 0 and 1 are used, the definition of groups 2 to 15 doesn't matter. By setting unused bits to 0 instead on 1, one instruction is removed for each lock and unlock action: 00000d5c : d5c: 3d 20 40 00 lis r9,16384 d60: 7d 3a c3 a6 mtspr 794,r9 d64: 39 20 00 00 li r9,0 d68: 90 83 00 00 stw r4,0(r3) d6c: 3d 20 60 00 lis r9,24576 d70: 7d 3a c3 a6 mtspr 794,r9 d74: 4e 80 00 20 blr Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/nohash/32/mmu-8xx.h b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h index 76af5b0cb16e..6aa3464a88ed 100644 --- a/arch/powerpc/include/asm/nohash/32/mmu-8xx.h +++ b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h @@ -37,16 +37,16 @@ * Therefore, we define 2 APG groups. lsb is _PMD_USER * 0 => Kernel => 01 (all accesses performed according to page definition) * 1 => User => 00 (all accesses performed as supervisor iaw page definition) - * 2-16 => NA => 11 (all accesses performed as user iaw page definition) + * 2-15 => Not Used */ -#define MI_APG_INIT 0x4fffffff +#define MI_APG_INIT 0x40000000 /* * 0 => Kernel => 01 (all accesses performed according to page definition) * 1 => User => 10 (all accesses performed according to swaped page definition) - * 2-16 => NA => 11 (all accesses performed as user iaw page definition) + * 2-15 => Not Used */ -#define MI_APG_KUEP 0x6fffffff +#define MI_APG_KUEP 0x60000000 /* The effective page number register. When read, contains the information * about the last instruction TLB miss. When MI_RPN is written, bits in @@ -117,16 +117,16 @@ * Therefore, we define 2 APG groups. lsb is _PMD_USER * 0 => Kernel => 01 (all accesses performed according to page definition) * 1 => User => 00 (all accesses performed as supervisor iaw page definition) - * 2-16 => NA => 11 (all accesses performed as user iaw page definition) + * 2-15 => Not Used */ -#define MD_APG_INIT 0x4fffffff +#define MD_APG_INIT 0x40000000 /* * 0 => No user => 01 (all accesses performed according to page definition) * 1 => User => 10 (all accesses performed according to swaped page definition) - * 2-16 => NA => 11 (all accesses performed as user iaw page definition) + * 2-15 => Not Used */ -#define MD_APG_KUAP 0x6fffffff +#define MD_APG_KUAP 0x60000000 /* The effective page number register. When read, contains the information * about the last instruction TLB miss. When MD_RPN is written, bits in -- 2.25.0