From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E335B50EC15; Wed, 30 Sep 2026 16:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786001; cv=none; b=rPxKom1NsZ0rgEzdsnOEyTXbF1WpF2dWfS62Z+5mki6mVimH5MpQaOQmWz6phiHiYGb+2sPRbgfHW5YUp06pxWGn4HFYsab61TLtjRl/ocIfu6FKWjZHnwgIH9gKitCZSfqXzWea9cYrw2emIlbn2n6o+IydW8EdxVsNbfzO9dQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786001; c=relaxed/simple; bh=teu0mDMEYwDxWQ3ouYyKHCIqs4p2CdxNrZ3b0mPJcXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QgZ8Zd4VIK7oDDZ5jipJAtqFm1YZPf60kb7Y1I9OjB2IRU1qC03uQ0mYLxSNRrtLWF3qNNLJTD0WnYQgjHIz+l1VIXvtjniGz+aygImyNKQ7i1mknUlz0NdAjkrqZNT2+xyYteVyH7NTRSpB8dMDgdgAme4hcQZ02+MJ3G7xGoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jgJGjFMM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jgJGjFMM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12E7B1F000FF; Wed, 30 Sep 2026 16:33:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790785999; bh=4UP//32jzFxfdyhEnwiSRJC/YgleSqcOcMgxXrEnAS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jgJGjFMM5qqx0aDpUdmfkc8z2lZeGfNSpu+t20rcIAq3OUbjnxQf2WdqY7fDQAK39 M9ZERLoGZ4TMC0FefRpXN+gQOowTSGX/FzjBhT4ckPFThHG8FL6Z5MMzvhKRm51ViR qFstaucr46yJF104m0UJ8OFMF+/MnhxlKz8q6V3k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Laight , Mark Rutland , Jinjie Ruan , Muhammad Usama Anjum , "Christopher Lameter (Ampere)" , Ada Couprie Diaz , Ard Biesheuvel , Catalin Marinas , James Morse , Marc Zyngier , Peter Zijlstra , Vladimir Murzin , Will Deacon , Yang Shi , "Lorenzo Stoakes (ARM)" Subject: [PATCH 6.1 707/982] arm64: percpu: Fix this_cpu_write() casting Date: Wed, 30 Sep 2026 17:24:03 +0200 Message-ID: <20260930152431.944735482@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland commit 885bff055a0f251a51a0d4fd4f0a7b525582a3de upstream. The arm64 implementation of this_cpu_write() casts 'val' to unsigned long. This is necessary to handle cases where 'val' is a pointer type, and to avoid spurious compiler warnings for the (unreachable!) cases where the pointer type would be cast to a smaller integer type. Unfortunately, the cast is applied to 'val' rather than '(val)', which won't always generate the expected value when 'val' is an expression. For example, for this_cpu_write(pcp, zero - 1), where 'pcp' is a u64 and 'zero' is a u32: * 'zero' ===> (u32) 0x00000000 * 'zero - 1' ===> (u32) 0xffffffff * '(unsigned long)zero - 1' ===> (u64) 0xffffffffffffffff * '(unsigned long)(zero - 1)' ===> (u64) 0x00000000ffffffff Fix this by adding brackets around 'val'. Fixes: 959bf2fd03b5 ("arm64: percpu: Rewrite per-cpu ops to allow use of LSE atomics") Reported-by: David Laight Signed-off-by: Mark Rutland Reviewed-by: David Laight Reviewed-by: Jinjie Ruan Tested-by: Muhammad Usama Anjum Acked-by: Christopher Lameter (Ampere) Cc: Ada Couprie Diaz Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Cc: Marc Zyngier Cc: Peter Zijlstra Cc: Vladimir Murzin Cc: Will Deacon Cc: Yang Shi Cc: stable@vger.kernel.org Reviewed-by: Lorenzo Stoakes (ARM) Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/percpu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/arm64/include/asm/percpu.h +++ b/arch/arm64/include/asm/percpu.h @@ -178,13 +178,13 @@ PERCPU_RET_OP(add, add, ldadd) _pcp_protect_return(__percpu_read_64, pcp) #define this_cpu_write_1(pcp, val) \ - _pcp_protect(__percpu_write_8, pcp, (unsigned long)val) + _pcp_protect(__percpu_write_8, pcp, (unsigned long)(val)) #define this_cpu_write_2(pcp, val) \ - _pcp_protect(__percpu_write_16, pcp, (unsigned long)val) + _pcp_protect(__percpu_write_16, pcp, (unsigned long)(val)) #define this_cpu_write_4(pcp, val) \ - _pcp_protect(__percpu_write_32, pcp, (unsigned long)val) + _pcp_protect(__percpu_write_32, pcp, (unsigned long)(val)) #define this_cpu_write_8(pcp, val) \ - _pcp_protect(__percpu_write_64, pcp, (unsigned long)val) + _pcp_protect(__percpu_write_64, pcp, (unsigned long)(val)) #define this_cpu_add_1(pcp, val) \ _pcp_protect(__percpu_add_case_8, pcp, val)