Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp409729imu; Fri, 25 Jan 2019 04:35:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ai8BYfM12x48+RVFlS6Ml5ZQ0ZIcVVePzOyU5cD28MIxZk6VUCsljWS+dNF6UQ0hZvSrz X-Received: by 2002:a17:902:b943:: with SMTP id h3mr10975747pls.12.1548419702042; Fri, 25 Jan 2019 04:35:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548419702; cv=none; d=google.com; s=arc-20160816; b=Gdfb9FWnISZ80mveB190nTTyyMtfWC2r4MhfkUFlxsSZd08tN32P1H+S4hlJCUo+D/ PdLQhJDbryR22e0gi+DbMWiv/ZgMhsBaFHd8KA1NfrMhS0jxd3BH3dW6BX7pce2oPdiv adEsrCcP6UWJ7TJgSDkGHKGa1qRxqEaCIKE9KnKaLKi4Tl0CkUNeE0EBUPV1fo1PIiLd 1IXisvagwbbfmUXvk5ynWciPE7JPHYFAzWQOolwkgeTifEnghtR9HiC4lSAraZtugTRt C6JQs6YRoSgAGqInlWwGHC/MeceYpXBDAuo73nMvVng382RunqqU0Lm4mRSH1WH2ZTTA p8/Q== 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=CrPkdK3q39TRGA/9Zt6xxGfth4BhEd3bTlrfCJDrkIk=; b=WNc0fQ0S/rQ5sPdeT7c1xGeGgDBUkQl52PdQzW3eRUupgtVh4yECLESWrxFAJpTuID J8NfzPYaSsmU1Hh36h42+DMgO8mFpBXyptz2f/cloKQCX93OLEI0YeAe4u54eil/mPZa USRcaLhOdkTf+kucIzcInqIcLbXIGFH9OGM5pQjZGYmTVYI08IAeWJHhLiYHMWK2DlML goAGL1YsOek0GdLKY7hdDA3nh0Wx8kRfxnIoFK08M8ORggLV33nBKoTnvgjJs8NCfNIJ Qtvhph1qNTXHTFuC/HHwY8iuJipQzbFhy9dDG6AiGY8ZXI0DYOqZLdE/fxF3oGZW39z9 9qcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=L3oGX9x5; 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 t13si25399673pgm.175.2019.01.25.04.34.46; Fri, 25 Jan 2019 04:35:02 -0800 (PST) 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=L3oGX9x5; 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 S1728740AbfAYMe1 (ORCPT + 99 others); Fri, 25 Jan 2019 07:34:27 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:34219 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728629AbfAYMeW (ORCPT ); Fri, 25 Jan 2019 07:34:22 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43mJP750WHz9tyxw; Fri, 25 Jan 2019 13:34:19 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=L3oGX9x5; 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 ndNutyRyUHjv; Fri, 25 Jan 2019 13:34:19 +0100 (CET) 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 43mJP73yShz9tyxr; Fri, 25 Jan 2019 13:34:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1548419659; bh=CrPkdK3q39TRGA/9Zt6xxGfth4BhEd3bTlrfCJDrkIk=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=L3oGX9x5ZkZeBwTFV8YU9G6OkfWD7FhZgsdz6Isv7EMPRIm6jKh6sYz3WanPuHxqS l5akjY+3DovmJs8AGFG3cU5AfvlZZInB9BDCNSGeV2CC04EsY2Nl5JRqg7DSxzI8el mJl6B1uPj/5a1zdzJuUYIq3BNSpYQyNpKmczVubQ= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D23478B87A; Fri, 25 Jan 2019 13:34:20 +0100 (CET) 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 GplIh6kJRcU9; Fri, 25 Jan 2019 13:34:20 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A5AAF8B761; Fri, 25 Jan 2019 13:34:20 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 819FA72DA9; Fri, 25 Jan 2019 12:34:20 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH 10/10] powerpc/book3s32: Reorder _PAGE_XXX flags to simplify TLB handling To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , joakim.tjernlund@infinera.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 25 Jan 2019 12:34:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For pages without _PAGE_USER, PP field is 00 For pages with _PAGE_USER, PP field is 10 for RW and 11 for RO. This patch sets _PAGE_USER to 0x002 and _PAGE_RW to 0x001 is order to simplify TLB handling by reducing amount of shifts. The location of _PAGE_PRESENT and _PAGE_HASHPTE doesn't matter as they are only SW related flags. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/32/hash.h | 8 ++++---- arch/powerpc/kernel/head_32.S | 5 +---- arch/powerpc/mm/hash_low_32.S | 6 ++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/32/hash.h b/arch/powerpc/include/asm/book3s/32/hash.h index 2a0a467d2985..a5907ea4fb40 100644 --- a/arch/powerpc/include/asm/book3s/32/hash.h +++ b/arch/powerpc/include/asm/book3s/32/hash.h @@ -17,9 +17,9 @@ * updating the accessed and modified bits in the page table tree. */ -#define _PAGE_PRESENT 0x001 /* software: pte contains a translation */ -#define _PAGE_HASHPTE 0x002 /* hash_page has made an HPTE for this pte */ -#define _PAGE_USER 0x004 /* usermode access allowed */ +#define _PAGE_RW 0x001 /* PP = x1: user write access allowed */ +#define _PAGE_USER 0x002 /* PP = 1x: usermode access allowed */ +#define _PAGE_HASHPTE 0x004 /* software: hash_page has made an HPTE for this pte */ #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */ #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */ #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */ @@ -27,7 +27,7 @@ #define _PAGE_DIRTY 0x080 /* C: page changed */ #define _PAGE_ACCESSED 0x100 /* R: page referenced */ #define _PAGE_EXEC 0x200 /* software: exec allowed */ -#define _PAGE_RW 0x400 /* software: user write access allowed */ +#define _PAGE_PRESENT 0x400 /* software: pte contains a translation */ #define _PAGE_SPECIAL 0x800 /* software: Special page */ #ifdef CONFIG_PTE_64BIT diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S index 9f25f44b6448..3131fbd9e7f5 100644 --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S @@ -524,7 +524,6 @@ InstructionTLBMiss: andc. r1,r1,r0 /* check access & ~permission */ bne- InstructionAddressInvalid /* return if access not permitted */ /* Convert linux-style PTE to low word of PPC-style PTE */ - rlwimi r0,r0,32-1,30,30 /* _PAGE_USER -> PP msb */ ori r1, r1, 0xe05 /* clear out reserved bits */ andc r1, r0, r1 /* PP = user? 2 : 0 */ BEGIN_FTR_SECTION @@ -592,8 +591,7 @@ DataLoadTLBMiss: * we would need to update the pte atomically with lwarx/stwcx. */ /* Convert linux-style PTE to low word of PPC-style PTE */ - rlwinm r1,r0,32-10,31,31 /* _PAGE_RW -> PP lsb */ - rlwimi r0,r0,32-1,30,30 /* _PAGE_USER -> PP msb */ + rlwinm r1, r0, 0, 31, 31 /* _PAGE_RW -> PP lsb */ rlwimi r0,r0,32-1,31,31 /* _PAGE_USER -> PP lsb */ ori r1,r1,0xe04 /* clear out reserved bits */ andc r1,r0,r1 /* PP = user? rw? 2: 3: 0 */ @@ -672,7 +670,6 @@ DataStoreTLBMiss: * we would need to update the pte atomically with lwarx/stwcx. */ /* Convert linux-style PTE to low word of PPC-style PTE */ - rlwimi r0,r0,32-1,30,30 /* _PAGE_USER -> PP msb */ li r1,0xe05 /* clear out reserved bits & PP lsb */ andc r1,r0,r1 /* PP = user? 2: 0 */ BEGIN_FTR_SECTION diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S index 2afd0dce6d6a..ab60f541c4d2 100644 --- a/arch/powerpc/mm/hash_low_32.S +++ b/arch/powerpc/mm/hash_low_32.S @@ -311,11 +311,9 @@ Hash_msk = (((1 << Hash_bits) - 1) * 64) _GLOBAL(create_hpte) /* Convert linux-style PTE (r5) to low word of PPC-style PTE (r8) */ - rlwinm r8,r5,32-10,31,31 /* _PAGE_RW -> PP lsb */ rlwinm r0,r5,32-7,31,31 /* _PAGE_DIRTY -> PP lsb */ - and r8,r8,r0 /* writable if _RW & _DIRTY */ - rlwimi r5,r5,32-1,30,30 /* _PAGE_USER -> PP msb */ - rlwimi r5,r5,32-2,31,31 /* _PAGE_USER -> PP lsb */ + and r8, r5, r0 /* writable if _RW & _DIRTY */ + rlwimi r5, r5, 32 - 1, 31, 31 /* _PAGE_USER -> PP lsb */ ori r8,r8,0xe04 /* clear out reserved bits */ andc r8,r5,r8 /* PP = user? (rw&dirty? 2: 3): 0 */ BEGIN_FTR_SECTION -- 2.13.3