Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3390794pxb; Mon, 17 Jan 2022 19:25:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmrylg7LQaYUfy083uBaIr6lm0LpeNkixcQfNfPaQQ5/3jxqMy6QjfGpaQakKR6c5+wzAR X-Received: by 2002:a62:3142:0:b0:4c3:a26a:331b with SMTP id x63-20020a623142000000b004c3a26a331bmr11314702pfx.21.1642476247385; Mon, 17 Jan 2022 19:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642476247; cv=none; d=google.com; s=arc-20160816; b=lF0/sQAxxZBsKvIlCMPUdIUibmcsoiQsV+OIbiYKD9TwhzxtTj+QrIpsLL0eRJW2wQ 8nrAWwFRGKQXRv87hHi9fUPU3KXJY47Ond3YJkuE2Nn+EkBOQUkQ3Y1hQ6fQeh/dldIW saACQmtEwstJVl+jKbYUoPXhomCfgT+YmAV5HWP97Lbyj3nqpablsb97Xn6nqVE6Gvnb HeT2W4MJNOBYKr4myOwurMWdBYLkNNEpeFs9Dj3yugKNRzaHSnHQ9CTDC4RMG58Qmpaz CB7LMFVoxxIpixSxnM1JFKN/AFK3OKGUkTV+JaLpA56unuAPGabB2KgFnQGwrWZ4bCBx /Rwg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g2QYq/np4z46oKimKmYO1dwe3MNb3eTbJLZ/ihg80XE=; b=GguPaCjoS5OiVHFYneBuASY1goP0vpJy78cdTM5RCumybdlLgLb3oZjeLdSIKjCC4B UP7/OGMyjY7CV7QqYgReiKgABqi6sb5nCEl5tWLzl/KmRiNUY3+Tg6xORsfkFR7rIDVh gIX91tdOcVihcqwUa4mFuyBVRIO/ViOXEVlZElKh2yaenfxH2WlZ+Ty+ESQwZERZHSCC 2K3STtFB2sfevWhb3YJ4ycBj+Pta2rRCeeuSW1C+xAzzoG5dkOOjgM2TtJqRSt7k5PCQ a77Z0/O8O2n3gDNd+R0nDNWtt8pNyKD+18GaB3iJHu8Mynozh8/b1WqtgnkMTqPQAvGQ pitQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KGy8GpeH; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si14079800plr.323.2022.01.17.19.23.55; Mon, 17 Jan 2022 19:24:07 -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=@kernel.org header.s=k20201202 header.b=KGy8GpeH; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346306AbiARCfi (ORCPT + 99 others); Mon, 17 Jan 2022 21:35:38 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:40746 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344241AbiARC3Y (ORCPT ); Mon, 17 Jan 2022 21:29:24 -0500 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 4E8ACB81238; Tue, 18 Jan 2022 02:29:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25D5EC36AE3; Tue, 18 Jan 2022 02:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472962; bh=hY4UWMyFSq0Q4bgph2NQBK7SyoqPgPe9sNmHDQXYo1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGy8GpeHvxWv3uoV99vqp+GdiXcBW1b++/lv2N0HW+0nhNWYRSbFZRSS4WP85Qe27 bfPCpW2bYhBRqs/J/OGPqoei6xDo96hJyFUFpHbmVoqxEJ4j2rIwj0iDKXnqkA6pQI KSRU5jnDwAfuSyTNEfdyrAaoQYVQwdcDibzxjjPlDsx70ZRjNEOJl3T1YpfnpeCWdN oZIaDyoj752+t042MgPfdMSAW+wwtDynciDsYkkFMsOY3Rbg2CqBzGMA3qTSU4MtXx K8I3vPP8AvtAnal4asrA83FI1VSvtHVll2y3elKEPN8ajdOX0GncL2QkZ98MAfdNdI Ct1mChzBO90VA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Langsdorf , Bob Moore , "Rafael J . Wysocki" , Sasha Levin , rafael@kernel.org, linux-acpi@vger.kernel.org, devel@acpica.org Subject: [PATCH AUTOSEL 5.16 179/217] ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions Date: Mon, 17 Jan 2022 21:19:02 -0500 Message-Id: <20220118021940.1942199-179-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Langsdorf [ Upstream commit f81bdeaf816142e0729eea0cc84c395ec9673151 ] ACPICA commit bc02c76d518135531483dfc276ed28b7ee632ce1 The current ACPI_ACCESS_*_WIDTH defines do not provide a way to test that size is small enough to not cause an overflow when applied to a 32-bit integer. Rather than adding more magic numbers, add ACPI_ACCESS_*_SHIFT, ACPI_ACCESS_*_MAX, and ACPI_ACCESS_*_DEFAULT #defines and redefine ACPI_ACCESS_*_WIDTH in terms of the new #defines. This was inititally reported on Linux where a size of 102 in ACPI_ACCESS_BIT_WIDTH caused an overflow error in the SPCR initialization code. Link: https://github.com/acpica/acpica/commit/bc02c76d Signed-off-by: Mark Langsdorf Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- include/acpi/actypes.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index ff8b3c913f217..248242dca28d3 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -536,8 +536,14 @@ typedef u64 acpi_integer; * Can be used with access_width of struct acpi_generic_address and access_size of * struct acpi_resource_generic_register. */ -#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + 2)) -#define ACPI_ACCESS_BYTE_WIDTH(size) (1 << ((size) - 1)) +#define ACPI_ACCESS_BIT_SHIFT 2 +#define ACPI_ACCESS_BYTE_SHIFT -1 +#define ACPI_ACCESS_BIT_MAX (31 - ACPI_ACCESS_BIT_SHIFT) +#define ACPI_ACCESS_BYTE_MAX (31 - ACPI_ACCESS_BYTE_SHIFT) +#define ACPI_ACCESS_BIT_DEFAULT (8 - ACPI_ACCESS_BIT_SHIFT) +#define ACPI_ACCESS_BYTE_DEFAULT (8 - ACPI_ACCESS_BYTE_SHIFT) +#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + ACPI_ACCESS_BIT_SHIFT)) +#define ACPI_ACCESS_BYTE_WIDTH(size) (1 << ((size) + ACPI_ACCESS_BYTE_SHIFT)) /******************************************************************************* * -- 2.34.1