Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3707434pxb; Mon, 24 Jan 2022 15:57:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6vV3HZLTaHf6lM4OHt0TgiQh4FrpEcgNWMJFT2C7VcCiyvGaFTehWNfniOvlyA0Illtnq X-Received: by 2002:a17:90a:de84:: with SMTP id n4mr740175pjv.76.1643068675469; Mon, 24 Jan 2022 15:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068675; cv=none; d=google.com; s=arc-20160816; b=igLJcHk4/kIiJpLx9tLKVlS8h+/Iq+mcwObh+c3MfuNlefy3b0oftx7+tDYplYUtE5 zX4YnIAnZ1qWEG81VZH2zjcQKm7fZnl2JV2wClqcvktwHaxsxfXmlxNGXFCKO7CVLRGA XlyhGZ+1ckhFaodammvBwWq/TVaZF1w7IOvjmNZ2pJeZ+otW4zhGP/9TwDMTejWN4oUW dSOlGNPAfoToRO6YXCLJZI1voUqwe71i5R1mc6Rz9cFJWQjxOKsGDdXHUjp3tbEXgyZv j3IJpSvlGeAopu11r1ATv+eoc+pL1BT92G7WHJA6rxzt9H013cHryIY6rhyzjXk2QEfi M/rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6rHVqC5JA4iN3U7JCS5NIMqYUlCT5khcT3bYJUJ1uzI=; b=vD63FIAaiLBNpSIcPm7grr6ecbresQ3YoiDMV7cuR703hiomoiDFUALLjICnGdBSgc cG/H3vm+hwDZ4FRJKRSkMrRS0B1PwELnmLQlrupNhlLKO0hx49eIIo93MKTTIm4etcdj SPuNsjGF5hf2HNqIpGA0XsqcltcwCzQUdGz+UD7Zx9ZSFVFz5P6v+JX4XZhuMGGXcJRZ B2JMPvY9vkMB+PRwDmKmtAQhutcOu8O2DaBUi5JZ6GfmitMpCE/LiaCschfZPIFGGRKU A/Hb+ZDhzjP2h1dMCByqmjwkIe5Ox4Nxu+zFs7E6DxIH29j1+WUIdcdPQljDQZXmc+dU 8qIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C54lZHw5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w71si1695571pgd.43.2022.01.24.15.57.43; Mon, 24 Jan 2022 15:57:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C54lZHw5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2365983AbiAXXwE (ORCPT + 99 others); Mon, 24 Jan 2022 18:52:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1837278AbiAXW4K (ORCPT ); Mon, 24 Jan 2022 17:56:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D454C055ABA; Mon, 24 Jan 2022 13:11:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EDCB4B8121C; Mon, 24 Jan 2022 21:11:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FD31C340E5; Mon, 24 Jan 2022 21:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058696; bh=l7UtJdL8SBoqJm1jldU5+fDq8XyAWe8H5vJ8rXhBJ5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C54lZHw5OfMRM9wD6Iq+6boezM9ZNkuL1WpzKAzsnKEUp30j7dB5JTyLkI3bOQdgL AUtOYnipAwSS8D4CSpyyqT0GthIBpkotR6tDh0VrFLCUb+jOUUb8lrhdpDHAnamQMp vMdgkIZaq1iy36+ngzy7jzUjLX5ZknUjR9vJPT2U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Richard Weinberger , Sasha Levin Subject: [PATCH 5.16 0340/1039] lib/logic_iomem: Fix operation on 32-bit Date: Mon, 24 Jan 2022 19:35:29 +0100 Message-Id: <20220124184136.735914825@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 4e8a5edac5010820e7c5303fc96f5a262e096bb6 ] On 32-bit, the first entry might be at 0/NULL, but that's strange and leads to issues, e.g. where we check "if (ret)". Use a IOREMAP_BIAS/IOREMAP_MASK of 0x80000000UL to avoid this. This then requires reducing the number of areas (via MAX_AREAS), but we still have 128 areas, which is enough. Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)") Signed-off-by: Johannes Berg Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- lib/logic_iomem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c index 54fa601f3300b..549b22d4bcde1 100644 --- a/lib/logic_iomem.c +++ b/lib/logic_iomem.c @@ -21,15 +21,15 @@ struct logic_iomem_area { #define AREA_SHIFT 24 #define MAX_AREA_SIZE (1 << AREA_SHIFT) -#define MAX_AREAS ((1ULL<<32) / MAX_AREA_SIZE) +#define MAX_AREAS ((1U << 31) / MAX_AREA_SIZE) #define AREA_BITS ((MAX_AREAS - 1) << AREA_SHIFT) #define AREA_MASK (MAX_AREA_SIZE - 1) #ifdef CONFIG_64BIT #define IOREMAP_BIAS 0xDEAD000000000000UL #define IOREMAP_MASK 0xFFFFFFFF00000000UL #else -#define IOREMAP_BIAS 0 -#define IOREMAP_MASK 0 +#define IOREMAP_BIAS 0x80000000UL +#define IOREMAP_MASK 0x80000000UL #endif static DEFINE_MUTEX(regions_mtx); -- 2.34.1