Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6346068yba; Wed, 1 May 2019 10:24:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuUxaEsNs4PQ3RLRXk8H8WXvO4O7sPJMJB4BG4U+kuSpUeVhvXyqOqkPoNrg/RM/gPUlo4 X-Received: by 2002:a17:902:b948:: with SMTP id h8mr78460513pls.39.1556731474930; Wed, 01 May 2019 10:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556731474; cv=none; d=google.com; s=arc-20160816; b=pygIS8D39sN9118ZVFCz1+UD1ScMf6XasW8k8/yFYkWcbfppF3Ki3JlEmaxhhR1Jr4 lqZj8In8h8UKeTzTIA9lDlOdIBjumkKastjo1tELuUsyrV6kU5IH7vjLiu5CTOdtglqB vvOKX338Zs8PajXNkT81B0580PFI/JHYwRxh61ggrL+YrsMHLgysVIiyqGY2da/0sijA h132xjSrqKGNAdvdnRuGLKAyHYRGiay4KZCr9YIe4eMJ0hcUccIEtSHcaSuKLxFbS5O1 0zewl/u6ybpd2Jm3eM8SugT4D6qCEJp1iUt09a2iUxkTFpf4IBnM5RSmjIVL5IFExCiM uJMg== 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:from:references:cc:to:subject:dkim-signature; bh=P+ycD4GZ6KQ1BUKCv6VtK/4BHfP/mJbbQKvt313twl8=; b=wAGjzWNACMifYPcwZbmLI+iuv7FltQHZEej8TM8ydi20obgBBPndbP5rjXAnL0yTzU 4piLeDwDwgOpHnOBGve5IUiibOIwtnZJcFTbcZvrO1U8efgvgvoZuPKSngLagB/GCKl+ huGhDlxpjNJ2WU1Ym3AFZUOs3pB6VcdSROChYpVtMHtGFShLkPncoHeAgM5b5q9kyScs 0UYBmHIK0+0yx+VqUzdGlkhG3rnQ/xUuvQ1Qu4lB30jIT31qZPn4qDdX80Hb0sk8ARBl CRFMkN2yo2/KMikudBNrG0zHQjPm62zbHh4aC/EZumF6rbQDpiJD3iYfQlzt8P6lluOP a/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=dNFlA7q+; 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 m186si29977744pfb.96.2019.05.01.10.24.19; Wed, 01 May 2019 10:24:34 -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=dNFlA7q+; 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 S1726167AbfEARWL (ORCPT + 99 others); Wed, 1 May 2019 13:22:11 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:41647 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbfEARWK (ORCPT ); Wed, 1 May 2019 13:22:10 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44vQDv2VRLz9tyc2; Wed, 1 May 2019 19:22:07 +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=dNFlA7q+; 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 InMtWq2E-DNV; Wed, 1 May 2019 19:22:07 +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 44vQDv1Rlxz9tybh; Wed, 1 May 2019 19:22:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1556731327; bh=P+ycD4GZ6KQ1BUKCv6VtK/4BHfP/mJbbQKvt313twl8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=dNFlA7q+L3AUpX1FPbXjlvyXrkKoTPNPVmqPEu1AZxaF47kLmQoiAHYJWDTdEqeeY OqLMsekNdjBkK3IaPX3BwfKLDJj/oaY8dKB5zA7LSYsBdjglEVtP8y+Z96EbAuRa1z faemrRGFe5Rvhfesl97Rn8XF59+XQ714ce3b2fzk= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E49368B84C; Wed, 1 May 2019 19:22:08 +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 t2ZbW3fjtIaX; Wed, 1 May 2019 19:22:08 +0200 (CEST) Received: from [192.168.232.53] (unknown [192.168.232.53]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6BE8B8B74C; Wed, 1 May 2019 19:22:08 +0200 (CEST) Subject: Re: [PATCH v2] powerpc/32s: fix BATs setting with CONFIG_STRICT_KERNEL_RWX To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Serge Belyshev , Segher Boessenkool Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <09733bd9d90f2ab9dfee9838442e0bea01df194d.1556640535.git.christophe.leroy@c-s.fr> <878svrat7x.fsf@concordia.ellerman.id.au> From: christophe leroy Message-ID: <47f3caee-510b-a95c-cf08-013a282141b6@c-s.fr> Date: Wed, 1 May 2019 19:22:06 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <878svrat7x.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 190501-4, 01/05/2019), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 01/05/2019 à 02:55, Michael Ellerman a écrit : > Christophe Leroy writes: >> Serge reported some crashes with CONFIG_STRICT_KERNEL_RWX enabled >> on a book3s32 machine. >> >> Analysis shows two issues: >> - BATs addresses and sizes are not properly aligned. >> - There is a gap between the last address covered by BATs and the >> first address covered by pages. >> >> Memory mapped with DBATs: >> 0: 0xc0000000-0xc07fffff 0x00000000 Kernel RO coherent >> 1: 0xc0800000-0xc0bfffff 0x00800000 Kernel RO coherent >> 2: 0xc0c00000-0xc13fffff 0x00c00000 Kernel RW coherent >> 3: 0xc1400000-0xc23fffff 0x01400000 Kernel RW coherent >> 4: 0xc2400000-0xc43fffff 0x02400000 Kernel RW coherent >> 5: 0xc4400000-0xc83fffff 0x04400000 Kernel RW coherent >> 6: 0xc8400000-0xd03fffff 0x08400000 Kernel RW coherent >> 7: 0xd0400000-0xe03fffff 0x10400000 Kernel RW coherent >> >> Memory mapped with pages: >> 0xe1000000-0xefffffff 0x21000000 240M rw present dirty accessed >> >> This patch fixes both issues. With the patch, we get the following >> which is as expected: >> >> Memory mapped with DBATs: >> 0: 0xc0000000-0xc07fffff 0x00000000 Kernel RO coherent >> 1: 0xc0800000-0xc0bfffff 0x00800000 Kernel RO coherent >> 2: 0xc0c00000-0xc0ffffff 0x00c00000 Kernel RW coherent >> 3: 0xc1000000-0xc1ffffff 0x01000000 Kernel RW coherent >> 4: 0xc2000000-0xc3ffffff 0x02000000 Kernel RW coherent >> 5: 0xc4000000-0xc7ffffff 0x04000000 Kernel RW coherent >> 6: 0xc8000000-0xcfffffff 0x08000000 Kernel RW coherent >> 7: 0xd0000000-0xdfffffff 0x10000000 Kernel RW coherent >> >> Memory mapped with pages: >> 0xe0000000-0xefffffff 0x20000000 256M rw present dirty accessed >> >> Reported-by: Serge Belyshev >> Fixes: 63b2bc619565 ("powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX") >> Cc: stable@vger.kernel.org > > I could probably still get this into v5.1 if you're confident it's a > good fix. If possible it would be great. Yes I'm confident it is a good fix: - The fix has no impact on the configurations I tested originally (they were lacking a trailing area not mapped with BATs and the boundarie between RW and RO was a power of 2 so ffs() returned the same as lfs()) - The fix was tested by myself on QEMU. - The fix was tested by Serge. - The fix was acked by Segher. - The fix make sense (ie ffs() is the good one, fls() was definitly wrong) Christophe > > cheers > --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus