From patchwork Tue Dec 10 04:47:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11281297 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 63DE86C1 for ; Tue, 10 Dec 2019 04:47:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 30B1320726 for ; Tue, 10 Dec 2019 04:47:26 +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="Q5ohWjCI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30B1320726 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 2BDA66B2A7A; Mon, 9 Dec 2019 23:47:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2948E6B2A7B; Mon, 9 Dec 2019 23:47:25 -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 1D10F6B2A7C; Mon, 9 Dec 2019 23:47:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 07D2F6B2A7A for ; Mon, 9 Dec 2019 23:47:25 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 9BE5B181AEF1A for ; Tue, 10 Dec 2019 04:47:24 +0000 (UTC) X-FDA: 76247998008.20.vase38_238658db63a0e X-Spam-Summary: 2,0,0,5e25cccacfe28556,d41d8cd98f00b204,dja@axtens.net,:linux-kernel@vger.kernel.org::linuxppc-dev@lists.ozlabs.org:linux-s390@vger.kernel.org:linux-xtensa@linux-xtensa.org:linux-arch@vger.kernel.org:linux-arm-kernel@lists.infradead.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:1978:1981:2194:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3873:3874:4250:4361:4605:5007:6119:6248:6261:6653:6737:6755:7901:9040:10004:11026:11473:11657:11658:11914:12043:12048:12219:12297:12517:12519:12555:12679:12895:13161:13229:13869:13894:14096:14181:14394:14721:21080:21433:21444:21451:21627:21740:21810:21819:30005:30054:30070:30074,0,RBL:209.85.216.66:@axtens.net:.lbl8.mailshell.net-62.14.0.100 66.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCa che:0,MS X-HE-Tag: vase38_238658db63a0e X-Filterd-Recvd-Size: 5445 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 04:47:23 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id w23so6872685pjd.2 for ; Mon, 09 Dec 2019 20:47:23 -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=y8tQSVFZXpglTzCwnCQJ/H8jDbSquTv0j0/ujEPlW6k=; b=Q5ohWjCIeOzukO5LCkWh2UDZUjzpG6Dg+k5QibSsNEXqnEUsNI3eOHJLFy8voZYt1D zWAwzTdpWafUiM/2V3jWWisOZsqR4bWCl+3Si1gmC/LlI61VQXqM8pt6m9UAyMGHCMQR a4aAP4oUxg9Iibn2yn+JTh0K/J6050DPkyO3I= 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=y8tQSVFZXpglTzCwnCQJ/H8jDbSquTv0j0/ujEPlW6k=; b=spk6JcU3Z4/6TxHtjZ/ZoXQksrLowtkqMPdIAnoJgXvFI4Gp87sXnIBxos6kLTolgV ROKDP+yAe1m0JYT9Ku0l9PbXhMViLgvwJG7rM/alJ3wXxQQDXfe/0cw6eTXHoa7LYgSe qZXIJRVdPE7dUUPkbqqjK7zsF7xSdOnta7I9ZHBfyX4BdSwpgJIotOzEsDh8IAY2fC/Q XiwBge5mX9TI+YgUXp2JEct+pu9wY5uuFdj4LrEb7VULKQdkw3tCbJrVIeJO0RcFPpDc xkj8e2h3IQ31F6sCKNSNC6PbULV2K8QSvg3KkhlYWa087EGyjoBQSQFhZc8DunHUqB0z RSDA== X-Gm-Message-State: APjAAAXoagcIIX1fI/F7qd5VS6B7WGzFuCIB9nBZvRnfToX6OJJnByZg 8xG9mNsgHogULKgLS64tYadvbQ== X-Google-Smtp-Source: APXvYqzZzlhFQwpykUHNZoV4iqQbstcouL0rgALlQzDURKcSExHxCCWi3YgmjP5uPHJuX5j1JCnLyA== X-Received: by 2002:a17:902:9f83:: with SMTP id g3mr30957647plq.234.1575953242726; Mon, 09 Dec 2019 20:47:22 -0800 (PST) Received: from localhost (2001-44b8-1113-6700-e460-0b66-7007-c654.static.ipv6.internode.on.net. [2001:44b8:1113:6700:e460:b66:7007:c654]) by smtp.gmail.com with ESMTPSA id e16sm1159270pgk.77.2019.12.09.20.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 20:47:21 -0800 (PST) From: Daniel Axtens To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kasan-dev@googlegroups.com, christophe.leroy@c-s.fr, aneesh.kumar@linux.ibm.com, bsingharora@gmail.com Cc: Daniel Axtens Subject: [PATCH v2 0/4] KASAN for powerpc64 radix, plus generic mm change Date: Tue, 10 Dec 2019 15:47:10 +1100 Message-Id: <20191210044714.27265-1-dja@axtens.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, 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. The big change from v1 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. Regards, Daniel Daniel Axtens (4): mm: define MAX_PTRS_PER_{PTE,PMD,PUD} kasan: use MAX_PTRS_PER_* for early shadow kasan: Document support on 32-bit powerpc powerpc: Book3S 64-bit "heavyweight" KASAN support Documentation/dev-tools/kasan.rst | 7 +- Documentation/powerpc/kasan.txt | 112 ++++++++++++++++++ arch/arm64/include/asm/pgtable-hwdef.h | 3 + arch/powerpc/Kconfig | 3 + arch/powerpc/Kconfig.debug | 21 ++++ 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 | 20 +++- arch/powerpc/kernel/process.c | 8 ++ arch/powerpc/kernel/prom.c | 59 ++++++++- arch/powerpc/mm/kasan/Makefile | 3 +- .../mm/kasan/{kasan_init_32.c => init_32.c} | 0 arch/powerpc/mm/kasan/init_book3s_64.c | 67 +++++++++++ arch/s390/include/asm/pgtable.h | 3 + arch/x86/include/asm/pgtable_types.h | 5 + arch/xtensa/include/asm/pgtable.h | 1 + include/asm-generic/pgtable-nop4d-hack.h | 9 +- include/asm-generic/pgtable-nopmd.h | 9 +- include/asm-generic/pgtable-nopud.h | 9 +- include/linux/kasan.h | 6 +- mm/kasan/init.c | 6 +- 23 files changed, 353 insertions(+), 25 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