From patchwork Fri Nov 20 18:43:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24118C56201 for ; Fri, 20 Nov 2020 18:44:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0A1D2245F for ; Fri, 20 Nov 2020 18:43:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vAlANwm9"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ArT35zTA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0A1D2245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gTWgG7SgVmhowek51LtGhXEE5gZjPkLLClPgT6/7wlQ=; b=vAlANwm96hauf+I0nBqqKQNKc Da+/jQRPCVtPrwsHIOnnayZKAXMw1YyOw6WLQfnBjbzLY/lmtYP0wWg77VqhvzcJkYptYfk9xsxBk 2T5+KdsMEoKiLTQXG5TgRyQ1wxOYdNZFtJHWgh44Z/wvh3uhGh0Hap2t0tg2yAWvX5VVei+PPjvNz qo5FtNOG6qTNHM9F6YKLzLgtEP16M8XbOmwRAQH+ixULmnMBJGSUmgLrQKCwVyNSumko2Z/prwNft uprqyhwLT3CWEUm/qwqTRCTElxRRjwHjdfps513B7mysAO/uDk4kZLqMK/l/ZNvFohqyasZCfBfGE xIR+ZZcIQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgBNW-0004tm-SK; Fri, 20 Nov 2020 18:43:26 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgBNT-0004s8-KL for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2020 18:43:25 +0000 Received: by mail-pl1-x642.google.com with SMTP id p6so2924065plr.7 for ; Fri, 20 Nov 2020 10:43:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WXCokNcFtmUFZk8OkEAohOIZoUd84BUeBegjeYFXaK0=; b=ArT35zTApfxrR1D++Yl4zdVcqMbNXWKgsa0paeogv6PsVQMX08hAhXuEAm5XltrVWc uZe7e7D6Wh40OS7WDxbltcmSugAp0AaEPsobXvyuFAX2K77ZisSUsaDjy7XaXa+H6pBy EtGUG/Og/DE0Uq5zQnMh1aat6V6ektoPy6gdfoYdKJo7Z3V9Yb54w1Q4EYmn8rIX6NYA gg7AQ3SyOFoUv3GbH/RlX0Hs2LdAijINN/hfenjEZvDP5+rp/8Dbt1q3insU0jt9KufL OyTutRqH2qjpuuJPYMyu1PxUd8ZQz6J0FOXX0vhHSmRf2Ewu5cMRJSlpMkRGp5QwGi+D jbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WXCokNcFtmUFZk8OkEAohOIZoUd84BUeBegjeYFXaK0=; b=H3La1Ween/Woj5EPytZS8791/jqCb/TR1mQ+sqb7bAFhXrvxYFRp8IuE1XY2fK6kFK uItNhRTENXPb6UtxC16Gr1VxZxpJm06cn3T2bponwO7tenG+2PFMcNNqMWKqtDNdf54z cTQ38L0EA8V+xvNTxRNZmtKBg9PY4pmm/1uS1TiZfGpZH2tSZaSy8fX0Tc2ceF27hR1V zQKUtfnyjSWVQJPlVZdTo9pH7UoeIgiArLEkQrZ+ljst33brEfV0nlSDcAwBwU9qUjLD N4+vqgFDqEMsNaBybEtXJeGb5nzqP7YdlrJHU1Lsm/y6atEhPHqxWbc/a0ruxSnUGEjL 4tdQ== X-Gm-Message-State: AOAM5339l+Y4luSjFEEtFaOa+AA9qnRmtpnoFKZULLX70IG3xLbJ28mq k4nG+UAX/9omvnvGIKgygE4= X-Google-Smtp-Source: ABdhPJzohs3MmB+IkhzVGQX6moCZPPkrpU7OcKdu237FnWfI5fZuik401VUybcFI/uigj/eyV0ODXw== X-Received: by 2002:a17:902:bc46:b029:d6:d98a:1a68 with SMTP id t6-20020a170902bc46b02900d6d98a1a68mr14200054plz.63.1605897801482; Fri, 20 Nov 2020 10:43:21 -0800 (PST) Received: from syed ([223.225.2.215]) by smtp.gmail.com with ESMTPSA id p15sm5191603pjg.21.2020.11.20.10.43.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 10:43:20 -0800 (PST) Date: Sat, 21 Nov 2020 00:13:02 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Subject: [RESEND PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201120_134323_936820_EBCB1383 X-CRM114-Status: GOOD ( 18.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, amit.kucheria@verdurent.com, arnd@arndb.de, yamada.masahiro@socionext.com, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, daniel.lezcano@linaro.org, vilhelm.gray@gmail.com, michal.simek@xilinx.com, bgolaszewski@baylibre.com, rrichter@marvell.com, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add explicit check to see if the value being written into the bitmap does not fall outside the bitmap. The situation that it is falling outside would never be possible in the code because the boundaries are required to be correct before the function is called. The responsibility is on the caller for ensuring the boundaries are correct. The code change is simply to silence the GCC warning messages because GCC is not aware that the boundaries have already been checked. As such, we're better off using __builtin_unreachable() here because we can avoid the latency of the conditional check entirely. Cc: Arnd Bergmann Signed-off-by: Syed Nayyar Waris Acked-by: William Breathitt Gray --- include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 386d08777342..efb6199ea1e7 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -78,8 +78,9 @@ * bitmap_get_value(map, start, nbits) Get bit value of size * 'nbits' from map at start * bitmap_set_value8(map, value, start) Set 8bit value to map at start - * bitmap_set_value(map, value, start, nbits) Set bit value of size 'nbits' - * of map at start + * bitmap_set_value(map, nbits, value, value_width, start) + * Set bit value of size value_width + * to map at start * * Note, bitmap_zero() and bitmap_fill() operate over the region of * unsigned longs, that is, bits behind bitmap till the unsigned long @@ -610,30 +611,36 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value, } /** - * bitmap_set_value - set n-bit value within a memory region + * bitmap_set_value - set value within a memory region * @map: address to the bitmap memory region - * @value: value of nbits - * @start: bit offset of the n-bit value - * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive). + * @nbits: size of map in bits + * @value: value of clump + * @value_width: size of value in bits (must be between 1 and BITS_PER_LONG inclusive) + * @start: bit offset of the value */ -static inline void bitmap_set_value(unsigned long *map, - unsigned long value, - unsigned long start, unsigned long nbits) +static inline void bitmap_set_value(unsigned long *map, unsigned long nbits, + unsigned long value, unsigned long value_width, + unsigned long start) { - const size_t index = BIT_WORD(start); + const unsigned long index = BIT_WORD(start); + const unsigned long length = BIT_WORD(nbits); const unsigned long offset = start % BITS_PER_LONG; const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG); const unsigned long space = ceiling - start; - value &= GENMASK(nbits - 1, 0); + value &= GENMASK(value_width - 1, 0); - if (space >= nbits) { - map[index] &= ~(GENMASK(nbits - 1, 0) << offset); + if (space >= value_width) { + map[index] &= ~(GENMASK(value_width - 1, 0) << offset); map[index] |= value << offset; } else { map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start); map[index + 0] |= value << offset; - map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits); + + if (index + 1 >= length) + __builtin_unreachable(); + + map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + value_width); map[index + 1] |= value >> space; } } From patchwork Fri Nov 20 18:44:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B110EC2D0E4 for ; Fri, 20 Nov 2020 18:44:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4AC982245F for ; Fri, 20 Nov 2020 18:44:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AaoxCYDQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JDmUnio1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AC982245F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Evrl6ezBppAJZ/5buXbzofVuvRe1+tsO83UuyIfAVR0=; b=AaoxCYDQjvU+QRkWw/BexYXis 03vKa7H1M9cb/M2LG9XzcREbF1wmS1Cj6kEGB0+UC7E+zRphXRDPCjrQRJVYbj9ljxd+yUOgBYst3 I1FzsolGoSI9xwwh6+88/X5taieCu/6Md6TpmXeVIdHnemi37GF0BTDxPwDY3sbgxSC2Is81d2/Zh udMxFY3z871yFkpzPnW++CWx9zHFC7UKwVfAkOvbrUDC+wv/9ILYvsB8ApKU40TpGv9WtVNjBGDi9 XuNkc/So/shoqX/R2kgCB4qz07ftBiG7C4eRJOZT6akW4ls5tn//pbrFHKS2V+bL4rg6KS4Pq4M77 bWNd95+8g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgBOX-000575-QQ; Fri, 20 Nov 2020 18:44:29 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgBOV-00055l-6w for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2020 18:44:27 +0000 Received: by mail-pl1-x643.google.com with SMTP id u2so5291756pls.10 for ; Fri, 20 Nov 2020 10:44:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cK5F4d0qMv8rWJ7QrP6ojZzILBcMD6l3/NGR5/zHn7g=; b=JDmUnio1aSGCqFrCLxgQawip7qmMCTVk/WxT1wywIs4ubhldWhE81sZ8HL1BspCcwU ZpXoOLh3nCOau9q+oL5oYYEGs5uhiuybwEUGN9OAEaENpAUNux57VoeF6h5n+9PsMQ+b QsQK08JsbIq94vZ2aE47GM5BtKOGOp99nCI5PXeQogU3Hbb1Y9fxQxHDf8nH/0F+a+zf 0mMAjPimAH6SC4apd3jbLAlpXpPttDSNZrbvcf/YR+zI1Rn3UoKvs36bIhpW2T70FMxn 4RBwnlgYg4jrjFhgHjWtOKXBgHx0+MGYyjNrd+SyLGK9sfbjpHbKruTMeZSM5VnNI/tm 1qMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cK5F4d0qMv8rWJ7QrP6ojZzILBcMD6l3/NGR5/zHn7g=; b=heThaGPcS3iF0QSqgBhfLgfXrr75+Oe+6ZbhufklKWRPE3RpHHGcBPMtQ6yf13Ns1a aHNe8ZEmRqeUEBYuzQnLKxCMBPaD8++J7SHxECMoHpDCN//yrsauPSyOql0fERxv3Qs9 kCVopQlKO/fDdPcrZuFtg9emxoX2u/BXFo6sZotPdB7Bz9n7FC2aWn/ZMPJ4b3hkoWJ8 LZmaee89pD/oNKrWU9iQGqJt8aLYtk282ucryZ1c4PggOpry12rw9gzPXa2vd3XMk+BL ojxMaFqGgCAkn9c3ADgpFyWgmM91DhY4sejNJHz7uz17VFFIaTy4HLIfd+nft58SbQZ+ bpQw== X-Gm-Message-State: AOAM532+tQQwKmgG322ezIAr9ja2LwF7DwCOfCFcUmV/1bIXcLgZlc0u RRyqMifnOtYlSH2ANpSwBug= X-Google-Smtp-Source: ABdhPJz4LuKXhDhCCts6c4qxBuonU2yyA62xYcyZVA/6Ht5a1UW44vjUMzTXOBHxjTCPcprZwATb3Q== X-Received: by 2002:a17:902:8609:b029:d8:fc3c:b01a with SMTP id f9-20020a1709028609b02900d8fc3cb01amr14765755plo.36.1605897865137; Fri, 20 Nov 2020 10:44:25 -0800 (PST) Received: from syed ([223.225.2.215]) by smtp.gmail.com with ESMTPSA id n10sm3988016pgb.45.2020.11.20.10.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 10:44:24 -0800 (PST) Date: Sat, 21 Nov 2020 00:14:04 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Subject: [RESEND PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test Message-ID: <27dfda9e32e6f7d0ba9399209c70e5c3c73d0113.1605893642.git.syednwaris@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201120_134427_283083_047B9AD4 X-CRM114-Status: GOOD ( 15.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, amit.kucheria@verdurent.com, arnd@arndb.de, yamada.masahiro@socionext.com, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, daniel.lezcano@linaro.org, vilhelm.gray@gmail.com, michal.simek@xilinx.com, bgolaszewski@baylibre.com, rrichter@marvell.com, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Modify the test where bitmap_set_value() is called. bitmap_set_value() now takes an extra bitmap-width as second argument and the width of value is now present as the fourth argument. Signed-off-by: Syed Nayyar Waris --- lib/test_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 1c5791ff02cb..7fafe6a0bc08 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -656,8 +656,8 @@ static void __init prepare_test_data(unsigned int index) unsigned long width = 0; for (i = 0; i < clump_test_data[index].count; i++) { - bitmap_set_value(clump_test_data[index].data, - clump_bitmap_data[(clump_test_data[index].offset)++], width, 32); + bitmap_set_value(clump_test_data[index].data, 256, + clump_bitmap_data[(clump_test_data[index].offset)++], 32, width); width += 32; } } From patchwork Fri Nov 20 17:46:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEB42C2D0E4 for ; Fri, 20 Nov 2020 17:47:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C70D2222F for ; Fri, 20 Nov 2020 17:47:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rd4vzUHS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QrKRFlMz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C70D2222F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mpBABIvc4xKk1SKuF+BNxsCf9lcAK7Fe0qz8OQ9xrjA=; b=Rd4vzUHSNNATbIBLZsOjz4zj9 tar7fWk4lz/cU0tlBh0Z0PF86Wh+eg6BXcy3nzR4KRdMXdldJ1h0mK9IzVPnptG7yCpOR47rBT3YX uVHF+c5qH/EItzD5NnZGT3AuMpuQTiIf87T2JUIKycuUFO8M1dGxKkqwKy38OXSJqSvJWlS3OSpLp xMmEjmBBYctkn6PVADRj3g36OHD1FATzKPrE6sYpWlEhwUMW1wgc4qHg4prnRWvIJsiJdkECTIiQf UyEFyXm+bg0ZqdDrg61gxqBvOkLEDQGKt+Jrdw4F0Bp55B2MnplP9z/eAwHCsuNTinY0g6G4/VVjj FzrukXP+A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgAV2-0003eY-BS; Fri, 20 Nov 2020 17:47:08 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgAUy-0003cB-C5 for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2020 17:47:05 +0000 Received: by mail-pl1-x641.google.com with SMTP id u2so5210348pls.10 for ; Fri, 20 Nov 2020 09:47:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uRfbcvxICboodQKlXinezNDbNPHvNn9T8ybYNIuKq0c=; b=QrKRFlMzxWnE/Ue3q/KmittrUjJjuEF4OPURcyVq7nhRqz0JfxrgqLN6zQh+gHym+9 k7rrN2qLtBi6jxTox7VWExWFFitaOV5Y2ltFx8CjyIxu0YM2sAppHoBXBRdvgYqs/lQE qBrhzi7kgGGr+Wreg+KjKM4RPlXsB6E16qVc4mHT5i4Comk6cSRNNVdYPW76IrAmfBSe 7SV9AVwG9+EcrA5nG81N1NlgMdNmZLicVZlhr7PsN733TGKOfjalgOWGO9HIfT64VKcC tn7LGnands5CUXs0q78EzAtbpVkHB1EVSxeyg5tkbBvDRXPha4zokV3Ml95H5qCUfNZE iRvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uRfbcvxICboodQKlXinezNDbNPHvNn9T8ybYNIuKq0c=; b=RL4U3bHHKptG91O5AR92A78M7Y3Jo/e4E5r9mSC7lXClLZiaC7IgWdcNAZA95CtBke 9e4IUrRO5f+qlI/wz6QKMCmyhYAgpZvEdLKgGlYbppp/N7XyO1Pti6Ia5AU28BJAOwCj 7212FPy/mTE9KNqUsHF4PIH53LM0DZzRcumaLx3rM/A0cjOkfjReRmMGUpL1y2L3MpW6 GB8padC1ZoOsRJ8wmUwFkHzrlRboMZ1iTDU2eIKTBYlgizWmG9B/Izv34ypXsOVJ1Q1u Lv3eGz1OumVbHHkcDrr0eU+D7ZzFzr6C7RsdlvwsbvHB+6ymnBWPG3DTIJlP2uEhbJg/ gNDA== X-Gm-Message-State: AOAM530IxAKajtKNOerDo/GylkFJW7pnbQz0gYO/ZQSrayVzWQtMGlUA dueZGAj/wGyYbFCvpOMzWic= X-Google-Smtp-Source: ABdhPJwxzFrhgYSWjQYVZb3/YDn5TAj02ZE2o3DR/INcrJCXODyEyqj+UWac7dctbvBTSIVUSUmVvQ== X-Received: by 2002:a17:902:868e:b029:d7:eb0d:79e8 with SMTP id g14-20020a170902868eb02900d7eb0d79e8mr14536568plo.12.1605894422031; Fri, 20 Nov 2020 09:47:02 -0800 (PST) Received: from syed ([2401:4900:2e82:cfda:fc82:287b:3e19:db98]) by smtp.gmail.com with ESMTPSA id k8sm4394747pfh.6.2020.11.20.09.46.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 09:47:01 -0800 (PST) Date: Fri, 20 Nov 2020 23:16:46 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Subject: [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201120_124704_570015_11880CD7 X-CRM114-Status: GOOD ( 13.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, vilhelm.gray@gmail.com, michal.simek@xilinx.com, bgolaszewski@baylibre.com, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Modify the bitmap_set_value() calls. bitmap_set_value() now takes an extra bitmap width as second argument and the width of value is now present as the fourth argument. Cc: Michal Simek Signed-off-by: Syed Nayyar Waris --- drivers/gpio/gpio-xilinx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index ad4ee4145db4..05dae086c4d0 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -151,16 +151,16 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, spin_lock_irqsave(&chip->gpio_lock[0], flags); spin_lock(&chip->gpio_lock[1]); - bitmap_set_value(old, state[0], 0, width[0]); - bitmap_set_value(old, state[1], width[0], width[1]); + bitmap_set_value(old, 64, state[0], width[0], 0); + bitmap_set_value(old, 64, state[1], width[1], width[0]); bitmap_replace(new, old, bits, mask, gc->ngpio); - bitmap_set_value(old, state[0], 0, 32); - bitmap_set_value(old, state[1], 32, 32); + bitmap_set_value(old, 64, state[0], 32, 0); + bitmap_set_value(old, 64, state[1], 32, 32); state[0] = bitmap_get_value(new, 0, width[0]); state[1] = bitmap_get_value(new, width[0], width[1]); - bitmap_set_value(new, state[0], 0, 32); - bitmap_set_value(new, state[1], 32, 32); + bitmap_set_value(new, 64, state[0], 32, 0); + bitmap_set_value(new, 64, state[1], 32, 32); bitmap_xor(changed, old, new, 64); if (((u32 *)changed)[0]) From patchwork Fri Nov 20 17:48:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F142C56201 for ; Fri, 20 Nov 2020 17:49:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 828AE22240 for ; Fri, 20 Nov 2020 17:49:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rm3kbcPn"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VuHTdBnu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 828AE22240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mP0p4ZfEIGVceobMsU2QEl3YRIm+dVnFHfz/Th/6Ehc=; b=Rm3kbcPnt4L93n5lSoTfxDx27 fddoxeOuPX49jhya77CKRYtyYyV0XllpcqLIK2DGlsbMWzJ+60xSY6Zg4GYraQ1OWJBmIIj8J9XS/ jLcvki8gsDNCsdVfTU9zDNkC0fqrx9QBwkIb5FM4C93Zqmq3VV0sHg1J/OpIX6gfq93PKuOB3fxBq 6zMSfr1SIL/C16mEXAeJ4ea95oOG71srJcy/TYU+yUaGMkMJHwaKZKx0Pka3tmsm8jGwjUI7Z1FjW uSwxEoYXC2L8BUTGXkrW21NPVoBU7Ke1wTn4qPQATnkUSRqWEWdEG24aVU/lbNfanZpN145+IN/Wv vCM8baW5A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgAWI-00046L-9x; Fri, 20 Nov 2020 17:48:26 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgAWF-00044s-Nx for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2020 17:48:24 +0000 Received: by mail-pg1-x542.google.com with SMTP id q28so7914579pgk.1 for ; Fri, 20 Nov 2020 09:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=VuHTdBnuHwGkq10ElqUJ8YPGsbNvZ5vJJtt345M1qoUcGa3PYxR4lS7NACyEa+776y 25Cok+kYcBGNapvo76mDOaCx8R2BhsQd67Zihv5M92ISuwt+n+e197ksp/H9yZz5VV+/ ADTwNtS4gbRFYkl+arTBx2OS0264zqmjJ2ndkSB/48sDHXwgG4IwXqArceJsjSnxlWxf sUjVZ4YMgL5Aw4nKwy3LDKR75YoSGXaAZCzQ/kskAh7Q9IFmzf/ggVl5bZkIqyDkWZ0t 9aIWKV1ISFUpBCLK2/LFkJgp345efuZZCPzuoptlJ4cPGAB6IPJ6YDMAr0H3vX9kBXfW vSNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=XXKc+NtI3T2HfSFWu/GRWuioyUAYdTgFsRhs5JQ+LKtzuiLhkNrKG8TNbuNyzSVgsx VCSoXuouwUdjJ00tRvf2tLVy8cEDRjCWqx3DKTYGap8BL3eMsKrCfrT9cC41hW3azAFA jVuGSHdkA5DNgsxvjp5DCZnUH0870IbjoiUDCLpwa2BG1Q1/ZA43YS+6kBwtQCCbY5Fx H3UHTQgS+FgPbudd7F9Bb6QR/t17vXJSNO8vsPZIqtnCb+7EOPbZib68Nbscy0ZtcZlZ FogXQYe+iBBJPdgVDJ2FxT8k578mkUSZ8Lt+eSnmcbsiuQN4YTdPaRHURUSuzew1WLQb RiiQ== X-Gm-Message-State: AOAM533s9eoq88mMGwBUvDunpHHwkW1wHJ3k9nSdWyQPTNsrv5rUtL4m lQz7t/fzLMMEJx+KcR42naA= X-Google-Smtp-Source: ABdhPJypIr3JQuMN0qO4OWeuGSIuRkEhb9DiluX5rcaHCu1V7dwikNflgns/SgKwMc7WyNCqdpQDvw== X-Received: by 2002:a17:90b:38e:: with SMTP id ga14mr10935553pjb.45.1605894501500; Fri, 20 Nov 2020 09:48:21 -0800 (PST) Received: from syed ([2401:4900:2e82:cfda:fc82:287b:3e19:db98]) by smtp.gmail.com with ESMTPSA id 184sm4533205pfc.28.2020.11.20.09.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 09:48:20 -0800 (PST) Date: Fri, 20 Nov 2020 23:18:05 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Subject: [PATCH 4/4] gpio: xilinx: Add extra check to see if sum of widths exceed 64 Message-ID: <5581771d86df1abaf33545ccd60caf4db7ad3c5e.1605893643.git.syednwaris@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201120_124823_818077_FACB624C X-CRM114-Status: GOOD ( 14.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, vilhelm.gray@gmail.com, michal.simek@xilinx.com, bgolaszewski@baylibre.com, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add extra check to see if sum of widths does not exceed 64. If it exceeds then return -EINVAL alongwith appropriate error message. Cc: Michal Simek Signed-off-by: Syed Nayyar Waris --- drivers/gpio/gpio-xilinx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 05dae086c4d0..a2e92a1cf50b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -340,6 +340,12 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base = -1; chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; + + if (chip->gc.ngpio > 64) { + dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64"); + return -EINVAL; + } + chip->gc.parent = &pdev->dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out;