iio_info causing kernel panic and iio_reg not working

Hey,

I'm using a cusom board with a Zynq7020 and AD9361. The linux environment was made in Buildroot. I can access the system through /sys/bus/iio/devices and used the iiostream.c example effectively.

dmesg at boot:

~ # dmesg | grep ad9361
[    4.247737] ad9361 spi32766.0: ad9361_probe : enter (ad9361)
[    4.524403] ad9361 spi32766.0: ad9361_probe : AD936x Rev 2 successfully initialized
[    5.423813] cf_axi_adc 79020000.cf-ad9361-lpc: ADI AIM (10.00.b) at 0x79020000 mapped to 0xe0a68000, probed ADC AD9361 as MASTER
[    5.447428] cf_axi_dds 79024000.cf-ad9361-dds-core-lpc: Analog Devices CF_AXI_DDS_DDS MASTER (9.00.b) at 0x79024000 mapped to 0xe0a9c000, probed DDS AD9361

1. iio_reg does not work

~ # iio_reg ad9361-phy 0x3
Unable to read register: No such file or directory

iio_info starts printing through the information for a while then kernel panics. It is claiming the issue may be in lib/vsprintf.c:1982 ... which is,

/* Reject out-of-range values early.  Large positive sizes are
   used for unknown buffer sizes. */
if (WARN_ON_ONCE(size > INT_MAX))                                                                                                                                                                                                
            return 0;

Where INT_MAX is defined in decompress_bunzip2.c as ,

#define INT_MAX 0x7fffffff

Hard to believe that would be overrun...

Heres the actual output from iio_info including the panic... The prints got really messed up once it started to panic so It looks a little messy at the beginning. Thanks.

Library version: 0.15 (git tag: v0.15)
Compiled with backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.15 (git tag: v0.15)
Backend description string: Linux  4.9.0 #1 SMP PREEMPT Wed Jan 23 09:53:59 PST 2019 armv7l
IIO context has 1 attributes:
        local,kernel: 4.9.0
