From patchwork Thu Jan 9 07:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11325103 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 E5AD7139A for ; Thu, 9 Jan 2020 07:08:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B2AA22072A for ; Thu, 9 Jan 2020 07:08:24 +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="jjaxrqgt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2AA22072A 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 EC6A38E0006; Thu, 9 Jan 2020 02:08:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E77468E0001; Thu, 9 Jan 2020 02:08:23 -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 D8CF58E0006; Thu, 9 Jan 2020 02:08:23 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id C43018E0001 for ; Thu, 9 Jan 2020 02:08:23 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 6FE00181AC9CB for ; Thu, 9 Jan 2020 07:08:23 +0000 (UTC) X-FDA: 76357217286.19.twig87_664d9141f2536 X-Spam-Summary: 2,0,0,705603b6fa5717e2,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:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1535:1543:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3874:4250:4321:4605:5007:6261:6653:7514:10004:11026:11473:11658:11914:12043:12048:12297:12438:12517:12519:12555:12895:12986:13894:14181:14394:14721:21080:21444:21451:21627:21795:21990:30012:30034:30051:30054,0,RBL:error,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:27,LUA_SUMMARY:none X-HE-Tag: twig87_664d9141f2536 X-Filterd-Recvd-Size: 5887 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Jan 2020 07:08:22 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id p9so2176606plk.9 for ; Wed, 08 Jan 2020 23:08:22 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Qbs6Z3rqfBFwWIlrYI64jfvYzlaBBfAFpq17iRyZdo=; b=jjaxrqgtuQWvcLmq+D4GEkthntJ1AB1dg7Zsaobj44hThZzcSOYsjfSAEpAsb5TYoq QhF1zdPTdzHfDN0QO0iIA3Uhmr3BOwatC2/Rxa1M2pAVm/ecy5AalaUnSt/QrAPIin10 6Pi//F+hwdSgp/fMILAMaBdSCfjtUDQfY8AZo= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Qbs6Z3rqfBFwWIlrYI64jfvYzlaBBfAFpq17iRyZdo=; b=HVCOx8SxOB06KoIPT1/O4Go5Iv79mIon8ea0C2PjmBf6fLzcoP4diUk7zIbRH/GnKb X7WovYlPD+rMhP6dMSHLOtrYzrP0NHuhbgKVjub/jTPKJQLo8HY088W9yJgxlp0FZnX6 adw7fVqgmIaz/oFVctHcJGrf2EvmBSe9xmDbj8KvYKniflgvGcpp/7YPYYzMVfFNdRmi Q3eYXEUT4mSX/tvJ+ZxF/1z7938thrXZI9q3XQUw7oo8YILa0gaxzSL5e0rrGaQroC50 ZKWk0zCqMVdnR9RtzTpad9SiUtCYkP7rVXlBK9Z4p4NsQ2z7WzuqY7SPaNcxWt1WNvYi GKrg== X-Gm-Message-State: APjAAAVvPdUrirbNDGko0mpog13lxsVmkUuA3ObHJv6hdwt5RErC7ZwQ AUmXiP8BpkOXD9QX3RH4bl/YIQ== X-Google-Smtp-Source: APXvYqxqBWr1/17jIQT9llZB0OhZEqZItMXn9tbTBlaWChZbzmzKMiBkRcPtEN88NsA9JRgkdWq4kA== X-Received: by 2002:a17:90a:6587:: with SMTP id k7mr3432299pjj.40.1578553701900; Wed, 08 Jan 2020 23:08:21 -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 199sm6721622pfv.81.2020.01.08.23.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 23:08:20 -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 1/4] kasan: define and use MAX_PTRS_PER_* for early shadow tables Date: Thu, 9 Jan 2020 18:08:08 +1100 Message-Id: <20200109070811.31169-2-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200109070811.31169-1-dja@axtens.net> References: <20200109070811.31169-1-dja@axtens.net> 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: powerpc has a variable number of PTRS_PER_*, set at runtime based on the MMU that the kernel is booted under. This means the PTRS_PER_* are no longer constants, and therefore breaks the build. Define default MAX_PTRS_PER_*s in the same style as MAX_PTRS_PER_P4D. As KASAN is the only user at the moment, just define them in the kasan header, and have them default to PTRS_PER_* unless overridden in arch code. Suggested-by: Christophe Leroy Suggested-by: Balbir Singh Reviewed-by: Christophe Leroy Reviewed-by: Balbir Singh Signed-off-by: Daniel Axtens --- include/linux/kasan.h | 18 +++++++++++++++--- mm/kasan/init.c | 6 +++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index e18fe54969e9..70865810d0e7 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -14,10 +14,22 @@ struct task_struct; #include #include +#ifndef MAX_PTRS_PER_PTE +#define MAX_PTRS_PER_PTE PTRS_PER_PTE +#endif + +#ifndef MAX_PTRS_PER_PMD +#define MAX_PTRS_PER_PMD PTRS_PER_PMD +#endif + +#ifndef MAX_PTRS_PER_PUD +#define MAX_PTRS_PER_PUD PTRS_PER_PUD +#endif + extern unsigned char kasan_early_shadow_page[PAGE_SIZE]; -extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE]; -extern pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD]; -extern pud_t kasan_early_shadow_pud[PTRS_PER_PUD]; +extern pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE]; +extern pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD]; +extern pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD]; extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D]; int kasan_populate_early_shadow(const void *shadow_start, diff --git a/mm/kasan/init.c b/mm/kasan/init.c index ce45c491ebcd..8b54a96d3b3e 100644 --- a/mm/kasan/init.c +++ b/mm/kasan/init.c @@ -46,7 +46,7 @@ static inline bool kasan_p4d_table(pgd_t pgd) } #endif #if CONFIG_PGTABLE_LEVELS > 3 -pud_t kasan_early_shadow_pud[PTRS_PER_PUD] __page_aligned_bss; +pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD] __page_aligned_bss; static inline bool kasan_pud_table(p4d_t p4d) { return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud)); @@ -58,7 +58,7 @@ static inline bool kasan_pud_table(p4d_t p4d) } #endif #if CONFIG_PGTABLE_LEVELS > 2 -pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD] __page_aligned_bss; +pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD] __page_aligned_bss; static inline bool kasan_pmd_table(pud_t pud) { return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd)); @@ -69,7 +69,7 @@ static inline bool kasan_pmd_table(pud_t pud) return false; } #endif -pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss; +pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE] __page_aligned_bss; static inline bool kasan_pte_table(pmd_t pmd) {