From patchwork Fri Mar 6 13:33:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11423975 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 060E9138D for ; Fri, 6 Mar 2020 13:34:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BDFE62084E for ; Fri, 6 Mar 2020 13:34:01 +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="aYql5mJg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDFE62084E 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 E91306B0006; Fri, 6 Mar 2020 08:34:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E417C6B0007; Fri, 6 Mar 2020 08:34:00 -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 D09BD6B0008; Fri, 6 Mar 2020 08:34:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id B7B636B0006 for ; Fri, 6 Mar 2020 08:34:00 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6CECC180AD802 for ; Fri, 6 Mar 2020 13:34:00 +0000 (UTC) X-FDA: 76565030640.18.quilt27_5d2547f9b6829 X-Spam-Summary: 2,0,0,5a6e748fb138af48,d41d8cd98f00b204,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:13894:14181:14394:14721:21080:21444:21451:21627:21795:21990:30012:30034:30051:30054,0,RBL:209.85.214.196:@axtens.net:.lbl8.mailshell.net-66.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: quilt27_5d2547f9b6829 X-Filterd-Recvd-Size: 5884 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Mar 2020 13:33:59 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id f8so865413plt.10 for ; Fri, 06 Mar 2020 05:33:59 -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=0eDFn39gIg7xtZfHp4ELa6UyXk2yfoJL9wFZ1T547PE=; b=aYql5mJg1qRvx0bdlSjJFiwjRBuVs1u8rwmZZ7Q8JCVNZDL+n/NkK1fARNuaFEMsgY q/bd1JT1jsrBNjOJ2HJuxMOcWiayN/4e90JEiceXjYEcT3d+emIzU04xR1mGn4g6oMwP HSqUziPwA1O6Kuow6PQlz8yjd2E/f/5vXwzgA= 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=0eDFn39gIg7xtZfHp4ELa6UyXk2yfoJL9wFZ1T547PE=; b=eOr45TmBCauV5UUv4/3UVPilWKHNVxfuSbtwtaUr5v/glZng9MsYn6mP5A4SZIOFup sJwu5abe01LMrqzBMeh7/sKkTGcDQlegIGewkZiOcK2ZWPWop5o+feWFNHxoFM6M3lkR QpxDCOmFIECzmqLkNojcTznmzAKiKngQg2JGD+bpoIwDBq1sdhwaW7w473DlueKKElZb mUTli2NqOVJJFUrOEI2bXNaJ9b1lQGZRS2XwrY5ug+dbl8j5xzw6C28jds7ZST9DL7td Amp3mo9F8D6qxcqu82TbaS5hVpBCqy55VXlrXMyNthGEAujh3pT4t8tKMViDPMPHldcl jZ+A== X-Gm-Message-State: ANhLgQ3BBbMDYlw58bun6zoMgj+K+awo7GsYS7sKstrrJ7djR4mwCwqE 7asPeCx0tjsQJjC/7+ddRX053g== X-Google-Smtp-Source: ADFU+vvi0UAi+HOQ78Clgq1UT/1FHCf/yoV7HNTK5ed7zTP9KnUForpSdg0/lPSVVMnzgZSBdGeY4A== X-Received: by 2002:a17:902:222:: with SMTP id 31mr3128704plc.108.1583501638997; Fri, 06 Mar 2020 05:33:58 -0800 (PST) Received: from localhost (2001-44b8-111e-5c00-b120-f113-a8cb-35fd.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:b120:f113:a8cb:35fd]) by smtp.gmail.com with ESMTPSA id o71sm9880171pjo.35.2020.03.06.05.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 05:33:57 -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 v8 1/4] kasan: define and use MAX_PTRS_PER_* for early shadow tables Date: Sat, 7 Mar 2020 00:33:37 +1100 Message-Id: <20200306133340.9181-2-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306133340.9181-1-dja@axtens.net> References: <20200306133340.9181-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 5cde9e7c2664..b3a4500633f5 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) {