Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2155715ybi; Sun, 16 Jun 2019 23:11:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYG7KKyHCXHe7JG2TEWsQHiM3w31QXviY93LgetisTL+FPnyLynU6xF8az8G+XTI6Jw3CY X-Received: by 2002:a62:1ac8:: with SMTP id a191mr50534534pfa.164.1560751915946; Sun, 16 Jun 2019 23:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560751915; cv=none; d=google.com; s=arc-20160816; b=A1la4LnI/ZqQ4RmGM/ZcHAihJEaDxryv4xyDcDHaULqDMQOWnroiGNSWUpnuKWvZy4 68jaqwSLMR8zJIDIGp+XcRqy68ElTZLhoAemhw+Jh0Ok3/kKfOKOOfpaPEUqto1zsL/S d5hKR42+nqx6kP4x9P6jhTsqcMX1z8ewhcBdrnm8zPo30qkIml4FSz8FHYxDWHoHb352 obLRqmPkceMLQJOfjkwl3juDyEfulCOeq8AUeoD/uc3RWaXsBuJ6N/c6hTA/Yt9tzFGn +GdFbAxspGRx2nVoAGR5gEFtNCRLb7jAdIqfpT2P3flDTt1uvC3aQ1eO2qy6BrYZDRV9 +GJA== 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=AeYbBJqrnbuK3ysLYT0tk2Zm0b9RNj2pBXn6SnxJees=; b=qwcMtIC5ZJ0MnDplMtsj+by5XAi3sJ9w+nG/aZ7aZeyY0jAe4zcySrjpDiSWku0mYe Dxz1kw1ExBfcc4dRrrW2tAhC713BJrQS4hWom0espoVciRETrBVcP1HOpN9OFwIVDfD0 viJEzDlq43lr8WaF9iwRdlcjkbZwIsUees9s1jJMq8Zd1v8dxYFAxw+oQbOZcrJhFIcE PLtRs8XtUA2jjiJ0ohC3q71BYY00XwOZhtgoohyL8GQXJJPLG2WpOrYRQrgrASqf4+cF K413Rru1reRV7Qfbwy+ZAiC+WOy/dp2bmKyMUf1IP7wagx0ZmZAdnFwqG12FZhLp4YsJ TMOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=rpy4PTPj; 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 h21si9584011pgv.102.2019.06.16.23.11.40; Sun, 16 Jun 2019 23:11:55 -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=rpy4PTPj; 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 S1726043AbfFQGKZ (ORCPT + 99 others); Mon, 17 Jun 2019 02:10:25 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:54175 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbfFQGKZ (ORCPT ); Mon, 17 Jun 2019 02:10:25 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 45S1626f24z9v0hJ; Mon, 17 Jun 2019 08:10:18 +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=rpy4PTPj; 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 nogowJqC3dEQ; Mon, 17 Jun 2019 08:10:18 +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 45S1625LcNz9v0hH; Mon, 17 Jun 2019 08:10:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1560751818; bh=AeYbBJqrnbuK3ysLYT0tk2Zm0b9RNj2pBXn6SnxJees=; h=From:Subject:To:Cc:Date:From; b=rpy4PTPj3AH4SgJlWEWl3pbR27f9xHrJT32oAwrxzTpdqccM0jpFeySxb6fPNnJSK VQhjOI8kZm5rW4ordwhodFbtjRN/DcBYeZPX2yRn9jBrx+62Jos/Z0YZ4xIChelES3 SxDgR0ADnAlvKoBy5ld/EHtHyEMRXJJSi3L2iaPw= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3BE168B77E; Mon, 17 Jun 2019 08:10:23 +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 hD4dG_ani6nB; Mon, 17 Jun 2019 08:10:23 +0200 (CEST) Received: from PO15451.localdomain (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E96238B75A; Mon, 17 Jun 2019 08:10:22 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 0) id 8A11966B22; Mon, 17 Jun 2019 06:10:22 +0000 (UTC) Message-Id: <4291e0dd36aafff58bec429ac5355d10206c72d6.1560751738.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] powerpc/32s: fix suspend/resume when IBATs 4-7 are used To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Andreas Schwab Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 17 Jun 2019 06:10:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, only IBAT1 and IBAT2 were used to map kernel linear mem. Since commit 63b2bc619565 ("powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX"), we may have all 8 BATs used for mapping kernel text. But the suspend/restore functions only save/restore BATs 0 to 3, and clears BATs 4 to 7. Make suspend and restore functions respectively save and reload the 8 BATs on CPUs having MMU_FTR_USE_HIGH_BATS feature. Reported-by: Andreas Schwab Cc: stable@vger.kernel.org Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/swsusp_32.S | 108 +++++++++++++++++++++++++------- arch/powerpc/platforms/powermac/sleep.S | 104 +++++++++++++++++++++++------- 2 files changed, 166 insertions(+), 46 deletions(-) diff --git a/arch/powerpc/kernel/swsusp_32.S b/arch/powerpc/kernel/swsusp_32.S index 7a919e9a3400..4d3068f24ff3 100644 --- a/arch/powerpc/kernel/swsusp_32.S +++ b/arch/powerpc/kernel/swsusp_32.S @@ -25,11 +25,19 @@ #define SL_IBAT2 0x48 #define SL_DBAT3 0x50 #define SL_IBAT3 0x58 -#define SL_TB 0x60 -#define SL_R2 0x68 -#define SL_CR 0x6c -#define SL_LR 0x70 -#define SL_R12 0x74 /* r12 to r31 */ +#define SL_DBAT4 0x60 +#define SL_IBAT4 0x68 +#define SL_DBAT5 0x70 +#define SL_IBAT5 0x78 +#define SL_DBAT6 0x80 +#define SL_IBAT6 0x88 +#define SL_DBAT7 0x90 +#define SL_IBAT7 0x98 +#define SL_TB 0xa0 +#define SL_R2 0xa8 +#define SL_CR 0xac +#define SL_LR 0xb0 +#define SL_R12 0xb4 /* r12 to r31 */ #define SL_SIZE (SL_R12 + 80) .section .data @@ -97,6 +105,24 @@ _GLOBAL(swsusp_arch_suspend) stw r4,SL_DBAT3(r11) mfdbatl r4,3 stw r4,SL_DBAT3+4(r11) +BEGIN_MMU_FTR_SECTION + mfdbatu r4,4 + stw r4,SL_DBAT4(r11) + mfdbatl r4,4 + stw r4,SL_DBAT4+4(r11) + mfdbatu r4,5 + stw r4,SL_DBAT5(r11) + mfdbatl r4,5 + stw r4,SL_DBAT5+4(r11) + mfdbatu r4,6 + stw r4,SL_DBAT6(r11) + mfdbatl r4,6 + stw r4,SL_DBAT6+4(r11) + mfdbatu r4,7 + stw r4,SL_DBAT7(r11) + mfdbatl r4,7 + stw r4,SL_DBAT7+4(r11) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) mfibatu r4,0 stw r4,SL_IBAT0(r11) mfibatl r4,0 @@ -113,6 +139,24 @@ _GLOBAL(swsusp_arch_suspend) stw r4,SL_IBAT3(r11) mfibatl r4,3 stw r4,SL_IBAT3+4(r11) +BEGIN_MMU_FTR_SECTION + mfibatu r4,4 + stw r4,SL_IBAT4(r11) + mfibatl r4,4 + stw r4,SL_IBAT4+4(r11) + mfibatu r4,5 + stw r4,SL_IBAT5(r11) + mfibatl r4,5 + stw r4,SL_IBAT5+4(r11) + mfibatu r4,6 + stw r4,SL_IBAT6(r11) + mfibatl r4,6 + stw r4,SL_IBAT6+4(r11) + mfibatu r4,7 + stw r4,SL_IBAT7(r11) + mfibatl r4,7 + stw r4,SL_IBAT7+4(r11) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) #if 0 /* Backup various CPU config stuffs */ @@ -263,6 +307,24 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) mtdbatu 3,r4 lwz r4,SL_DBAT3+4(r11) mtdbatl 3,r4 +BEGIN_MMU_FTR_SECTION + lwz r4,SL_DBAT4(r11) + mtdbatu 4,r4 + lwz r4,SL_DBAT4+4(r11) + mtdbatl 4,r4 + lwz r4,SL_DBAT5(r11) + mtdbatu 5,r4 + lwz r4,SL_DBAT5+4(r11) + mtdbatl 5,r4 + lwz r4,SL_DBAT6(r11) + mtdbatu 6,r4 + lwz r4,SL_DBAT6+4(r11) + mtdbatl 6,r4 + lwz r4,SL_DBAT7(r11) + mtdbatu 7,r4 + lwz r4,SL_DBAT7+4(r11) + mtdbatl 7,r4 +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) lwz r4,SL_IBAT0(r11) mtibatu 0,r4 lwz r4,SL_IBAT0+4(r11) @@ -279,27 +341,25 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) mtibatu 3,r4 lwz r4,SL_IBAT3+4(r11) mtibatl 3,r4 -#endif - BEGIN_MMU_FTR_SECTION - li r4,0 - mtspr SPRN_DBAT4U,r4 - mtspr SPRN_DBAT4L,r4 - mtspr SPRN_DBAT5U,r4 - mtspr SPRN_DBAT5L,r4 - mtspr SPRN_DBAT6U,r4 - mtspr SPRN_DBAT6L,r4 - mtspr SPRN_DBAT7U,r4 - mtspr SPRN_DBAT7L,r4 - mtspr SPRN_IBAT4U,r4 - mtspr SPRN_IBAT4L,r4 - mtspr SPRN_IBAT5U,r4 - mtspr SPRN_IBAT5L,r4 - mtspr SPRN_IBAT6U,r4 - mtspr SPRN_IBAT6L,r4 - mtspr SPRN_IBAT7U,r4 - mtspr SPRN_IBAT7L,r4 + lwz r4,SL_IBAT4(r11) + mtibatu 4,r4 + lwz r4,SL_IBAT4+4(r11) + mtibatl 4,r4 + lwz r4,SL_IBAT5(r11) + mtibatu 5,r4 + lwz r4,SL_IBAT5+4(r11) + mtibatl 5,r4 + lwz r4,SL_IBAT6(r11) + mtibatu 6,r4 + lwz r4,SL_IBAT6+4(r11) + mtibatl 6,r4 + lwz r4,SL_IBAT7(r11) + mtibatu 7,r4 + lwz r4,SL_IBAT7+4(r11) + mtibatl 7,r4 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) +#endif /* Flush all TLBs */ lis r4,0x1000 diff --git a/arch/powerpc/platforms/powermac/sleep.S b/arch/powerpc/platforms/powermac/sleep.S index 6bbcbec97712..2d7b035bee09 100644 --- a/arch/powerpc/platforms/powermac/sleep.S +++ b/arch/powerpc/platforms/powermac/sleep.S @@ -33,10 +33,18 @@ #define SL_IBAT2 0x48 #define SL_DBAT3 0x50 #define SL_IBAT3 0x58 -#define SL_TB 0x60 -#define SL_R2 0x68 -#define SL_CR 0x6c -#define SL_R12 0x70 /* r12 to r31 */ +#define SL_DBAT4 0x60 +#define SL_IBAT4 0x68 +#define SL_DBAT5 0x70 +#define SL_IBAT5 0x78 +#define SL_DBAT6 0x80 +#define SL_IBAT6 0x88 +#define SL_DBAT7 0x90 +#define SL_IBAT7 0x98 +#define SL_TB 0xa0 +#define SL_R2 0xa8 +#define SL_CR 0xac +#define SL_R12 0xb0 /* r12 to r31 */ #define SL_SIZE (SL_R12 + 80) .section .text @@ -104,6 +112,24 @@ _GLOBAL(low_sleep_handler) stw r4,SL_DBAT3(r1) mfdbatl r4,3 stw r4,SL_DBAT3+4(r1) +BEGIN_MMU_FTR_SECTION + mfdbatu r4,4 + stw r4,SL_DBAT4(r1) + mfdbatl r4,4 + stw r4,SL_DBAT4+4(r1) + mfdbatu r4,5 + stw r4,SL_DBAT5(r1) + mfdbatl r4,5 + stw r4,SL_DBAT5+4(r1) + mfdbatu r4,6 + stw r4,SL_DBAT6(r1) + mfdbatl r4,6 + stw r4,SL_DBAT6+4(r1) + mfdbatu r4,7 + stw r4,SL_DBAT7(r1) + mfdbatl r4,7 + stw r4,SL_DBAT7+4(r1) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) mfibatu r4,0 stw r4,SL_IBAT0(r1) mfibatl r4,0 @@ -120,6 +146,24 @@ _GLOBAL(low_sleep_handler) stw r4,SL_IBAT3(r1) mfibatl r4,3 stw r4,SL_IBAT3+4(r1) +BEGIN_MMU_FTR_SECTION + mfibatu r4,4 + stw r4,SL_IBAT4(r1) + mfibatl r4,4 + stw r4,SL_IBAT4+4(r1) + mfibatu r4,5 + stw r4,SL_IBAT5(r1) + mfibatl r4,5 + stw r4,SL_IBAT5+4(r1) + mfibatu r4,6 + stw r4,SL_IBAT6(r1) + mfibatl r4,6 + stw r4,SL_IBAT6+4(r1) + mfibatu r4,7 + stw r4,SL_IBAT7(r1) + mfibatl r4,7 + stw r4,SL_IBAT7+4(r1) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) /* Backup various CPU config stuffs */ bl __save_cpu_setup @@ -303,6 +347,24 @@ grackle_wake_up: mtdbatu 3,r4 lwz r4,SL_DBAT3+4(r1) mtdbatl 3,r4 +BEGIN_MMU_FTR_SECTION + lwz r4,SL_DBAT4(r1) + mtdbatu 4,r4 + lwz r4,SL_DBAT4+4(r1) + mtdbatl 4,r4 + lwz r4,SL_DBAT5(r1) + mtdbatu 5,r4 + lwz r4,SL_DBAT5+4(r1) + mtdbatl 5,r4 + lwz r4,SL_DBAT6(r1) + mtdbatu 6,r4 + lwz r4,SL_DBAT6+4(r1) + mtdbatl 6,r4 + lwz r4,SL_DBAT7(r1) + mtdbatu 7,r4 + lwz r4,SL_DBAT7+4(r1) + mtdbatl 7,r4 +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) lwz r4,SL_IBAT0(r1) mtibatu 0,r4 lwz r4,SL_IBAT0+4(r1) @@ -319,25 +381,23 @@ grackle_wake_up: mtibatu 3,r4 lwz r4,SL_IBAT3+4(r1) mtibatl 3,r4 - BEGIN_MMU_FTR_SECTION - li r4,0 - mtspr SPRN_DBAT4U,r4 - mtspr SPRN_DBAT4L,r4 - mtspr SPRN_DBAT5U,r4 - mtspr SPRN_DBAT5L,r4 - mtspr SPRN_DBAT6U,r4 - mtspr SPRN_DBAT6L,r4 - mtspr SPRN_DBAT7U,r4 - mtspr SPRN_DBAT7L,r4 - mtspr SPRN_IBAT4U,r4 - mtspr SPRN_IBAT4L,r4 - mtspr SPRN_IBAT5U,r4 - mtspr SPRN_IBAT5L,r4 - mtspr SPRN_IBAT6U,r4 - mtspr SPRN_IBAT6L,r4 - mtspr SPRN_IBAT7U,r4 - mtspr SPRN_IBAT7L,r4 + lwz r4,SL_IBAT4(r1) + mtibatu 4,r4 + lwz r4,SL_IBAT4+4(r1) + mtibatl 4,r4 + lwz r4,SL_IBAT5(r1) + mtibatu 5,r4 + lwz r4,SL_IBAT5+4(r1) + mtibatl 5,r4 + lwz r4,SL_IBAT6(r1) + mtibatu 6,r4 + lwz r4,SL_IBAT6+4(r1) + mtibatl 6,r4 + lwz r4,SL_IBAT7(r1) + mtibatu 7,r4 + lwz r4,SL_IBAT7+4(r1) + mtibatl 7,r4 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) /* Flush all TLBs */ -- 2.13.3