Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1469071ybp; Wed, 9 Oct 2019 14:47:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCkouFGAqleSmml+Qj/5VXxEOp7SJXDOon+/QMxhwDYCD6x6sQlg8ZQwX140dsPT9dsUJb X-Received: by 2002:a50:ace1:: with SMTP id x88mr5102372edc.132.1570657677160; Wed, 09 Oct 2019 14:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570657677; cv=none; d=google.com; s=arc-20160816; b=hPByTmY7WyPeaeyepwxehp+LnmEB30VjTvx26WklKN/eqJ8B0SQMbfM6jQ+m4Nl6ls WTnailtzi8dthaKSIe8o3flGe3PKShb1p6ejO5RdWZTyVqLBPzeZOOtSsb+9YE8HPKap 7i4Dj36mhfZvp2Pq+CpXw14UP5Z7vBwVhGUGnlVsCHgUAxMB6sD/ZWSoPiZWICES9gx3 /qL2XfthPIR9NQJotzS64KV+mHHSpNXqxkITNUoxul2A08b+em8uIkhCWxSwsqT8ubiQ x/cFFhKMxdSD7l6bFZ7QvNg5Y+PELOY8TPEM9rURVVCp5JAyoLb11oB1QF2UC70bPjyu ADHA== 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=neyxcVlEmCYVV210NlpiIy48qmIVtJilY8X2MVXciDE=; b=b4K2mFNKc62ZtItbaNrWeW79oZRYmilKgjvLCN8IhVR2KotrqLwWn9Bj3glLjj2Tuc iJgjUVab2m+qp5xRgwDF92FACmXusU0RZM0yk7yTG6VvkH6YnB0nDkcEFOEjPQp+i5xl s5a1Mto2aFwpU9mj/ktO8agWb0qY0whi6zz+HjoL4Jubuzte0RybpFgHF9l7KJpWS2Pd RUEP5sGmPRTsMb7z52lujLdgxAJSXtg4U7gCaEqULbPckIYrMF+K1j8wwsMiZh5lYefb Ge2jIk+Hj3f8sgc1ik7n0BqBBbED0BMtIGmJYvs/bljknaoQLkPu/ArnYRAS8OWgImU0 A3tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MtOlueDn; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y43si2100314edd.42.2019.10.09.14.47.33; Wed, 09 Oct 2019 14:47:57 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MtOlueDn; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732012AbfJIVpV (ORCPT + 99 others); Wed, 9 Oct 2019 17:45:21 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34636 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729865AbfJIVpV (ORCPT ); Wed, 9 Oct 2019 17:45:21 -0400 Received: by mail-lf1-f66.google.com with SMTP id r22so2791865lfm.1 for ; Wed, 09 Oct 2019 14:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=neyxcVlEmCYVV210NlpiIy48qmIVtJilY8X2MVXciDE=; b=MtOlueDnBpCLLEX2Ak6A1UGYP494h9lCZm1pV8BJ37DnmZThV8Cu6TuRxcyEaBgdxv vmE6qZRNxinv3MjeqeL9e1j4c0lUF/zXMij6GZBHfIDNr1GkpJq4pf3S29L8Ja4XVROO h0qIWxvLOxOOgSZExbFZnLfYSVHar+rvO6V/+iHNoxWbCSyHkf7BQNK50E6WSFeoMZob z/guRRiKnm6BFj8Cf+HrsDdJ8BOWfM4qXLXq15CfIPCPxgwZz1ANUd8i57j7zNYC4HR1 rCpqYRx5VeEcn5wFD3Bcb90c7jZVlA1O9fM8ADwpXMInl+60xDLIL2FDGxiOqa3IAhKn hsYQ== 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=neyxcVlEmCYVV210NlpiIy48qmIVtJilY8X2MVXciDE=; b=bT9Yf4PJ6sd5XE/c4aBvUEVt6XzQKVt8ruSpeftaG9tObgWnYjFyr7SrqOLzkizfdh V1/0Tgj4A4QCIpRQsPWQJUDKBxety8PW50AXceq0rWbe7+DU37vCLMgbAZyTFuvtvgup CI3AXI7Y+SqFBaBwbm/DzIeBawTrylfYKYSb5uJVc2oBPO6+JNKZ+Ur/pa/fo0lXFJ3p 39/M7KgNIhX9ALRF0tYq4An6GZeeMqaX2EAtwjvVz1k22sAotJh/JP8A2zFwYc8zpgjR 3lnJpJOJHscwLDFO+2gK79+CSeMbxwsWEU40DQY+EYTdcUv0R89U3PwD/TGsBkvAy2L0 C0dg== X-Gm-Message-State: APjAAAUJTcss9Wui8UisxJbwYsKrwZQR1UFM/gRhuFIyYE22QabV+6hT 5BjZslMWyQujtIhZKbN1RY6iKG3MBm8= X-Received: by 2002:ac2:4471:: with SMTP id y17mr3575074lfl.28.1570657519502; Wed, 09 Oct 2019 14:45:19 -0700 (PDT) Received: from localhost.localdomain (h-98-128-228-153.NA.cust.bahnhof.se. [98.128.228.153]) by smtp.gmail.com with ESMTPSA id v22sm701503ljh.56.2019.10.09.14.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 14:45:18 -0700 (PDT) From: Rikard Falkeborn To: rikard.falkeborn@gmail.com Cc: akpm@linux-foundation.org, bp@alien8.de, joe@perches.com, johannes@sipsolutions.net, keescook@chromium.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, yamada.masahiro@socionext.com, x86@kernel.org Subject: [Patch v4 0/2] Add compile time sanity check of GENMASK inputs Date: Wed, 9 Oct 2019 23:45:00 +0200 Message-Id: <20191009214502.637875-1-rikard.falkeborn@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190811184938.1796-1-rikard.falkeborn@gmail.com> References: <20190811184938.1796-1-rikard.falkeborn@gmail.com> 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 Hello, Add build time validity checks of GENMASK (and GENMASK_ULL) inputs. The main differences from v3: - Patch v3 1/3 was merged into Linus tree through the x86 tree and is not part of this series any longer. - Disable the input check for GCC < 4.9 due to a gcc bug. Joe Perches sent a patch series to fix existing misuses, currently there are two remaining such misuses (which patches pending) left in Linus tree. However, the remaining two cases are in unused macros and will not break any builds until someone tries to use them. There was also an arm-specific misuse which have also been fixed since v2 of this patchset was merged to linux-next. When v3 of this patchset was included in linux-next, there were not additional build failures or warnings (there are some failed builds due to other patches though), however and Geert Uytterhoeven reported that it broke compilation with old versions of gcc so a v4 is needed. Changelog Since v3 - Patch v2 1/3 (the x86 build warning) has been merged into Linus tree through the x86 tree (and is therefore not part of v4). - Disable the GENMASK input check if GCC version < 4.9 due to a compiler bug [0]. [0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449 Since v2 - Use __builtin_constant_p instead of __is_constexpr to avoid pulling in kernel.h (that include was missing in v2, so the header was no longer builable standalone - add cast to BUILD_BUG_ON_ZERO to make the type int - Remove unnecessary casts due to the above - Drop patch that renamed macro arguments Since v1 - Add comment about why inputs are not checked when used in asm file - Use UL(0) instead of 0 - Extract mask creation in a separate macro to improve readability - Use high and low instead of h and l (part of this was extracted to a separate patch) - Updated commit message Rikard Falkeborn (2): linux/build_bug.h: Change type to int linux/bits.h: Add compile time sanity check of GENMASK inputs include/linux/bits.h | 22 ++++++++++++++++++++-- include/linux/build_bug.h | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) -- 2.23.0