Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp941644ybl; Thu, 12 Dec 2019 07:18:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzS3e8MU9u/ipxRqVe44/t3mzKx0WFF+RVCsEbx6HLfcZqmf2ISWoVSle2wW7Astfva0l3A X-Received: by 2002:aca:bd85:: with SMTP id n127mr5375051oif.136.1576163882882; Thu, 12 Dec 2019 07:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576163882; cv=none; d=google.com; s=arc-20160816; b=PgtKLyOEAgXDdMjeeIN6PmK29vZQBIx2pV1UY/6dverlxOmHX0Ndik6GJup6fCKMQG /UYiZuoxni9gw9DTl5YIBvLrT7Emnc5KDV043U0IBhzwOXfy0zilnBfM+rICW6A/gr6G k8DsLZYTMO9UMsNoZGiktZhrNpnGeR/hWDBgfFjcapT1UJbyf/7SYRi0s+cBgOynOMZ4 KFaDYeB3OrWprfwYje109ro3fCsOsRwF8B/R8dB73NTEFRTVPb8p7+kmdJEv6N4xX14m 3vn5mZOUqGcGqiWIk6olp3kNyGLohh/RM7cSy7KD03obZ09N4p7x7TfQQAZTfCiGK6sx Cafg== 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=hw7pbm5ZSn/YgWBhazKTeiCLvFMpKrZ3mbIvcxopwH8=; b=pHXUPrN31LyuK0TtxxzbLnPeCq69xEWNtxc1RKbO7JjFqdsrdBQMteNQ7xX6LsPMW9 uVFH6w8hjaapaAZS76U1EpBOO2VMR+HD86AACILm+TT20Cbc8Ks4QFC2gB0qLeNQ0anw Hi5cXLk6um4njpww7HdaWw2hDfHVDXhxZGtiepW7lS0+vMOrAcw2stDX3KRaSLRqcwfm AJv4Jv+XhsYdRblYSeLyKpU/0kSzyCjbq9FeVirIk9kGlfRZqiXwu9bBxrvDaUcUUdbb Rf5t/faZFClZLbkGN/S5esq1k9rBQg4Jd93srv/tMAcIwAdzei3PrREIOq83G8cRimbJ vfkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=S2vM1eFB; 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 w138si3001932oiw.46.2019.12.12.07.17.46; Thu, 12 Dec 2019 07:18:02 -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=S2vM1eFB; 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 S1729240AbfLLPRL (ORCPT + 99 others); Thu, 12 Dec 2019 10:17:11 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33766 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728774AbfLLPRH (ORCPT ); Thu, 12 Dec 2019 10:17:07 -0500 Received: by mail-pg1-f193.google.com with SMTP id 6so1312942pgk.0 for ; Thu, 12 Dec 2019 07:17:07 -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=hw7pbm5ZSn/YgWBhazKTeiCLvFMpKrZ3mbIvcxopwH8=; b=S2vM1eFBJ5BtH8zNbmu8DjgSQRleESkKe5JJ86KfwXlSAZVsGV1xwzrWLNLBABM6nC 3nCHiEDrC97cSMiHlZbzRL5zOCchNNKBn18aky0NarJ5dA1XSEtQKrbYDTGDDHZZ0/fg 8Yrftimr1c2yf3dNdkhW4XOiMziHanksMcaXk= 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=hw7pbm5ZSn/YgWBhazKTeiCLvFMpKrZ3mbIvcxopwH8=; b=CkM8MS0TrIzYzpnk3p4PbUM0aN+alfQubRGPs1QrGKOKtMosFqIoM8z5GgJPEeRErP 34GJQBqJVglBN/2cHbxHFOnbVelxRUjO+qYlXQ+XYblEJu1mz08ESRCgsVVk64TgJm8F fq95I5FCXd2/phGF9oRsSVnHgDFzl6Td2tLztLA4IIUP8m69+wKuzGR9h2mvOqcmxGpB n5Bz+i4FbFKkP9z/E0x/OeXckDXn4gx8tYVqcMVYG6v7iv3e055na+M/B/3JvogsSPPn eXBJ3RPuq/DAdg+JGGmscMA8o9sR7gSKDbO+1x2NEM3Poru4LL2zllSvystxoxQuxgMc Focg== X-Gm-Message-State: APjAAAXjTwrvYEvrsmRdNKKoOlxQxkuqqkWZyrWTQpunWYLrSFaaXnBH WKUHf8eNM7Y3X71W0H/GTo6uQvQ3kZ8= X-Received: by 2002:a63:1106:: with SMTP id g6mr10842363pgl.13.1576163826623; Thu, 12 Dec 2019 07:17:06 -0800 (PST) Received: from localhost (2001-44b8-1113-6700-b116-2689-a4a9-76f8.static.ipv6.internode.on.net. [2001:44b8:1113:6700:b116:2689:a4a9:76f8]) by smtp.gmail.com with ESMTPSA id d24sm7941034pfq.75.2019.12.12.07.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 07:17:05 -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 v3 1/3] kasan: define and use MAX_PTRS_PER_* for early shadow tables Date: Fri, 13 Dec 2019 02:16:54 +1100 Message-Id: <20191212151656.26151-2-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191212151656.26151-1-dja@axtens.net> References: <20191212151656.26151-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 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