Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1770053lqe; Mon, 8 Apr 2024 22:25:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkv7UNkeE3lf/M0WChiTUEodVKliNh863e4wcf8Javd9TXjNrlbRI+wxkFTHknQL+2svGgPK0fJ1d08mgX4Q8lFqWedcoGGUUD7yiwNg== X-Google-Smtp-Source: AGHT+IFkaqwMOMsjQ0ybSeqBWf9+XsGKDiXJPI0Lt5Ve5cnxi8pg6Djz1EYccd6E8Cj6Anb/ag9O X-Received: by 2002:a05:622a:1387:b0:434:c73e:7e3c with SMTP id o7-20020a05622a138700b00434c73e7e3cmr2362819qtk.30.1712640318359; Mon, 08 Apr 2024 22:25:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712640318; cv=pass; d=google.com; s=arc-20160816; b=kQ2Y2029+0UZlweT3UxopUGnBOje2L6hdEiNArJFXZcPhKzGfvnUJKgtLIOeEBDriA +fYAUpNUStS/4zNmRCl031cVE5Cmot+Z9XXlhbBns3aSIF9n+qfMYpUMGDZLFo7RxQ95 G2cluVB9vTTO4V2w8JhHOFxXnVYIgIdhrTgs9GJRPmUW8/ACTD9etzeF9EGlFk1HLFMV DPksFmhj2ZJDWwQgC8DPM0yfYzZgl3rgIn8++egtBRG3sNEPfNbyadulep48VF5lwO7C 7N+m2J0j5vAg9oE540NTyjRNKOXcffs6JRsE81Rz6rczZ2jsq/dzDf87CSg/i8dVpjan nVzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=FBSe4rDQmSTpv21rWEaJ0GJmEOffcUGm1Kyb8bb+B0c=; fh=rN3V1l2ySs1jLoOyNP0M/UrkZRhjLe22rqypKmGS9BI=; b=Jlz4vfGBDn1TAl/padFs9UPpIUPNqaHk7qTeJcERhPZ/RVje0dM2YxMHbDC4EUGYMB vZIbYkK+pNNylxCTxZltTkV8k0N6T/ylwKmN4BDdgZL+/hxiTcEFn0dN+YWJc5BJ+BsF HT8ZLvMOiRCkIrz6omTrIBQvrz4O4HJXtnN7EQMnB23vOW8Yv8RyFKCUhXfJFTdrub7K 75otLLoyOpwvIcJI27lp/0McejXCcX+oqxczYQL0Ssj7pZdcPbCCYe5ZMNPTKo6o9akN /dlfSGNE8iZd82a4HAWvjaQS7HpFByJQNWHagLrBWhQ9lPTmk6ny23v9nnYf0tpdGI2X dwNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ZxH2qNbe; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-136249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z8-20020ac87f88000000b004347cd84569si4121934qtj.155.2024.04.08.22.25.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 22:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ZxH2qNbe; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-136249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 18F0E1C229DE for ; Tue, 9 Apr 2024 05:25:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D71D63087; Tue, 9 Apr 2024 05:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="ZxH2qNbe" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E1CB54BCB; Tue, 9 Apr 2024 05:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712640310; cv=none; b=rDwdYhD312hsvurzjIw9IgBwXFGcm37SlV6YwagxswnHdjsxLKEXyNC8pnZALz+49w39W8vehY2XHuU5ql16SNofzkejGD+zNQRlG2+V3M+kw2PHweS1mOVw17vQy4s3XbxtTIqcS4lFYwXVF7KlmZO71r3Jfbh0y8t1wE9IJl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712640310; c=relaxed/simple; bh=c+E0Ivgu8zc3jsKPVvka9jymECqjH91wtE41Wl9104c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=pse2kReQoemp9Stua4Oy09CWcBah4i4ECa1OEfsjrvrLuL4P7BOSG0bw5daEbW6ddvLSUWDk4+n4DHI4DF/uKslaAZJ/66kblaUdT0EzDCcDui6x5OtRACWHbDSBSF++IZ3TsklkRcPXzzKtJx8BU/N9hz5tWYrBTskfnASjk9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=ZxH2qNbe; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from localhost.localdomain (unknown [167.220.77.82]) by linux.microsoft.com (Postfix) with ESMTPSA id C0CEC20EA451; Mon, 8 Apr 2024 22:25:07 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C0CEC20EA451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712640307; bh=FBSe4rDQmSTpv21rWEaJ0GJmEOffcUGm1Kyb8bb+B0c=; h=From:To:Cc:Subject:Date:From; b=ZxH2qNbetXYoC5X+JBetIEOdZixI3OTd/3EXEfyemurOcvab17TfSReMc3gnLdKnF M5jCY5LrRkJLCqTQuY+6yYylrMT29XMT76HnStrh4rr+DtoDZIoiwFA0mDYDBsDYp4 AdYgJdPxvCquqQm/2MgtoqvLR+AlEyDhGsZv6EfI= From: Jarred White To: "Rafael J. Wysocki" , Len Brown , Jarred White , Easwar Hariharan , linux-acpi@vger.kernel.org (open list:ACPI), linux-kernel@vger.kernel.org (open list) Cc: Vanshidhar Konda , stable@vger.kernel.org Subject: [PATCH] ACPI: CPPC: Fix bit_offset shift in MASK_VAL macro Date: Mon, 8 Apr 2024 22:23:09 -0700 Message-Id: <20240409052310.3162495-1-jarredwhite@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit 2f4a4d63a193 ("ACPI: CPPC: Use access_width over bit_width for system memory accesses") neglected to properly wrap the bit_offset shift when it comes to applying the mask. This may cause incorrect values to be read and may cause the cpufreq module not be loaded. [ 11.059751] cpu_capacity: CPU0 missing/invalid highest performance. [ 11.066005] cpu_capacity: partial information: fallback to 1024 for all CPUs Also, corrected the bitmask generation in GENMASK (extra bit being added). Fixes: 2f4a4d63a193 ("ACPI: CPPC: Use access_width over bit_width for system memory accesses") Signed-off-by: Jarred White CC: Vanshidhar Konda CC: stable@vger.kernel.org #5.15+ --- drivers/acpi/cppc_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 4bfbe55553f4..00a30ca35e78 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -170,8 +170,8 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time); #define GET_BIT_WIDTH(reg) ((reg)->access_width ? (8 << ((reg)->access_width - 1)) : (reg)->bit_width) /* Shift and apply the mask for CPC reads/writes */ -#define MASK_VAL(reg, val) ((val) >> ((reg)->bit_offset & \ - GENMASK(((reg)->bit_width), 0))) +#define MASK_VAL(reg, val) (((val) >> (reg)->bit_offset) & \ + GENMASK(((reg)->bit_width) - 1, 0)) static ssize_t show_feedback_ctrs(struct kobject *kobj, struct kobj_attribute *attr, char *buf) -- 2.33.8