From patchwork Thu Jan 9 07:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11325101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A014C1395 for ; Thu, 9 Jan 2020 07:08:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6453C206ED for ; Thu, 9 Jan 2020 07:08:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=axtens.net header.i=@axtens.net header.b="X0mwyBro" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6453C206ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8ABA68E0005; Thu, 9 Jan 2020 02:08:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 85BF68E0001; Thu, 9 Jan 2020 02:08:19 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 771748E0005; Thu, 9 Jan 2020 02:08:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 611DD8E0001 for ; Thu, 9 Jan 2020 02:08:19 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 0A1F352A0 for ; Thu, 9 Jan 2020 07:08:19 +0000 (UTC) X-FDA: 76357217118.09.soup30_65a2a38f5175a X-Spam-Summary: 2,0,0,3d9044848c23862a,d41d8cd98f00b204,dja@axtens.net,:linux-kernel@vger.kernel.org::linuxppc-dev@lists.ozlabs.org:kasan-dev@googlegroups.com:christophe.leroy@c-s.fr:aneesh.kumar@linux.ibm.com:bsingharora@gmail.com:dja@axtens.net,RULES_HIT:41:355:379:541:973:988:989:1260:1311:1314:1345:1437:1515:1535:1542:1711:1730:1747:1777:1792:1801:2393:2559:2562:2693:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4605:5007:6119:6248:6261:6653:6755:7903:9040:10004:11026:11473:11657:11658:11914:12043:12048:12219:12296:12297:12517:12519:12555:12679:12895:13869:13894:14096:14181:14394:14721:21080:21433:21444:21451:21627:21740:21810:21819:30005:30012:30054:30070:30074,0,RBL:209.85.216.65:@axtens.net:.lbl8.mailshell.net-62.14.0.100 66.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:32,LUA_SUMMARY:none X-HE-Tag: soup30_65a2a38f5175a X-Filterd-Recvd-Size: 5669 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Jan 2020 07:08:18 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id a6so745930pjh.2 for ; Wed, 08 Jan 2020 23:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=T66c+Moc6bo3p93sqP0BtCTOoS4UuskhqiuSGC0rhF8=; b=X0mwyBronhFAvsmlzbsKHNTgZEAlq+hZMT0u/m/S4Ga/TZgU/CFDxsjZZ3Sb7W55KC CdkUz5Dg0Rm3zAxOestRih3sAYV0lUc8gsaw9ERRphopmY3ahW9F7n7rj8luEwH0+y67 wtXFs2N+rq3CmbwLg9VRq/leG03nLJfNUz9uA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=T66c+Moc6bo3p93sqP0BtCTOoS4UuskhqiuSGC0rhF8=; b=aD7U2b7FvB1Y1ORTN/5eF56KQPIgjQqyHm7DiJJk5Hsjo/UISasaFXSwDF1Ypqs1ge YDXTOr3RkNVSnQiCjdbh+o4lQTR/3eXdWoefIdlcjLWkge809o4EYYIiImIBVqIzqbQF Z+jyX1lu3i6jKxRxqPAYmC1I2f96VdpZ/Q8kLlH6uOWJO5uvJKmewvSge+bq1w85pqfF eoOOASInCDS02PG03m9IvbEj/R+bgeHlKDtDKqQQjNO/RSU/axaNwXnKNynQLXu3ZngM UMl1ehYAipk82WYEjQHdHvwVmEO38X4A5KQNW5f0jnFEjxg0ZnlM5q7l3hmm5vNZELSx v1cg== X-Gm-Message-State: APjAAAXFTD9P8F+NL3G3Zdnjf0UfZFt0JFrM6TollmGCW2WuqNKY5D0k Ug7k+dvNuSahide1GZpx1Ug/1Q== X-Google-Smtp-Source: APXvYqwzwS6C8pCrRttWQJOjzO+q0lE36tEIXD7GIldhthPyaszfHYJdYFpvK3Y8vgvuZ304JF1PRA== X-Received: by 2002:a17:90a:cb83:: with SMTP id a3mr3531968pju.80.1578553697170; Wed, 08 Jan 2020 23:08:17 -0800 (PST) Received: from localhost (2001-44b8-1113-6700-5cb3-ebc3-7dc6-a17b.static.ipv6.internode.on.net. [2001:44b8:1113:6700:5cb3:ebc3:7dc6:a17b]) by smtp.gmail.com with ESMTPSA id i23sm6139143pfo.11.2020.01.08.23.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 23:08:16 -0800 (PST) From: Daniel Axtens To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com, christophe.leroy@c-s.fr, aneesh.kumar@linux.ibm.com, bsingharora@gmail.com Cc: Daniel Axtens Subject: [PATCH v5 0/4] KASAN for powerpc64 radix Date: Thu, 9 Jan 2020 18:08:07 +1100 Message-Id: <20200109070811.31169-1-dja@axtens.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Building on the work of Christophe, Aneesh and Balbir, I've ported KASAN to 64-bit Book3S kernels running on the Radix MMU. This provides full inline instrumentation on radix, but does require that you be able to specify the amount of physically contiguous memory on the system at compile time. More details in patch 4. v5: ptdump support. More cleanups, tweaks and fixes, thanks Christophe. Details in patch 4. I have seen another stack walk splat, but I don't think it's related to the patch set, I think there's a bug somewhere else, probably in stack frame manipulation in the kernel or (more unlikely) in the compiler. v4: More cleanups, split renaming out, clarify bits and bobs. Drop the stack walk disablement, that isn't needed. No other functional change. v3: Reduce the overly ambitious scope of the MAX_PTRS change. Document more things, including around why some of the restrictions apply. Clean up the code more, thanks Christophe. v2: The big change is the introduction of tree-wide(ish) MAX_PTRS_PER_{PTE,PMD,PUD} macros in preference to the previous approach, which was for the arch to override the page table array definitions with their own. (And I squashed the annoying intermittent crash!) Apart from that there's just a lot of cleanup. Christophe, I've addressed most of what you asked for and I will reply to your v1 emails to clarify what remains unchanged. Daniel Axtens (4): kasan: define and use MAX_PTRS_PER_* for early shadow tables kasan: Document support on 32-bit powerpc powerpc/mm/kasan: rename kasan_init_32.c to init_32.c powerpc: Book3S 64-bit "heavyweight" KASAN support Documentation/dev-tools/kasan.rst | 7 +- Documentation/powerpc/kasan.txt | 122 ++++++++++++++++++ arch/powerpc/Kconfig | 2 + arch/powerpc/Kconfig.debug | 23 +++- arch/powerpc/Makefile | 11 ++ arch/powerpc/include/asm/book3s/64/hash.h | 4 + arch/powerpc/include/asm/book3s/64/pgtable.h | 7 + arch/powerpc/include/asm/book3s/64/radix.h | 5 + arch/powerpc/include/asm/kasan.h | 15 ++- arch/powerpc/kernel/prom.c | 61 ++++++++- arch/powerpc/mm/kasan/Makefile | 3 +- .../mm/kasan/{kasan_init_32.c => init_32.c} | 0 arch/powerpc/mm/kasan/init_book3s_64.c | 71 ++++++++++ arch/powerpc/mm/ptdump/ptdump.c | 10 +- arch/powerpc/platforms/Kconfig.cputype | 1 + include/linux/kasan.h | 18 ++- mm/kasan/init.c | 6 +- 17 files changed, 350 insertions(+), 16 deletions(-) create mode 100644 Documentation/powerpc/kasan.txt rename arch/powerpc/mm/kasan/{kasan_init_32.c => init_32.c} (100%) create mode 100644 arch/powerpc/mm/kasan/init_book3s_64.c