From patchwork Mon Jul 22 11:55:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 169370 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7429750ilk; Mon, 22 Jul 2019 04:55:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw62quNvlNxdVfZGW1byNpmFymDmsEXHhT1KjKIorHAb3y1P+MkdrzG+W+gI+fUdn7rDPS8 X-Received: by 2002:a17:90a:d80b:: with SMTP id a11mr73177368pjv.53.1563796530171; Mon, 22 Jul 2019 04:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563796530; cv=none; d=google.com; s=arc-20160816; b=0RubmnJrh8GW/h01oWCEjao0KXRe5CfJvQK/rpb0TaIt2nBsijCmv33HYXhqcRi9pl v8BukFgFYOMoo4EpBq4MSv45pqzJCmzPSG3bQ1oKgkmkKvro3xIurKi0CxU77yKP/psg BpcDIImAvc6lHn4i7GvIPw7SmhAbCo9FwFbnTZFpJFYA0vKoaWibeFxgRjq/vL7CpTJW JbhMO9I+dxlz4IZqeDe3cEgkV1gkMrX0AhYf4D1ryrNygwrtdYFah7J08qtRTVwofPrB 7hHeogPizdvXsVuBAAGo4RtKKGCCB7TmI04/SbH8AlSc0vVClwZcGatC6jL4mhs3CeEp tKiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from; bh=8n2eT6Gq0Ds2ptPfNQ2uWs4D9vto+uVFQLB6t8h69rY=; b=T6MuUntkElwVNOzhHZjZqhGQ09f7Wjv1CpDpiJFIDOH+OYKl3f3QBebuZ4mXgDLGOx e1W2A5xY1wuwLT5IRMQhwHpIO2xdq9CEzhkUXAWGeiMSciKdcaRoT5bm0mbhNjPxs5ua UQ9SOqpnwoX2tNYapwzCtrbeJjZqbAIND0yslbzmQ9n3yiPcVfrIsgp55RrD0KRR95AG e7IhKd3wzUcUqFvsZp5O2H7mt4GubPS0ec0LjtSlahCLFVryXE0xkVn/FIhvIYk4iCy5 7xnWLkVa7vtEFNo7dWI+zrbwg9vv3JKo/QTOkByCFqjRNbi+sTOm14NZKhRiY4kT7lJY nevQ== ARC-Authentication-Results: i=1; mx.google.com; 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 e80si8579727pfh.121.2019.07.22.04.55.29; Mon, 22 Jul 2019 04:55:30 -0700 (PDT) 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; 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 S1730073AbfGVLz3 (ORCPT + 29 others); Mon, 22 Jul 2019 07:55:29 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:46629 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730062AbfGVLz2 (ORCPT ); Mon, 22 Jul 2019 07:55:28 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MSbov-1i0IYV27p3-00T06j; Mon, 22 Jul 2019 13:55:22 +0200 From: Arnd Bergmann Cc: Arnd Bergmann , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Will Deacon , Christoph Lameter , Mark Rutland , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH] [v3] page flags: prioritize kasan bits over last-cpuid Date: Mon, 22 Jul 2019 13:55:13 +0200 Message-Id: <20190722115520.3743282-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:HYCKKaWem6pMuWADqfMV+oLPSrN4UO4x5g8SpZTmnBVDkynf91r u4QKrrDHUt8/L0iJAYkC0sRQIH8sGZT1eJYIG0RPerjoOSnjqfL1TguSBpVTT8B9g4uHjy2 ZA7aKQ0OaZsIg/+/qG90Abp81/nRdkOh+m8yzTAL5In48TozJn5YF/lF8b78mymIdIBLg76 s1Hfb6QgTM1V/YP9cUn6w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:vBG3mOLaeAU=:guUWUZc8D6eSdeLn+5NxyV 1FMBdMbh3gfxEpkKl3SogitvEh4ZH7K7U4/jUzUNa/++1/ahkInucQ4Wp76voSBRSmB8m2vNS L2gNOH5AwqAfUaCeOXgMOqAt0L6Ntuf/8hgo6yk9Hm453wrU6n+Pm+0KV/G+A1WIh2Xy5jmGf R3rgQgHvnEaY1ohRQjKuZCSUjtUc2LY+9JLdN0vISYYZNRGV755z01ENjHpJVM4xt7q+rNxp6 y+3rts1GL0ouI3sqefSAowCCzvoTch3Y1gRiLlME//e5bhN0JKGVdClvHm/9E9BL80DpB83WC iPNxNapVXGRh2uHmpbnOIYW7ZGrdyl6t+0blZdiGIUWPP1H8/FyH8JoIvIe2Jmd8eNfOkCf5E S5tMStUvUkq3wtjBtRDONd6duaWXY8FlRO2Qv7LKqCumTzTGdYpoQZB2IN2vxrCgCg46FgSVF DSzonEV7wj7LJPopGNJ2J6mJlGnmd3zPZ50rjqjEV15LS+mC02VPFuGgZN7kMCgcfGKeHwR6h tIq+LnCkSJc8WHXAIu4MEDfx3H9QP+PdGhMBlu99bqLHDmgI/X/l2e1tuzSs3rtoVR8SMTrXw KKx+rC3bRbg9NrHq6BufmAM8d0T2HHOvwja85N+EEYRaV5Ts671eu8BnXKzBtu2pQH6VLxhdh h0iiZ/LuZBX7xI2Uk8kJrumpV239WjEPOr088W+bx2TwIuDtPQH1oEWyN17dRXFyYKq5a9iwd D/d4aQQNRDHKRk3la1/JZMErAPiRinswvmESMA== To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ARM64 randdconfig builds regularly run into a build error, especially when NUMA_BALANCING and SPARSEMEM are enabled but not SPARSEMEM_VMEMMAP: #error "KASAN: not enough bits in page flags for tag" The last-cpuid bits are already contitional on the available space, so the result of the calculation is a bit random on whether they were already left out or not. Adding the kasan tag bits before last-cpuid makes it much more likely to end up with a successful build here, and should be reliable for randconfig at least, as long as that does not randomize NR_CPUS or NODES_SHIFT but uses the defaults. In order for the modified check to not trigger in the x86 vdso32 code where all constants are wrong (building with -m32), enclose all the definitions with an #ifdef. Fixes: 2813b9c02962 ("kasan, mm, arm64: tag non slab memory allocated via pagealloc") Link: https://lore.kernel.org/lkml/20190618095347.3850490-1-arnd@arndb.de/ Reviewed-by: Andrey Konovalov Signed-off-by: Arnd Bergmann --- v3: rework the #error message to make more sense v2: fix a build regression with vdso32 --- include/linux/page-flags-layout.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) -- 2.20.0 Reviewed-by: Andrey Ryabinin diff --git a/include/linux/page-flags-layout.h b/include/linux/page-flags-layout.h index 1dda31825ec4..71283739ffd2 100644 --- a/include/linux/page-flags-layout.h +++ b/include/linux/page-flags-layout.h @@ -32,6 +32,7 @@ #endif /* CONFIG_SPARSEMEM */ +#ifndef BUILD_VDSO32_64 /* * page->flags layout: * @@ -76,20 +77,22 @@ #define LAST_CPUPID_SHIFT 0 #endif -#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS +#ifdef CONFIG_KASAN_SW_TAGS +#define KASAN_TAG_WIDTH 8 +#else +#define KASAN_TAG_WIDTH 0 +#endif + +#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT+KASAN_TAG_WIDTH \ + <= BITS_PER_LONG - NR_PAGEFLAGS #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT #else #define LAST_CPUPID_WIDTH 0 #endif -#ifdef CONFIG_KASAN_SW_TAGS -#define KASAN_TAG_WIDTH 8 #if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH+LAST_CPUPID_WIDTH+KASAN_TAG_WIDTH \ > BITS_PER_LONG - NR_PAGEFLAGS -#error "KASAN: not enough bits in page flags for tag" -#endif -#else -#define KASAN_TAG_WIDTH 0 +#error "Not enough bits in page flags" #endif /* @@ -104,4 +107,5 @@ #define LAST_CPUPID_NOT_IN_PAGE_FLAGS #endif +#endif #endif /* _LINUX_PAGE_FLAGS_LAYOUT */