From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E619EC54798 for ; Tue, 5 Mar 2024 17:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:From: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+XQGJU7W2HiNMOEyQaaW+W5cy38kuvu+YwIfh1at5rU=; b=sB0uU52jAzJbAS +ElXuij2oJQ8h9x9Af1ZqgIAhl40FZ9wwmAUR2Mg88bHDm8QzAuHWtV9el3VpIam9DXFDuIEYNE97 oeiQ/4ltClZtZuMV2NVmLYQun2HEW5pa+o8tfwdxqVWWzH38zLNVOvPrreMk+gdBSuxuOvnGgeW4p VlnQgxp45bxaDV5RiWukm07IH3nTY0HMtBw88g8CCRDtIL0+DEp43XzyDoNr2xqzqHByQ0e7lG6El 3qvCex7Hmt+XDxk6ny6r/J4wpZIGmvvRmtfYguULd7bA6LRrm1PhqfZT1YP01i+w4PxhUgoApjI4T SMvJlpXk79ApVlW0EYmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhYwL-0000000EkiS-2kag; Tue, 05 Mar 2024 17:50:57 +0000 Received: from out-175.mta0.migadu.com ([91.218.175.175]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhYwG-0000000EkbZ-1eat for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 17:50:55 +0000 Message-ID: <917fe6fb-bd04-4f63-ac48-a84764e9b089@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709661044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qYEtmtu4yMx3F+ooHk+Opk4awM0NK13PNSGqM9UHTCc=; b=MrJUOCTuvwTd9E4v/SCzCRTw/bkfMvAQHpCFT4DDkVZ9q2XGO/6jfGt6X1un5rsOyS+RMT 7pE6zpKZV/lT+PbCJvTDtq1Ru3flbqoRxZM4rzkR14u+TYDAbIKZ12DbeYQpg0yu0HoMQc 7l9eUsvnBr1gRZ8iCH7iptae9zlw+Wo= Date: Tue, 5 Mar 2024 12:50:40 -0500 MIME-Version: 1.0 Subject: Re: iio: xilinx-ams: shift-out-of-bounds in ams_enable_channel_sequence Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson To: Manish Narani , Michal Simek Cc: Jonathan Cameron , "linux-arm-kernel@lists.infradead.org" References: In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240305_095052_974331_EFA14EE8 X-CRM114-Status: GOOD ( 15.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org +CC Michal The email for the listed maintainer (Anand Ashok Dumbre ) bounces. Does he still work for Xilinx/AMD? --Sean On 3/5/24 12:30, Sean Anderson wrote: > Hi, > > When enabling UBSAN on a ZynqMP Ultrascale+, I see the following error during boot: > > [ 1.447628] ================================================================================ > [ 1.447832] UBSAN: shift-out-of-bounds in ../drivers/iio/adc/xilinx-ams.c:426:16 > [ 1.448019] shift exponent 66 is too large for 64-bit type 'long long unsigned int' > [ 1.448211] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.6.20+ #90 > [ 1.448368] Hardware name: xlnx,zynqmp (DT) > [ 1.448475] Call trace: > [ 1.448547] dump_backtrace+0x9c/0x11c > [ 1.448655] show_stack+0x18/0x24 > [ 1.448749] dump_stack_lvl+0xac/0xd4 > [ 1.448853] dump_stack+0x18/0x24 > [ 1.448947] ubsan_epilogue+0x10/0x44 > [ 1.449051] __ubsan_handle_shift_out_of_bounds+0x98/0x134 > [ 1.449191] ams_enable_channel_sequence+0x22c/0x23c > [ 1.449324] ams_probe+0x570/0x6d4 > [ 1.449423] platform_probe+0x68/0x108 > [ 1.449530] really_probe+0x158/0x3b0 > [ 1.449632] __driver_probe_device+0x88/0x1a0 > [ 1.449747] driver_probe_device+0x3c/0x138 > [ 1.449859] __driver_attach+0xe4/0x1bc > [ 1.449964] bus_for_each_dev+0x78/0xe0 > [ 1.450068] driver_attach+0x24/0x30 > [ 1.450167] bus_add_driver+0x110/0x240 > [ 1.450271] driver_register+0x60/0x128 > [ 1.450376] __platform_driver_register+0x28/0x34 > [ 1.450500] ams_driver_init+0x1c/0x28 > [ 1.450609] do_one_initcall+0x78/0x2c8 > [ 1.450714] kernel_init_freeable+0x2f8/0x59c > [ 1.450831] kernel_init+0x30/0x150 > [ 1.450932] ret_from_fork+0x10/0x20 > [ 1.451073] ================================================================================ > > When applying the following patch: > > diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c > index f0b71a1220e0..1ced8cff461a 100644 > --- a/drivers/iio/adc/xilinx-ams.c > +++ b/drivers/iio/adc/xilinx-ams.c > @@ -414,8 +414,17 @@ static void ams_enable_channel_sequence(struct iio_dev *indio_dev) > > /* Run calibration of PS & PL as part of the sequence */ > scan_mask = BIT(0) | BIT(AMS_PS_SEQ_MAX); > - for (i = 0; i < indio_dev->num_channels; i++) > + for (i = 0; i < indio_dev->num_channels; i++) { > + if (indio_dev->channels[i].scan_index >= 64) { > + const struct iio_chan_spec *chan = &indio_dev->channels[i]; > + > + dev_warn(&indio_dev->dev, > + "channel %d (%d %d.%d @ %lx) has scan_index %d\n", > + i, chan->type, chan->channel, chan->channel2, > + chan->address, chan->scan_index); > + } > scan_mask |= BIT_ULL(indio_dev->channels[i].scan_index); > + } > > if (ams->ps_base) { > /* put sysmon in a soft reset to change the sequence */ > > I see these additional outputs: > > [ 1.447457] iio iio:device0: channel 0 (0 0.0 @ 60) has scan_index 66 > [ 1.451280] iio iio:device0: channel 1 (0 1.0 @ 6c) has scan_index 67 > [ 1.451446] iio iio:device0: channel 2 (0 2.0 @ 78) has scan_index 68 > [ 1.451612] iio iio:device0: channel 3 (0 3.0 @ 7c) has scan_index 69 > [ 1.451777] iio iio:device0: channel 4 (0 4.0 @ 80) has scan_index 70 > [ 1.451942] iio iio:device0: channel 5 (0 5.0 @ 84) has scan_index 71 > [ 1.452107] iio iio:device0: channel 6 (0 6.0 @ 9c) has scan_index 72 > > Indicating that the issue is with the ams_ctrl_channels using the > AMS_CTRL_CHAN_VOLTAGE macro. > > --Sean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel