Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1678936ybl; Wed, 8 Jan 2020 23:10:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxh7RsG4nTbRDt3C5uifBHt06ocRKGTdsM+LXwsEAL/e9pu0b0sBRdBPkC71w8uL0xxTUzs X-Received: by 2002:aca:4b06:: with SMTP id y6mr2101803oia.81.1578553811428; Wed, 08 Jan 2020 23:10:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578553811; cv=none; d=google.com; s=arc-20160816; b=XmiH5jtoJ0Yx2XAnVIhU6bbuJXm0nKNj2EXAiSHqQjuPvJbc7l3xT+lgc8qjm91mBZ wZ4c6OQZ6m69lshbBOH/pWaAaZkL1SVffzfrzdQclAAj8tMeqrpc7LS6RPHnEpb2fX3R 2SHTiov/xqCV+5VBR8NevCAbrgji1aRn0Gt96YrWI/8rpbacDgJ5yWApzP2iCUD+dS/b pVGP7+XNSwXoGnL/be57r044rgpKa7mi2E3NKR/g+AhEudwhhJ2p5Cd/QcMkYwphg5dP NtlGp29Q8jCXhPC0JnhW1eQ9qBwA4MTW8wV7ZfjUt9JjDxJipmcGpzCayJGOM/9Q03BB npqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+Qbs6Z3rqfBFwWIlrYI64jfvYzlaBBfAFpq17iRyZdo=; b=wzyl540pQ/XjQw6LtSjL+REktLFg62R+sODyWLtVcKqdvPFVuUvomgpmzWgOU15SLM ABkH4dfUKxEGDNxO26+gq0MUJ85oHyhPB2gSfcWV/n+gpVGwKFNMmqaLH4XFchr0mJ1d l3K9LtQHaea2ieGe0fQhDuVgm6XV6re74eWWGZx/IMGD5aiSVJlJjYCKh1GCdPmHblzr t+6PsEm9+aQK0htI+iyHbSShbmECUpXXnhqKbZUoIsY9P5bTVdLBFsgeA2niJ03/EpPg Uaunk+C86pjtleA9PQ94B8oP+6UiFeTt3rfANOsnT7cPg+n+oQY1QWES7hgZP7quW1H0 jVww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=jjaxrqgt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u25si3525721otg.170.2020.01.08.23.09.59; Wed, 08 Jan 2020 23:10:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=jjaxrqgt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbgAIHIX (ORCPT + 99 others); Thu, 9 Jan 2020 02:08:23 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35643 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgAIHIW (ORCPT ); Thu, 9 Jan 2020 02:08:22 -0500 Received: by mail-pl1-f193.google.com with SMTP id g6so2188546plt.2 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=Mqr17PifSEx4h9H4dqX8ysfByACOiK3nRrt6/EnyhG2gnPB1MR4tCgSFT3rFffpqBf AEqMaSoq0W6CNnIsQKWYkwTfhjFj0c4lsyAnuwcwtwT++0j0nOLfHEs/PvjgkjVUK4cO JYu3Wm0ZcA1TRNuB3K0+sPOjWRE20fiC8apAPCksUXsdXUjW8Ow2nbdpiQvFGRWsdyJf 2sswZHLA/Wp7neKOQnNCBtcM3YJLSADPVNO1hAJYhfGCqCFIxIpYS1SvPmyC7OEnq/LH xLb3k4i9Y2AdlefI9FtDYgQMJN5Z2lfCCffcEHZkHqDJewF1s3y15sh6azY4JiQ0PPqD QKIg== X-Gm-Message-State: APjAAAX9ja6X7r16yWL7UCDC4NMpGHnd+jYbj35XeT5i8O7hrDhRXALb 4uCM5McNPWVZ4NB86UEeXBfLmpemsgo= 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.20.1