Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp469264ybi; Fri, 24 May 2019 06:42:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5KQjUdaLFuplcY4h+RpaIb1jPwNZeLlyYIauQ3Mgk99Ysgb3e25HNxJqInXy0HsKKhMuV X-Received: by 2002:a17:902:e46:: with SMTP id 64mr23939779plw.165.1558705322659; Fri, 24 May 2019 06:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558705322; cv=none; d=google.com; s=arc-20160816; b=owjI7/mpNFwLB6vkf3il8cZHnc4KyhiuXTvp333pju/IHap+ImOOA9X+Rwk7hLxJyj LefyqmwbSqX4uiMuPHXxXGVJQToPlXPOD7Q+Co3ZTwXPgqNiqgey51oOWQrlhe8ceIBg qprThXpqx4N2wtNWuzR2qGtRwskJ1V7O7UpRXl0jBYvDgbyYfypBU0bmo+3Fhcwvv3+b U3ePpkjRFlBJrFXYmswhm9ddW4ISXH0+TfluwJFZN6MyK1Gsa3f/1+7qyhuruZLml/zA uuktAmGctVKe7cFdC9iXb6XlGp307fR88FxmO1T5Sols93pUBNW8uMQdJnREMe9M4Qtn zciw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=dNQmp4NjVmmDcT7XPeKzhurMj7uO+tx6pR8p+ltkIPQ=; b=VHV4bVWYw+S/IOr4d1AEcr3n6B901dqkcUFBLyQZnxfJvXrDvpOfNuQZFJRB4+E9Fx KNJ9qswpy8mIn9OxyakgNnJ1GZEkiuuaMfrlWVBFDgHZrk1wstNaXZU5ugDTSJ5lKKku U80Y9Rjc1B9UiDO8q3dL4VSGW4XewemIAkT6H13uMizszCjVyVNmtcJit45MGkBmaqX8 Gy9TYiGrktmmRzwlKY0KabwAelZwAKMzX3QdTmHzYqr9WKoAbeb74uK3E84AFW08I+of LHY0Fh81c05OxSRDu/FjUdi45bvDQy7qFFS8ShSIn4v6V++jNCyNCD5AIgrDjF1faKHY 8qdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=TSUZUAqp; 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 g70si4023401pgc.588.2019.05.24.06.41.45; Fri, 24 May 2019 06:42:02 -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=TSUZUAqp; 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 S2403824AbfEXNjB (ORCPT + 99 others); Fri, 24 May 2019 09:39:01 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:9078 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391124AbfEXNjA (ORCPT ); Fri, 24 May 2019 09:39:00 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 459SBn3dnQz9vDbw; Fri, 24 May 2019 15:38:57 +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=TSUZUAqp; 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 mOq06eIpRzHs; Fri, 24 May 2019 15:38:57 +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 459SBn2ZRfz9vDbt; Fri, 24 May 2019 15:38:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1558705137; bh=dNQmp4NjVmmDcT7XPeKzhurMj7uO+tx6pR8p+ltkIPQ=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=TSUZUAqpWLUEP6N+IDvZjESvyQK7AfQ3ng8tklkbNkI/RfSssr6t8WlOKuWTXORY1 DXGZ1+RhBkPvWDCQFDSbUwMIe7SdWopg19/zrV6yWk8E7bjLbVRfuHl4e7Aanok4mT TxTWlpn2sSU4ewAEOuGVcwQ/Z6LNOABNSGC7+Zi8= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C63828B877; Fri, 24 May 2019 15:38:58 +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 JKziJ3JuUJGp; Fri, 24 May 2019 15:38:58 +0200 (CEST) Received: from PO15451 (po15451.idsi0.si.c-s.fr [172.25.231.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A41ED8B7BF; Fri, 24 May 2019 15:38:58 +0200 (CEST) Subject: Re: [RFC PATCH v2] powerpc: fix kexec failure on book3s/32 From: Christophe Leroy To: Aaro Koskinen Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <8164abbe117d8353bb88132d7cfa8bc26a60ca66.1558677767.git.christophe.leroy@c-s.fr> Message-ID: <8c3088b3-5fea-3cff-23f1-f6bc433d9a38@c-s.fr> Date: Fri, 24 May 2019 15:38:58 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <8164abbe117d8353bb88132d7cfa8bc26a60ca66.1558677767.git.christophe.leroy@c-s.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 24/05/2019 à 08:05, Christophe Leroy a écrit : > Fixes: 63b2bc619565 ("powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX") > Signed-off-by: Christophe Leroy Reported-by: Aaro Koskinen > --- > arch/powerpc/kernel/machine_kexec_32.c | 8 ++++++++ > arch/powerpc/mm/book3s32/mmu.c | 7 +++++-- > arch/powerpc/mm/mmu_decl.h | 2 ++ > 3 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kernel/machine_kexec_32.c b/arch/powerpc/kernel/machine_kexec_32.c > index affe5dcce7f4..83e61a8f8468 100644 > --- a/arch/powerpc/kernel/machine_kexec_32.c > +++ b/arch/powerpc/kernel/machine_kexec_32.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > typedef void (*relocate_new_kernel_t)( > unsigned long indirection_page, > @@ -35,6 +36,8 @@ void default_machine_kexec(struct kimage *image) > unsigned long page_list; > unsigned long reboot_code_buffer, reboot_code_buffer_phys; > relocate_new_kernel_t rnk; > + unsigned long bat_size = 128 << 10; > + unsigned long bat_mask = ~(bat_size - 1); > > /* Interrupts aren't acceptable while we reboot */ > local_irq_disable(); > @@ -54,6 +57,11 @@ void default_machine_kexec(struct kimage *image) > memcpy((void *)reboot_code_buffer, relocate_new_kernel, > relocate_new_kernel_size); > > + printk(KERN_INFO "Reboot code buffer at %lx\n", reboot_code_buffer); > + mtsrin(mfsrin(reboot_code_buffer) & ~SR_NX, reboot_code_buffer); > + setibat(7, reboot_code_buffer & bat_mask, reboot_code_buffer_phys & bat_mask, > + bat_size, PAGE_KERNEL_TEXT); A call to update_bats() have to be added here after setibat() Christophe > + > flush_icache_range(reboot_code_buffer, > reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE); > printk(KERN_INFO "Bye!\n"); > diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c > index fc073cb2c517..7124700edb0f 100644 > --- a/arch/powerpc/mm/book3s32/mmu.c > +++ b/arch/powerpc/mm/book3s32/mmu.c > @@ -124,8 +124,8 @@ static unsigned int block_size(unsigned long base, unsigned long top) > * of 2 between 128k and 256M. > * Only for 603+ ... > */ > -static void setibat(int index, unsigned long virt, phys_addr_t phys, > - unsigned int size, pgprot_t prot) > +void setibat(int index, unsigned long virt, phys_addr_t phys, > + unsigned int size, pgprot_t prot) > { > unsigned int bl = (size >> 17) - 1; > int wimgxpp; > @@ -197,6 +197,9 @@ void mmu_mark_initmem_nx(void) > if (cpu_has_feature(CPU_FTR_601)) > return; > > + if (IS_ENABLED(CONFIG_KEXEC)) > + nb--; > + > for (i = 0; i < nb - 1 && base < top && top - base > (128 << 10);) { > size = block_size(base, top); > setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_TEXT); > diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h > index 7bac0aa2026a..478584d50cf2 100644 > --- a/arch/powerpc/mm/mmu_decl.h > +++ b/arch/powerpc/mm/mmu_decl.h > @@ -103,6 +103,8 @@ void print_system_hash_info(void); > extern void mapin_ram(void); > extern void setbat(int index, unsigned long virt, phys_addr_t phys, > unsigned int size, pgprot_t prot); > +void setibat(int index, unsigned long virt, phys_addr_t phys, > + unsigned int size, pgprot_t prot); > > extern int __map_without_bats; > extern unsigned int rtas_data, rtas_size; >