From patchwork Fri Oct 13 15:44:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 10005127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 76877602B3 for ; Fri, 13 Oct 2017 15:44:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66457290B4 for ; Fri, 13 Oct 2017 15:44:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59D48290B8; Fri, 13 Oct 2017 15:44:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0938C290B4 for ; Fri, 13 Oct 2017 15:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OhCOhuS6FTAu05fBpvxNaxEPRdKU52oaSUtgkWBATgc=; b=OvGDTEBgldxhSG Yg+WiWSPkitz/mXgWCz7ULLR1dzFHVHWd5Hyzj/dyPApKG0hVGhOmlUIxXsfBDELbXkfXquPGRlTY RDRd29L/TokmHZSyfL0YiiX5pa9xzLgGBAEX4maCrLuhKM1kbUvKY7typqbdrnXptcQnWUCPwyF3y j7GLbPB0BReFEAf/D+BGd28pcYK7UpI+JzQja4ZXHbH3uOGjjMuPQgY0fkZOSwuzSem4LcNW1/P9f n/BOirGVY9q5CWxsN9fYY/r1LIU5cv4tl3W0XpcOGYqeoARy8d+ybDrdOy+SSoWtAfMoRvFnuAR4a oZ3akmEpx2EmkwMNtYzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e328m-0001bt-1N; Fri, 13 Oct 2017 15:44:48 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e328i-0001af-HV for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2017 15:44:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A673A1529; Fri, 13 Oct 2017 08:44:22 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 765373F3E1; Fri, 13 Oct 2017 08:44:22 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 8A01E1AE1369; Fri, 13 Oct 2017 16:44:26 +0100 (BST) Date: Fri, 13 Oct 2017 16:44:26 +0100 From: Will Deacon To: Pavel Tatashin Subject: Re: [PATCH v11 7/9] arm64/kasan: add and use kasan_map_populate() Message-ID: <20171013154426.GC4746@arm.com> References: <20171009221931.1481-1-pasha.tatashin@oracle.com> <20171009221931.1481-8-pasha.tatashin@oracle.com> <20171010155619.GA2517@arm.com> <20171010171047.GC2517@arm.com> <20171013144319.GB4746@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171013_084444_604597_0D4EB12F X-CRM114-Status: GOOD ( 22.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-s390@vger.kernel.org, Ard Biesheuvel , mgorman@techsingularity.net, sam@ravnborg.org, borntraeger@de.ibm.com, catalin.marinas@arm.com, x86@kernel.org, heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Michal Hocko , linux-mm@kvack.org, Steve Sistare , willy@infradead.org, sparclinux@vger.kernel.org, bob.picco@oracle.com, daniel.m.jordan@oracle.com, linuxppc-dev@lists.ozlabs.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Pavel, On Fri, Oct 13, 2017 at 11:09:41AM -0400, Pavel Tatashin wrote: > > It shouldn't be difficult to use section mappings with my patch, I just > > don't really see the need to try to optimise TLB pressure when you're > > running with KASAN enabled which already has something like a 3x slowdown > > afaik. If it ends up being a big deal, we can always do that later, but > > my main aim here is to divorce kasan from vmemmap because they should be > > completely unrelated. > > Yes, I understand that kasan makes system slow, but my point is why > make it even slower? However, I am OK adding your patch to the series, > BTW, symmetric changes will be needed for x86 as well sometime later. > > > > > This certainly doesn't sound right; mapping the shadow with pages shouldn't > > lead to problems. I also can't seem to reproduce this myself -- could you > > share your full .config and a pointer to the git tree that you're using, > > please? > > Config is attached. I am using my patch series + your patch + today's > clone from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Great, I hit the same problem with your .config. It might actually be CONFIG_DEBUG_MEMORY_INIT which does it. > Also, in a separate e-mail i sent out the qemu arguments. > > > > >> I feel, this patch requires more work, and I am troubled with using > >> base pages instead of large pages. > > > > I'm happy to try fixing this, because I think splitting up kasan and vmemmap > > is the right thing to do here. > > Thank you very much. Thanks for sharing the .config and tree. It looks like the problem is that kimg_shadow_start and kimg_shadow_end are not page-aligned. Whilst I fix them up in kasan_map_populate, they remain unaligned when passed to kasan_populate_zero_shadow, which confuses the loop termination conditions in e.g. zero_pte_populate and the shadow isn't configured properly. Fixup diff below; please merge in with my original patch. Will --->8 diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index b922826d9908..207b1acb823a 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -146,7 +146,7 @@ asmlinkage void __init kasan_early_init(void) static void __init kasan_map_populate(unsigned long start, unsigned long end, int node) { - kasan_pgd_populate(start & PAGE_MASK, PAGE_ALIGN(end), node, false); + kasan_pgd_populate(start, end, node, false); } /* @@ -183,8 +183,8 @@ void __init kasan_init(void) struct memblock_region *reg; int i; - kimg_shadow_start = (u64)kasan_mem_to_shadow(_text); - kimg_shadow_end = (u64)kasan_mem_to_shadow(_end); + kimg_shadow_start = (u64)kasan_mem_to_shadow(_text) & PAGE_MASK; + kimg_shadow_end = PAGE_ALIGN((u64)kasan_mem_to_shadow(_end)); mod_shadow_start = (u64)kasan_mem_to_shadow((void *)MODULES_VADDR); mod_shadow_end = (u64)kasan_mem_to_shadow((void *)MODULES_END);