Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1318367ybl; Wed, 18 Dec 2019 16:37:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxZuKxKlJIYrUptLoVCxb+nfKl73th283Ugh2h+uOm1nvD1ePkRa8swNckXme6f2M2WTmP/ X-Received: by 2002:a9d:f26:: with SMTP id 35mr5985460ott.260.1576715856206; Wed, 18 Dec 2019 16:37:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576715856; cv=none; d=google.com; s=arc-20160816; b=NEQA4B0fKe0NNww+6NP3r1W38VHMB92GH+S2muIC3HQ5JJmFe35ouOGfEtCNyLiNFS Ffpe9hEv4Ucs1GKHZizCNemN/r+65ciYixjtvnBBXmSUy/PAFr9Cj6msLCAeVJbpS+YD CH4vpm/9nkUFpNUOEeIvoeehHn2zVSBSqZLPvz52Eyg2MQtdzgKubwP/bqvFHcLjRvPy Nz5y5BQ5z792ukFfmk9elDI+W4Y9BO8DoWQH0zDxoEwld7s0GosCLedFzhXTbcew86dV 3zj1WteiUFRCaTu9LwPwtEd5pA8O8zGsRVI8QsJmSDea9mamB2+CLWvuKawi1iZS0cyJ iGCw== 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=JlTxJY/ibY6ybOWjtmtswA5FAx9Os4CutCsiuKWx/FtU7i9Cs6th4wf/eXkLRrO95s ms74i2/17IjKmTQ08dGP//gK1EvhQUqzjnHJ3zdO1MO/7ryD6jruRwc1phMpsCdzzIDO rjZGmG8hO2XIKq8+fsry75vrYrgZoiQ7qv0cnv1NvRuWn6y7mI7v3tdKXHs8qZZF17jg cbyISntsukEdtp6EjrsXIyvZlAjAwx+az/wVLwyMS+rvNuT7WrZR3fzQ8fKy1Mr85rBq Wz4pmGlhw2c5PJTsJsm+Nlp1rftFqzBgsxTjaHa0Uz/Rk6YtAy7+khp1+47lUj7YGst9 7bkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=qQ6wvPa5; 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 c24si2343470otf.14.2019.12.18.16.37.25; Wed, 18 Dec 2019 16:37:36 -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=qQ6wvPa5; 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 S1726744AbfLSAgm (ORCPT + 99 others); Wed, 18 Dec 2019 19:36:42 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40495 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfLSAgl (ORCPT ); Wed, 18 Dec 2019 19:36:41 -0500 Received: by mail-pf1-f195.google.com with SMTP id q8so2155108pfh.7 for ; Wed, 18 Dec 2019 16:36:41 -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=qQ6wvPa5T3OeNVxwA87hFA41gmpM7vkAFnS2rGFLutQBqnc7qjk0QlK1PcT83fv5rv gJ/JPxG0xGMG8mlQ2cOu6kQw8DapB5ipU/R737L8ScMI1v9UHIOQMKdbJspAC0SB3n2M jv59tJ9NI/d2DJNK7h87ruz0Z17vGP7GniWWA= 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=Rk6Hwab5REv6yI60DoZLIu+z6Www5OyJfH/tz8iKRvB+H5EPzZ5znk46/wJ+ODpeDm IZplX1KW0xxMXplIpKSXOCBEvhv17PVnGk4Rqr2zA2+Bg8i1AuUXF723pDGNtkbHayHt n7S7TDXUT0WENpd8ypGDYmv+5EFoNJ5uKv2Fwt/rw7Ocb7Xts0e/nRcPuJrlDxOUHP13 dlkFehv15299X558Esgr9q+y7TXHiNZmV+5sLIUkKvxj3mBbZ0ywWHBGreGIhJLdDS2R V9RcVD1Nkjy0mih985Rz/aqBbKvCq0TP92KIaoKqHrKBN784rDcIuOyT5RZUq9FtZs3C /yig== X-Gm-Message-State: APjAAAUP4mVGvc73+DfI+2FtuNUN+HZ8WqA7yhxm+Qii7qz6EcHWHqFB 82LCKdRlObFbU2vNk1RGDcowgeUlKAE= X-Received: by 2002:a63:5211:: with SMTP id g17mr6345964pgb.426.1576715800699; Wed, 18 Dec 2019 16:36:40 -0800 (PST) Received: from localhost (2001-44b8-111e-5c00-b05d-cbfe-b2ee-de17.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:b05d:cbfe:b2ee:de17]) by smtp.gmail.com with ESMTPSA id u26sm4807512pfn.46.2019.12.18.16.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2019 16:36:40 -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 v4 1/4] kasan: define and use MAX_PTRS_PER_* for early shadow tables Date: Thu, 19 Dec 2019 11:36:27 +1100 Message-Id: <20191219003630.31288-2-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191219003630.31288-1-dja@axtens.net> References: <20191219003630.31288-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