Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654149pxb; Mon, 24 Jan 2022 14:32:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDsczjUybD4XLaxO/oOYtwCFD6VmIEeBGZh/N/4aMKHhk7zJ9gYlPwuA5Cyl7uHgXSlugm X-Received: by 2002:a63:2a0d:: with SMTP id q13mr13290589pgq.601.1643063529174; Mon, 24 Jan 2022 14:32:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063529; cv=none; d=google.com; s=arc-20160816; b=lYNy/SvRMzvBAqIiOl/nyBOvq+bNLC+moIdDNdoNU6fpZL8Gt8cUtYFHb5mB7+WS5B 4R419uS9uvW5zpR2cuSzEZijR0HTkAr30OXBojuK67NJySA8XphZLRT6XoSsd28BZvNw +XoUrLUBRWeKnimFBOUhz+24fFtj8JpyyWO5UmHF8M0IgxKEZgDle44+4M85uGgcWDOP juzQcpgv/CMCm4zAYs9lC3LqAPliKRDT6YU+9ooE7l1rEHD9FHPw7yPLUPs02v9zeZu5 NgAwSK7p+VcKlkOI94EyNPxdSgjTXIVeoV2r47oLh+td7wJfWzVDdZioZan7R1q/II3b dPnA== 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=R0+stxK0uWcyTwM8iOdcvWdGR1Vrnr1ZQViTpVkeEOE1VHTTsu2ynxcs0F4cHz0MBs 46QBxeyN0t3USZZNyyOeL0c1K4E3/5rUSwZ1+DcREqF3FENlSdFEO1BGfGlExSn0wHwG LLqhjUBddEYDyj7QCtT71y+kvitOw2Mmia8BWweLdbbatWcyNFM/4nRPRrrSbIdsdYxC uoF47IN9kl2d7nyAqqVJBm6lmE2Nd8VlEb2uwjFBD79tHh/4qTzwxd6ZXw79lnf2Aquv PAtPEMa7aiqJPyAxvDm6DFwBqDvinw0U29Sj01PLvLMXUCtJvtXVJUrrAkH4tUASqbWb Dn5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=znh9VTSL; 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 r70si5073319pgr.157.2022.01.24.14.31.57; Mon, 24 Jan 2022 14:32:09 -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=znh9VTSL; 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 S1587871AbiAXWaB (ORCPT + 99 others); Mon, 24 Jan 2022 17:30:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377544AbiAXVhm (ORCPT ); Mon, 24 Jan 2022 16:37:42 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 719CFC0BD12B; Mon, 24 Jan 2022 12:23:59 -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 dfw.source.kernel.org (Postfix) with ESMTPS id EE8D96090A; Mon, 24 Jan 2022 20:23:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D8CC340E5; Mon, 24 Jan 2022 20:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055838; bh=l7UtJdL8SBoqJm1jldU5+fDq8XyAWe8H5vJ8rXhBJ5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=znh9VTSLc/tTsENBSJQJGG0K7MI0ei3pIzurkaSVMsQrEX6w0Defk96eVplwbSGlf O+U3mYoGs/JxB7b5T881u5zSe2eP+oL87Qgk5sHrfT5fCqA9vomnXDXyRvPPAzp2W5 xMmxBaDQAndOPepUA5qFmo4Axq84GDCdlb2gBRtQ= 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.15 282/846] lib/logic_iomem: Fix operation on 32-bit Date: Mon, 24 Jan 2022 19:36:39 +0100 Message-Id: <20220124184110.654106787@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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