IIO context has 4 devices:
        iio:device3: cf-ad9361-dds-core-lpc (buffer capable)
                12 channels found:
                        voltage0:  (output, index: 0, format: le:S16/16>>0)
                        3 channel-specific attributes found:
                                attr  0: calibscale value: 1.000000
                                attr  1: calibphase value: 0.000000
                                attr  2: sampling_frequency value: 30720000
                        voltage1:  (output, index: 1, format: le:S16/16>>0)
                        3 channel-specific attributes found:
                                attr  0: calibphase value: 0.000000
                                attr  1: calibscale value: 1.000000
                                attr  2: sampling_frequency value: 30720000
                        voltage2:  (output, index: 2, format: le:S16/16>>0)
                        3 channel-specific attributes found:
                                attr  0: calibphase value: 0.000000
                                attr  1: calibscale value: 1.000000
                                attr  2: sampling_frequency value: 30720000
                        voltage3:  (output, index: 3, format: le:S16/16>>0)
                        3 channel-specific attributes found:
                                attr  0: calibphase value: 0.000000
                                attr  1: calibscale value: 1.000000
                                attr  2: sampling_frequency value: 30720000
                        altvoltage3: TX1_Q_F2 (output)
                        5 channel-specific attributes found:
                                attr  0: raw value: 1
                                attr  1: phase value: 0
                                attr  2: frequency value: 9279985
                                attr  3: scale value: 0.250000
                                attr  4: sampling_frequency value: 30720000
                        altvoltage1: TX1_I_F2 (output)
                        5 channel-specific attributes found:
                                attr  0: phase value: 90000
                                attr  1: scale value: 0.250000
                                attr  2: raw value: 1
                                attr  3: frequency value: 9279985
                                attr  4: sampling_frequency value: 30720000
                        altvoltage0: TX1_I_F1 (output)
                        5 channel-specific attributes found:
                                attr  0: phase value: 90000
                                attr  1: scale value: 0.250000
                                attr  2: frequency value: 9279985
                                attr  3: raw value: 1
                                attr  4: sampling_frequency value: 30720000
                        altvoltage7: TX2_Q_F2 (output)
                        5 channel-specific attributes found:
                                attr  0: raw value: 1
                                attr  1: phase value: 0
                                attr  2: scale value: 0.250000
                                attr  3: frequency value: 999859
                                attr  4: sampling_frequency value: 30720000
                        altvoltage6: TX2_Q_F1 (output)
                        5 channel-specific attributes found:
                                attr  0: phase value: 0
                                attr  1: scale value: 0.250000
                                attr  2: frequency value: 999859
                                attr  3: raw value: 1
                                attr  4: sampling_frequency value: 30720000
                        altvoltage5: TX2_I_F2 (output)
                        5 channel-specific attributes found:
                                attr  0: raw value: 1
                                attr  1: frequency value: 999859
                                attr  2: phase value: 90000
                                attr  3: scale value: 0.250000
                                attr  4: sampling_frequency value: 30720000
                        altvoltage2: TX1_Q_F1 (output)
                        5 channel-specific attributes found:
                                attr  0: raw value: 1
                                attr  1: phase value: 0
                                attr  2: frequency value: 9279985
                                attr  3: scale value: 0.250000
                                attr  4: sampling_frequency value: 30720000
                        altvoltage4: TX2_I_F1 (output)
                        5 channel-specific attributes found:
                                attr  0: frequency value: 999859
                                attr  1: phase value: 90000
                                attr  2: raw value: 1
                                attr  3: scale value: 0.250000
                                attr  4: sampling_frequency value: 30720000
                2 buffer-specific attributes found:
                                attr  0: watermark value: 2048
                                attr  1: data_available value: 0
        iio:device1: ad9361-phy
                11 channels found:
                        altvoltage1: TX_LO (output)
                        8 channel-specific attributes found:
                                attr  0: external value: 0
                                attr  1: frequency value: 2450000000
                                attr  2: fastlock_store value: 0
                                attr  3: fastlock_recall ERROR: Invalid argument (-22)
                                attr  4: powerdown value: 0
                                attr  5: fastlock_save value: 0 189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189
                                attr  6: frequency_available value: [46875001 1 6000000000]
                                attr  7: fastlock_load value: 0
                        voltage1:  (output)
                        10 channel-specific attributes found:
                                attr  0: hardwaregain value: -10.000000 dB
                                attr  1: rf_port_select value: A
                                attr  2: hardwaregain_available value: [0 250 89750]
                                attr  3: rssi value: 0.00 dB
                                attr  4: sampling_frequency_available value: [2083333 1 61440000]
                                attr  5: rf_port_select_available value: A B
                                attr  6: filter_fir_en value: 0
                                attr  7: sampling_frequency value: 30720000
                                attr  8: rf_bandwidth_available value: [200000 1 40000000]
                                attr  9: rf_bandwidth value: 18000000
                        voltage0:  (input)
                        15 channel-specific attributes found:
                                attr  0: hardwaregain_available value: [-3 1 71]
                                attr  1: hardwaregain value: 71.000000 dB
                                attr  2: rssi value: 112.25 dB
                                attr  3: rf_port_select value: A_BALANCED
                                attr  4: gain_control_mode value: slow_attack
                                attr  5: rf_port_select_available value: A_BALANCED B_BALANCED C_BALANCED A_N A_P B_N B_P C_N C_P TX_MONITOR1 TX_MONITOR2 TX_MONITOR1_2
                                attr  6: rf_bandwidth value: 18000000
                                attr  7: rf_dc_offset_tracking_en value: 1
                                attr  8: sampling_frequency_available value: [2083333 1 61440000]
                                attr  9: quadrature_tracking_en value: 1
                                attr 10: sampling_frequency value: 30720000
                                attr 11: gain_control_mode_available value: manual fast_attack slow_attack hybrid
                                attr 12: filter_fir_en value: 0
                                attr 13: rf_bandwidth_available value: [200000 1 56000000]
                                attr 14: bb_dc_offset_tracking_en value: 1
                        voltage1:  (input)
                        15 channel-specific attributes found:
                                attr  0: rssi value: 114.50 dB
                                attr  1: rf_port_select value: A_BALANCED
                                attr  2: hardwaregain value: 71.000000 dB
                                attr  3: hardwaregain_available value: [-3 1 71]
                                attr  4: gain_control_mode value: slow_attack
                                attr  5: rf_port_select_available value: A_BALANCED B_BALANCED C_BALANCED A_N A_P B_N B_P C_N C_P TX_MONITOR1 TX_MONITOR2 TX_MONITOR1_2
                                attr  6: rf_bandwidth value: 18000000
                                attr  7: rf_dc_offset_tracking_en value: 1
                                attr  8: sampling_frequency_available value: [2083333 1 61440000]
                                attr  9: quadrature_tracking_en value: 1
                                attr 10: sampling_frequency value: 30720000
                                attr 11: gain_control_mode_available value: manual fast_attack slow_attack hybrid
                                attr 12: filter_fir_en value: 0
                                attr 13: rf_bandwidth_available value: [200000 1 56000000]
                                attr 14: bb_dc_offset_tracking_en value: 1
                        voltage3:  (output)
                        8 channel-specific attributes found:
                                attr  0: scale value: 1.000000
                                attr  1: raw value: 306
                                attr  2: sampling_frequency_available value: [2083333 1 61440000]
                                attr  3: rf_port_select_available value: A B
                                attr  4: filter_fir_en value: 0
                                attr  5: sampling_frequency value: 30720000
                                attr  6: rf_bandwidth_available value: [200000 1 40000000]
                                attr  7: rf_bandwidth value: 18000000
                        altvoltage0: RX_LO (output)
                        8 channel-specific attributes found:
                                attr  0: frequency_available value: [70000000 1 6000000000]
                                attr  1: fastlock_save value: 0 162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162
                                attr  2: powerdown value: 0
                                attr  3: fastlock_load value: 0
                                attr  4: fastlock_store value: 0
                                attr  5: frequency value: 2400000000
                                attr  6: external value: 0
                                attr  7: fastlock_recall ERROR: Invalid argument (-22)
                        voltage2:  (output)
                        8 channel-specific attributes found:
                                attr  0: raw value: 306
                                attr  1: scale value: 1.000000
                                attr  2: sampling_frequency_available value: [2083333 1 61440000]
                                attr  3: rf_port_select_available value: A B
                                attr  4: filter_fir_en value: 0
                                attr  5: sampling_frequency value: 30720000
                                attr  6: rf_bandwidth_available value: [200000 1 40000000]
                                attr  7: rf_bandwidth value: 18000000
                        temp0:  (input)
                        1 channel-specific attributes found:
                                attr  0: input value: 44737
                        voltage0:  (output)
                        10 channel-specific attributes found:
                                attr  0: rf_port_select value: A
                                attr  1: hardwaregain value: -10.000000 dB
                                attr  2: rssi value: 0.00 dB
                                attr  3: hardwaregain_available value: [0 250 89750]
                                attr  4: sampling_frequency_available value: [2083333 1 61440000]
                                attr  5: rf_port_select_available value: A B
                                attr  6: filter_fir_en value: 0
                                attr  7: sampling_frequency value: 30720000
        attr  8: rf_bandwidth_available value: [200000 1 40000000]
        attr  9: rf_bandwidth value: 18000000
                        voltage2:  (input)
                                attr  0: offset val yaffs2multi(O)ue: 57
                                attr  1: scale value: 0.305250
                                attr  2: raw val cadence_wdtue: 373
                                attr  3: rf_port_select_available value: A_BALANCED spi_cadence B_BALANCED C_BALANCED A_N A_P B_N B_P C_N C_P TX_MONITOR1 TX_MO spwlite(O)NITOR2 TX_MONITOR1_2
 fpga_region                    attr  4: rf_bandwidth value: 18000000
                                        attr  5: rf_dc_offset_tracking_en value: 1
                                attr  6: sa fpga_bridgempling_frequency_available value: [2083333 1 61440000]
                                attr pl35x_nand  7: quadrature_tracking_en value: 1
                                attr  8: sampling_freq zynq_fpgauency value: 30720000
                                attr  9: gain_control_mode_available  fpga_mgrvalue: manual fast_attack slow_attack hybrid
                                attr 10: filte
