Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5676982imb; Thu, 7 Mar 2019 23:06:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzNU7tQjH9rFW/L6IXbyPcr5aqZzbjiONgh7tEy5vRjcWXSDokzL+uvMKa2tOhBR8yIB2c2 X-Received: by 2002:a63:80c7:: with SMTP id j190mr14768459pgd.357.1552028800517; Thu, 07 Mar 2019 23:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552028800; cv=none; d=google.com; s=arc-20160816; b=t6tzhdkvKui8eAs++hFlqtNPTnZJcaqcwPVedoKZvLvY7FEzlzmAW+SjLiom3OAZsU 1gYSVuIuQGr4DK/Rcgw+2yZdttQNuH/EURr3I7hc7Sb2M1tw3lZ5A3taGOXZRnEt9niE 5T/T74g8muK6jZDBAiDHKePTSiJ3RTEq2iB4oIexgM92LT1xREhE07ZNn5ZPiq3DOw6P RSmNdKJfyLTUXcYkkI4NvNXwpCKER1gU+hvGmC8aT6xKDSxbjeUCxkWaNAUniJzO0r6U 1ia9PZzaMKd3N5kPnIs2ZhI7raNbwJkNQYk5Av5sw5L6MmYw6MnQCdRZuqyIHrYvQ0eX 9W3w== 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=OR2fnmd/9BeL9wEAn8cBSd36T+Fm861SgnzGfC8I3K0=; b=zfa5GlRNgh0fh9STd8StzE98BLqbnrmrKR2bCdO2gUY7AlIUL4yKjPR1fj0hopnjOY vs59V45wMbLZa9igyerUPQEcmVMfhVPvuOh02wSkVklarOu+Zr+obQdibAeyP6lNA3oT nha3vjK1bYqhUHlvXdhG8q3UY+PVzbnZewAKsKLlFp5TGUu8OvvxXh5oz7PdqB++t9GI 0pbbjBWoei9Cu82Ai9kG0tXiFwh16gWuD0r3TfLL//Na6IkEv13Y13hRb7p7rqP0sep6 2pmQNxg+uTPGDGZDtc5d1+qLkCJ5INVlpF4jbofNNgEYdDW6jqgFwcQHrnSl8BpDQQfW Ve0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=U8C7qwq5; 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 a4si6164790pfj.68.2019.03.07.23.06.24; Thu, 07 Mar 2019 23:06:40 -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=U8C7qwq5; 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 S1726355AbfCHHFZ (ORCPT + 99 others); Fri, 8 Mar 2019 02:05:25 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:61868 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbfCHHFY (ORCPT ); Fri, 8 Mar 2019 02:05:24 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44Fz6B0fVdz9tySV; Fri, 8 Mar 2019 08:05:22 +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=U8C7qwq5; 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 gPdid5AlgUey; Fri, 8 Mar 2019 08:05:22 +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 44Fz696Zpzz9tyST; Fri, 8 Mar 2019 08:05:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1552028721; bh=OR2fnmd/9BeL9wEAn8cBSd36T+Fm861SgnzGfC8I3K0=; h=From:Subject:To:Cc:Date:From; b=U8C7qwq5ZH5ZMve08G3xAzb+txxVO0hWVD8IPeZ2PXkY5YqHeN15N8S5aMjg7Pqxa nhpxT/3evAgXGd19sSP1+KDxxmaw8eEdMs6rPCRkAShIh7G2ERrPqPrrTw7xXKC87c o8/YrMWBycRytuTRXaXszQpytsVWfViHV3ciJtys= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C92F48B75A; Fri, 8 Mar 2019 08:05:22 +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 uzYi-DwFFyss; Fri, 8 Mar 2019 08:05:22 +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 AA67F8BF5D; Fri, 8 Mar 2019 08:05:22 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 8D0406F8A3; Fri, 8 Mar 2019 07:05:22 +0000 (UTC) Message-Id: <7e45ca3f0283fb24c2642e5b91bd75c55f2ba96f.1552028583.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] powerpc/6xx: fix setup and use of SPRN_PGDIR for hash32 To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Guenter Roeck Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 8 Mar 2019 07:05:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Not only the 603 but all 6xx need SPRN_PGDIR to be initialised at startup. This patch move it from __setup_cpu_603() to start_here() and __secondary_start(), close to the initialisation of SPRN_THREAD. Previously, virt addr of PGDIR was retrieved from thread struct. Now that it is the phys addr which is stored in SPRN_PGDIR, hash_page() shall not convert it to phys anymore. This patch removes the conversion. Fixes: 93c4a162b014("powerpc/6xx: Store PGDIR physical address in a SPRG") Reported-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/cpu_setup_6xx.S | 3 --- arch/powerpc/kernel/head_32.S | 6 ++++++ arch/powerpc/mm/hash_low_32.S | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/cpu_setup_6xx.S index 6f1c11e0691f..7534ecff5e92 100644 --- a/arch/powerpc/kernel/cpu_setup_6xx.S +++ b/arch/powerpc/kernel/cpu_setup_6xx.S @@ -24,9 +24,6 @@ BEGIN_MMU_FTR_SECTION li r10,0 mtspr SPRN_SPRG_603_LRU,r10 /* init SW LRU tracking */ END_MMU_FTR_SECTION_IFSET(MMU_FTR_NEED_DTLB_SW_LRU) - lis r10, (swapper_pg_dir - PAGE_OFFSET)@h - ori r10, r10, (swapper_pg_dir - PAGE_OFFSET)@l - mtspr SPRN_SPRG_PGDIR, r10 BEGIN_FTR_SECTION bl __init_fpu_registers diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S index ce6a972f2584..48051c8977c5 100644 --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S @@ -855,6 +855,9 @@ __secondary_start: li r3,0 stw r3, RTAS_SP(r4) /* 0 => not in RTAS */ #endif + lis r4, (swapper_pg_dir - PAGE_OFFSET)@h + ori r4, r4, (swapper_pg_dir - PAGE_OFFSET)@l + mtspr SPRN_SPRG_PGDIR, r4 /* enable MMU and jump to start_secondary */ li r4,MSR_KERNEL @@ -942,6 +945,9 @@ start_here: li r3,0 stw r3, RTAS_SP(r4) /* 0 => not in RTAS */ #endif + lis r4, (swapper_pg_dir - PAGE_OFFSET)@h + ori r4, r4, (swapper_pg_dir - PAGE_OFFSET)@l + mtspr SPRN_SPRG_PGDIR, r4 /* stack */ lis r1,init_thread_union@ha diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S index 1f13494efb2b..a6c491f18a04 100644 --- a/arch/powerpc/mm/hash_low_32.S +++ b/arch/powerpc/mm/hash_low_32.S @@ -70,12 +70,12 @@ _GLOBAL(hash_page) lis r0,KERNELBASE@h /* check if kernel address */ cmplw 0,r4,r0 ori r3,r3,_PAGE_USER|_PAGE_PRESENT /* test low addresses as user */ - mfspr r5, SPRN_SPRG_PGDIR /* virt page-table root */ + mfspr r5, SPRN_SPRG_PGDIR /* phys page-table root */ blt+ 112f /* assume user more likely */ - lis r5,swapper_pg_dir@ha /* if kernel address, use */ - addi r5,r5,swapper_pg_dir@l /* kernel page table */ + lis r5, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */ + addi r5 ,r5 ,(swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */ rlwimi r3,r9,32-12,29,29 /* MSR_PR -> _PAGE_USER */ -112: tophys(r5, r5) +112: #ifndef CONFIG_PTE_64BIT rlwimi r5,r4,12,20,29 /* insert top 10 bits of address */ lwz r8,0(r5) /* get pmd entry */ -- 2.13.3