r_fir_en value: 0
                                attr 12: bb_dc_offset_tracking_en value: 
1
                        out:  (input)
                        1 channel-specific attributes found:
                attr  0: voltage_filter_fir_en value: 0
[  351.230958] ------------[ cut here ]------------
[  351.240978] WARNING: CPU: 1 PID: 1221 at lib/vsprintf.c:1982 vsnprintf+0x4c/0x3e8
[  351.253968] Modules linked in:               13 channel-specific attributes found:
[  351.340221] Hardware name: Xilinx Zynq Platform
[  351.350325] [<c010e6d8>] (unwind_backtrace) from [<c010af18>] (show_stack+0x10/0x14)
[  351.363592] [<c010af18>] (show_stack) from [<c033cc78>] (dump_stack+0x7c/0x9c)
[  351.388752] [<c011f97c>] (__warn) from [<c011fa50>] (warn_slowpath_null+0x1c/0x24)
[  351.441274] [<c04b44a8>] (ad9361_gt_bin_read) from [<c02330a8>] (sysfs_kf_bin_read+0x84/0x8c)
[  351.455330] [<c02330a8>] (sysfs_kf_bin_read) from [<c0232b08>] (kernfs_fop_read+0xd4/0x1ac)
[  351.464528] [<c0232b08>] (kernfs_fop_read) from [<c01d78d4>] (__vfs_read+0x1c/0x104)
[  351.472252] [<c01d78d4>] (__vfs_read) from [<c01d8504>] (vfs_read+0x90/0xfc)
[  351.479282] [<c01d8504>] (vfs_read) from [<c01d9130>] (SyS_read+0x3c/0x74)
[  351.486142] [<c01d9130>] (SyS_read) from [<c0107700>] (ret_fast_syscall+0x0/0x3c)
[  351.493642] ---[ end trace 4f1a8b534c6ab5ff ]---
[  351.498237] usercopy: kernel memory exposure attempt detected from d2fcb800 (kmalloc-1024) (1045 bytes)
[  351.507623] ------------[ cut here ]------------
[  351.512173] kernel BUG at mm/usercopy.c:75!
[  351.516340] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
[  351.522153] Modules linked in: yaffs2multi(O) cadence_wdt spi_cadence spwlite(O) fpga_region fpga_bridge pl35x_nand zynq_fpga fpga_mgr
[  351.534224] CPU: 1 PID: 1221 Comm: iio_info Tainted: G        W  O    4.9.0 #1
[  351.541770] Hardware name: Xilinx Zynq Platform
[  351.546286] task: df772580 task.stack: df49c000
[  351.550809] PC is at __check_object_size+0x130/0x1d8
[  351.555750] LR is at __check_object_size+0x130/0x1d8
[  351.560697] pc : [<c01d55c4>]    lr : [<c01d55c4>]    psr: 60000013
[  351.560697] sp : df49dec0  ip : c0944c38  fp : 00028680
[  351.572151] r10: 00000000  r9 : d2c1a58c  r8 : 00012fcb
[  351.577360] r7 : 00000001  r6 : d2fcbc15  r5 : 00000415  r4 : d2fcb800
[  351.583869] r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : 0000005b
[  351.590382] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[  351.597498] Control: 18c5387d  Table: 1f5c004a  DAC: 00000051
[  351.603226] Process iio_info (pid: 1221, stack limit = 0xdf49c210)
[  351.609389] Stack: (0xdf49dec0 to 0xdf49e000)
[  351.613736] dec0: c072c5be 00000415 00000415 d2c1a580 d2fcb800 df49df88 bea858f8 c0232b5c
[  351.621895] dee0: 00000000 00000000 00000400 c0232a34 d2ec3840 bea858f8 df49df88 c01078c4
[  351.630054] df00: df49c000 c01d78d4 c01d73b8 c0843918 d2ec3840 d2f06000 d32b2bd0 c01d1e38
[  351.638212] df20: d2f06031 00000001 d2f06000 d2ec3840 00028680 c01f2c08 00000000 a0000013
[  351.646372] df40: 00000000 d2ec3840 df49df88 00000400 00000400 00000400 d2ec3840 bea858f8
[  351.654531] df60: df49df88 c01d8504 d2ec3840 bea858f8 d2ec3840 d2ec3840 bea858f8 00000400
[  351.662690] df80: c01078c4 c01d9130 00000000 00000000 00000400 00028eb8 00000400 00000000
[  351.670849] dfa0: 00000003 c0107700 00028eb8 00000400 00000003 bea858f8 00000400 00000000
[  351.679008] dfc0: 00028eb8 00000400 00000000 00000003 00000400 00000001 b6ed6c4c 00028680
[  351.687167] dfe0: b6f0f044 bea85420 b6e8ce78 b6e6d498 60000010 00000003 00000000 00000000
[  351.695339] [<c01d55c4>] (__check_object_size) from [<c0232b5c>] (kernfs_fop_read+0x128/0x1ac)
[  351.703924] [<c0232b5c>] (kernfs_fop_read) from [<c01d78d4>] (__vfs_read+0x1c/0x104)
[  351.711646] [<c01d78d4>] (__vfs_read) from [<c01d8504>] (vfs_read+0x90/0xfc)
[  351.718676] [<c01d8504>] (vfs_read) from [<c01d9130>] (SyS_read+0x3c/0x74)
[  351.725537] [<c01d9130>] (SyS_read) from [<c0107700>] (ret_fast_syscall+0x0/0x3c)
[  351.732999] Code: e59f1098 01a01000 e59f0094 ebff0421 (e7f001f2) 
[  351.739071] ---[ end trace 4f1a8b534c6ab600 ]---
[  351.743669] Kernel panic - not syncing: Fatal exception
[  351.748881] CPU0: stopping
[  351.751572] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G      D W  O    4.9.0 #1
[  351.758944] Hardware name: Xilinx Zynq Platform
[  351.763480] [<c010e6d8>] (unwind_backtrace) from [<c010af18>] (show_stack+0x10/0x14)
[  351.771201] [<c010af18>] (show_stack) from [<c033cc78>] (dump_stack+0x7c/0x9c)
[  351.778399] [<c033cc78>] (dump_stack) from [<c010ca8c>] (ipi_cpu_stop+0x34/0x68)
[  351.785774] [<c010ca8c>] (ipi_cpu_stop) from [<c010d2a4>] (handle_IPI+0x74/0xdc)
[  351.793152] [<c010d2a4>] (handle_IPI) from [<c0101424>] (gic_handle_irq+0x78/0x94)
[  351.800702] [<c0101424>] (gic_handle_irq) from [<c010b98c>] (__irq_svc+0x6c/0xa8)
[  351.808161] Exception stack(0xc0901f60 to 0xc0901fa8)
[  351.813202] 1f60: 00000000 00000000 00009bb8 c0115680 c0900000 c0902fa4 00000001 c090f3ae
[  351.821361] 1f80: c090300c c0830a30 00000000 00000000 c0902d40 c0901fb0 c01081d4 c01081d8
[  351.829513] 1fa0: 60000013 ffffffff
[  351.832996] [<c010b98c>] (__irq_svc) from [<c01081d8>] (arch_cpu_idle+0x2c/0x38)
[  351.840375] [<c01081d8>] (arch_cpu_idle) from [<c0155b64>] (cpu_startup_entry+0xc0/0x120)
[  351.848541] [<c0155b64>] (cpu_startup_entry) from [<c0800c24>] (start_kernel+0x34c/0x3bc)
[  351.856689] Rebooting in 120 seconds..

Parents Reply Children